/*
  Epoch concept tokens. Unofficial concept by Studio Drewskii, not affiliated with Epoch.
  Three layers: 1) primitives (--epoch-*), raw values only, never read by styles.css or main.js.
                2) semantic (--color-*, --space-*, --type-*, --radius-*, --motion-*, --layer-*), the only layer styles.css reads.
                3) component (--header-*, --frame-*, --pill-*, --hero-*, --btn-*, --proof-*, --panel-*, --msg-*, --map-*, --legend-*),
                   built from semantic.
  Primitive colors marked "Epoch" are Epoch's own (epoch.blue CSS variables and computed styles, brand/extract.json,
  Nov 2, 2026). The rest (other slate steps, navy tints, blue-600, blue-50, forest tints, mint-400) are derived, contrast-checked in
  DESIGN_SYSTEM.md section 3.
  Units: rem for type and space (1rem = 16px), unitless line heights, ms for time.
*/

/* ---------- Fonts (SIL OFL 1.1, see /fonts/OFL-*.txt) ---------- */
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0, U+00A9, U+00B7, U+2013, U+2018-2019, U+201C-201D, U+2026, U+2192, U+20AC;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00B7;
}
/* Metric-matched fallbacks (capsize xWidthAvg method, computed with fontTools 4.66.1).
   Inter var (opsz 14-32, wght 400-600): upm 2048, asc 1984, desc 494, avg 0.4735 em.
   Liberation Sans (Arial metrics): avg 0.4411 em. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans");
  size-adjust: 107.34%;
  ascent-override: 90.25%;
  descent-override: 22.47%;
  line-gap-override: 0%;
}
/* IBM Plex Mono 400 vs Liberation Mono (Courier New metrics). */
@font-face {
  font-family: "Plex Mono Fallback";
  src: local("Courier New"), local("CourierNewPSMT"), local("Liberation Mono");
  size-adjust: 99.98%;
  ascent-override: 102.52%;
  descent-override: 27.5%;
  line-gap-override: 0%;
}

:root {
  color-scheme: light;

  /* ========== 1. PRIMITIVES ========== */
  --epoch-slate-0: #ffffff;   /* oklch(100.0% 0.000 0) */
  --epoch-slate-50: #f8fafc;  /* oklch(98.4% 0.003 248), Epoch surface-muted */
  --epoch-slate-100: #f1f5f9; /* oklch(96.8% 0.007 248), Epoch surface-alt */
  --epoch-slate-200: #e2e8f0; /* oklch(92.9% 0.013 256) */
  --epoch-slate-300: #cbd5e1; /* oklch(86.9% 0.020 253) */
  --epoch-slate-350: #b8c2d4; /* oklch(81.2% 0.028 262), derived panel muted */
  --epoch-slate-400: #94a3b8; /* oklch(71.1% 0.035 257) */
  --epoch-slate-500: #64748b; /* oklch(55.4% 0.041 257) */
  --epoch-slate-600: #475569; /* oklch(44.6% 0.037 257), Epoch ink-muted */
  --epoch-slate-700: #334155; /* oklch(37.2% 0.039 257) */
  --epoch-slate-800: #1e293b; /* oklch(27.9% 0.037 260), Epoch h2 */
  --epoch-slate-900: #0f172a; /* oklch(20.8% 0.040 266), Epoch ink */

  --epoch-navy-900: #1a2035; /* oklch(24.9% 0.041 271), Epoch header */
  --epoch-navy-800: #242c45; /* oklch(29.8% 0.047 270), derived bubble */
  --epoch-navy-700: #2c3550; /* oklch(33.4% 0.049 270), derived card */
  --epoch-navy-600: #3a4566; /* oklch(39.6% 0.058 270), derived hairline on navy */

  --epoch-blue-300: #60a5fa;  /* oklch(71.4% 0.143 255), Epoch accent, focus on navy */
  --epoch-blue-500: #376fd0;  /* oklch(55.6% 0.161 261), Epoch primary */
  --epoch-blue-600: #2c5bb0;  /* oklch(48.6% 0.145 261), derived hover */
  --epoch-blue-50: #eef3fb;   /* oklch(96.3% 0.012 260), derived tag tint */

  --epoch-forest-950: #011f14; /* oklch(21.3% 0.043 165), Epoch footer */
  --epoch-forest-800: #13302a; /* oklch(28.5% 0.037 178), derived map land */
  --epoch-forest-600: #2f5c4c; /* oklch(43.7% 0.057 168), derived map line */
  --epoch-mint-400: #5cc99a;   /* oklch(75.9% 0.123 163), derived status ok */
  --epoch-amber-400: #fbbf24;  /* oklch(83.7% 0.164 84), Epoch TRACE badge, status flag */

  --epoch-font-sans: "Inter", "Inter Fallback", Arial, system-ui, sans-serif;
  --epoch-font-mono: "IBM Plex Mono", "Plex Mono Fallback", "Courier New", ui-monospace, monospace;

  --epoch-radius-xs: 0.25rem;
  --epoch-radius-sm: 0.375rem;
  --epoch-radius-md: 0.75rem;
  --epoch-radius-lg: 1.25rem;
  --epoch-radius-full: 62.4375rem;

  --epoch-shadow-panel: 0 1.5rem 4rem -1.5rem #1a203559, 0 0.125rem 0.375rem -0.125rem #1a20352e;
  --epoch-ring-ink: inset 0 0 0 1px #0f172a14;  /* 8% ink ring */
  --epoch-ring-navy: inset 0 0 0 1px #ffffff1a; /* 10% white ring on navy */

  --epoch-ease-out: cubic-bezier(0.22, 1, 0.36, 1); /* entrances */
  --epoch-ease-state: ease;                         /* Epoch's own transitions */
  --epoch-ease-linear: linear;

  /* ========== 2. SEMANTIC ========== */
  /* Color: page */
  --color-bg: var(--epoch-slate-0);
  --color-bg-subtle: var(--epoch-slate-50);
  --color-text: var(--epoch-slate-900);         /* 17.85:1 on bg, APCA Lc 104.6 */
  --color-text-body: var(--epoch-slate-700);    /* 10.35:1, Lc 94.0 */
  --color-text-muted: var(--epoch-slate-600);   /* 7.58:1, Lc 86.3 */
  --color-line: var(--epoch-slate-200);
  --color-line-strong: var(--epoch-slate-300);
  --color-accent: var(--epoch-blue-500);
  --color-accent-hover: var(--epoch-blue-600);
  --color-on-accent: var(--epoch-slate-0);      /* 4.83:1 on blue-500, 6.50:1 on blue-600 */
  --color-accent-text: var(--epoch-blue-600);   /* links, 6.50:1 */
  --color-accent-tint: var(--epoch-blue-50);
  --color-focus: var(--epoch-blue-500);
  --color-logo: var(--epoch-slate-700);         /* proof logos via currentColor */
  --color-brand: var(--epoch-navy-900);         /* Epoch wordmark via currentColor */
  --color-depth-1: var(--epoch-forest-600); /* readable forest; 950 sat too close to the navy panel */
  --color-depth-2: var(--epoch-slate-200);

  /* Color: panel (dark surface) */
  --color-panel-bg: var(--epoch-navy-900);
  --color-panel-raised: var(--epoch-navy-800);
  --color-panel-card: var(--epoch-navy-700);
  --color-panel-line: var(--epoch-navy-600);
  --color-panel-text: var(--epoch-slate-50);    /* 15.42:1 on navy-900 */
  --color-panel-body: var(--epoch-slate-300);   /* 10.86:1 */
  --color-panel-muted: var(--epoch-slate-350);  /* 8.99:1, Lc -67.1 */
  --color-panel-focus: var(--epoch-blue-300);   /* 6.34:1, non-text */
  --color-status-ok: var(--epoch-mint-400);     /* 7.89:1 */
  --color-status-flag: var(--epoch-amber-400);  /* 9.66:1 */
  --color-status-approx: var(--epoch-slate-350);
  --color-map-land: var(--epoch-forest-800);
  --color-map-line: var(--epoch-forest-600);

  /* Type */
  --type-family-sans: var(--epoch-font-sans);
  --type-family-mono: var(--epoch-font-mono);
  --type-weight-regular: 400;
  --type-weight-medium: 500;
  --type-weight-bold: 600;

  --type-display-size: clamp(2.25rem, 1.45rem + 3.1vw, 4rem); /* 36 at 390, 47 at 768, 54.9 at 1024, 64 at 1440 */
  --type-display-cap: 12cqi;                                   /* binds at 1280 (57.6px in a 480px column) */
  --type-display-leading: 1.04;
  --type-display-tracking: -0.035em;

  --type-lede-size: clamp(1rem, 0.93rem + 0.3vw, 1.1875rem); /* 16 at 390, 19 at 1440 */
  --type-lede-leading: 1.5;
  --type-lede-measure: 34em;

  --type-body-size: 0.9375rem;   /* 15 */
  --type-body-leading: 1.45;
  --type-ui-size: 0.9375rem;     /* buttons, nav */
  --type-small-size: 0.8125rem;  /* 13 */
  --type-small-leading: 1.45;
  --type-panel-size: 0.875rem;   /* 14 */
  --type-panel-leading: 1.5;
  --type-mono-size: 0.75rem;     /* 12 */
  --type-mono-leading: 1.5;
  --type-tracking-tight: -0.011em;
  --type-tracking-normal: 0;

  /* Space (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-14: 3.5rem;
  --space-16: 4rem;

  --space-page: 1.25rem;     /* 20 below 768; steps in the media queries below: 32, 48, 64 */
  --space-gutter: 1.5rem;
  --space-hero-top: var(--space-6);  /* 24 below 768; 40, 32, 32, 56 below */
  --space-frame-gap: var(--space-2); /* header to frame: 8 below 768, 16 from 768 */
  --space-copy-cta: var(--space-6);  /* lede to CTA: 24 below 768, 32 from 768 */
  --space-cta-proof: var(--space-8); /* CTA to proof: 32 below 768, 40 from 768 */
  --space-copy-panel: var(--space-8);/* stacked copy to panel: 32 below 768, 40 at 768 */
  --space-stack-sm: var(--space-4);
  --space-stack-md: var(--space-6);
  --space-stack-lg: var(--space-8);
  --space-stack-xl: var(--space-10);

  --size-target: 2.75rem;     /* 44 */
  --size-content-max: 82rem;  /* 1312 */
  --size-screen: 100dvh;      /* room below the footer so the hero can leave the viewport */
  --size-hairline: 1px;
  --size-tick: 0.4375rem;     /* 7, frame corner ticks */

  /* Radius */
  --radius-control: var(--epoch-radius-sm);
  --radius-chip: var(--epoch-radius-xs);
  --radius-card: var(--epoch-radius-md);
  --radius-panel: var(--epoch-radius-lg);
  --radius-pill: var(--epoch-radius-full);

  /* Depth */
  --shadow-panel: var(--epoch-shadow-panel);
  --ring-ink: var(--epoch-ring-ink);
  --ring-panel: var(--epoch-ring-navy);
  --depth-offset-1: 0.625rem;  /* 10 */
  --depth-inset-1: 1rem;
  --depth-offset-2: 1.125rem;  /* 18 */
  --depth-inset-2: 2rem;
  --depth-shift: var(--space-4); /* one even forest offset, inline-end and below */

  /* Layers */
  --layer-behind: -1;
  --layer-base: 0;
  --layer-raised: 1;
  --layer-header: 10;
  --layer-menu: 20;
  --layer-skip: 30;

  /* Motion */
  --motion-fast: 180ms;
  --motion-base: 300ms;
  --motion-slow: 450ms;
  --motion-slower: 900ms;
  --motion-count: 1600ms;
  --motion-stagger: 120ms;
  --motion-loop-start: 600ms;  /* after load, idle, panel 50% in view */
  --motion-hold: 12000ms;      /* end state reached; holds */
  --motion-ease-out: var(--epoch-ease-out);
  --motion-ease-state: var(--epoch-ease-state);
  --motion-ease-linear: var(--epoch-ease-linear);
  --motion-rise: 0.5rem;
  --motion-press-scale: 0.97;
  --motion-nudge: 0.125rem;    /* 2px: focus offset and link arrow */
  --motion-ring-from: 0.6;    /* flagged plot rings scale from this to 1 */

  /* Beat start times (DESIGN_SYSTEM section 9) */
  --beat-1: 0ms;      /* user message + file chip */
  --beat-2: 1400ms;   /* status line, counters 0 to 48 / 19 / 31 */
  --beat-3: 3400ms;   /* scope reply */
  --beat-4: 4600ms;   /* plots, then legend rows */
  --beat-5: 7400ms;   /* confirm card; Yes pressed at 8800ms; follow-up at 9400ms */
  --beat-5-press: 8800ms;
  --beat-5-reply: 9400ms;
  --beat-6: 10400ms;  /* Drafting DDS chip */
  --beat-4a: 5400ms;  /* legend row: no flags */
  --beat-4b: 5900ms;  /* legend row: legality flag */
  --beat-4c: 6400ms;  /* legend row: street address */

  /* ========== 3. COMPONENT ========== */
  --header-height: 3.5rem;          /* 56 below 768, 64 at 768, 72 from 1024 */
  --header-bg: var(--color-bg);
  --header-line: var(--color-line);
  --header-nav-gap: var(--space-8);
  --header-logo-height: 1.5rem;     /* 24, Epoch mark + wordmark 2500x600 (padded viewBox), renders 100 wide */

  --frame-line: var(--color-line);
  --frame-tick: var(--color-line-strong);
  --frame-inset: var(--space-page);
  --frame-pad: var(--space-6);   /* content sits this far inside the frame */

  --pill-height: 2rem;
  --pill-pad-inline: var(--space-1) var(--space-3);
  --pill-gap: var(--space-2);
  --pill-line: var(--color-line);
  --pill-text: var(--color-text-body);
  --pill-tag-bg: var(--color-accent-tint);
  --pill-tag-text: var(--color-accent-text);
  --pill-date-text: var(--color-text-muted);

  --hero-cols-copy: 5;
  --hero-cols-panel: 7;
  --hero-cols-copy-md: 6;
  --hero-cols-panel-md: 6;

  --btn-height: 3rem;               /* 48 hero */
  --btn-height-sm: 2.5rem;          /* 40 header, hit area padded to 44 */
  --btn-pad-inline: var(--space-5);
  --btn-radius: var(--radius-control);
  --btn-bg: var(--color-accent);
  --btn-bg-hover: var(--color-accent-hover);
  --btn-text: var(--color-on-accent);
  --btn-weight: var(--type-weight-bold); /* Epoch's own .btn and .cta are 600 on --color-primary */
  --link-arrow-shift: var(--motion-nudge);

  --proof-gap: var(--space-6);
  --proof-gap-sm: var(--space-3);
  --proof-color: var(--color-logo);
  --proof-h-altana: 1.6875rem;   /* 27, optical, aspect 4.47 */
  --proof-h-assent: 1.375rem;    /* 22, optical, aspect 3.84 */
  --proof-h-resilinc: 2.375rem;  /* 38, optical, aspect 2.43 */
  --proof-h-3e: 1.5625rem;       /* 25, optical, aspect 2.83 */
  --proof-scale-sm: 0.82;        /* one row in the 390 column */

  --panel-bg: var(--color-panel-bg);
  --panel-radius: var(--radius-panel);
  --panel-pad: var(--space-6);
  --panel-pad-sm: var(--space-4);
  --panel-gap: var(--space-3);
  --panel-split: 40rem;          /* container width where chat and evidence sit side by side */
  --panel-chat-share: 1fr;
  --panel-evidence-share: 1.25fr; /* map gets the wider share */
  --panel-head-height: 2.75rem;
  --panel-ctl-min: 6rem;         /* fixed slot so Pause / Resume / Replay never reflow the head */

  --msg-user-bg: var(--color-panel-raised);
  --msg-radius: var(--radius-card);
  --msg-pad: var(--space-3) var(--space-4);
  --chip-height: 1.75rem;
  --chip-bg: var(--color-panel-card);
  --counter-width: 2ch;

  --confirm-bg: var(--color-panel-card);
  --confirm-radius: var(--radius-card);
  --fake-btn-height: 2.25rem;

  --map-aspect: 320 / 200;
  --map-bg: var(--color-map-land);
  --map-line: var(--color-map-line);
  --map-plot: var(--color-map-line);
  --map-plot-ok: var(--color-status-ok);
  --map-plot-flag: var(--color-status-flag);
  --map-plot-approx: var(--color-status-approx);
  --map-stroke: 1.25;            /* unitless, SVG user units */

  --legend-dot: 0.5rem;
  --legend-row: 1.75rem;
  --dds-fill: 0.7;               /* bar rests here; the sequence fills up to it */
  --num: 0;                      /* counter @property; styles.css reads it */
}

/* Breakpoint steps (fold budgets in DESIGN_SYSTEM section 7) */
@media (min-width: 48rem) {   /* 768 */
  :root {
    --space-page: var(--space-8);
    --space-hero-top: var(--space-10);
    --space-frame-gap: var(--space-4);
    --space-copy-cta: var(--space-8);
    --space-cta-proof: var(--space-10);
    --space-copy-panel: var(--space-10);
    --header-height: 4rem;
  }
}
@media (min-width: 64rem) {   /* 1024 */
  :root {
    --space-hero-top: var(--space-8);
    --header-height: 4.5rem;
  }
}
@media (min-width: 80rem) {   /* 1280 */
  :root { --space-page: var(--space-12); }
}
@media (min-width: 90rem) {   /* 1440 */
  :root {
    --space-page: var(--space-16);
    --space-hero-top: var(--space-14);
  }
}

/* Contrast and color-scheme preferences */
@media (prefers-contrast: more) {
  :root {
    --color-text-body: var(--epoch-slate-900);
    --color-text-muted: var(--epoch-slate-800);
    --color-line: var(--epoch-slate-500);
    --color-panel-body: var(--epoch-slate-50);
    --color-panel-muted: var(--epoch-slate-300);
    --color-panel-line: var(--epoch-slate-400);
    --color-accent: var(--epoch-blue-600);
  }
}
@media (forced-colors: active) {
  :root {
    --color-logo: CanvasText;
    --color-brand: CanvasText;
    --color-focus: Highlight;
    --color-panel-focus: Highlight;
    --shadow-panel: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms;
    --motion-base: 0ms;
    --motion-slow: 0ms;
    --motion-slower: 0ms;
    --motion-count: 0ms;
    --motion-rise: 0;
  }
}
