/* ============================================================================
   Auth — Signup, Login, password reset, settings form controls.
   One narrow centered column on the aistarlets tokens (aistarlets.css).
   Google-first: the provider button is the primary CTA, the email form sits
   under an "or" divider. Dark-only.
   Class names are shared with settings.html / account templates.
   ============================================================================ */

:root { --auth-radius: 24px; --auth-ctl-h: 52px; }

/* ---------- Stage ------------------------------------------------------- */
.auth {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 60vh;
    padding: clamp(28px, 6vh, 72px) 18px clamp(28px, 6vh, 56px);
}

/* ---------- The card ---------------------------------------------------- */
.auth-card {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 424px;
    padding: clamp(28px, 5vw, 40px) clamp(22px, 5vw, 36px) clamp(24px, 5vw, 32px);
    border-radius: var(--auth-radius);
    background: var(--ast-surface);
    border: 1px solid var(--ast-line);
    box-shadow: 0 30px 90px -50px rgba(0, 0, 0, .85);
}

.auth-main { display: flex; flex-direction: column; }

/* ---------- Head -------------------------------------------------------- */
.auth-wordmark {
    display: block;
    width: fit-content;
    margin: 0 auto 22px;
    font-weight: 800;
    font-size: 21px;
    letter-spacing: -.03em;
    line-height: 1;
    color: var(--ast-text);
    text-decoration: none;
}
.auth-wordmark span { color: var(--ast-accent-a); }

.auth-head { margin-bottom: 22px; text-align: center; }
.auth-title {
    margin: 0 0 6px;
    font-weight: 800;
    font-size: clamp(1.5rem, 3vw, 1.7rem);
    line-height: 1.1;
    letter-spacing: -.02em;
    color: var(--ast-text);
    text-wrap: balance;
}
.auth-sub { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ast-muted); }

/* ---------- Provider button (primary CTA) ------------------------------- */
.auth-socials { display: flex; flex-direction: column; gap: 10px; }
.auth-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    min-height: var(--auth-ctl-h);
    padding: 0 20px;
    border-radius: 14px;
    font-family: var(--ast-font);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    color: #1f1f1f;
    background: #fff;
    border: 1px solid #fff;
    box-shadow: 0 10px 26px -14px rgba(255, 255, 255, .55);
    transition: background .18s ease, transform .16s ease, box-shadow .18s ease;
}
.auth-google:hover { background: #f1f1f4; transform: translateY(-1px); }
.auth-google:active { transform: scale(.99); }
.auth-google:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--ast-accent-a) 40%, transparent);
}
.auth-google svg { flex-shrink: 0; }

/* ---------- Divider ----------------------------------------------------- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 18px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--ast-faint);
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--ast-line); }

/* ---------- Fields ------------------------------------------------------ */
.auth-form { display: flex; flex-direction: column; gap: 12px; }

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ast-muted);
}
/* Quiet forms (signup / login) rely on placeholders; the label stays for AT. */
.auth-form--quiet .auth-field > label {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.auth-input { position: relative; display: flex; align-items: center; }
.auth-input-icon {
    position: absolute;
    left: 15px;
    width: 18px; height: 18px;
    color: var(--ast-muted);
    pointer-events: none;
    transition: color .2s ease;
}
.auth-input input {
    box-sizing: border-box;
    width: 100%;
    min-height: var(--auth-ctl-h);
    padding: 0 16px 0 44px;
    font-family: var(--ast-font);
    font-size: 15px;
    color: var(--ast-text);
    background: var(--ast-surface-soft);
    border: 1px solid var(--ast-line-strong);
    border-radius: 14px;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.auth-input input::placeholder { color: var(--ast-muted); }
.auth-input input:focus {
    outline: none;
    border-color: var(--ast-accent-a);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--ast-accent-a) 16%, transparent);
}
.auth-input:focus-within .auth-input-icon { color: var(--ast-accent-a); }
.auth-input--toggle input { padding-right: 50px; }

/* show / hide password */
.auth-input-toggle {
    position: absolute;
    right: 6px;
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ast-muted);
    cursor: pointer;
    transition: color .16s ease, background .16s ease;
}
.auth-input-toggle:hover { color: var(--ast-text); background: var(--ast-surface-hover); }
.auth-input-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--ast-accent-a) 30%, transparent);
}
.auth-input-toggle svg { width: 19px; height: 19px; }
.auth-input-toggle .i-hide { display: none; }
.auth-input-toggle[aria-pressed="true"] .i-show { display: none; }
.auth-input-toggle[aria-pressed="true"] .i-hide { display: block; }

/* invalid state + inline error */
.auth-field.is-invalid .auth-input input {
    border-color: color-mix(in oklab, var(--ast-danger) 70%, transparent);
}
.auth-field.is-invalid .auth-input input:focus {
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--ast-danger) 16%, transparent);
}
.auth-field.is-invalid .auth-input-icon { color: var(--ast-danger); }
.auth-error {
    margin: 0;
    padding: 0 4px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--ast-danger);
}
.auth-error a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

/* password row: "Forgot?" sits on the right of the field on login */
.auth-field-row {
    display: flex;
    justify-content: flex-end;
    margin-top: -2px;
    padding: 0 4px;
}
.auth-field-row a {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ast-muted);
    text-decoration: none;
}
.auth-field-row a:hover { color: var(--ast-accent-a); }

/* ---------- Submit ------------------------------------------------------ */
.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin-top: 2px;
    width: 100%;
    min-height: var(--auth-ctl-h);
    padding: 0 16px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-family: var(--ast-font);
    font-size: 15px;
    font-weight: 700;
    color: var(--ast-bg);
    background: var(--ast-accent);
    box-shadow: 0 10px 26px -12px var(--ast-accent-a);
    transition: transform .16s ease, filter .2s ease, opacity .2s ease;
}
.auth-submit:hover { transform: translateY(-1px); filter: brightness(1.04); }
.auth-submit:active { transform: scale(.99); }
.auth-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--ast-accent-a) 40%, transparent);
}
.auth-submit[disabled] { opacity: .7; cursor: default; transform: none; filter: none; }

/* ---------- Legal line + footer link ------------------------------------ */
.auth-legal {
    margin: 18px 0 0;
    text-align: center;
    font-size: 12px;
    line-height: 1.55;
    color: var(--ast-muted);
    text-wrap: balance;
}
.auth-legal a { color: var(--ast-text-2); text-decoration: underline; text-underline-offset: 2px; }
.auth-legal a:hover { color: var(--ast-accent-a); }

.auth-alt {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--ast-line);
    text-align: center;
    font-size: 14px;
    color: var(--ast-muted);
    line-height: 1.7;
}
.auth-alt a {
    color: var(--ast-text);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid color-mix(in oklab, var(--ast-accent-a) 60%, transparent);
    padding-bottom: 1px;
    transition: color .2s ease, border-color .2s ease;
}
.auth-alt a:hover { color: var(--ast-accent-a); border-color: var(--ast-accent-a); }
.auth-alt .auth-alt-muted { display: block; margin-bottom: 6px; }
.auth-alt .auth-forgot { font-weight: 500; }

/* ---------- Status pages (link-sent / complete / expired) --------------- */
.auth-status { text-align: center; }
.auth-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px; height: 58px;
    margin-bottom: 20px;
    border-radius: 50%;
    color: var(--ast-accent-a);
    background: color-mix(in oklab, var(--ast-accent-a) 14%, transparent);
    box-shadow: 0 0 0 6px color-mix(in oklab, var(--ast-accent-a) 7%, transparent);
}
.auth-status-icon svg { width: 27px; height: 27px; }
.auth-status .auth-title { margin-bottom: 10px; }
.auth-status .auth-sub + .auth-sub { margin-top: 10px; }
.auth-status .auth-submit { margin-top: 26px; }
.auth-status .auth-alt { margin-top: 22px; }

/* ---------- Messages / errors ------------------------------------------- */
.auth-messages { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.auth-message {
    padding: 12px 15px;
    border-radius: 13px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    background: var(--ast-surface-soft);
    border: 1px solid var(--ast-line-strong);
    color: var(--ast-text-2);
}
.auth-message.error {
    background: color-mix(in oklab, var(--ast-danger) 12%, var(--ast-surface));
    color: var(--ast-danger);
    border-color: color-mix(in oklab, var(--ast-danger) 40%, transparent);
}
.auth-message.success {
    background: color-mix(in oklab, var(--ast-online) 12%, var(--ast-surface));
    color: var(--ast-online);
    border-color: color-mix(in oklab, var(--ast-online) 40%, transparent);
}

/* Django field errors + helptext (reset / settings forms) */
.auth-form .errorlist {
    list-style: none;
    margin: 2px 0 0;
    padding: 0 4px;
    font-size: 12.5px;
    color: var(--ast-danger);
}
.auth-form .helptext { font-size: 12px; color: var(--ast-muted); line-height: 1.5; }
.auth-login .auth-form .helptext { display: none; }

/* ---------- Responsive -------------------------------------------------- */
@media (max-width: 800px) {
    .auth { padding: 18px 0 32px; }
    /* Full-bleed on mobile: the page itself is the card. */
    .auth-card {
        max-width: none;
        padding: 22px 20px 28px;
        border: none;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }
    .auth-wordmark { margin-bottom: 18px; }
}
