/* =============================================================================
   BitZed Admin — sign-in page
   Editorial split layout: paper brand panel with serif headline, form panel.
   ============================================================================= */

:root, [data-theme="light"] {
    --page:          #fbf9f5;
    --text:          #15130f;
    --text-2:        #6b655a;
    --text-3:        #a39b8c;
    --line:          #e6e0d4;
    --line-hover:    #cfc6b6;
    --field:         #ffffff;
    --field-shadow:  0 1px 2px rgba(40, 30, 10, 0.05);
    --icon:          #a39b8c;
    --chip:          #ffffff;
    --chip-line:     #e6e0d4;

    --btn:           #15130f;
    --btn-hover:     #2a2620;
    --btn-text:      #fbf9f5;
    --btn-shadow:    0 1px 2px rgba(21, 19, 15, 0.25),
                     0 8px 20px -6px rgba(21, 19, 15, 0.35),
                     inset 0 1px 0 rgba(255, 255, 255, 0.08);

    --brand-bg:      #f1ece2;
    --brand-ink:     #15130f;
    --brand-muted:   #6b655a;
    --brand-faint:   #a39b8c;
    --brand-rule:    #15130f;
    --brand-rule-2:  #d9d1c2;
    --brand-divider: #e2dbcd;
    --brand-grain:   0.22;
    --brand-blend:   multiply;
    --brand-accent:  #e07b0c;

    --accent:        #e8870f;
    --ring:          rgba(232, 135, 15, 0.20);
    --danger:        #c4320a;
    --danger-bg:     #fdf2ec;
    --danger-line:   #f6cdb8;
    --warn:          #b54708;

    color-scheme: light;
}

[data-theme="dark"] {
    --page:          #0f0e0c;
    --text:          #f1ece2;
    --text-2:        #a39b8c;
    --text-3:        #6f685c;
    --line:          #2a2722;
    --line-hover:    #3d3931;
    --field:         #171512;
    --field-shadow:  0 1px 2px rgba(0, 0, 0, 0.4);
    --icon:          #7d766a;
    --chip:          #171512;
    --chip-line:     #2a2722;

    --btn:           #f1ece2;
    --btn-hover:     #fbf7ef;
    --btn-text:      #15130f;
    --btn-shadow:    0 1px 2px rgba(0, 0, 0, 0.5),
                     0 10px 26px -8px rgba(240, 145, 43, 0.22),
                     inset 0 -1px 0 rgba(0, 0, 0, 0.08);

    --brand-bg:      #181613;
    --brand-ink:     #f1ece2;
    --brand-muted:   #a39b8c;
    --brand-faint:   #6f685c;
    --brand-rule:    #f1ece2;
    --brand-rule-2:  #34302a;
    --brand-divider: #26231e;
    --brand-grain:   0.10;
    --brand-blend:   overlay;
    --brand-accent:  #f0912b;

    --accent:        #f0912b;
    --ring:          rgba(240, 145, 43, 0.24);
    --danger:        #f97066;
    --danger-bg:     rgba(240, 68, 56, 0.08);
    --danger-line:   rgba(240, 68, 56, 0.28);
    --warn:          #fdb022;

    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color 0.25s ease, color 0.25s ease;
}

button, input { font: inherit; color: inherit; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.auth {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}
@media (min-width: 960px) {
    .auth { grid-template-columns: minmax(440px, 46%) 1fr; }
}

/* ── Brand panel (editorial) ────────────────────────────────────────────── */
.auth-brand {
    display: none;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: var(--brand-bg);
    color: var(--brand-ink);
    padding: 56px 60px;
    flex-direction: column;
    justify-content: space-between;
    gap: 48px;
    transition: background-color 0.25s ease, color 0.25s ease;
}
@media (min-width: 960px) { .auth-brand { display: flex; } }

/* Paper grain */
.auth-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: var(--brand-grain);
    mix-blend-mode: var(--brand-blend);
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Hairline divider between panels */
.auth-brand::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 1px;
    background: var(--brand-divider);
}

.auth-brand-index {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--brand-rule);
    font-size: 12px;
    letter-spacing: 0.04em;
}
.auth-brand-index b {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--brand-faint);
    font-variant-numeric: tabular-nums;
}

.auth-brand-headline {
    margin: 0;
    font-family: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-size: clamp(60px, 6.6vw, 104px);
    line-height: 0.92;
    letter-spacing: -0.025em;
}
.auth-brand-headline em {
    color: var(--brand-accent);
}

.auth-brand-foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--brand-rule-2);
}
.auth-brand-foot img {
    width: 58px;
    height: 58px;
    object-fit: contain;
    flex: none;
}
/* The eagle's dark outline needs a light ground on the dark panel */
[data-theme="dark"] .auth-brand-foot img,
[data-theme="dark"] .auth-mobile-brand img {
    padding: 7px;
    border-radius: 50%;
    background: #f1ece2;
    filter: none;
}
.auth-brand-foot p {
    margin: 0;
    max-width: 240px;
    text-align: right;
    font-size: 13px;
    line-height: 1.55;
    color: var(--brand-muted);
}

/* ── Form panel ─────────────────────────────────────────────────────────── */
.auth-main {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 72px 16px 32px;
}
@media (min-width: 960px) {
    .auth-main { padding: 48px; }
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid var(--chip-line);
    background: var(--chip);
    color: var(--text-2);
    box-shadow: var(--field-shadow);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--line-hover); }
.theme-toggle:active { transform: scale(0.96); }
[data-theme="light"] .theme-icon-sun  { display: none; }
[data-theme="dark"]  .theme-icon-moon { display: none; }

.auth-panel {
    width: 100%;
    max-width: 380px;
}

.auth-mobile-brand {
    display: flex;
    margin-bottom: 28px;
}
.auth-mobile-brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(40, 30, 10, 0.18));
}
@media (min-width: 960px) { .auth-mobile-brand { display: none; } }

.auth-head h1 {
    margin: 0;
    font-family: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    font-size: 48px;
    line-height: 1;
    font-weight: 400;
    letter-spacing: -0.015em;
}
.auth-head p {
    margin: 12px 0 0;
    font-size: 15px;
    color: var(--text-2);
    letter-spacing: -0.005em;
}

.auth-form {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: -0.005em;
}

.control {
    position: relative;
    display: flex;
    align-items: center;
}
.control input {
    width: 100%;
    height: 46px;
    padding: 0 14px 0 42px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--field);
    box-shadow: var(--field-shadow);
    font-size: 15px;
    letter-spacing: -0.005em;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.25s ease;
}
.control input[type="password"],
.control input#password { padding-right: 46px; }
.control input:hover { border-color: var(--line-hover); }
.control input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--ring), var(--field-shadow);
}
.control input:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--field) inset;
    caret-color: var(--text);
}
.control input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--field) inset, 0 0 0 4px var(--ring);
}
.field.is-invalid .control input { border-color: var(--danger); }
.field.is-invalid .control input:focus { box-shadow: 0 0 0 4px var(--danger-line); }

.control-icon {
    position: absolute;
    left: 14px;
    width: 17px;
    height: 17px;
    color: var(--icon);
    pointer-events: none;
    transition: color 0.15s ease;
}
.control:focus-within .control-icon { color: var(--text); }

.control-action {
    position: absolute;
    right: 6px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--icon);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.control-action:hover { color: var(--text); background: var(--line); }
.control-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.control-action svg { width: 17px; height: 17px; }
.control-action .eye-closed { display: none; }
.control-action[aria-pressed="true"] .eye-open { display: none; }
.control-action[aria-pressed="true"] .eye-closed { display: block; }

.field-hint {
    margin: 8px 0 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--warn);
}
.field-hint[hidden] { display: none; }

.auth-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid var(--danger-line);
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    animation: shake 0.38s cubic-bezier(.36, .07, .19, .97);
}
.auth-error[hidden] { display: none; }
.auth-error svg { flex: none; width: 17px; height: 17px; margin-top: 1px; }
@keyframes shake {
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.auth-submit {
    position: relative;
    margin-top: 6px;
    height: 46px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    background: var(--btn);
    color: var(--btn-text);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    box-shadow: var(--btn-shadow);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.2s ease;
}
.auth-submit:hover { background: var(--btn-hover); transform: translateY(-1px); }
.auth-submit:active { transform: translateY(1px) scale(0.995); }
.auth-submit:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring), var(--btn-shadow); }
.auth-submit:disabled { cursor: progress; opacity: 0.85; }

.login-arrow, .login-spinner { width: 16px; height: 16px; }
.login-arrow { transition: transform 0.18s ease; }
.auth-submit:hover .login-arrow { transform: translateX(3px); }
.login-spinner { display: none; animation: spin 0.8s linear infinite; }
.auth-submit.is-busy .login-spinner { display: block; }
.auth-submit.is-busy .login-arrow { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ── Entrance ───────────────────────────────────────────────────────────── */
.auth-mobile-brand, .auth-head, .auth-form > * {
    animation: rise 0.6s cubic-bezier(.2, .7, .2, 1) both;
}
.auth-head              { animation-delay: 0.04s; }
.auth-form > :nth-child(1) { animation-delay: 0.10s; }
.auth-form > :nth-child(2) { animation-delay: 0.15s; }
.auth-form > :nth-child(3) { animation-delay: 0.20s; }
.auth-form > :nth-child(4) { animation-delay: 0.20s; }
.auth-form > .auth-error { animation: shake 0.38s cubic-bezier(.36, .07, .19, .97); }
.auth-brand > * { animation: fade 0.9s ease both; }
.auth-brand-headline { animation-delay: 0.08s; }
.auth-brand-foot     { animation-delay: 0.16s; }
@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
@keyframes fade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Short desktop viewports: keep the headline from crowding the rules */
@media (min-width: 960px) and (max-height: 760px) {
    .auth-brand { padding: 44px 56px; }
    .auth-brand-headline { font-size: clamp(56px, 5.6vw, 84px); }
}
