/* ═══════════════════════════════════════════════════════════════════
   MYTHOS — Apex login · the cinematic ARRIVAL
   Dark stage (ink), drifting starfield, breathing orange glow, the
   "Mythos." wordmark rising letter-by-letter, the orange dot pop + ring
   + localized bloom, then a WHITE orange-bordered login card gliding up.

   Ported from the ARRIVAL half of the canonical reference prototype
   (frontend/_shared/mythos-dl/reference/Mythos-Login-and-Hub.html),
   adapted to production: real routes, real auth, no demo replay/caption.
   Uses canonical tokens (tokens.css). The brand mark is the round orange
   dot — never a god-emblem icon.
   ═══════════════════════════════════════════════════════════════════ */

/* Local easing aliases that the prototype leans on (tokens.css doesn't
   ship these specific two). Everything else is a canonical var(--…). */
:root {
  --arr-in:    cubic-bezier(0.16, 1, 0.3, 1);
  --arr-spring:cubic-bezier(0.34, 1.56, 0.64, 1);
  --arr-glide: cubic-bezier(0.7, 0, 0.18, 1);
  --arr-ink:   #08080C;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--arr-ink);
  color: #fff;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* The host element of the whole arrival. */
#flow-root { position: fixed; inset: 0; }

/* ── starfield + breathing glow ─────────────────────────────────────── */
#stars {
  position: fixed; inset: 0; z-index: 0; display: block;
}
.glow {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(620px 460px at 50% 38%, rgba(232, 97, 26, 0.18), transparent 70%);
  animation: arr-breathe 6s ease-in-out infinite;
}
@keyframes arr-breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ── stage / centered column ────────────────────────────────────────── */
.stage {
  position: fixed; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.col { display: flex; flex-direction: column; align-items: center; width: min(92vw, 384px); }

/* ── wordmark (round orange dot) ────────────────────────────────────── */
.top { display: flex; flex-direction: column; align-items: center; position: relative; will-change: transform; }

.mark {
  font-family: var(--font-wordmark);
  font-size: clamp(56px, 11vw, 108px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  display: flex; align-items: flex-end;
  color: #fff; position: relative;
}
.mark span {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.46em) scale(0.9);
  filter: blur(16px);
  will-change: transform, opacity, filter;
}
/* canonical dot geometry — round orange, baseline-aligned */
.mark .dot {
  position: relative;
  width: 0.18em; height: 0.18em;
  border-radius: 50%;
  background: var(--brand-orange);
  margin-left: 0.07em; margin-bottom: 0.12em;
  opacity: 0; transform: scale(0); filter: none;
  box-shadow: 0 0 18px rgba(232, 97, 26, 0.5);
}
.mark .dot::after {
  content: ""; position: absolute; inset: -7px;
  border-radius: 50%;
  border: 2px solid rgba(232, 97, 26, 0.6);
  opacity: 0;
}

/* the letters rise once the stage gets .play (added by login.js) */
.play .mark span:not(.dot) { animation: arr-rise 1s var(--arr-in) forwards; }
.play .mark span:nth-child(1) { animation-delay: 0.14s; }
.play .mark span:nth-child(2) { animation-delay: 0.23s; }
.play .mark span:nth-child(3) { animation-delay: 0.32s; }
.play .mark span:nth-child(4) { animation-delay: 0.41s; }
.play .mark span:nth-child(5) { animation-delay: 0.50s; }
.play .mark span:nth-child(6) { animation-delay: 0.59s; }
.play .mark .dot       { animation: arr-dotpop 0.82s var(--arr-spring) 0.74s forwards; }
.play .mark .dot::after { animation: arr-dotring 1.05s var(--arr-in) 0.80s forwards; }

@keyframes arr-rise { to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); } }
@keyframes arr-dotpop {
  0%   { opacity: 0; transform: scale(0);    box-shadow: 0 0 0 0 rgba(232, 97, 26, 0); }
  55%  { opacity: 1; transform: scale(1.32); box-shadow: 0 0 38px 5px rgba(232, 97, 26, 0.7); }
  100% { opacity: 1; transform: scale(1);    box-shadow: 0 0 18px rgba(232, 97, 26, 0.5); }
}
@keyframes arr-dotring { 0% { opacity: 0.75; transform: scale(0.45); } 100% { opacity: 0; transform: scale(2.4); } }

/* localized bloom behind the wordmark, flares as the dot lands */
.bloom {
  position: absolute; left: 50%; top: 46%;
  width: 460px; height: 330px; z-index: -1; pointer-events: none;
  transform: translate(-50%, -50%) scale(0.5); opacity: 0; filter: blur(12px);
  background: radial-gradient(closest-side, rgba(232, 97, 26, 0.30), transparent 72%);
}
.play .bloom { animation: arr-bloom 2s var(--arr-in) 0.55s forwards; }
@keyframes arr-bloom {
  0%   { opacity: 0;    transform: translate(-50%, -50%) scale(0.5); }
  45%  { opacity: 1;    transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0.45; transform: translate(-50%, -50%) scale(1.18); }
}

/* ── tagline ────────────────────────────────────────────────────────── */
.tag {
  display: flex; align-items: center; margin-top: 20px;
  color: rgba(255, 255, 255, 0.40);
  font-size: clamp(11px, 1.3vw, 12.5px);
  letter-spacing: 0.28em; text-transform: uppercase;
  opacity: 0; transform: translateY(8px); filter: blur(5px);
}
.play .tag { animation: arr-fade 0.9s var(--arr-in) 1.12s forwards; }
@keyframes arr-fade { to { opacity: 1; transform: translateY(0); filter: blur(0); } }
.tag .sep {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-orange); margin: 0 14px;
  box-shadow: 0 0 10px rgba(232, 97, 26, 0.7);
}

/* ── login card (white, 1.6px orange border) ───────────────────────── */
.login { width: 100%; margin-top: 34px; opacity: 0; will-change: transform, filter; }
.card {
  background: #fff;
  border: 1.6px solid var(--brand-orange);
  border-radius: 20px;
  padding: 26px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 34px rgba(232, 97, 26, 0.14);
}

/* card error banner (server-rendered or fetch failures) */
.card-error {
  display: none;
  align-items: center; gap: 8px;
  margin-bottom: 14px; padding: 9px 12px;
  border-radius: 10px;
  background: var(--error-bg); color: var(--error-dark);
  border: 0.5px solid color-mix(in oklab, var(--error) 30%, transparent);
  font-size: 12.5px; font-weight: var(--fw-medium); line-height: 1.35;
}
.card-error.visible { display: flex; }
.card-error svg { width: 15px; height: 15px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.field { margin-bottom: 13px; text-align: left; }
.field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: var(--fw-semibold); }
.field input {
  width: 100%; height: 44px;
  border: 1px solid var(--border-light);
  border-radius: 12px; padding: 0 14px;
  font-family: var(--font-sans); font-size: 14px;
  color: var(--text-primary); background: #FCFCFD;
  outline: none;
  transition: border-color 0.15s var(--arr-in), box-shadow 0.15s var(--arr-in);
}
.field input::placeholder { color: var(--text-tertiary); }
.field input:focus { border-color: var(--brand-orange); box-shadow: 0 0 0 3px rgba(232, 97, 26, 0.10); }
.field input:disabled { opacity: 0.6; cursor: not-allowed; }
.field.has-error input { border-color: var(--error); }
.field .field-err {
  display: none; margin-top: 6px;
  font-size: 11.5px; font-weight: var(--fw-medium); color: var(--error-dark);
}
.field.has-error .field-err { display: block; }

/* primary submit — orange, with spinner + check states */
.signin {
  width: 100%; height: 44px; margin-top: 8px;
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--brand-orange); color: #fff;
  font-family: var(--font-sans); font-weight: var(--fw-bold); font-size: 15px;
  transition: background 0.2s var(--arr-in), transform 0.15s var(--arr-in);
  position: relative; overflow: hidden;
}
.signin:hover { background: var(--brand-orange-hover); }
.signin:active { transform: scale(0.99); }
.signin:disabled { cursor: default; }

.signin .lbl,
.signin .spin,
.signin .ck {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s ease;
}
.signin .lbl { position: static; transition: opacity 0.2s ease; }
.signin .spin,
.signin .ck { opacity: 0; }
.signin .spin svg { width: 18px; height: 18px; animation: arr-spin 0.72s linear infinite; }
.signin .ck svg { width: 24px; height: 24px; }
.signin .ck path {
  fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 28; stroke-dashoffset: 28;
}
@keyframes arr-spin { to { transform: rotate(360deg); } }

/* busy: hide label, show spinner */
.signin.is-busy .lbl { opacity: 0; }
.signin.is-busy .spin { opacity: 1; }
/* success: hide label + spinner, draw the check */
.signin.ok .lbl { opacity: 0; }
.signin.ok .spin { opacity: 0; }
.signin.ok .ck { opacity: 1; }
.signin.ok .ck path { animation: arr-check 0.42s var(--arr-in) 0.05s forwards; }
@keyframes arr-check { to { stroke-dashoffset: 0; } }

.forgot {
  display: block; text-align: center; margin-top: 14px;
  color: var(--text-secondary); font-size: 12.5px; text-decoration: none;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans); width: 100%;
  transition: color 0.15s var(--arr-in);
}
.forgot:hover { color: var(--text-primary); }

/* ── mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 420px) {
  .card { padding: 22px 18px; border-radius: 18px; }
  .col { width: 100%; }
}

/* ── reduced motion → instant ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  .glow { animation: none; opacity: 0.8; }
  .mark span, .mark .dot, .tag, .login { opacity: 1 !important; filter: none !important; }
  .mark span { transform: none !important; }
  .mark .dot { transform: scale(1) !important; }
}

/* ── Shared footer (mythos-footer.js) on the dark arrival ───────────────
   The shared footer ships a light (#f5f5f7) bar; on the dark cinematic
   login that reads as a jarring white strip. Re-skin it to blend: a faint,
   transparent credit line pinned to the bottom, matching the dark theme. */
.mythos-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: transparent !important;
  border-top: none !important;
  color: rgba(255, 255, 255, 0.30) !important;
  z-index: 3;
}
.mythos-footer a,
.mythos-footer .mythos-footer__powered,
.mythos-footer .mythos-footer__version { color: rgba(255, 255, 255, 0.34) !important; }
.mythos-footer .mythos-footer__pill {
  background: rgba(255, 255, 255, 0.08) !important;
  color: rgba(255, 255, 255, 0.55) !important;
}
