/* ============================================================================
   Echelon Score — design system foundation, v0.2 (2026-08-05)

   v0.2: product named (Echelon Score / EchelonScore.com — Michael, 2026-08-05)
   and the green/mint accent retired at Michael's call. New direction reads on
   the name: an echelon is a rank formation, so the brand voice is INSIGNIA —
   deep navy ink with a restrained brass secondary, cool slate neutrals. The
   original brief still stands: this product should look like a public record,
   not a startup dashboard. Credibility is the design brief.

   Green survives ONLY as the semantic `--verified` state (deep emerald, not
   mint) — verified-means-green is a convention worth keeping, and keeping it
   OUT of the brand accent makes the seal unmistakable rather than ambient.

   Semantic layer is the important part: `--verified` / `--unverified` /
   `--flag` / `--alert` encode the product's core distinctions and must never
   collapse into the accent. Swapping brand palette = editing primitives here,
   nothing else.
   ========================================================================= */

:root {
  /* --- palette primitives (do not use directly in components) --- */
  --c-ink-900: #10151D;
  --c-ink-800: #161D28;
  --c-ink-600: #28313F;
  --c-slate-500: #5B6472;
  --c-slate-400: #8B95A5;
  --c-paper-100: #FFFFFF;
  --c-paper-200: #F2F4F7;
  --c-rule-300: #D7DBE2;
  --c-navy-600: #24446E;
  --c-navy-400: #7CA4D8;
  --c-brass-600: #8F6F2A;
  --c-brass-400: #D2A44E;
  --c-emerald-600: #177351;
  --c-emerald-400: #48BE8D;
  --c-rust-600: #A04539;
  --c-rust-400: #D97D66;

  /* --- semantic surface + text --- */
  --bg: var(--c-paper-200);
  --surface: var(--c-paper-100);
  --surface-sunken: #EDF0F4;
  --rule: var(--c-rule-300);
  --text: #131924;
  --text-muted: var(--c-slate-500);
  --accent: var(--c-navy-600);
  --accent-2: var(--c-brass-600);

  /* --- semantic domain states (the product's core distinction) --- */
  --verified: var(--c-emerald-600);
  --unverified: var(--c-slate-400);
  --flag: var(--c-brass-600);
  --alert: var(--c-rust-600);

  /* --- type --- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;

  --size-display: clamp(24px, 3.2vw, 34px);
  --size-h2: 15px;
  --size-body: 14.5px;
  --size-sm: 12.5px;
  --size-label: 11px;   /* mono, letterspaced, sentence case */
  --size-figure: clamp(20px, 2.4vw, 26px);
  --track-label: 0.08em;

  /* --- space (4px base) --- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  /* --- form --- */
  --radius: 3px;         /* records are square-ish; heavy rounding reads as consumer app */
  --border: 1px solid var(--rule);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--c-ink-900);
    --surface: var(--c-ink-800);
    --surface-sunken: #121826;
    --rule: var(--c-ink-600);
    --text: #E5E9EF;
    --text-muted: var(--c-slate-400);
    --accent: var(--c-navy-400);
    --accent-2: var(--c-brass-400);
    --verified: var(--c-emerald-400);
    --unverified: var(--c-slate-500);
    --flag: var(--c-brass-400);
    --alert: var(--c-rust-400);
  }
}

/* Viewer's explicit toggle must win over the OS preference, in BOTH directions. */
:root[data-theme="dark"] {
  --bg: var(--c-ink-900);
  --surface: var(--c-ink-800);
  --surface-sunken: #121826;
  --rule: var(--c-ink-600);
  --text: #E5E9EF;
  --text-muted: var(--c-slate-400);
  --accent: var(--c-navy-400);
  --accent-2: var(--c-brass-400);
  --verified: var(--c-emerald-400);
  --unverified: var(--c-slate-500);
  --flag: var(--c-brass-400);
  --alert: var(--c-rust-400);
}
:root[data-theme="light"] {
  --bg: var(--c-paper-200);
  --surface: var(--c-paper-100);
  --surface-sunken: #EDF0F4;
  --rule: var(--c-rule-300);
  --text: #131924;
  --text-muted: var(--c-slate-500);
  --accent: var(--c-navy-600);
  --accent-2: var(--c-brass-600);
  --verified: var(--c-emerald-600);
  --unverified: var(--c-slate-400);
  --flag: var(--c-brass-600);
  --alert: var(--c-rust-600);
}

/* ---- primitives shared across surfaces ---- */

.rp-label {
  font-family: var(--font-mono);
  font-size: var(--size-label);
  letter-spacing: var(--track-label);
  color: var(--text-muted);
}

.rp-figure {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rp-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.09em;
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid currentColor;
  vertical-align: 1px;
  white-space: nowrap;
}

.rp-panel {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
}

/* The insignia: three chevrons in diagonal echelon — the flight/naval formation
   the word actually names: lead element top-left (white), wingmen trailing
   down-right. Brass on navy. Every leg and the stagger axis are EXACTLY 45° so
   diagonals rasterize clean at small sizes. Canonical paths (26 viewBox):
   M4 9 L8 5 L12 9 · M9 14 L13 10 L17 14 · M14 19 L18 15 L22 19 */
.es-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Pinned to PRIMITIVES on purpose: the insignia is an artifact, not text.
     Semantic --accent flips light in dark mode, which washed the mark out
     (light strokes on light blue). The patch stays navy/brass in both themes. */
  background: var(--c-navy-600);
  border-radius: var(--radius);
  /* A patch is square, always: refuse flex-shrink and hold 1:1 no matter what
     container tries to compress it. The svg fills the tile — padding comes from
     the viewBox margins, so tile and glyph can never desync. */
  flex: none;
  aspect-ratio: 1 / 1;
}
.es-mark svg { display: block; width: 100%; height: 100%; }
.es-mark .chev { fill: none; stroke: var(--c-brass-400); stroke-width: 2.4; stroke-linecap: square; }
.es-mark .chev.top { stroke: #FFFFFF; }

/* Slim site nav — brand lives here on subpages so each page's h1 can name the
   page instead of restating the product. Hub (/) carries the full masthead. */
.es-nav {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) 0; border-bottom: var(--border);
  font-size: var(--size-sm);
}
.es-nav .es-mark { width: 34px; height: 34px; flex: none; }
.es-nav .word {
  font-weight: 700; letter-spacing: -0.02em; color: var(--text);
  text-decoration: none; white-space: nowrap;
  font-size: 17px; line-height: 1.15;
  display: flex; flex-direction: column;
}
/* The tagline rides with the wordmark as a lockup, so the promise travels with
   the name onto every page instead of living only on the hub. */
/* .es-tag, not .tag: cards.html already owns `.tag` for its receipt pills. */
.es-nav .word .es-tag {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 400;
  letter-spacing: 0.04em; color: var(--text-muted);
}
/* Narrow screens wrap the links under the lockup rather than dropping the
   tagline: the promise should survive on a phone. */
@media (max-width: 620px) {
  .es-nav { flex-wrap: wrap; row-gap: var(--sp-2); }
  .es-nav .links { margin-left: 0; flex-basis: 100%; gap: var(--sp-3); }
}
.es-nav .links { margin-left: auto; display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.es-nav .links a {
  color: var(--text-muted); text-decoration: none;
  font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.06em;
  padding: 3px 2px; border-bottom: 2px solid transparent;
}
.es-nav .links a:hover { color: var(--text); }
.es-nav .links a[aria-current="page"] {
  color: var(--accent); border-bottom-color: var(--accent-2);
}

:where(a, button, select, input, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
