/* =====================================================================
   RytePad – auth & utility pages (login, register, reset, logout, 404)
   v5.14 · same font stack as app.css (the browser's sans-serif, no font downloads), the site's blue,
   ink and line colours, 8px / 14px radii, compact spacing so the register page fits a laptop screen
   without scrolling. 5.14: the submit button keeps its place and shows the spinner inside itself
   (no jump), remember-me row, dimmer placeholders, a little more air on short screens and phones.
   ===================================================================== */

:root {
    --font: sans-serif; /* keep in step with --font in app.css */
    --primary: #2f6fb3; --primary-600: #245c99; --primary-soft: #e7f0fa; --primary-ink: #163a66;
    --bg: #f5f7fb; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #eef2f7; --border: #e2e8f0; --border-strong: #cbd5e1;
    --text: #0f172a; --text-2: #334155; --text-3: #64748b;
    --danger: #b91c1c; --danger-soft: #fee2e2; --success: #15803d; --success-soft: #dcfce7;
    --radius: 8px; --radius-l: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 24px 48px -28px rgba(22, 58, 102, .35);
    --btn-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 10px 24px -12px rgba(47, 111, 179, .7);
    --ring: 0 0 0 4px rgba(47, 111, 179, .18);
    color-scheme: light;
}
:root[data-theme="dark"] {
    --primary: #5b9be0; --primary-600: #4f8bd0; --primary-soft: rgba(91, 155, 224, .16); --primary-ink: #b7d4f5;
    --bg: #0f1115; --surface: #171a20; --surface-2: #1d2128; --surface-3: #262b34; --border: #262b34; --border-strong: #343a45;
    --text: #eef0f3; --text-2: #b4bac4; --text-3: #7c8492;
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .14); --success: #4ade80; --success-soft: rgba(74, 222, 128, .14);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 16px 48px -16px rgba(0, 0, 0, .7);
    --btn-shadow: none;
    --ring: 0 0 0 4px rgba(91, 155, 224, .3);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text);
    background: var(--bg);
    /* same soft gradient as the home page hero */
    background-image:
        radial-gradient(900px 540px at 8% -10%, rgba(47, 111, 179, .22), transparent 62%),
        radial-gradient(760px 460px at 92% 6%, rgba(227, 121, 42, .16), transparent 60%),
        radial-gradient(640px 420px at 55% 108%, rgba(122, 90, 245, .12), transparent 60%),
        linear-gradient(180deg, #f2f6fc 0%, #e6eef9 100%);
    background-attachment: fixed;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100vh; padding: 16px;
    -webkit-font-smoothing: antialiased;
}
:root[data-theme="dark"] body {
    background-image: radial-gradient(1000px 600px at 10% -10%, var(--primary-soft), transparent 60%), radial-gradient(800px 500px at 100% 110%, var(--primary-soft), transparent 60%);
}
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 .75em; }

/* ---------- Card ---------- */
.login-container {
    width: 100%; max-width: 420px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l);
    box-shadow: var(--shadow); padding: 32px 30px 26px; text-align: center;
    position: relative; overflow: hidden;
    animation: rise .35s cubic-bezier(.2, .8, .2, 1);
}
/* a thin brand line along the top of the card (the same blue and orange as the background glow) */
.login-container::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--primary) 0%, #5b9be0 55%, #e3792a 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.logo { margin: 0 0 22px; line-height: 0; }
.logo img { height: 28px; width: auto; }
:root[data-theme="dark"] .logo img { filter: invert(1) hue-rotate(180deg) brightness(1.15); }
.login-container h2 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin: 0 0 6px; }
.subtitle { color: var(--text-3); font-size: .9rem; margin: 0 0 24px; text-wrap: balance; }
form { text-align: left; }

/* ---------- Fields ---------- */
.form-group { position: relative; margin-bottom: 12px; }
.form-group label { display: block; font-size: .8rem; line-height: 1.3; font-weight: 600; letter-spacing: .01em; color: var(--text-2); margin-bottom: 6px; }
.form-group input {
    width: 100%; height: 42px; font: inherit; font-size: 16px; /* 16px: stops iOS zooming into the field */ color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
    padding: 0 12px; outline: none; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none; appearance: none;
}
.form-group input::placeholder { color: var(--text-3); opacity: .6; }
.form-group input:hover { border-color: #94a3b8; }
.form-group input:focus { border-color: var(--primary); box-shadow: var(--ring); }
/* the browser's autofill tint (yellow / blue) is replaced by the field's own surface */
.form-group input:-webkit-autofill, .form-group input:-webkit-autofill:hover, .form-group input:-webkit-autofill:focus { -webkit-text-fill-color: var(--text); -webkit-box-shadow: 0 0 0 1000px var(--surface) inset; box-shadow: 0 0 0 1000px var(--surface) inset; transition: background-color 9999s ease-out; }
.form-group input[type="password"], .form-group input.has-toggle { padding-right: 62px; }
.toggle-password {
    position: absolute; right: 7px; bottom: 8px; height: 26px; line-height: 26px; padding: 0 9px; border-radius: 6px;
    font-size: .74rem; font-weight: 600; color: var(--text-2); cursor: pointer; user-select: none;
    background: var(--surface-3); transition: background .15s, color .15s;
}
.toggle-password:hover { color: var(--text); background: var(--border); }
.toggle-password:focus-visible { outline: none; box-shadow: var(--ring); }

/* remember me + forgot link on one row, between the password field and the button */
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 14px; font-size: .85rem; }
.form-row .forgot-password { margin: 0; font-size: inherit; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); cursor: pointer; user-select: none; line-height: 1.3; }
.check input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--primary); cursor: pointer; }
.check input:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 3px; }

button[type="submit"] {
    width: 100%; height: 44px; margin-top: 6px; font: inherit; font-size: .95rem; font-weight: 600; color: #fff;
    background: var(--primary); border: 1px solid var(--primary); border-radius: var(--radius); padding: 0 16px; cursor: pointer;
    box-shadow: var(--btn-shadow); transition: background .15s, transform .05s, box-shadow .15s;
}
button[type="submit"]:hover { background: var(--primary-600); border-color: var(--primary-600); transform: translateY(-1px); box-shadow: 0 2px 4px rgba(16, 24, 40, .1), 0 14px 28px -12px rgba(47, 111, 179, .75); }
button[type="submit"]:active { transform: translateY(0); box-shadow: var(--btn-shadow); }
button[type="submit"]:focus-visible { outline: none; box-shadow: var(--ring); }
button[type="submit"]:disabled { opacity: .6; cursor: default; box-shadow: none; transform: none; }
:root[data-theme="dark"] button[type="submit"] { color: #0b1a2b; }
:root[data-theme="dark"] button[type="submit"]:hover { box-shadow: none; }
/* while the request runs the button stays exactly where it is, its label hidden and a spinner in its place (no jump);
   .is-success (sign-up done, logging in) turns it green */
button[type="submit"].is-busy { position: relative; color: transparent !important; opacity: 1; cursor: default; pointer-events: none; text-shadow: none; box-shadow: var(--btn-shadow); transform: none; }
button[type="submit"].is-busy::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite;
}
:root[data-theme="dark"] button[type="submit"].is-busy::after { border-color: rgba(11, 26, 43, .3); border-top-color: #0b1a2b; }
button[type="submit"].is-busy.is-success { background: var(--success); border-color: var(--success); }
:root[data-theme="dark"] button[type="submit"].is-busy.is-success::after { border-color: rgba(11, 26, 43, .3); border-top-color: #0b1a2b; }

/* ---------- Messages / spinner ---------- */
.message { min-height: 0; font-size: .875rem; margin: 0 0 12px; }
/* the scripts clear the box with innerHTML = "" before each submit but used to leave the error class on it,
   which kept an empty red bar on screen; an empty box is now always hidden */
.message:empty { display: none; margin: 0; }
.message p { margin: 0; }
.error, .error-message, .message .error { color: var(--danger); background: var(--danger-soft); border-left: 3px solid var(--danger); border-radius: var(--radius); padding: 9px 12px; text-align: left; line-height: 1.45; }
.error-message p.error { background: transparent; border: 0; padding: 0; }
.success, .success-message { color: var(--success); background: var(--success-soft); border-left: 3px solid var(--success); border-radius: var(--radius); padding: 9px 12px; text-align: left; line-height: 1.45; }
/* the old stand-alone spinner under the form (no longer in the pages; the button shows it now) */
.spinner {
    display: none; width: 22px; height: 22px; margin: 12px auto 0; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite;
}
.spinner.success-spinner { border-color: var(--success-soft); border-top-color: var(--success); }
@keyframes spin { to { transform: rotate(360deg); } }
#progress-dots::after { content: ""; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ---------- Links under the form ---------- */
.forgot-password, .register-link, .small.resend-link { font-size: .88rem; margin-top: 14px; }
.register-link { padding-top: 14px; border-top: 1px solid var(--border); color: var(--text-2); }
.register-link a { font-weight: 600; }
a:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.terms-privacy { font-size: .76rem; color: var(--text-3); margin-top: 13px; line-height: 1.45; text-wrap: balance; }
/* reserves the Turnstile widget's height so the form doesn't jump when it loads */
.turnstile-holder { display: flex; justify-content: center; min-height: 65px; margin: 4px 0 10px; }
.turnstile-holder:empty { min-height: 0; margin: 0; }

/* logout */
.login-container.logout p.message { color: var(--text-2); margin-bottom: 22px; }
.login-container.logout > a {
    display: inline-flex; align-items: center; justify-content: center; min-width: 200px; height: 44px; padding: 0 24px; font-weight: 600; color: #fff;
    background: var(--primary); border: 1px solid var(--primary); border-radius: var(--radius); box-shadow: var(--btn-shadow); transition: background .15s, transform .05s, box-shadow .15s;
}
.login-container.logout > a:hover { background: var(--primary-600); border-color: var(--primary-600); text-decoration: none; transform: translateY(-1px); }
:root[data-theme="dark"] .login-container.logout > a { color: #0b1a2b; }

/* value props under the card (optional, same look as the home page trust line) */
.auth-perks { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 14px; font-size: .78rem; color: var(--text-3); }
.auth-perks span::before { content: "\2713"; color: var(--success); font-weight: 700; margin-right: 5px; }

/* ---------- 404 ---------- */
.card.notfound { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow); padding: 36px 32px; text-align: center; }
.card.notfound .brand img { height: 26px; }
.card.notfound .code { font-size: 4.5rem; font-weight: 800; letter-spacing: -.05em; color: var(--primary); line-height: 1; margin: 18px 0 8px; }
.card.notfound h1 { font-size: 1.3rem; letter-spacing: -.02em; margin: 0 0 6px; }
.card.notfound .lead { color: var(--text-2); margin-bottom: 22px; }
.card.notfound .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: .92rem; font-weight: 600; padding: 10px 18px; border-radius: var(--radius); border: 1px solid var(--border-strong); color: var(--text); background: var(--surface); }
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: #94a3b8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--btn-shadow); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
:root[data-theme="dark"] .btn-primary { color: #0b1a2b; }
.card.notfound .meta { margin: 22px 0 0; font-size: .82rem; color: var(--text-3); }

/* short laptop screens: trim the vertical rhythm a little more so register still fits */
@media (max-height: 640px) and (min-width: 481px) {
    body { padding: 10px 16px; }
    .login-container { padding: 26px 30px 22px; }
    .logo { margin-bottom: 18px; }
    .login-container h2 { margin-bottom: 5px; }
    .subtitle { margin-bottom: 20px; }
    .turnstile-holder { margin: 2px 0 6px; }
    .terms-privacy, .register-link, .forgot-password { margin-top: 10px; }
    .register-link { padding-top: 10px; }
}
/* very short screens (1280x720 laptops): a second, tighter step for the register form */
@media (max-height: 600px) and (min-width: 481px) {
    body { padding: 8px 16px; }
    .login-container { padding: 24px 30px 22px; }
    .logo { margin-bottom: 16px; }
    .login-container h2 { margin-bottom: 4px; }
    .subtitle { margin-bottom: 16px; }
    .form-group input { height: 40px; }
    .toggle-password { bottom: 7px; }
    button[type="submit"] { margin-top: 4px; }
    .turnstile-holder { margin: 0 0 6px; }
    .terms-privacy, .register-link, .forgot-password { margin-top: 8px; }
    .register-link { padding-top: 8px; }
}
@media (max-width: 480px) {
    body { padding: 12px; }
    .login-container { padding: 28px 20px 22px; border-radius: 12px; }
    .login-container h2 { font-size: 1.3rem; }
    .form-group { margin-bottom: 15px; }
    .form-row { margin-bottom: 16px; }
}