/*
 * Sign in, register, forgot password, reset password.
 *
 * These four pages carried near-identical inline <style> blocks — roughly 800
 * lines between them, all describing the same card. They now share this file,
 * so the four cannot drift apart again.
 *
 * Sign-in is the one screen with nothing else on it, so it is where the
 * material is clearest: a single pane of glass floating on the painted sky,
 * its head lit a shade brighter than its body, as a real sheet is where the
 * light catches it. Requires style.css, which defines the tokens.
 */

body {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--s-5) var(--s-4) var(--s-6);
}

@media (min-height: 700px) {
    body { align-items: center; }
}

.login-wrap, .register-wrap { width: 100%; max-width: 27rem; }

/*
 * A thicker blur than the panes inside the app, and the heavier of the two
 * shadows: there is nothing else on this screen for it to sit level with, so
 * it has to lift off the ground on its own.
 */
.login-card, .register-card {
    background: var(--surface);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid var(--glass-edge);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lift), inset 0 1px 0 var(--glass-inner);
    overflow: hidden;
}

/* ── Masthead ───────────────────────────────────────────────────────────── */

/*
 * The one piece of weight on the page. Left-aligned, because a register is
 * written from the left, and because centred text at this size reads as a
 * splash screen rather than as the head of a form. The lighter fill is the
 * lit top edge of the pane, not a gradient banner.
 */
.login-hero, .register-hero {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-5) var(--s-5) var(--s-4);
    background: var(--sunken);
    border-bottom: 1px solid var(--rule);
}

/*
 * The app's mark. It is a white calendar drawn with a slate outline, so on a
 * pale pane it needs a ground of its own or it dissolves into the glass.
 */
.auth-logo {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    padding: 6px;
    border-radius: var(--r-md);
    background: var(--accent-strong);
    box-shadow: 0 6px 16px rgb(24 119 242 / 30%);
}
.login-hero h1, .register-hero h1 {
    margin: 0;
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
}
.login-hero p, .register-hero p {
    margin: var(--s-1) 0 0;
    font-size: 0.875rem;
    color: var(--ink-muted);
    max-width: none;
}

/* ── Body ───────────────────────────────────────────────────────────────── */

.login-body, .register-body { padding: var(--s-5); }

.login-greeting { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--s-1); }
.login-sub { font-size: 0.875rem; color: var(--ink-muted); margin-bottom: var(--s-5); }

/* ── Fields ─────────────────────────────────────────────────────────────── */

.form-field { margin-bottom: var(--s-4); }

/*
 * Sentence case, not tracked-out capitals. All-caps labels are slower to read
 * and are one of the commonest tells of a generated page.
 */
.form-label {
    display: block;
    margin-bottom: var(--s-1);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-muted);
    letter-spacing: 0;
    text-transform: none;
}

.input-wrap { position: relative; }

.input-icon {
    position: absolute;
    left: var(--s-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-faint);
    pointer-events: none;
    z-index: 1;
}

/*
 * A field is a thinner pane set into the card: less blur, a brighter fill on
 * focus. It reads as recessed rather than as a white box dropped on glass.
 */
.form-input {
    width: 100%;
    min-height: 44px;                       /* section 2.1 */
    padding: var(--s-2) var(--s-3) var(--s-2) 2.5rem;
    border: 1px solid var(--glass-edge);
    border-radius: var(--r-md);
    /* 16px floor, or iOS zooms the page in on focus and never zooms back
       (section 5.2). The old value was 14px. */
    font: inherit;
    font-size: max(1rem, 16px);
    color: var(--ink);
    background: var(--sunken);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.form-input::placeholder { color: var(--ink-faint); }
.form-input:focus {
    background: var(--surface-strong);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-sunken);
}
.form-input.is-invalid { border-color: var(--absent); }

/* Reachable by keyboard — it used to carry tabindex="-1". */
.pw-toggle {
    position: absolute;
    right: var(--s-1);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: 0;
    border-radius: var(--r-sm);
    color: var(--ink-faint);
    cursor: pointer;
    z-index: 1;
}
.pw-toggle:hover { color: var(--accent); }

.form-divider {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: var(--s-5) 0;
}

/* ── Messages ───────────────────────────────────────────────────────────── */

/* Bordered all the way round, matching .alert in style.css. */
.error-alert, .success-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
    padding: var(--s-3);
    margin-bottom: var(--s-4);
    border: 1px solid;
    border-radius: var(--r-md);
    font-size: 0.9rem;
}
.error-alert   { background: var(--absent-sunken);  border-color: var(--absent);  color: var(--absent); }
.success-alert { background: var(--present-sunken); border-color: var(--present); color: var(--present); }
.error-alert i, .success-alert i { flex-shrink: 0; margin-top: 2px; }

/* The message is focused after a rejected submit; it should not draw its own
   focus ring on top of the coloured block. */
.error-alert:focus { outline: none; }
.error-alert:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* ── Submit ─────────────────────────────────────────────────────────────── */

/* The one solid thing on the screen. Everything else is translucent, so the
   action the page exists for is the only object with real weight. */
.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: var(--r-md);
    background: var(--accent-strong);
    color: var(--on-accent);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px rgb(24 119 242 / 32%);
    transition: background-color .15s ease, box-shadow .15s ease;
}
.btn-login:hover { background: var(--accent-hover); box-shadow: 0 8px 22px rgb(24 119 242 / 38%); }
.btn-login:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ── Footer ─────────────────────────────────────────────────────────────── */

.login-footer, .register-footer {
    margin-top: var(--s-4);
    font-size: 0.875rem;
    color: var(--ink-muted);
}
.login-footer a, .register-footer a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.login-footer a:hover, .register-footer a:hover { text-decoration: underline; }
.login-footer .sep, .register-footer .sep { margin: 0 var(--s-2); color: var(--ink-faint); }

/* Links sit on their own line on a phone rather than wrapping mid-row. */
@media (max-width: 24rem) {
    .login-footer .sep, .register-footer .sep { display: block; height: 0; margin: var(--s-2) 0; overflow: hidden; }
}

/* ── Password strength ──────────────────────────────────────────────────── */

/*
 * Only reset_password.php uses this. The width and colour are set from script;
 * this gives it the track, the geometry and the transition.
 *
 * The bar is a second cue, not the only one — checkStrength() also writes the
 * word ("Weak", "Strong") next to it, which is what section 13.3 requires.
 */
.pw-strength {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-top: var(--s-2);
}
.pw-strength-bar {
    flex: 1;
    height: 4px;
    background: var(--rule);
    border-radius: var(--r-sm);
    overflow: hidden;
}
/*
 * Scaled, not resized. Animating width relays out the page on every frame;
 * a transform is composited and costs nothing. checkStrength() sets the
 * scale, so the bar is always full width and drawn from the left edge.
 */
.pw-strength-fill {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    transform: scaleX(0);
    transform-origin: left center;
    /* Named properties, not `all` (section 10.1). */
    transition: transform .2s ease, background-color .2s ease;
}
.pw-strength-label { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
    .pw-strength-fill { transition: none; }
}
