/* =========================================================================
   login.css — the Aegisaur fleet login design system.

   Served same-origin under the strict CSP (`style-src 'self'`): ONE stylesheet,
   NO inline styles, NO webfonts (a refined system-font stack — nothing is
   fetched off-origin, so nothing can silently fall back), NO remote images
   (all decoration is CSS gradients + inline SVG). Light + dark are token-level:
   :root carries the light palette, redefined under prefers-color-scheme: dark
   and again under :root[data-theme] so a host theme toggle wins in both
   directions. Every interactive element keeps a visible focus ring, and the
   one motion moment (the passkey glyph) is disabled under prefers-reduced-motion.

   Concept: the login as a secure civic threshold. A deep steel-navy identity
   "keep" pairs with a crisp working card; one restrained heraldic-gold accent
   marks only the primary passkey action, the focal glyph, and focus.
   ========================================================================= */

/* ---- reset (the BFF ships raw HTML, no framework reset) ------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; }
h1, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
svg { display: block; }

/* ---- tokens: light (default) -------------------------------------------- */
:root {
  color-scheme: light dark;

  --font-serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* type scale (1.20 minor third, 16px base) */
  --step--1: 0.813rem;   /* 13px  — labels, mono captions */
  --step-0:  1rem;       /* 16px  — body */
  --step-1:  1.125rem;   /* 18px  — lede */
  --step-2:  1.5rem;     /* 24px  — card h1 */
  --step-3:  1.875rem;   /* 30px  — hero wordmark */

  --space-1: 0.375rem;
  --space-2: 0.625rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.25rem;
  --space-6: 3.25rem;

  --radius: 12px;
  --radius-sm: 8px;

  /* civic palette — steel navy + cool bone + one heraldic gold */
  --stage-bg: #E8E5DC;
  --surface: #FCFBF8;
  --surface-inset: #F1EEE7;
  --ink: #142740;          /* headings */
  --text: #29384F;         /* body */
  --text-soft: #57657F;    /* muted / secondary */
  --line: #DBD6C9;
  --line-strong: #C7C1B1;

  --gold: #A9761B;
  --gold-ink: #8A5F13;     /* gold used AS small text (meets contrast on bone) */
  --gold-veil: rgba(169, 118, 27, 0.12);

  --danger: #A6302A;
  --danger-ink: #8F2A24;
  --danger-veil: rgba(166, 48, 42, 0.08);

  /* the identity "keep" — navy in BOTH themes (it is the brand surface) */
  --keep: #122842;
  --keep-2: #0B1B30;
  --keep-line: rgba(210, 224, 245, 0.14);
  --keep-ink: #F3F0E6;     /* wordmark / mark on the keep */
  --keep-soft: #A9B8D2;    /* aside body copy */
  --keep-glow: rgba(217, 169, 78, 0.18);

  /* primary action = gold plate, deep-navy legend (both themes) */
  --btn-primary-bg: var(--gold);
  --btn-primary-bg-hi: #BC8724;
  --btn-primary-text: #14263F;

  --focus: #B98526;
  --shadow-card: 0 1px 2px rgba(18, 30, 52, 0.06), 0 18px 44px -22px rgba(18, 30, 52, 0.30);
}

/* ---- tokens: dark ------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --stage-bg: #08111E;
    --surface: #101F38;
    --surface-inset: #16273F;
    --ink: #EBF1F9;
    --text: #D2DCEC;
    --text-soft: #90A0BC;
    --line: #21344F;
    --line-strong: #2C4162;

    --gold: #E0B04A;
    --gold-ink: #E7BC63;
    --gold-veil: rgba(224, 176, 74, 0.15);

    --danger: #E58279;
    --danger-ink: #EE9188;
    --danger-veil: rgba(229, 130, 121, 0.12);

    --keep: #0B1A2E;
    --keep-2: #06111F;
    --keep-line: rgba(150, 176, 214, 0.16);
    --keep-ink: #F3F0E6;
    --keep-soft: #9CACC8;
    --keep-glow: rgba(224, 176, 74, 0.20);

    --btn-primary-bg: var(--gold);
    --btn-primary-bg-hi: #EBBE5F;
    --btn-primary-text: #0A1626;

    --focus: #E7BC63;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 60px -28px rgba(0, 0, 0, 0.7);
  }
}
/* explicit host toggle wins over the OS media query, in both directions */
:root[data-theme="light"] {
  --stage-bg: #E8E5DC; --surface: #FCFBF8; --surface-inset: #F1EEE7;
  --ink: #142740; --text: #29384F; --text-soft: #57657F;
  --line: #DBD6C9; --line-strong: #C7C1B1;
  --gold: #A9761B; --gold-ink: #8A5F13; --gold-veil: rgba(169,118,27,0.12);
  --danger: #A6302A; --danger-ink: #8F2A24; --danger-veil: rgba(166,48,42,0.08);
  --keep: #122842; --keep-2: #0B1B30; --keep-line: rgba(210,224,245,0.14);
  --keep-ink: #F3F0E6; --keep-soft: #A9B8D2; --keep-glow: rgba(217,169,78,0.18);
  --btn-primary-bg: var(--gold); --btn-primary-bg-hi: #BC8724; --btn-primary-text: #14263F;
  --focus: #B98526;
  --shadow-card: 0 1px 2px rgba(18,30,52,0.06), 0 18px 44px -22px rgba(18,30,52,0.30);
}
:root[data-theme="dark"] {
  --stage-bg: #08111E; --surface: #101F38; --surface-inset: #16273F;
  --ink: #EBF1F9; --text: #D2DCEC; --text-soft: #90A0BC;
  --line: #21344F; --line-strong: #2C4162;
  --gold: #E0B04A; --gold-ink: #E7BC63; --gold-veil: rgba(224,176,74,0.15);
  --danger: #E58279; --danger-ink: #EE9188; --danger-veil: rgba(229,130,121,0.12);
  --keep: #0B1A2E; --keep-2: #06111F; --keep-line: rgba(150,176,214,0.16);
  --keep-ink: #F3F0E6; --keep-soft: #9CACC8; --keep-glow: rgba(224,176,74,0.20);
  --btn-primary-bg: var(--gold); --btn-primary-bg-hi: #EBBE5F; --btn-primary-text: #0A1626;
  --focus: #E7BC63;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 24px 60px -28px rgba(0,0,0,0.7);
}

/* ---- base --------------------------------------------------------------- */
body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--text);
  background: var(--stage-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- viewport: the two-column civic keep -------------------------------- */
.aeg-viewport {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

/* ---- identity aside (desktop) ------------------------------------------- */
.aeg-aside { display: none; }

.aeg-aside__inner {
  position: relative;
  z-index: 1;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.aeg-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--keep-ink);
}
.aeg-wordmark {
  font-family: var(--font-serif);
  font-size: var(--step-3);
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--keep-ink);
}
.aeg-aside__lede {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--keep-ink);
  text-wrap: balance;
  max-width: 20ch;
}
.aeg-aside__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--keep-soft);
  font-size: var(--step-0);
}
.aeg-aside__list li {
  position: relative;
  padding-left: 1.5rem;
}
.aeg-aside__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border: 1.5px solid var(--gold);
  border-radius: 1px;
  transform: rotate(45deg);
}
.aeg-aside__foot {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--keep-soft);
  opacity: 0.85;
}

/* ---- the working stage -------------------------------------------------- */
.aeg-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-3) var(--space-5);
  min-height: 100vh;
  min-height: 100dvh;
}

/* mobile brand bar (hidden once the aside appears) */
.aeg-topbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
}
.aeg-wordmark--sm { font-size: 1.35rem; color: var(--ink); }

/* ---- the card ----------------------------------------------------------- */
.aeg-card {
  position: relative;
  width: 100%;
  max-width: 27.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5) clamp(1.25rem, 5vw, 2.25rem);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
/* the gold "seal" hairline across the card top */
.aeg-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold) 22%, var(--gold) 78%, transparent);
  opacity: 0.9;
}
/* the retry <button> the passkey modules append directly to <main> */
.aeg-card > button {
  display: block;
  width: 100%;
  margin-top: var(--space-4);
  padding: 0.72rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.aeg-card > button:hover { background: var(--surface-inset); }

/* ---- screen scaffold ---------------------------------------------------- */
.aeg-screen {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.aeg-screen--centered, .aeg-screen--ceremony { text-align: center; align-items: center; }

.aeg-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-ink);
}
.aeg-h1 {
  font-family: var(--font-serif);
  font-size: var(--step-2);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-wrap: balance;
}
.aeg-lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--text-soft);
  max-width: 34ch;
  text-wrap: pretty;
}
.aeg-screen--centered .aeg-lede, .aeg-screen--ceremony .aeg-lede { margin-inline: auto; }

.aeg-status {
  font-size: var(--step-0);
  color: var(--text-soft);
  max-width: 34ch;
  margin-inline: auto;
  min-height: 3rem; /* reserve space so status text swaps don't jump the layout */
}

/* ---- the focal glyph (ceremony / status / result) ----------------------- */
.aeg-glyph {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  margin-bottom: var(--space-1);
  border-radius: 50%;
  color: var(--text-soft);
  background: var(--surface-inset);
  border: 1px solid var(--line);
}
.aeg-mark--glyph { width: 2.1rem; height: 2.1rem; }
.aeg-glyph--live { color: var(--gold); background: var(--gold-veil); border-color: color-mix(in srgb, var(--gold) 34%, transparent); }
.aeg-glyph--ok { color: var(--gold); background: var(--gold-veil); border-color: color-mix(in srgb, var(--gold) 34%, transparent); }
.aeg-glyph--muted { color: var(--text-soft); opacity: 0.85; }

/* the breathing halo — one deliberate motion moment */
.aeg-glyph--live::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  opacity: 0.5;
  animation: aeg-pulse 2.6s ease-out infinite;
}
.aeg-glyph--live .aeg-mark__key { animation: aeg-key 2.6s ease-in-out infinite; }
@keyframes aeg-pulse {
  0%   { transform: scale(0.9); opacity: 0.55; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}
@keyframes aeg-key {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ---- brand mark (keystone + keyhole) ------------------------------------ */
.aeg-mark { flex: none; }
.aeg-mark--lg { width: 2.4rem; height: 2.4rem; }
.aeg-mark--sm { width: 1.7rem; height: 1.7rem; }
.aeg-mark__stone { stroke: currentColor; }
.aeg-mark__key { stroke: var(--gold); }

/* ---- form --------------------------------------------------------------- */
.aeg-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
  text-align: left;
}
.aeg-field { display: flex; flex-direction: column; gap: var(--space-1); }
.aeg-label {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.aeg-input {
  width: 100%;
  padding: 0.72rem 0.85rem;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--surface-inset);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.aeg-input::placeholder { color: var(--text-soft); }
.aeg-input:hover { border-color: var(--text-soft); }
.aeg-input:focus-visible {
  outline: none;
  border-color: var(--focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--gold-veil);
}
.aeg-input--code {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  letter-spacing: 0.42em;
  text-align: center;
  padding-inline: 0.5rem;
}

/* ---- actions + buttons -------------------------------------------------- */
.aeg-actions { display: flex; flex-direction: column; gap: var(--space-2); }

.aeg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.8rem 1.1rem;
  font-size: var(--step-0);
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.06s ease, box-shadow 0.14s ease;
}
.aeg-btn:active { transform: translateY(1px); }
.aeg-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--stage-bg), 0 0 0 5px var(--focus);
}
.aeg-btn__mark { width: 1.15rem; height: 1.15rem; }

.aeg-btn--primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
.aeg-btn--primary .aeg-mark__stone { stroke: var(--btn-primary-text); }
.aeg-btn--primary .aeg-mark__key { stroke: var(--btn-primary-text); }
.aeg-btn--primary:hover { background: var(--btn-primary-bg-hi); }

.aeg-btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.aeg-btn--ghost:hover { background: var(--surface-inset); border-color: var(--text-soft); }

.aeg-btn--fed {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  font-weight: 500;
}
.aeg-btn--fed:hover { background: var(--surface-inset); border-color: var(--text-soft); }
.aeg-fedform { margin: 0; }
.aeg-fedform + .aeg-fedform { margin-top: var(--space-2); }

/* ---- divider ------------------------------------------------------------ */
.aeg-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-3);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
}
.aeg-divider::before, .aeg-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---- alert -------------------------------------------------------------- */
.aeg-alert {
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger) 38%, transparent);
  background: var(--danger-veil);
  color: var(--danger-ink);
  font-size: var(--step--1);
  line-height: 1.45;
}
.aeg-alert strong { font-weight: 600; }

/* ---- footer ------------------------------------------------------------- */
.aeg-foot {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
}
.aeg-foot__lock { width: 0.9rem; height: 0.9rem; color: var(--text-soft); }

/* ---- desktop: reveal the identity keep ---------------------------------- */
@media (min-width: 60rem) {
  .aeg-viewport { grid-template-columns: minmax(22rem, 42%) 1fr; }
  .aeg-topbar { display: none; }

  .aeg-aside {
    display: flex;
    align-items: center;
    padding: var(--space-6) clamp(2.5rem, 4vw, 4rem);
    color: var(--keep-ink);
    background:
      radial-gradient(120% 80% at 18% 0%, var(--keep-glow), transparent 46%),
      linear-gradient(157deg, var(--keep) 0%, var(--keep-2) 100%);
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--keep-line);
  }
  /* a quiet guilloché / blueprint texture on the keep */
  .aeg-aside::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
      repeating-linear-gradient(90deg, var(--keep-line) 0 1px, transparent 1px 46px),
      repeating-linear-gradient(0deg, var(--keep-line) 0 1px, transparent 1px 46px);
    mask-image: radial-gradient(90% 90% at 30% 40%, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(90% 90% at 30% 40%, #000 0%, transparent 78%);
    opacity: 0.6;
    pointer-events: none;
  }
  .aeg-stage {
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-5);
  }
  .aeg-card { padding: var(--space-6) clamp(1.75rem, 3vw, 2.75rem) var(--space-5); }
}

/* small-screen breathing room */
@media (max-width: 26rem) {
  .aeg-h1 { font-size: 1.35rem; }
  .aeg-aside__lede { font-size: 1.4rem; }
}

/* ---- motion: respect the user ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .aeg-glyph--live::after { animation: none; opacity: 0.4; }
  .aeg-glyph--live .aeg-mark__key { animation: none; opacity: 1; }
  .aeg-btn, .aeg-input { transition: none; }
  .aeg-btn:active { transform: none; }
}

/* ---- forced-colors (Windows high contrast) ------------------------------ */
@media (forced-colors: active) {
  .aeg-card, .aeg-input, .aeg-btn { border: 1px solid CanvasText; }
  .aeg-btn:focus-visible, .aeg-input:focus-visible { outline: 2px solid Highlight; }
}
