/* Nephysis design tokens: the single source of truth for colour, type, space and shape.
 *
 * Theme selection:
 *   <html data-theme="light|dark">  explicit choice (switch, saved in localStorage + cookie)
 *   no attribute                    follow prefers-color-scheme
 * :root carries the light values; dark is applied by the media query (unless the user
 * forced light) and by [data-theme="dark"].
 *
 * The accent (Matrix green) is for details only: highlights, focus rings, the active nav
 * item, status pips, the main chart series. Never a button background or a large fill.
 *
 * Type: a Helvetica-style sans for text and UI, Space Grotesk for headings only, and
 * JetBrains Mono only where data is shown (numbers, tables, codes, logs).
 */

/* ---- Fonts (self-hosted, SIL OFL; licences next to the files) ---------------------- */
@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/SpaceGrotesk-Variable.7f0108a716f2.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Variable.e0548087438b.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* ---- Light (default) -------------------------------------------------------------- */
:root {
  color-scheme: light;
  --bg: #F3F3F1;
  --surface: #EAEAE7;
  --raised: #E2E2DE;
  --line: #D3D3CF;
  --line-strong: #BDBDB8;
  --text: #141518;
  --muted: #5E636B;
  --faint: #8C9097;          /* tertiary text, disabled */
  --accent: #008F11;
  --accent-dim: rgba(0, 143, 17, 0.12);
  --accent-glow: rgba(0, 143, 17, 0.30);
  --error: #C62F35;
  --error-dim: rgba(198, 47, 53, 0.10);
  --grid-faint: rgba(20, 21, 24, 0.045);
  --overlay: rgba(243, 243, 241, 0.92);
  /* Chart secondary series, darkest first (read by charts.js) */
  --series-1: #6B7078;
  --series-2: #9A9EA5;
  --series-3: #B9BCC1;
  --series-4: #4A4E55;
  /* Map tile filter (read by .map) */
  --map-filter: grayscale(1) contrast(0.95);
}

/* ---- Dark ------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B0C0E;
    --surface: #121417;
    --raised: #171A1E;
    --line: #24272C;
    --line-strong: #33373D;
    --text: #E6E7E9;
    --muted: #8B9098;
    --faint: #5C6168;
    --accent: #00C83A;
    --accent-dim: rgba(0, 200, 58, 0.12);
    --accent-glow: rgba(0, 200, 58, 0.35);
    --error: #E5484D;
    --error-dim: rgba(229, 72, 77, 0.12);
    --grid-faint: rgba(230, 231, 233, 0.035);
    --overlay: rgba(11, 12, 14, 0.94);
    --series-1: #9AA0A8;
    --series-2: #6E737B;
    --series-3: #50545B;
    --series-4: #C4C7CC;
    --map-filter: grayscale(1) invert(1) brightness(0.9) contrast(0.9);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0C0E;
  --surface: #121417;
  --raised: #171A1E;
  --line: #24272C;
  --line-strong: #33373D;
  --text: #E6E7E9;
  --muted: #8B9098;
  --faint: #5C6168;
  --accent: #00C83A;
  --accent-dim: rgba(0, 200, 58, 0.12);
  --accent-glow: rgba(0, 200, 58, 0.35);
  --error: #E5484D;
  --error-dim: rgba(229, 72, 77, 0.12);
  --grid-faint: rgba(230, 231, 233, 0.035);
  --overlay: rgba(11, 12, 14, 0.94);
  --series-1: #9AA0A8;
  --series-2: #6E737B;
  --series-3: #50545B;
  --series-4: #C4C7CC;
  --map-filter: grayscale(1) invert(1) brightness(0.9) contrast(0.9);
}

/* ---- Theme-independent ------------------------------------------------------------ */
:root {
  --font-sans: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, sans-serif;
  --font-display: "Space Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Type scale (px-based, rem so user zoom works) */
  --fs-xs: 0.6875rem;   /* 11  labels, tags */
  --fs-sm: 0.8125rem;   /* 13  dense data, secondary */
  --fs-md: 0.9375rem;   /* 15  body */
  --fs-lg: 1.125rem;    /* 18  h3 */
  --fs-xl: 1.5rem;      /* 24  h2 */
  --fs-2xl: 2rem;       /* 32  h1 */
  --fs-3xl: 2.75rem;    /* 44  display */
  --tracking-label: 0.06em;
  --tracking-wide: 0.16em;

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

  /* Shape: square. 2 px max anywhere. */
  --radius: 2px;
  --border: 1px solid var(--line);
  --border-strong: 1px solid var(--line-strong);

  /* Layout */
  --gutter: 16px;
  --maxw: 1440px;
  --bar-h: 52px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur: 140ms;
}
@media (min-width: 900px) {
  :root { --gutter: 32px; }
}
