/* ============================================================================
   Auth Experience — Editorial Split Layout, Semantic Tokens & Playful Mascot
   Dual Theme (Dark & Light) • RTL/LTR Native • WCAG AA Contrast
   ============================================================================ */

:root {
    --ae-surface-page: #080d18;
    --ae-surface-panel: #0c1322;
    --ae-surface-input: #111b2e;
    --ae-surface-input-focus: #152138;
    --ae-surface-elevated: #141f35;
    --ae-surface-control: rgba(255, 255, 255, 0.05);
    --ae-surface-control-hover: rgba(255, 255, 255, 0.1);
    --ae-border-subtle: rgba(148, 163, 184, 0.16);
    --ae-border-strong: rgba(148, 163, 184, 0.28);
    --ae-ink-primary: #f1f5f9;
    --ae-ink-secondary: #cbd5e1;
    --ae-ink-muted: #94a3b8;
    --ae-brand: #1b68ff;
    --ae-brand-hover: #357bff;
    --ae-brand-soft: rgba(27, 104, 255, 0.16);
    --ae-brand-link: #60a5fa;
    --ae-amber: #f59e0b;
    --ae-mascot-ring-bg: #111c32;
    --ae-mascot-ring-border: rgba(148, 163, 184, 0.22);
    --ae-bubble-bg: #152238;
    --ae-bubble-border: rgba(148, 163, 184, 0.22);
    --ae-shadow-dropdown: 0 18px 42px -12px rgba(2, 6, 23, 0.72);
    --ae-shadow-cta: 0 10px 24px -8px rgba(27, 104, 255, 0.55);
}

html.theme-light,
body.theme-light {
    --ae-surface-page: #f4f7fb;
    --ae-surface-panel: #ffffff;
    --ae-surface-input: #f8fafc;
    --ae-surface-input-focus: #ffffff;
    --ae-surface-elevated: #ffffff;
    --ae-surface-control: #f1f5f9;
    --ae-surface-control-hover: #e2e8f0;
    --ae-border-subtle: #e2e8f0;
    --ae-border-strong: #cbd5e1;
    --ae-ink-primary: #0f172a;
    --ae-ink-secondary: #334155;
    --ae-ink-muted: #64748b;
    --ae-brand: #1b68ff;
    --ae-brand-hover: #1454d6;
    --ae-brand-soft: rgba(27, 104, 255, 0.1);
    --ae-brand-link: #1d4ed8;
    --ae-amber: #d97706;
    --ae-mascot-ring-bg: #eef4ff;
    --ae-mascot-ring-border: #cbd5e1;
    --ae-bubble-bg: #f8fafc;
    --ae-bubble-border: #dbe3ef;
    --ae-shadow-dropdown: 0 18px 40px -12px rgba(15, 23, 42, 0.18);
    --ae-shadow-cta: 0 10px 24px -8px rgba(27, 104, 255, 0.36);
}

html,
body {
    background-color: var(--ae-surface-page) !important;
    color: var(--ae-ink-primary) !important;
    min-height: 100%;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* ============================================================================
   Split Editorial Layout
   ============================================================================ */

.auth-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background: var(--ae-surface-page);
}

.auth-visual-pane {
    position: relative;
    flex: 0 0 50%;
    min-height: 100vh;
    overflow: hidden;
    background: #0a1222;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.25rem 2.75rem;
}

@media (min-width: 1360px) {
    .auth-visual-pane {
        flex: 0 0 54%;
        padding: 2.75rem 3.5rem;
    }
}

.auth-hero-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 42%;
    transform: scale(1.03);
    animation: authHeroDrift 26s ease-in-out infinite alternate;
    will-change: transform;
}

@keyframes authHeroDrift {
    0% {
        transform: scale(1.02) translate3d(0, 0, 0);
    }
    100% {
        transform: scale(1.08) translate3d(0, -10px, 0);
    }
}

.auth-hero-scrim {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(7, 13, 24, 0.62) 0%, rgba(7, 13, 24, 0.16) 40%, rgba(7, 13, 24, 0.88) 84%, rgba(7, 13, 24, 0.96) 100%);
    pointer-events: none;
}

.auth-visual-top,
.auth-visual-bottom {
    position: relative;
    z-index: 2;
}

.auth-brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none !important;
    color: #ffffff !important;
}

.auth-brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    overflow: hidden;
    flex-shrink: 0;
}

.auth-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-brand-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.25;
}

.auth-brand-sub {
    display: block;
    font-size: 0.74rem;
    color: rgba(241, 245, 249, 0.76);
    font-weight: 500;
}

.auth-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.38rem 0.9rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.64);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    color: #f8fafc;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.9rem;
}

.auth-status-chip .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.auth-visual-title {
    font-size: clamp(1.35rem, 2.2vw, 1.85rem);
    font-weight: 800;
    line-height: 1.3;
    color: #ffffff;
    margin-bottom: 0.55rem;
    max-width: 34rem;
}

.auth-visual-copy {
    font-size: 0.92rem;
    line-height: 1.65;
    color: rgba(226, 232, 240, 0.84);
    margin: 0;
    max-width: 32rem;
}

/* ============================================================================
   Form Panel & Top Utility Bar
   ============================================================================ */

.auth-form-pane {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    background: var(--ae-surface-panel);
    padding: 1.5rem 2.25rem 2.25rem;
    position: relative;
    transition: background-color 0.25s ease;
}

.auth-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    max-width: 520px;
    margin: 0 auto 1.25rem;
}

.auth-home-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ae-ink-secondary);
    background: var(--ae-surface-control);
    border: 1px solid var(--ae-border-subtle);
    text-decoration: none !important;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.auth-home-link:hover {
    background: var(--ae-surface-control-hover);
    color: var(--ae-ink-primary);
    border-color: var(--ae-border-strong);
}

.auth-topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

/* Locale Switcher Dropdown */
.auth-locale-wrap {
    position: relative;
}

.auth-locale-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.48rem;
    height: 38px;
    padding: 0 0.8rem;
    border-radius: 10px;
    background: var(--ae-surface-control);
    border: 1px solid var(--ae-border-subtle);
    color: var(--ae-ink-primary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.auth-locale-trigger:hover,
.auth-locale-trigger[aria-expanded="true"] {
    background: var(--ae-surface-control-hover);
    border-color: var(--ae-border-strong);
}

.auth-locale-trigger .fe-globe {
    color: var(--ae-brand-link);
    font-size: 0.95rem;
}

.auth-locale-trigger .auth-locale-chevron {
    font-size: 0.82rem;
    color: var(--ae-ink-muted);
    transition: transform 0.2s ease;
}

.auth-locale-trigger[aria-expanded="true"] .auth-locale-chevron {
    transform: rotate(180deg);
}

.auth-locale-menu {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    min-width: 210px;
    padding: 0.45rem;
    border-radius: 14px;
    background: var(--ae-surface-elevated);
    border: 1px solid var(--ae-border-subtle);
    box-shadow: var(--ae-shadow-dropdown);
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transform: translate3d(0, -6px, 0) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s ease;
}

.auth-locale-wrap.is-open .auth-locale-menu {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0) scale(1);
}

.auth-locale-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--ae-ink-primary);
    cursor: pointer;
    text-align: start;
    transition: background-color 0.16s ease;
}

.auth-locale-option:hover {
    background: var(--ae-surface-control-hover);
}

.auth-locale-option.is-active {
    background: var(--ae-brand-soft);
    color: var(--ae-brand-link);
}

.auth-locale-option-left {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.auth-locale-flag {
    font-size: 1.08rem;
    line-height: 1;
}

.auth-locale-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.25;
}

.auth-locale-dir {
    display: block;
    font-size: 0.68rem;
    color: var(--ae-ink-muted);
    font-weight: 600;
}

/* Theme Toggle Button */
.auth-theme-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--ae-surface-control);
    border: 1px solid var(--ae-border-subtle);
    color: var(--ae-amber);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.auth-theme-btn:hover {
    background: var(--ae-surface-control-hover);
    border-color: var(--ae-border-strong);
    transform: translateY(-1px);
}

.auth-theme-btn .theme-moon-icon {
    display: none;
}

.auth-theme-btn .theme-sun-icon {
    display: inline-block;
}

body.theme-light .auth-theme-btn {
    color: #334155;
}

body.theme-light .auth-theme-btn .theme-sun-icon {
    display: none;
}

body.theme-light .auth-theme-btn .theme-moon-icon {
    display: inline-block;
}

/* Center Form Container */
.auth-form-center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-form {
    width: 100%;
    max-width: 420px;
}

.auth-form.wide {
    max-width: 520px;
}

.auth-heading {
    font-size: 1.38rem;
    font-weight: 800;
    color: var(--ae-ink-primary);
    margin-bottom: 0.3rem;
}

.auth-subheading {
    font-size: 0.88rem;
    color: var(--ae-ink-muted);
    margin-bottom: 0;
    line-height: 1.55;
}

/* ============================================================================
   Playful Port-Captain Mascot
   ============================================================================ */

.auth-mascot-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.15rem;
}

.auth-mascot-stage {
    position: relative;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: var(--ae-mascot-ring-bg);
    border: 2px solid var(--ae-mascot-ring-border);
    box-shadow: 0 12px 26px -14px rgba(15, 23, 42, 0.45);
    overflow: hidden;
    transition: border-color 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-mascot-wrap.is-watching .auth-mascot-stage {
    border-color: var(--ae-brand);
}

.auth-mascot-wrap.is-peeking-blocked .auth-mascot-stage {
    border-color: var(--ae-amber);
    transform: scale(1.03);
}

.auth-mascot-wrap.is-error .auth-mascot-stage {
    border-color: #ef4444;
    animation: mascotHeadShake 0.48s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.auth-mascot-wrap.is-submitting .auth-mascot-stage {
    border-color: #10b981;
    transform: translateY(-3px) scale(1.04);
}

@keyframes mascotHeadShake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    18% { transform: translate3d(-6px, 0, 0) rotate(-3deg); }
    36% { transform: translate3d(6px, 0, 0) rotate(3deg); }
    54% { transform: translate3d(-4px, 0, 0) rotate(-2deg); }
    72% { transform: translate3d(4px, 0, 0) rotate(2deg); }
}

.auth-mascot-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.mascot-head-group {
    transform-origin: 70px 76px;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.mascot-eyes-pupil {
    transition: transform 0.12s ease-out;
    will-change: transform;
}

.mascot-eyelids {
    transform-origin: 70px 67px;
    transform: scaleY(0);
    animation: mascotNaturalBlink 4.8s ease-in-out infinite;
    will-change: transform;
}

@keyframes mascotNaturalBlink {
    0%, 92%, 100% { transform: scaleY(0); }
    96% { transform: scaleY(1); }
}

.mascot-brows {
    transform-origin: 70px 56px;
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-mascot-wrap.is-watching .mascot-brows {
    transform: translate3d(0, -2.5px, 0);
}

.auth-mascot-wrap.is-password-hidden .mascot-brows {
    transform: translate3d(0, 1.5px, 0);
}

.auth-mascot-wrap.is-error .mascot-brows {
    transform: translate3d(0, -4px, 0);
}

.mascot-blush {
    opacity: 0;
    transition: opacity 0.28s ease;
}

.auth-mascot-wrap.is-peeking-blocked .mascot-blush,
.auth-mascot-wrap.is-submitting .mascot-blush {
    opacity: 0.72;
}

/* Mouth expression toggling */
.mascot-mouth-idle,
.mascot-mouth-curious,
.mascot-mouth-shy,
.mascot-mouth-oops,
.mascot-mouth-happy {
    transition: opacity 0.18s ease;
}

.mascot-mouth-curious,
.mascot-mouth-shy,
.mascot-mouth-oops,
.mascot-mouth-happy {
    opacity: 0;
}

.auth-mascot-wrap.is-watching .mascot-mouth-idle,
.auth-mascot-wrap.is-password-hidden .mascot-mouth-idle {
    opacity: 0;
}

.auth-mascot-wrap.is-watching .mascot-mouth-curious,
.auth-mascot-wrap.is-password-hidden .mascot-mouth-curious {
    opacity: 1;
}

.auth-mascot-wrap.is-peeking-blocked .mascot-mouth-idle,
.auth-mascot-wrap.is-peeking-blocked .mascot-mouth-curious {
    opacity: 0;
}

.auth-mascot-wrap.is-peeking-blocked .mascot-mouth-shy {
    opacity: 1;
}

.auth-mascot-wrap.is-error .mascot-mouth-idle,
.auth-mascot-wrap.is-error .mascot-mouth-curious,
.auth-mascot-wrap.is-error .mascot-mouth-shy {
    opacity: 0;
}

.auth-mascot-wrap.is-error .mascot-mouth-oops {
    opacity: 1;
}

.auth-mascot-wrap.is-submitting .mascot-mouth-idle,
.auth-mascot-wrap.is-submitting .mascot-mouth-curious,
.auth-mascot-wrap.is-submitting .mascot-mouth-shy,
.auth-mascot-wrap.is-submitting .mascot-mouth-oops {
    opacity: 0;
}

.auth-mascot-wrap.is-submitting .mascot-mouth-happy {
    opacity: 1;
}

/* Articulated Hands (Spring up to cover eyes when Show Password is clicked!) */
.mascot-hand-left,
.mascot-hand-right {
    transition: transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
}

.mascot-hand-left {
    transform: translate3d(-4px, 46px, 0) rotate(-14deg);
    transform-origin: 42px 124px;
}

.mascot-hand-right {
    transform: translate3d(4px, 46px, 0) rotate(14deg);
    transform-origin: 98px 124px;
}

/* Slight polite ready-lift when password is focused & masked */
.auth-mascot-wrap.is-password-hidden .mascot-hand-left {
    transform: translate3d(0, 26px, 0) rotate(-6deg);
}

.auth-mascot-wrap.is-password-hidden .mascot-hand-right {
    transform: translate3d(0, 26px, 0) rotate(6deg);
}

/* FULL EYE COVER when Show Password reveals plain text! */
.auth-mascot-wrap.is-peeking-blocked .mascot-hand-left {
    transform: translate3d(10px, -24px, 0) rotate(16deg);
}

.auth-mascot-wrap.is-peeking-blocked .mascot-hand-right {
    transform: translate3d(-10px, -24px, 0) rotate(-16deg);
}

.auth-mascot-wrap.is-peeking-blocked .mascot-head-group {
    transform: translate3d(0, 3px, 0) rotate(-5deg) !important;
}

/* Mascot Witty Caption Pill */
.auth-mascot-bubble {
    margin-top: 0.6rem;
    padding: 0.26rem 0.78rem;
    border-radius: 999px;
    background: var(--ae-bubble-bg);
    border: 1px solid var(--ae-bubble-border);
    color: var(--ae-ink-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.auth-mascot-wrap.is-peeking-blocked .auth-mascot-bubble {
    border-color: var(--ae-amber);
    color: var(--ae-amber);
}

.auth-mascot-wrap.is-error .auth-mascot-bubble {
    border-color: #ef4444;
    color: #ef4444;
}

/* ============================================================================
   Form Controls & Accessible States
   ============================================================================ */

.auth-field {
    margin-bottom: 1rem;
}

.auth-field label {
    display: block;
    font-weight: 700;
    font-size: 0.84rem;
    margin-bottom: 0.4rem;
    color: var(--ae-ink-secondary);
}

.auth-field .form-control {
    background: var(--ae-surface-input);
    border: 1px solid var(--ae-border-subtle);
    border-radius: 11px;
    color: var(--ae-ink-primary);
    padding: 0.68rem 0.95rem;
    font-size: 0.92rem;
    height: auto;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-field .form-control::placeholder {
    color: var(--ae-ink-muted);
    opacity: 0.72;
}

.auth-field .form-control:focus {
    background: var(--ae-surface-input-focus);
    border-color: var(--ae-brand);
    box-shadow: 0 0 0 3px var(--ae-brand-soft);
    color: var(--ae-ink-primary);
    outline: none;
}

.auth-field .form-control.has-password-toggle {
    padding-inline-end: 2.85rem;
}

.auth-password-toggle {
    position: absolute;
    inset-inline-end: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--ae-ink-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease;
}

.auth-password-toggle:hover {
    color: var(--ae-ink-primary);
    background: var(--ae-surface-control-hover);
}

.auth-password-toggle.is-revealed {
    color: var(--ae-amber);
}

.auth-link {
    color: var(--ae-brand-link);
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.16s ease;
}

.auth-link:hover {
    color: var(--ae-brand-link);
    text-decoration: underline;
}

.auth-muted-text {
    color: var(--ae-ink-muted);
}

.auth-remember-label {
    color: var(--ae-ink-secondary);
    font-weight: 600;
    cursor: pointer;
}

.btn-auth-primary {
    background: var(--ae-brand);
    border: none;
    border-radius: 11px;
    font-weight: 800;
    font-size: 0.94rem;
    padding: 0.78rem 1.2rem;
    width: 100%;
    color: #ffffff !important;
    box-shadow: var(--ae-shadow-cta);
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-auth-primary:hover {
    background: var(--ae-brand-hover);
    transform: translateY(-1px);
}

.btn-auth-primary:active {
    transform: translateY(0);
}

.btn-auth-primary:focus-visible {
    outline: 2px solid var(--ae-brand-link);
    outline-offset: 2px;
}

/* ============================================================================
   Responsive Mobile & Tablet Layout
   ============================================================================ */

@media (max-width: 991.98px) {
    .auth-shell {
        flex-direction: column;
    }

    .auth-visual-pane {
        flex: none;
        width: 100%;
        min-height: 210px;
        padding: 1.25rem 1.5rem;
    }

    .auth-visual-copy {
        display: none;
    }

    .auth-visual-title {
        font-size: 1.2rem;
        margin-bottom: 0;
    }

    .auth-form-pane {
        padding: 1.25rem 1.35rem 2.5rem;
    }

    .auth-mascot-stage {
        width: 98px;
        height: 98px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-hero-media,
    .mascot-eyelids {
        animation: none !important;
    }
    .mascot-head-group,
    .mascot-eyes-pupil,
    .mascot-hand-left,
    .mascot-hand-right {
        transition: none !important;
    }
}
