/*
 * Login, first password and code pages (layouts/student-auth), ported from the owner-approved gate page
 * (.superpowers/sdd/2026-10-22-student-platform-redesign/gate-approved/index.html: .a-body, .auth-*,
 * .d-auth, .login-foot, .meter, .rules, .chk). Built to public/css/ui/auth.css by scripts/build-ui.mjs
 * and linked by layouts/student-auth only.
 *
 * Changes against the approved page:
 *   - variable names: --text -> --ink, --text-2 -> --muted (tokens.js names);
 *   - the page's phone frame (.a-body) and desktop frame (.d-auth .stack) become .auth-main/.auth-stack:
 *     top-aligned with 28px on phones, centred with 56px and a 28px card padding from 640px;
 *   - .meter/.rules/.chk/.login-foot get an auth- prefix (ui.css is loaded on other pages too);
 *   - the strength meter and the rules are drawn from the classes the first-password script already
 *     sets (bg-red-500, text-green-600 ...), because the script replaces className on #meter and
 *     #meter-label: they are styled through their parents, never through a class of their own.
 */

.auth-main,.auth-main *{box-sizing:border-box}
.auth-main{min-height:100vh;min-height:100dvh;display:grid;justify-items:center;align-content:start;padding:28px 16px 24px}
.auth-stack{width:100%;max-width:440px;display:grid;gap:18px;min-width:0}

/* Emblem + school name (or the greeting) above the card */
.auth-brand{display:grid;justify-items:center;gap:6px;text-align:center;color:var(--ink);text-decoration:none;justify-self:center}
.auth-brand img{width:64px;height:64px;border-radius:16px;background:#ffffff;padding:4px;box-shadow:var(--shadow)}
.auth-brand b{font:900 20px/1.25 var(--font-head);color:var(--ink)}
.auth-brand small{font:500 13px/1.3 var(--font-body);color:var(--muted)}

/* The card */
.auth-card.ui-card{padding:20px;gap:16px}
.auth-card h1{margin:0;font:800 24px/1.25 var(--font-head);color:var(--ink)}
.auth-card .lead{margin:-8px 0 0;font-size:15px;line-height:1.6;color:var(--muted)}
.auth-card form{display:grid;gap:16px;margin:0}
.auth-card .auth-status{padding:10px 14px;border-radius:var(--r-ctl);background:var(--good-soft);color:var(--good);font:600 15px/1.5 var(--font-body)}
.auth-card .auth-errors{margin:6px 0 0;padding:0;list-style:none;font:600 13px/1.5 var(--font-body);color:var(--bad)}
.auth-foot{margin:0;display:flex;gap:8px;align-items:flex-start;font-size:15px;line-height:1.6;color:var(--muted)}
.auth-foot .ui-icon{margin-top:3px}

/* Quiet text button under the ID field (Ruling R24): switches the same field to the staff email mode */
.auth-mode{justify-self:start;display:inline-flex;align-items:center;min-height:44px;margin-block:-8px;padding:0 4px;border:0;background:transparent;color:var(--green);font:600 15px/1.4 var(--font-body);text-decoration:underline;text-underline-offset:3px;cursor:pointer}
.auth-mode:hover{color:var(--green-deep)}
:root.dark .auth-mode:hover{color:var(--ink)}

/* Below the card: «تسجيل الخروج» (ghost button) and the code page's way back */
.auth-out{justify-self:center;margin:0}

/* Desktop frame of the approved page (.d-auth): centred, more air, a 28px card padding */
@media (min-width:640px){
    .auth-main{align-content:center;padding:56px 24px 64px}
    .auth-stack{gap:20px}
    .auth-card.ui-card{padding:28px}
}

/* Code page: six spaced English digits */
/* letter-spacing also adds .6em after the last digit; text-indent:.6em puts the same space before the first, so the digits sit centred. */
.auth-card #code{direction:ltr;text-align:center;letter-spacing:.6em;text-indent:.6em;font:800 24px/1.2 var(--font-head);font-variant-numeric:tabular-nums}
.auth-card .auth-resend{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:0 4px;margin:0;text-align:center}
.auth-resend button{min-height:44px;padding:0 6px;border:0;background:transparent;color:var(--green);font:700 15px/1.4 var(--font-head);text-decoration:underline;text-underline-offset:3px;cursor:pointer}
.auth-resend button:disabled{color:var(--muted);text-decoration:none;cursor:not-allowed}
.auth-resend #countdown{font-size:13px;color:var(--muted)}

/* Strength meter: one track cut into four by surface-coloured gaps, the fill in the status colours */
.auth-meter{display:flex;align-items:center;gap:10px}
.auth-meter-track{flex:1;height:8px;border-radius:999px;background:var(--track);overflow:hidden;position:relative}
.auth-meter-track::after{content:"";position:absolute;inset:0;background:repeating-linear-gradient(to left,transparent 0 calc(25% - 3px),var(--surface) calc(25% - 3px) 25%)}
.auth-meter-track > div{display:block;height:100%;border-radius:999px}
.auth-meter > span{min-width:44px;width:auto;text-align:left;font:700 13px/1 var(--font-head);color:var(--muted)}
.auth-meter .bg-red-500{background:var(--bad)}
.auth-meter .bg-orange-500{background:var(--warn)}
.auth-meter .bg-yellow-500{background:var(--gold)}
.auth-meter .bg-green-600{background:var(--good)}
.auth-meter .text-red-500{color:var(--bad)}
.auth-meter .text-orange-500{color:var(--warn)}
.auth-meter .text-yellow-600{color:var(--gold-ink)}
.auth-meter .text-green-600{color:var(--good)}

/* Rules: an empty ring, then a green check when the script marks the rule as met */
.auth-rules{list-style:none;margin:0;padding:0;display:grid;gap:6px;font-size:13px;line-height:1.5;color:var(--muted)}
.auth-rules li{display:flex;align-items:center;gap:8px;color:var(--muted)}
.auth-rules li::before{content:"";width:16px;height:16px;border-radius:50%;border:2px solid var(--field-border);box-sizing:border-box;flex:none}
.auth-rules li.text-green-600{color:var(--good);font-weight:600}
.auth-rules li.text-green-600::before{border:0;background:var(--good) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/12px no-repeat}
:root.dark .auth-rules li.text-green-600::before{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f1c15' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")}

/* «متطابقتان ✓» / «غير متطابقتين» under the confirmation field (classes set by the same script) */
.auth-card #match{margin:0;height:auto;font:600 13px/1.5 var(--font-body)}
.auth-card #match:empty{display:none}
.auth-card #match.text-green-600{color:var(--good)}
.auth-card #match.text-red-500{color:var(--bad)}

/* «إظهار كلمة المرور»: the #show checkbox in a 44px row */
.auth-chk{display:flex;align-items:center;gap:10px;min-height:44px;font:600 15px/1.4 var(--font-body);color:var(--ink);cursor:pointer}
.auth-chk input{width:22px;height:22px;margin:0;accent-color:var(--btn-primary)}
