/* =============================================================================
   authentication.css  —  Auth pages (start, verify, login, register).

   This file ASSUMES tokens.css is loaded BEFORE it. All colors, surfaces,
   shadows, and motion come from there. Both dark (default) and light
   ([data-theme="light"]) themes are supported automatically.

   Sections:
     1.  Local font-face declarations (Estedad)
     2.  sr-only utility
     3.  Page layout (atmosphere shell)
     4.  Logo + theme toggle (corner controls)
     5.  Auth card (glassmorphic)
     6.  Auth header (badge + title + subtitle)
     7.  Form fields (input, password)
     8.  Primary + secondary buttons
     9.  Links / help / back row
     10. Toast / alert banner
     11. OTP 6-box + countdown + resend
     12. Password strength meter
     13. Register page (2-col grid + extras)
     14. Field errors / inline help
     15. Floating support FAB
     16. Light-theme fine-tuning
     17. Responsive
   ========================================================================== */

/* =============================================================================
   1. FONTS  —  Estedad family
   ========================================================================== */
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-Black.ttf') format('truetype');      font-weight:900; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-ExtraBold.ttf') format('truetype');  font-weight:800; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-Bold.ttf') format('truetype');       font-weight:700; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-SemiBold.ttf') format('truetype');   font-weight:600; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-Medium.ttf') format('truetype');     font-weight:500; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-Regular.ttf') format('truetype');    font-weight:400; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-Light.ttf') format('truetype');      font-weight:300; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-ExtraLight.ttf') format('truetype'); font-weight:200; font-display:swap; }
@font-face { font-family:'Estedad'; src:url('../fonts/ttf/Estedad-Thin.ttf') format('truetype');       font-weight:100; font-display:swap; }


/* =============================================================================
   2. SR-ONLY  (visually hidden but available to screen readers)
   ========================================================================== */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* =============================================================================
   3. PAGE LAYOUT  —  full-height centered shell sitting on .atmosphere
   ========================================================================== */
html, body { min-height: 100%; }
body { background: transparent; }   /* atmosphere paints the bg */

.auth-page {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 90px 16px 100px;       /* leave room for logo + support FAB */
    z-index: 1;
}


/* =============================================================================
   4. LOGO + CORNER CONTROLS
   ========================================================================== */
.auth-logo {
    position: absolute;
    top: 26px; right: 28px;
    display: inline-flex; align-items: center;
    transition: transform var(--t-fast);
    z-index: 5;
}
.auth-logo:hover { transform: translateY(-1px); }

.auth-logo__img {
    height: 42px;
    width: auto;
}
/* Dark logo (logo.png) — default visible. Drop-shadow makes it pop on the
   navy atmosphere. Light logo (logo2.png) hidden until [data-theme="light"]. */
.auth-logo__img--dark {
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .30));
}
.auth-logo__img--light {
    display: none;
}
[data-theme="light"] .auth-logo__img--dark  { display: none; }
[data-theme="light"] .auth-logo__img--light { display: block; filter: none; }

/* Theme toggle  (top-left, mirror of logo) */
.auth-theme-toggle {
    position: absolute;
    top: 26px; left: 28px;
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--ink-white);
    cursor: pointer;
    font-size: 1.05rem;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--t-fast);
    z-index: 5;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.auth-theme-toggle:hover {
    border-color: var(--gold-line);
    color: var(--gold-300);
    background: var(--surface-gold);
}
[data-theme="light"] .auth-theme-toggle:hover { color: var(--gold-700); }
.auth-theme-toggle .bi { transition: opacity var(--t), transform var(--t); position: absolute; }
.auth-theme-toggle .bi-sun-fill        { opacity: 1; transform: rotate(0); color: var(--gold-300); }
.auth-theme-toggle .bi-moon-stars-fill { opacity: 0; transform: rotate(-90deg); }
[data-theme="light"] .auth-theme-toggle .bi-sun-fill        { opacity: 0; transform: rotate(90deg); }
[data-theme="light"] .auth-theme-toggle .bi-moon-stars-fill { opacity: 1; transform: rotate(0); color: var(--navy-700); }


/* =============================================================================
   5. AUTH CARD  —  glassmorphic surface, gold hairline accent
   ========================================================================== */
.auth-card {
    position: relative;
    width: 100%;
    max-width: 480px;
    padding: 32px 28px 26px;
    border-radius: var(--r-lg);
    background: var(--surface-1);
    border: 1px solid var(--line);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: authCardIn .5s var(--t-slow);
}
.auth-card::before {
    content: ""; position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg,
        transparent, rgba(255, 194, 24, .50) 50%, transparent);
    pointer-events: none;
}
@keyframes authCardIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-card--register { max-width: 720px; }


/* =============================================================================
   6. AUTH HEADER
   ========================================================================== */
.auth-head { text-align: center; margin-bottom: 22px; }

.auth-title {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    margin: 0 0 14px;
    border-radius: var(--r-pill);
    background: var(--surface-gold);
    border: 1px solid var(--gold-line);
    color: var(--gold-300);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
}
.auth-title i { font-size: .9rem; }
[data-theme="light"] .auth-title { color: var(--gold-700); }

/* Card heading proper (semantic level chosen by template — h1) */
.auth-head h1.auth-title { font-size: .78rem; }   /* keep it pill-sized */
.auth-head h1.auth-title + .auth-subtitle { margin-top: 0; }

/* If a page wants a big heading instead of the pill, it can use .auth-heading */
.auth-heading {
    font-family: var(--ff-display);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--ink-white);
    line-height: 1.4;
    letter-spacing: -.012em;
    margin: 0 0 10px;
}

.auth-subtitle {
    color: var(--ink-soft);
    font-size: .9rem;
    line-height: 1.8;
    margin: 0 auto;
    max-width: 38ch;
}


/* =============================================================================
   7. FORM FIELDS
   ========================================================================== */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="tel"],
.auth-form input[type="password"],
.auth-form input[type="number"],
.auth-form input:not([type]) {
    width: 100%;
    padding: 13px 16px;
    background: var(--surface-1);
    color: var(--ink-white);
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r);
    font-family: inherit;
    font-size: .95rem;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color var(--t-fast),
                background var(--t-fast),
                box-shadow var(--t-fast);
}
.auth-form input::placeholder { color: var(--ink-faint); }
.auth-form input:hover {
    border-color: var(--line-strong);
    background: var(--surface-2);
}
.auth-form input:focus {
    outline: none;
    border-color: var(--gold-500);
    background: var(--surface-2);
    box-shadow: 0 0 0 4px rgba(255, 194, 24, .14);
}

/* Input wrapper for password (eye icon overlay) */
.auth-password-wrap {
    position: relative;
    width: 100%;
}
.auth-password-wrap input { padding-left: 46px; }   /* room for eye icon (RTL: left side) */

.auth-password-toggle {
    position: absolute;
    top: 50%; left: 8px;
    transform: translateY(-50%);
    width: 34px; height: 34px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--t-fast);
}
.auth-password-toggle:hover {
    background: var(--surface-gold);
    color: var(--gold-400);
}
.auth-password-toggle i { font-size: 1rem; }


/* =============================================================================
   8. BUTTONS
   ========================================================================== */
.auth-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 22px;
    border: none;
    border-radius: var(--r);
    background: linear-gradient(135deg,
        var(--gold-300), var(--gold-500) 50%, var(--gold-600));
    color: var(--navy-900);
    font-family: inherit;
    font-weight: 800;
    font-size: .95rem;
    cursor: pointer;
    box-shadow: var(--shadow-gold);
    position: relative;
    overflow: hidden;
    transition: transform var(--t-fast), box-shadow var(--t-fast);
    text-decoration: none;
}
.auth-btn::before {
    content: ""; position: absolute;
    top: 0; bottom: 0; left: -85%; width: 50%;
    background: linear-gradient(90deg,
        transparent, rgba(255, 255, 255, .55), transparent);
    transform: skewX(-22deg);
    transition: left .85s ease;
    pointer-events: none;
}
.auth-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px rgba(255, 194, 24, .42);
}
.auth-btn:hover:not(:disabled)::before { left: 130%; }
.auth-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}
.auth-btn i { font-size: 1rem; }

/* Secondary  (resend, etc.) */
.auth-btn--secondary {
    background: var(--surface-2);
    color: var(--ink-white);
    border: 1.5px solid var(--line-strong);
    box-shadow: none;
    font-weight: 700;
}
.auth-btn--secondary::before { display: none; }
.auth-btn--secondary:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--gold-line);
    color: var(--gold-300);
    background: var(--surface-gold);
    box-shadow: none;
}
[data-theme="light"] .auth-btn--secondary:hover:not(:disabled) {
    color: var(--gold-700);
}


/* =============================================================================
   9. LINKS / HELP / BACK
   ========================================================================== */
.auth-links {
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.auth-back {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .82rem;
    color: var(--ink-soft);
    transition: color var(--t-fast);
}
.auth-back::before {
    content: "→";
    font-size: .9rem;
    transition: transform var(--t-fast);
}
.auth-back:hover {
    color: var(--gold-300);
}
.auth-back:hover::before { transform: translateX(-3px); }
[data-theme="light"] .auth-back:hover { color: var(--gold-700); }

.auth-help {
    font-size: .78rem;
    color: var(--ink-muted);
    text-align: center;
    line-height: 1.9;
    margin: 0;
}
.auth-help a {
    color: var(--gold-300);
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 194, 24, .35);
    padding-bottom: 1px;
    transition: all var(--t-fast);
}
.auth-help a:hover {
    color: var(--gold-400);
    border-bottom-color: var(--gold-400);
}
[data-theme="light"] .auth-help a { color: var(--gold-700); }
[data-theme="light"] .auth-help a:hover { color: var(--gold-600); }

.auth-help-sep {
    color: var(--ink-faint);
    margin: 0 4px;
}

/* Inline link row used on verify pages */
.auth-links-row {
    display: flex; flex-wrap: wrap; gap: 6px 8px;
    align-items: center; justify-content: center;
    font-size: .8rem;
}
.auth-link {
    color: var(--ink-soft);
    border-bottom: 1px dashed rgba(255, 194, 24, .25);
    padding-bottom: 1px;
    transition: all var(--t-fast);
}
.auth-link:hover {
    color: var(--gold-300);
    border-bottom-color: var(--gold-line);
}
[data-theme="light"] .auth-link:hover { color: var(--gold-700); }
.auth-dot { color: var(--ink-faint); font-size: .7rem; }


/* =============================================================================
   10. TOAST / ALERT
   ========================================================================== */
.auth-alert {
    position: fixed;
    top: 22px; left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    min-width: 280px;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: var(--r);
    background: rgba(220, 38, 38, .14);
    border: 1px solid rgba(220, 38, 38, .35);
    color: #fecaca;
    font-size: .88rem;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: authAlertIn .25s var(--t-slow);
}
.auth-alert.is-success {
    background: rgba(34, 197, 94, .14);
    border-color: rgba(34, 197, 94, .35);
    color: #bbf7d0;
}
@keyframes authAlertIn {
    from { opacity: 0; transform: translate(-50%, -8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
[data-theme="light"] .auth-alert {
    background: rgba(220, 38, 38, .08);
    color: #991b1b;
}
[data-theme="light"] .auth-alert.is-success {
    background: rgba(34, 197, 94, .08);
    color: #166534;
}


/* =============================================================================
   11. OTP 6-BOX + COUNTDOWN + RESEND
   ========================================================================== */
.otp-wrap {
    margin: 4px 0 8px;
}
.otp {
    display: flex;
    gap: 8px;
    justify-content: center;
    direction: ltr;
}
.otp__box {
    width: 48px; height: 56px;
    text-align: center;
    background: var(--surface-1) !important;
    color: var(--ink-white) !important;
    border: 1.5px solid var(--line-strong) !important;
    border-radius: var(--r) !important;
    font-family: var(--ff) !important;
    font-size: 1.4rem !important;
    font-weight: 700 !important;
    padding: 0 !important;
    transition: border-color var(--t-fast),
                background var(--t-fast),
                box-shadow var(--t-fast),
                transform var(--t-fast);
    -webkit-appearance: none;
    appearance: none;
    caret-color: var(--gold-400);
}
.otp__box:hover {
    border-color: rgba(255, 194, 24, .25) !important;
}
.otp__box:focus {
    outline: none;
    border-color: var(--gold-500) !important;
    background: var(--surface-2) !important;
    box-shadow: 0 0 0 4px rgba(255, 194, 24, .14);
    transform: translateY(-1px);
}
.otp__box.filled {
    background: rgba(255, 194, 24, .08) !important;
    border-color: var(--gold-500) !important;
    color: var(--gold-300) !important;
}
[data-theme="light"] .otp__box.filled {
    color: var(--gold-700) !important;
}
.otp__box.error {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, .10) !important;
    color: #fca5a5 !important;
    animation: otpShake .35s ease;
}
[data-theme="light"] .otp__box.error {
    color: #b91c1c !important;
}
@keyframes otpShake {
    0%,100% { transform: translateX(0); }
    25%     { transform: translateX(-4px); }
    75%     { transform: translateX(4px); }
}

.otp-timer {
    text-align: center;
    margin-top: 6px;
    font-size: .82rem;
    color: var(--ink-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    width: 100%;
}
.otp-timer #remaining {
    color: var(--gold-300);
    font-weight: 800;
    font-size: .95rem;
    min-width: 1.5em;
}
[data-theme="light"] .otp-timer #remaining { color: var(--gold-700); }


/* =============================================================================
   12. PASSWORD STRENGTH METER
   ========================================================================== */
.password-strength {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--r);
}
.password-strength__meta {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .78rem;
    color: var(--ink-soft);
    margin-bottom: 8px;
}
.password-strength__meta strong {
    color: var(--ink-white);
    font-weight: 700;
}
.password-strength__meta span { color: var(--ink-muted); }

.password-strength__bar {
    position: relative;
    height: 6px;
    background: var(--surface-3);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.password-strength__bar > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    transition: width var(--t), background var(--t);
    background: var(--ink-faint);
}
.password-strength__bar > span.strength-1 { background: #ef4444; }
.password-strength__bar > span.strength-2 { background: #f97316; }
.password-strength__bar > span.strength-3 { background: #f59e0b; }
.password-strength__bar > span.strength-4 { background: #84cc16; }
.password-strength__bar > span.strength-5 {
    background: linear-gradient(90deg, var(--gold-400), var(--gold-600));
}

.password-checklist {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 4px;
}
.password-checklist li {
    position: relative;
    padding-right: 22px;
    font-size: .76rem;
    color: var(--ink-muted);
    transition: color var(--t-fast);
}
.password-checklist li::before {
    content: "○";
    position: absolute; right: 0; top: 0;
    color: var(--ink-faint);
    font-size: .9rem; line-height: 1.4;
    transition: all var(--t-fast);
}
.password-checklist li.is-valid {
    color: var(--ink-soft);
}
.password-checklist li.is-valid::before {
    content: "✓";
    color: #84cc16;
    font-weight: 800;
}
.password-checklist li.is-invalid::before {
    content: "✕";
    color: #ef4444;
}


/* =============================================================================
   13. REGISTER PAGE  —  2-col grid + extras
   ========================================================================== */
.auth-page--register {
    /* Slightly more breathing room since the card is taller */
    padding-top: 100px;
    padding-bottom: 110px;
}

.auth-form--register {
    gap: 16px;
}

.auth-register-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.auth-field label {
    color: var(--ink-soft);
    font-size: .82rem;
    font-weight: 700;
}

.auth-field--password,
.auth-field--register-password {
    margin-top: 4px;
}


/* =============================================================================
   14. FIELD ERRORS / INLINE HELP
   ========================================================================== */
.auth-form-errors {
    display: flex; flex-direction: column; gap: 6px;
    margin: 0 0 4px;
}
.auth-form-error-box {
    padding: 10px 14px;
    border-radius: var(--r-sm);
    background: rgba(220, 38, 38, .10);
    border: 1px solid rgba(220, 38, 38, .26);
    color: #fecaca;
    font-size: .82rem;
    line-height: 1.7;
}
[data-theme="light"] .auth-form-error-box {
    background: rgba(220, 38, 38, .06);
    color: #991b1b;
}

.auth-field-error {
    font-size: .74rem;
    color: #fca5a5;
    line-height: 1.6;
    padding-right: 2px;
}
[data-theme="light"] .auth-field-error { color: #b91c1c; }

.auth-inline-help {
    margin: 0;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    background: var(--surface-1);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: .78rem;
    line-height: 1.7;
}
.auth-inline-help--warn {
    background: rgba(255, 194, 24, .07);
    border-color: var(--gold-line);
    color: var(--gold-300);
}
[data-theme="light"] .auth-inline-help--warn { color: var(--gold-700); }


/* =============================================================================
   15. FLOATING SUPPORT FAB
   ========================================================================== */
#support {
    position: fixed;
    bottom: 22px; right: 24px;
    z-index: 50;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px 10px 14px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--ink-white);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    transition: all var(--t-fast);
}
#support i {
    font-size: 1rem;
    color: var(--gold-300);
}
#support:hover {
    transform: translateY(-2px);
    border-color: var(--gold-line);
    color: var(--gold-300);
    background: var(--surface-gold);
    box-shadow: var(--shadow);
}
[data-theme="light"] #support i { color: var(--gold-600); }
[data-theme="light"] #support:hover { color: var(--gold-700); }


/* =============================================================================
   16. LIGHT-THEME FINE-TUNING  (most things flip via tokens.css; this section
                                 only fixes a few hardcoded colors)
   ========================================================================== */
[data-theme="light"] .auth-card {
    background: var(--surface-2);   /* solid white surface in light */
    border-color: var(--line);
    box-shadow: var(--shadow);
}
[data-theme="light"] .auth-form input,
[data-theme="light"] .otp__box {
    background: #ffffff !important;
}
[data-theme="light"] .auth-form input:focus,
[data-theme="light"] .otp__box:focus {
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(255, 194, 24, .18);
}

[data-theme="light"] .auth-btn--secondary {
    background: #ffffff;
}
[data-theme="light"] .auth-btn--secondary:hover:not(:disabled) {
    background: var(--surface-gold);
}

[data-theme="light"] .password-strength {
    background: #ffffff;
}

[data-theme="light"] #support { background: #ffffff; }
[data-theme="light"] .auth-theme-toggle { background: #ffffff; }


/* =============================================================================
   17. RESPONSIVE
   ========================================================================== */
@media (max-width: 720px) {
    .auth-page { padding: 80px 14px 100px; }
    .auth-logo { top: 18px; right: 18px; }
    .auth-logo__img { height: 36px; }
    .auth-theme-toggle { top: 18px; left: 18px; width: 38px; height: 38px; }
    .auth-card { padding: 26px 20px 22px; border-radius: var(--r-md); }
    .auth-card--register { max-width: 100%; }
    .auth-register-grid { grid-template-columns: 1fr; gap: 12px; }
    .otp__box { width: 44px; height: 52px; font-size: 1.25rem !important; }
    .otp { gap: 6px; }
}

@media (max-width: 420px) {
    .auth-heading { font-size: 1.2rem; }
    .auth-subtitle { font-size: .85rem; }
    .otp__box { width: 40px; height: 48px; font-size: 1.15rem !important; }
    .otp { gap: 5px; }
    #support {
        bottom: 16px; right: 16px;
        padding: 9px 14px 9px 12px;
        font-size: .76rem;
    }
}
