/* ===========================================================================
   Auth screens — "Control Room / Signal Terminal" art direction.
   Self-contained dark palette, scoped to .auth. Distinct from the themeable
   app shell on purpose: the sign-in is a fixed, art-directed first impression.
   Type: Instrument Serif (display) · IBM Plex Mono (technical) · Hanken Grotesk (UI)
   =========================================================================== */

.auth {
    /* palette */
    --ink:      #0a0d12;
    --ink-2:    #0e121a;
    --ink-3:    #141a24;
    --line:     rgba(255, 255, 255, 0.08);
    --line-2:   rgba(255, 255, 255, 0.14);
    --text:     #e9ebef;
    --muted:    #828c9b;
    --faint:    #4b5563;
    /* ⚠ AMC'S SIGNAL IS CYAN. AI-BPMS's sign-in — same art direction, same
       stage, same layout — is amber (#ffb000). Two identical amber login
       screens on one machine, one on :80 and one on :8080, is how somebody
       types their password into the wrong application and then reports that
       the system is broken.

       Warm against cool is the fastest distinction a person can make at a
       glance, and amber/cyan survives every common form of colour blindness —
       which an amber/orange or red/green split would not.

       --signal-rgb exists so every translucent variant below, and the
       constellation canvas in auth.js, derives from ONE value. The colour used
       to be written out eleven times as rgba(255,176,0,…) plus once more in
       JavaScript, so re-skinning meant finding all twelve. */
    --signal:     #22d3ee;
    --signal-2:   #67e8f9;
    --signal-rgb: 34, 211, 238;
    --signal-soft: rgba(var(--signal-rgb), 0.13);
    /* Text that sits ON the signal colour — the primary button, the checkbox
       tick. Near-black with a cyan cast, so it belongs to the palette. */
    --on-signal:  #04222a;
    --ok:       #4ade80;

    /* tokens the shared flash partial expects, mapped to this palette */
    --color-surface: var(--ink-3);
    --color-text: var(--text);
    --color-muted: var(--muted);
    --color-border: var(--line-2);
    --color-success: var(--ok);     --color-success-bg: #11241a;
    --color-danger:  #ff6b6b;       --color-danger-bg:  #251416;
    /* Tinted to the signal, like the rest — #241c0c was the amber-dark these
       banners used, and an amber panel on a cyan page reads as a stray. */
    --color-info:    var(--signal); --color-info-bg:    #0a2026;
    --color-warning: var(--signal); --color-warning-bg: #0a2026;
    --motion-duration: 200ms;

    margin: 0;
    min-height: 100vh;
    background: var(--ink);
    color: var(--text);
    font-family: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.auth * { box-sizing: border-box; }
.auth ::selection { background: var(--signal); color: var(--on-signal); }

/* --- shell: split stage / form ------------------------------------------- */
.auth-wrap {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    min-height: 100vh;
    position: relative;
}

/* film grain over everything */
.auth-wrap::after {
    content: "";
    position: fixed; inset: 0;
    pointer-events: none; z-index: 50;
    opacity: 0.05; mix-blend-mode: overlay;
    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='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* =======================  LEFT — THE STAGE  ============================== */
.stage {
    position: relative;
    overflow: hidden;
    padding: clamp(2rem, 5vw, 4.5rem);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        radial-gradient(120% 90% at 12% 0%, rgba(var(--signal-rgb), 0.08), transparent 55%),
        radial-gradient(80% 70% at 100% 100%, rgba(40, 70, 120, 0.12), transparent 60%),
        var(--ink-2);
    border-right: 1px solid var(--line);
}
/* blueprint grid */
.stage::before {
    content: "";
    position: absolute; inset: 0; z-index: 0;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(120% 100% at 30% 20%, #000 35%, transparent 80%);
            mask-image: radial-gradient(120% 100% at 30% 20%, #000 35%, transparent 80%);
    opacity: 0.6;
}
/* node constellation canvas */
.stage canvas {
    position: absolute; inset: 0; z-index: 1;
    width: 100%; height: 100%;
    opacity: 0.9;
}
.stage > * { position: relative; z-index: 2; }

/* rotated edge label */
.edge-label {
    position: absolute; left: 1.1rem; top: 50%;
    transform: translateY(-50%) rotate(180deg);
    writing-mode: vertical-rl;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem; letter-spacing: 0.32em;
    color: var(--faint); text-transform: uppercase;
    z-index: 3;
}

/* top rail: brand mark + status */
.stage-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
}
.brand-mark {
    display: flex; align-items: center; gap: 0.6rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.7rem; letter-spacing: 0.28em;
    text-transform: uppercase; color: var(--muted);
}
.brand-mark .glyph {
    width: 26px; height: 26px; display: grid; place-items: center;
    border: 1px solid var(--line-2); border-radius: 6px;
    color: var(--signal); font-size: 0.9rem;
    box-shadow: inset 0 0 12px rgba(var(--signal-rgb), 0.18);
}
.status-chip {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.64rem; letter-spacing: 0.2em; text-transform: uppercase;
    color: var(--muted);
    padding: 0.4rem 0.7rem; border: 1px solid var(--line);
    border-radius: 999px; background: rgba(0,0,0,0.2);
}
.status-chip .dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    animation: pulse 2.4s infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
    70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* headline */
.stage-head { max-width: 18ch; }
.kicker {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.74rem; letter-spacing: 0.34em; text-transform: uppercase;
    color: var(--signal); margin: 0 0 1.4rem;
    display: inline-flex; align-items: center; gap: 0.7rem;
}
.kicker::before {
    content: ""; width: 26px; height: 1px; background: var(--signal);
    display: inline-block;
}
.headline {
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    font-size: clamp(3.2rem, 7vw, 6.4rem);
    line-height: 0.92; letter-spacing: -0.01em;
    margin: 0; color: var(--text);
}
.headline em {
    font-style: italic; color: var(--signal);
    position: relative;
}
.headline .amp {
    font-style: italic; color: var(--signal-2);
    font-size: 1.05em; padding: 0 0.04em;
}
.subhead {
    margin: 1.8rem 0 0; max-width: 34ch;
    color: var(--muted); font-size: 1.02rem; line-height: 1.6;
}

/* bottom metadata rail */
.stage-foot {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--faint);
    display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; align-items: center;
}
.stage-foot .sep { color: var(--line-2); }
.cursor {
    display: inline-block; width: 8px; height: 1.05em; transform: translateY(2px);
    background: var(--signal); margin-left: 2px;
    animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* corner registration crosshairs */
.crosshair {
    position: absolute; width: 16px; height: 16px; z-index: 3;
    color: var(--line-2);
}
.crosshair::before, .crosshair::after {
    content: ""; position: absolute; background: currentColor;
}
.crosshair::before { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-50%); }
.crosshair::after  { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-50%); }
.crosshair.tl { top: 18px; left: 18px; }
.crosshair.br { bottom: 18px; right: 18px; }

/* =======================  RIGHT — THE FORM  ============================= */
.panel {
    position: relative;
    display: flex; flex-direction: column; justify-content: center;
    padding: clamp(2rem, 4vw, 4rem);
    background: var(--ink);
}
.panel-inner { width: 100%; max-width: 380px; margin: 0 auto; }

/* inline flash banner (renders without JS; auto-dismiss is progressive) */
.auth-flash {
    position: relative; overflow: hidden;
    display: flex; align-items: flex-start; gap: 0.6rem;
    padding: 0.8rem 2.1rem 0.85rem 0.9rem; margin-bottom: 1.5rem;
    border: 1px solid var(--line-2); border-left-width: 3px; border-radius: 10px;
    font-size: 0.9rem; line-height: 1.45;
    background: var(--ink-3);
}
.auth-flash-icon { flex-shrink: 0; margin-top: 1px; }
.auth-flash-msg { flex: 1; }
.auth-flash.is-success { border-left-color: var(--ok);     color: #bdf0cf; background: #11241a; }
.auth-flash.is-error   { border-left-color: #ff6b6b;       color: #ffc4c4; background: #251416; }
.auth-flash.is-info    { border-left-color: var(--signal); color: var(--signal-2); background: #241c0c; }

/* dismiss (×) — inherits the banner's text colour, quiet until hovered */
.auth-flash-close {
    position: absolute; top: 0.5rem; right: 0.45rem;
    width: 22px; height: 22px; padding: 0;
    display: inline-grid; place-items: center;
    border: 0; border-radius: 6px; cursor: pointer;
    color: inherit; background: transparent; opacity: 0.5;
    transition: opacity var(--motion-duration), background var(--motion-duration);
}
.auth-flash-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.auth-flash-close:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; opacity: 1; }

/* Countdown bar. Driven by a CSS animation (not JS) so it starts when the
   banner paints — the lifetime is anchored to what the user actually sees, not
   to when a render-blocking font stylesheet lets the inline script run. Its
   animationend is what triggers removal; --flash-life is set per banner. */
.auth-flash-bar {
    position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
    background: currentColor; opacity: 0.4;
    transform-origin: left center;
    animation: flash-countdown var(--flash-life, 4500ms) linear forwards;
}
@keyframes flash-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
/* hovering holds the message — pure CSS, no timer bookkeeping */
.auth-flash:hover .auth-flash-bar,
.auth-flash:focus-within .auth-flash-bar { animation-play-state: paused; }

/* exit transition (collapses so siblings reflow smoothly) */
.auth-flash.dismissing {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0 !important;
    margin-bottom: 0;
    padding-top: 0; padding-bottom: 0;
    border-width: 0;
    transition: opacity 320ms ease, transform 320ms ease,
                max-height 380ms ease, margin 380ms ease,
                padding 380ms ease, border-width 380ms ease;
}
.auth-flash:not(.dismissing) { max-height: 200px; }

.form-index {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.7rem; letter-spacing: 0.3em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 0.9rem;
    display: flex; align-items: center; gap: 0.6rem;
}
.form-index b { color: var(--signal); font-weight: 600; }
.form-title {
    font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
    font-size: clamp(2.2rem, 4vw, 2.9rem); line-height: 1.02;
    margin: 0 0 0.5rem; letter-spacing: -0.01em;
}
.form-sub { color: var(--muted); font-size: 0.94rem; margin: 0 0 2rem; line-height: 1.55; }

.field { margin-bottom: 1.15rem; }
.field > label {
    display: block;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 0.5rem;
}
.field .req { color: var(--signal); }
.control {
    position: relative;
    display: flex; align-items: center;
    border: 1px solid var(--line-2);
    border-radius: 10px;
    background: var(--ink-3);
    transition: border-color var(--motion-duration), box-shadow var(--motion-duration), background var(--motion-duration);
}
.control:focus-within {
    border-color: var(--signal);
    background: #171b22;
    box-shadow: 0 0 0 4px var(--signal-soft);
}
.control input,
.control textarea {
    flex: 1; width: 100%;
    border: 0; outline: 0; background: transparent;
    color: var(--text); font: inherit; font-size: 0.95rem;
    padding: 0.78rem 0.9rem;
}
.control textarea { resize: vertical; min-height: 4.5rem; line-height: 1.5; }
.control input::placeholder { color: var(--faint); }
.control .tick {
    padding-right: 0.8rem; color: var(--faint);
    transition: color var(--motion-duration);
    display: inline-flex;
}
.control:focus-within .tick { color: var(--signal); }
.control input:not(:placeholder-shown) + .tick { color: var(--ok); }

.field-hint {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.62rem; letter-spacing: 0.06em; color: var(--faint);
    margin-top: 0.45rem;
}

/* "Not you?" — quiet by default; this is an escape hatch, not a call to action */
.field-switch {
    display: inline-block; margin-top: 0.5rem;
    font-size: 0.76rem; color: var(--faint); text-decoration: none;
    transition: color var(--motion-duration);
}
.field-switch:hover { color: var(--signal); text-decoration: underline; text-underline-offset: 3px; }

/* options row */
.options {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0.4rem 0 1.6rem; gap: 1rem;
}
.check {
    display: inline-flex; align-items: center; gap: 0.55rem;
    font-size: 0.85rem; color: var(--muted); cursor: pointer; user-select: none;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
    width: 17px; height: 17px; border: 1px solid var(--line-2); border-radius: 5px;
    display: inline-grid; place-items: center; background: var(--ink-3);
    transition: all var(--motion-duration);
}
.check .box svg { width: 11px; height: 11px; stroke: var(--on-signal); opacity: 0; transform: scale(0.6); transition: all var(--motion-duration); }
.check input:checked + .box { background: var(--signal); border-color: var(--signal); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }
.check input:focus-visible + .box { box-shadow: 0 0 0 4px var(--signal-soft); }

.linklike { color: var(--signal); text-decoration: none; font-size: 0.85rem; transition: color var(--motion-duration); }
.linklike:hover { color: var(--signal-2); text-decoration: underline; text-underline-offset: 3px; }

/* submit */
.btn-signal {
    position: relative; overflow: hidden;
    width: 100%; border: 0; cursor: pointer;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--on-signal); background: var(--signal);
    padding: 0.95rem 1.1rem; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
    transition: transform 120ms ease, box-shadow var(--motion-duration);
    box-shadow: 0 8px 24px -10px rgba(var(--signal-rgb), 0.6);
}
.btn-signal:hover { box-shadow: 0 12px 30px -8px rgba(var(--signal-rgb), 0.7); }
.btn-signal:active { transform: translateY(1px); }
.btn-signal .arrow { transition: transform var(--motion-duration); }
.btn-signal:hover .arrow { transform: translateX(4px); }
.btn-signal::before {
    content: ""; position: absolute; inset: 0; transform: translateX(-101%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
    transition: transform 600ms ease;
}
.btn-signal:hover::before { transform: translateX(101%); }
/* busy state while the form posts */
.btn-signal.is-busy { pointer-events: none; opacity: 0.9; }
.btn-signal.is-busy .arrow { animation: signal-arrow 0.9s ease-in-out infinite; }
@keyframes signal-arrow { 0%,100% { transform: translateX(0); } 50% { transform: translateX(5px); } }

/* =======================  LOADING OVERLAY  ============================== */
.auth-loading {
    position: absolute; inset: 0; z-index: 20;
    display: flex; align-items: center; justify-content: center;
    background: rgba(8, 11, 16, 0.72);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    opacity: 0; visibility: hidden;
    transition: opacity 260ms ease, visibility 0s linear 260ms;
}
.auth-loading.is-active { opacity: 1; visibility: visible; transition: opacity 260ms ease; }
.auth-loading-inner {
    position: relative;
    display: flex; flex-direction: column; align-items: flex-start;
    gap: 1.15rem; width: min(300px, 78%);
    transform: translateY(8px); transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}
.auth-loading.is-active .auth-loading-inner { transform: none; }

.auth-loading-kicker {
    display: inline-flex; align-items: center; gap: 0.65rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.7rem; letter-spacing: 0.3em; text-transform: uppercase;
    color: var(--signal);
}
.auth-loading-kicker::before {
    content: ""; width: 22px; height: 1px; background: var(--signal);
}

/* transmission rail — one travelling pulse, echoing the stage's node-link glyph */
.auth-rail {
    width: 100%; height: 2px; position: relative; overflow: hidden;
    background: var(--line); border-radius: 2px;
}
.auth-rail i {
    position: absolute; inset-block: 0; left: 0; width: 42%;
    background: linear-gradient(90deg, transparent, var(--signal), transparent);
    animation: rail 1.45s cubic-bezier(0.6, 0, 0.35, 1) infinite;
}
@keyframes rail { from { transform: translateX(-105%); } to { transform: translateX(340%); } }

/* the sequence reads as a log: left-aligned, monospace, one line per state */
.auth-seq { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 0.62rem; }
.auth-seq-step {
    display: flex; align-items: center; gap: 0.7rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.73rem; letter-spacing: 0.04em;
    color: var(--faint);
    opacity: 0.45;
    transition: opacity 320ms ease, color 320ms ease;
}
.auth-seq-step.is-active { opacity: 1; color: var(--text); }
.auth-seq-step.is-done   { opacity: 1; color: var(--muted); }

/* marker: hollow when pending, pulsing amber while active, ticked once done */
.auth-seq-mark {
    position: relative; flex: none;
    width: 13px; height: 13px; border-radius: 50%;
    border: 1px solid var(--line-2);
    transition: border-color 320ms ease, background 320ms ease;
}
.auth-seq-step.is-active .auth-seq-mark {
    border-color: var(--signal);
    box-shadow: 0 0 0 0 rgba(var(--signal-rgb), 0.55);
    animation: mark-pulse 1.5s ease-out infinite;
}
.auth-seq-step.is-active .auth-seq-mark::after {
    content: ""; position: absolute; inset: 3px;
    border-radius: 50%; background: var(--signal);
}
.auth-seq-step.is-done .auth-seq-mark { border-color: var(--ok); background: transparent; animation: none; box-shadow: none; }
.auth-seq-step.is-done .auth-seq-mark::after {
    content: ""; position: absolute; left: 3.5px; top: 1px;
    width: 4px; height: 7px;
    border: solid var(--ok); border-width: 0 1.5px 1.5px 0;
    transform: rotate(42deg);
}
@keyframes mark-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(var(--signal-rgb), 0.5); }
    70%  { box-shadow: 0 0 0 6px rgba(var(--signal-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--signal-rgb), 0); }
}

.auth-loading-foot {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.6rem; letter-spacing: 0.22em; text-transform: uppercase;
    color: var(--faint);
}

/* footer line */
.panel-foot {
    margin-top: 1.8rem; padding-top: 1.4rem; border-top: 1px solid var(--line);
    font-size: 0.9rem; color: var(--muted); text-align: center;
}
.panel-foot a { color: var(--signal); text-decoration: none; font-weight: 600; }
.panel-foot a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Confidential reporting portal entry point (MD-007 §4.1).
   Visually quieter than "Request access" — it should be findable by someone
   looking for it, without turning the sign-in page into an advertisement. */
.panel-report {
    margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--line);
    text-align: center; display: flex; flex-direction: column; gap: 0.25rem;
}
.panel-report a {
    color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.85rem;
    transition: color var(--motion-duration);
}
.panel-report a:hover { color: var(--signal); text-decoration: underline; text-underline-offset: 3px; }
.panel-report span { color: var(--muted); font-size: 0.72rem; opacity: 0.75; }
.back-link {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-family: "IBM Plex Mono", monospace; font-size: 0.7rem; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--muted); text-decoration: none; margin-bottom: 1.6rem;
    transition: color var(--motion-duration);
}
.back-link:hover { color: var(--signal); }

/* grid for the request form */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem; }
.grid-2 .col-span { grid-column: 1 / -1; }

/* --- entrance choreography ----------------------------------------------- */
.reveal { opacity: 0; transform: translateY(14px); animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.d1 { animation-delay: 0.05s; } .d2 { animation-delay: 0.14s; }
.d3 { animation-delay: 0.23s; } .d4 { animation-delay: 0.32s; }
.d5 { animation-delay: 0.41s; } .d6 { animation-delay: 0.50s; }
.d7 { animation-delay: 0.59s; } .d8 { animation-delay: 0.68s; }

/* --- responsive ----------------------------------------------------------- */
@media (max-width: 900px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .stage { min-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
    .edge-label { display: none; }
    .panel { padding: 2.2rem 1.5rem 3rem; }
}
@media (max-width: 520px) {
    .grid-2 { grid-template-columns: 1fr; }
    .stage { padding: 1.6rem; }
}

/* --- reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .auth *, .auth *::before, .auth *::after { animation: none !important; transition: none !important; }
    .reveal { opacity: 1; transform: none; }
}
