/* ═══════════════════════════════════════════════════════════════════════
   AUTH + ADMIN — extends "Trading-Desk Noir"
   Every colour, duration and radius comes from styles.css. The login screen is
   the same instrument as the Command Center, not a second design language.

   Login layout: split. Left states what the product does (and draws it); right
   is the form. A centred card would have been faster to build and said nothing.
   ═══════════════════════════════════════════════════════════════════════ */

.auth-body {
  margin: 0;
  min-height: 100dvh; /* dvh, not vh — mobile browser chrome eats vh */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow-x: hidden;
}

.auth-shell {
  display: grid;
  /* Art side slightly wider: it carries the diagram, the form only needs ~440px */
  grid-template-columns: 1.08fr 0.92fr;
  min-height: 100dvh;
}

/* ── LEFT: product story ────────────────────────────────────────────────── */

.auth-aside {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: var(--space-6) clamp(28px, 5vw, 64px);
  border-right: 1px solid var(--border);
  background:
    linear-gradient(160deg, rgba(13, 19, 33, 0.92), rgba(4, 7, 13, 0.96)),
    var(--bg-raised);
}

/* Engineering-drawing grid. Masked so it fades rather than ending on a hard edge. */
.auth-aside-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.055) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(120% 90% at 30% 40%, #000 35%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 30% 40%, #000 35%, transparent 78%);
  pointer-events: none;
}

.auth-aside-glow {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  top: -22vmax;
  left: -18vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 229, 150, 0.1), transparent 66%);
  filter: blur(40px);
  pointer-events: none;
  animation: aside-drift 30s ease-in-out infinite alternate;
}

@keyframes aside-drift {
  to { transform: translate3d(8vmax, 6vmax, 0) scale(1.12); }
}

.auth-aside-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
}

/* ── Logo ───────────────────────────────────────────────────────────────── */

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
  margin-bottom: clamp(24px, 4vh, 44px);
}

.auth-logo-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 14px rgba(46, 229, 150, 0.28));
}

.auth-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.auth-logo-text em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 3px;
}

.auth-logo-compact { display: none; }

/* ── Headline ───────────────────────────────────────────────────────────── */

.auth-aside-title {
  margin: 0 0 clamp(22px, 3.4vh, 34px);
  font-size: clamp(27px, 3.4vw, 40px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.028em;
}

.auth-aside-title span {
  background: linear-gradient(96deg, var(--accent) 8%, var(--cyan) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── The diagram ────────────────────────────────────────────────────────── */

.auth-figure {
  margin: 0 0 clamp(22px, 3.4vh, 34px);
}

.auth-diagram {
  width: 100%;
  height: auto;
  max-width: 470px;
  overflow: visible;
}

.auth-diagram .dlabel {
  font-family: var(--font-mono);
  font-size: 7.6px;
  font-weight: 600;
  letter-spacing: 0.17em;
  fill: var(--text-faint);
}

.auth-diagram .dmeta {
  font-family: var(--font-mono);
  font-size: 7.4px;
  letter-spacing: 0.07em;
  fill: rgba(113, 128, 156, 0.85);
}

/* Waveform: a slow breathing scale, staggered per bar. Reads as "listening". */
.auth-diagram .bar {
  fill: url(#gEmerald);
  transform-box: fill-box;
  transform-origin: center;
  animation: bar-pulse 1.5s var(--ease-spring) infinite alternate;
  animation-delay: calc(var(--b) * 95ms);
}

@keyframes bar-pulse {
  from { transform: scaleY(0.4); opacity: 0.5; }
  to   { transform: scaleY(1);   opacity: 1; }
}

/* Cards fade up once, on a stagger — the "four answers appearing" beat */
.auth-diagram .card {
  animation: card-in 620ms var(--ease-out) both;
  animation-delay: calc(560ms + var(--c) * 110ms);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

.auth-diagram .stage {
  animation: stage-in 560ms var(--ease-out) both;
  animation-delay: calc(var(--s) * 150ms);
}

@keyframes stage-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Trust points ───────────────────────────────────────────────────────── */

.auth-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.auth-points li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  max-width: 52ch; /* keeps line length inside the readable band */
  animation: auth-rise 520ms var(--ease-out) both;
  animation-delay: calc(760ms + var(--i) * 90ms);
}

.auth-points strong {
  color: var(--text);
  font-weight: 600;
}

.pt-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}

.pt-icon svg { width: 15px; height: 15px; }

/* ── RIGHT: the form ───────────────────────────────────────────────────── */

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) clamp(24px, 4vw, 56px);
}

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

.auth-form-head h1 {
  margin: 0 0 7px;
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.022em;
}

.auth-form-head p {
  margin: 0 0 var(--space-5);
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
}

.auth-field { margin-bottom: var(--space-4); }

.auth-field label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-dim);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 13px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  pointer-events: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.auth-input-icon svg { width: 17px; height: 17px; }

.auth-input-wrap:focus-within .auth-input-icon { color: var(--accent); }

.auth-panel input[type="email"],
.auth-panel input[type="password"],
.auth-panel input[type="text"] {
  width: 100%;
  /* 48px: comfortably past the 44px minimum target */
  min-height: 48px;
  padding: 12px 14px 12px 40px;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text);
  background: rgba(4, 7, 13, 0.7);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

/* Password field leaves room for the reveal button */
#password { padding-right: 46px; }

.auth-panel input::placeholder { color: var(--text-faint); }

.auth-panel input:hover { border-color: rgba(148, 163, 184, 0.34); }

.auth-panel input:focus-visible {
  outline: none;
  border-color: var(--accent-border);
  background: rgba(4, 7, 13, 0.9);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-panel input[aria-invalid="true"] { border-color: var(--danger-border); }
.auth-panel input[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px var(--danger-soft); }
.auth-panel input[aria-invalid="true"] + .auth-toggle { right: 6px; }

.auth-toggle {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  /* 40px hit area for an 18px glyph */
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.auth-toggle:hover { color: var(--text-dim); background: rgba(148, 163, 184, 0.09); }
.auth-toggle:focus-visible { outline: 2px solid var(--accent-border); outline-offset: 1px; }
.auth-toggle svg { width: 18px; height: 18px; }

/* Field error — sits directly below its input, announced via aria-live */
.auth-error {
  display: none;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--danger);
  line-height: 1.45;
}

.auth-error.show { display: flex; }

.auth-error::before {
  content: "";
  width: 3px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 2px;
  background: var(--danger);
}

/* Form-level banner */
.auth-alert {
  display: none;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: 11px 13px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #ffc9c0;
  font-size: 12.5px;
  line-height: 1.5;
}

.auth-alert.show { display: flex; }
.auth-alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

/* ── Submit ─────────────────────────────────────────────────────────────── */

.auth-submit {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #04140c;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 10px 28px -14px var(--accent-glow);
  transition: transform var(--dur-fast) var(--ease-spring),
    filter var(--dur-fast) var(--ease-out), box-shadow var(--dur-med) var(--ease-out),
    opacity var(--dur-fast) linear;
}

.auth-submit:hover:not(:disabled) {
  filter: brightness(1.07);
  box-shadow: 0 14px 34px -14px var(--accent-glow);
}

/* Scale-press per the motion spec — transform only, so it cannot reflow */
.auth-submit:active:not(:disabled) { transform: scale(0.978); }
.auth-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.auth-submit:disabled { opacity: 0.6; cursor: progress; box-shadow: none; }

.auth-submit-arrow {
  width: 17px;
  height: 17px;
  transition: transform var(--dur-med) var(--ease-spring);
}

.auth-submit:hover:not(:disabled) .auth-submit-arrow { transform: translateX(3px); }
.auth-submit:disabled .auth-submit-arrow { display: none; }

.auth-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(4, 20, 12, 0.28);
  border-top-color: #04140c;
  border-radius: 50%;
  animation: auth-spin 620ms linear infinite;
}

@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ── Footer ─────────────────────────────────────────────────────────────── */

.auth-foot {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.auth-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.auth-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: dot-breathe 2.6s ease-in-out infinite;
}

@keyframes dot-breathe {
  50% { opacity: 0.42; box-shadow: 0 0 0 5px rgba(46, 229, 150, 0.05); }
}

.auth-foot p {
  margin: 9px 0 0;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.55;
}

/* ── Entrance motion ────────────────────────────────────────────────────────
   Framer Motion's feel — spring curve, per-child stagger, exit shorter than
   enter — expressed with the tokens already in styles.css. There is no React
   in this app to hang a motion library off. */

@keyframes auth-rise {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

.auth-stagger > * {
  animation: auth-rise var(--dur-slow) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* Shake on a rejected sign-in: motion that carries meaning, not decoration */
@keyframes auth-shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(3px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
  40%, 60% { transform: translate3d(5px, 0, 0); }
}

.auth-panel.rejected .auth-panel-inner { animation: auth-shake 420ms var(--ease-out); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1040px) {
  .auth-shell { grid-template-columns: 1fr; }

  /* The aside becomes a compact banner above the form rather than disappearing —
     the diagram is the strongest thing on the page. */
  .auth-aside {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: var(--space-5) var(--space-5) var(--space-4);
  }

  .auth-aside-inner { max-width: 620px; }
  .auth-aside-title { font-size: clamp(24px, 5vw, 32px); }
  .auth-points { display: none; } /* form first on small screens */
  .auth-panel { padding: var(--space-5) var(--space-5) var(--space-6); }
}

@media (max-width: 620px) {
  /* Below this the diagram is too small to read; drop the aside and show the
     compact brand above the form instead. */
  .auth-aside { display: none; }
  .auth-logo-compact { display: inline-flex; margin-bottom: var(--space-5); }
  .auth-panel { align-items: flex-start; padding-top: var(--space-6); }
  .auth-form-head h1 { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-aside-glow,
  .auth-diagram .bar,
  .auth-diagram .card,
  .auth-diagram .stage,
  .auth-points li,
  .auth-stagger > *,
  .auth-panel.rejected .auth-panel-inner,
  .auth-dot,
  .auth-spinner {
    animation: none !important;
  }
  .auth-stagger > *, .auth-points li, .auth-diagram .card, .auth-diagram .stage {
    opacity: 1;
    transform: none;
  }
  .auth-submit-arrow, .auth-submit:hover .auth-submit-arrow { transition: none; transform: none; }
  /* The travelling pulses are SMIL, not CSS — login.js stops them too */
  .auth-diagram .pulse { display: none; }
}
