/* ==========================================================================
   Mythos OLT - auth pages
   Login, change password, and 2FA setup.
   Plain CSS on purpose: these pages must render without the Tailwind runtime.
   Loaded after theme.css.
   ========================================================================== */

[hidden] { display: none !important; }
.hidden { display: none !important; }

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

body.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem 1rem;
    padding-top: max(2rem, env(safe-area-inset-top));
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
    background: var(--bg);
    overflow-x: hidden;
}

.auth-shell {
    width: 100%;
    max-width: 26rem;
}
.auth-shell--wide { max-width: 34rem; }

.auth-shell.fade-in { animation: authIn .18s var(--ease); }
@keyframes authIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------------- header */
.auth-head {
    margin-bottom: 1.15rem;
    text-align: left;
}

.logo-badge {
    position: relative;
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-bottom: .8rem;
    color: var(--accent);
    background: var(--surface2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
}
.logo-badge svg { width: 1.35rem; height: 1.35rem; display: block; flex: none; }

.logo-badge--amber { color: var(--amber); }
.logo-badge--sm {
    width: 2rem;
    height: 2rem;
    margin: 0 auto .55rem;
    border-radius: var(--r-sm);
}
.logo-badge--sm svg { width: 1.05rem; height: 1.05rem; }

.auth-eyebrow {
    margin-bottom: .25rem;
    font-family: var(--font-mono);
    font-size: .625rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.auth-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.01em;
    color: var(--text);
}

.auth-sub {
    margin: .3rem 0 0;
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--muted);
}

/* ------------------------------------------------------------------ card */
.auth-card {
    padding: 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: none;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: .9rem;
}

/* ---------------------------------------------------------------- fields */
.field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.field > label {
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

.input {
    width: 100%;
    min-height: 2.75rem;
    padding: .55rem .7rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: .875rem;
    line-height: 1.35;
    transition: border-color .12s var(--ease), background-color .12s var(--ease);
}
.input:hover { border-color: var(--border-strong); }
.input:focus {
    border-color: var(--focus);
    background: var(--surface);
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}
.input::placeholder { color: var(--muted); opacity: .75; }
.input[aria-invalid="true"] { border-color: var(--red); }

.input-wrap { position: relative; }
.input-wrap--toggle .input { padding-right: 2.9rem; }

.input-icon {
    position: absolute;
    left: .7rem;
    top: 50%;
    width: 1rem;
    height: 1rem;
    color: var(--muted);
    pointer-events: none;
    transform: translateY(-50%);
}
.input-wrap:focus-within .input-icon { color: var(--text); }
.input-wrap .input--icon { padding-left: 2.15rem; }

.pw-toggle {
    position: absolute;
    top: 50%;
    right: .3rem;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    transform: translateY(-50%);
    transition: color .12s var(--ease), background-color .12s var(--ease);
}
.pw-toggle:hover { color: var(--text); background: var(--surface3); }
.pw-toggle svg { width: 1.05rem; height: 1.05rem; }

.code-input {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: .35em;
    text-align: center;
}

/* --------------------------------------------------------------- buttons */
.btn-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    width: 100%;
    min-height: 2.75rem;
    padding: .55rem .85rem;
    background: var(--text);
    border: 1px solid var(--text);
    border-radius: var(--r-sm);
    color: var(--bg);
    font-family: var(--font-display);
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .01em;
    transition: opacity .12s var(--ease);
}
.btn-auth:hover:not(:disabled) { opacity: .88; }
.btn-auth:active:not(:disabled) { opacity: .8; }
.btn-auth:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
    background: var(--surface2);
    border-color: var(--border-strong);
    color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface3);
    border-color: var(--muted);
    opacity: 1;
}

.btn-auth .spinner { display: none; }
.btn-auth.is-loading .spinner { display: inline-block; }
.btn-auth.is-loading { cursor: wait; }

/* ---------------------------------------------------------------- alerts */
.error-box {
    display: none;
    align-items: flex-start;
    gap: .45rem;
    margin-bottom: .85rem;
    padding: .5rem .6rem;
    background: var(--bad-soft);
    border: 1px solid var(--red);
    border-radius: var(--r-sm);
    color: var(--red);
    font-size: .75rem;
    line-height: 1.45;
}
.error-box.show { display: flex; }
.error-box svg { width: 1rem; height: 1rem; flex: none; margin-top: .05rem; }

.hint { margin: 0; font-size: .6875rem; line-height: 1.45; color: var(--muted); }
.hint-good { color: var(--accent); }
.hint-bad { color: var(--red); }

.notice {
    display: flex;
    align-items: flex-start;
    gap: .45rem;
    padding: .55rem .65rem;
    background: var(--warn-soft);
    border: 1px solid var(--amber);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: .75rem;
    line-height: 1.5;
}
.notice svg { width: 1rem; height: 1rem; flex: none; margin-top: .1rem; color: var(--amber); }
.notice strong { color: var(--amber); }

/* -------------------------------------------------------- network summary */
.summary {
    margin-bottom: .9rem;
    padding: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .45rem .7rem;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

.summary-title {
    margin: 0;
    font-family: var(--font-mono);
    font-size: .625rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-tile {
    min-width: 0;
    padding: .6rem .55rem;
    border-left: 1px solid var(--border);
}
.summary-tile:first-child { border-left: 0; }

.summary-label {
    font-family: var(--font-mono);
    font-size: .5625rem;
    line-height: 1.3;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-value {
    margin-top: .2rem;
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.summary-value.is-online { color: var(--accent); }
.summary-value.is-offline { color: var(--muted); }
.summary-value.is-los { color: var(--red); }

.summary-foot {
    margin: 0;
    padding: .45rem .7rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: .625rem;
    line-height: 1.4;
    color: var(--muted);
}

/* -------------------------------------------------------------- fragments */
.auth-step-head { text-align: center; }

.step-copy {
    margin: .35rem 0 0;
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--text);
}

.step-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
}

.step-num {
    display: inline-grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    background: var(--surface2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xs);
    font-family: var(--font-mono);
    font-size: .625rem;
    font-weight: 600;
    color: var(--muted);
}

.auth-links {
    display: flex;
    justify-content: center;
    padding-top: .1rem;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: .25rem .35rem;
    background: transparent;
    border: 0;
    color: var(--muted);
    font-family: var(--font-body);
    font-size: .75rem;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    transition: color .12s var(--ease);
}
.link-btn:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.recovery-box {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding-top: .1rem;
}

.secret-row { display: flex; align-items: stretch; gap: .4rem; }

.secret-code {
    flex: 1;
    min-width: 0;
    padding: .55rem .6rem;
    overflow-wrap: anywhere;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .8125rem;
    line-height: 1.4;
    text-align: center;
}

.btn-copy {
    flex: 0 0 auto;
    min-height: 2.75rem;
    padding: .4rem .65rem;
    background: var(--surface2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: var(--font-display);
    font-size: .75rem;
    font-weight: 600;
}
.btn-copy:hover { background: var(--surface3); border-color: var(--muted); }

/* -------------------------------------------------------------------- QR */
.qr-wrap {
    display: flex;
    justify-content: center;
    padding: .65rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}
.qr-wrap img {
    display: block;
    width: 200px;
    height: 200px;
    padding: 8px;
    background: #ffffff;
    border-radius: 4px;
}
.qr-placeholder {
    padding: 2rem .75rem;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: .6875rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
}

.recovery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .3rem;
}

.recovery-code {
    padding: .4rem .45rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .75rem;
    line-height: 1.4;
    text-align: center;
    overflow-wrap: anywhere;
}
.recovery-code:hover { border-color: var(--border-strong); }

.success-badge {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    margin: 0 auto .5rem;
    color: var(--accent);
    background: var(--ok-soft);
    border: 1px solid var(--accent);
    border-radius: var(--r-md);
}
.success-badge svg { width: 1.5rem; height: 1.5rem; }

.auth-footer {
    margin-top: .9rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
    font-size: .6875rem;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
}
.auth-footer .link-btn { font-size: .6875rem; min-height: 2rem; }

/* ---------------------------------------------------------- theme toggle */
.auth-theme-toggle {
    position: fixed;
    top: max(.9rem, env(safe-area-inset-top));
    right: max(.9rem, env(safe-area-inset-right));
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--muted);
    transition: color .12s var(--ease), border-color .12s var(--ease), background .12s var(--ease);
}
.auth-theme-toggle:hover {
    color: var(--text);
    border-color: var(--muted);
    background: var(--surface2);
}
.auth-theme-toggle:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    color: var(--text);
}
.auth-theme-toggle svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------- responsive */
@media (max-height: 900px) {
    body.auth { align-items: flex-start; }
}

@media (max-width: 420px) {
    body.auth { padding: 1.25rem .75rem; }
    .auth-title { font-size: 1.2rem; }
    .auth-card { padding: .95rem; }
    .summary-tile { padding: .5rem .4rem; }
    .summary-value { font-size: 1.1rem; }
    .auth-footer { margin-top: .75rem; }
    .auth-theme-toggle { top: max(.75rem, env(safe-area-inset-top)); right: max(.75rem, env(safe-area-inset-right)); }
}

@media (max-width: 340px) {
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary-tile:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }
    .summary-tile:nth-child(4) { border-top: 1px solid var(--border); }
}

@media (pointer: coarse), (max-width: 900px) {
    .pw-toggle { width: 44px; height: 44px; right: .15rem; }
    .link-btn,
    .auth-footer .link-btn { min-height: 44px; }
    .recovery-code { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-shell.fade-in { animation: none; }
    .btn-auth, .input, .pw-toggle, .link-btn, .auth-theme-toggle { transition: none; }
}
