/* GridPulse design tokens: the one source for type, colour, status and sizing on the globe (public/globe.html) and the
   Charts page (public/index.html). Loaded before each page's own <style>, which uses these names and nothing older.
   scripts/redesign/contrast.mjs checks every colour pair here (node scripts/redesign/contrast.mjs; it must exit 0).
   The globe is a night scene and always dark; the Charts page keeps its light theme ([data-theme="light"], or the OS
   setting when the viewer hasn't picked one), which redefines the colours at the end of this file. */
:root {
  color-scheme: dark;                     /* form controls, scrollbars and the search clear button draw dark too */
  /* ---- type: Inter for words, JetBrains Mono for numbers only (with tabular figures) ---- */
  --font-text: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --text-fine: 12px;  --lh-fine: 16px;    /* legal and footnotes only, never essential information */
  --text-meta: 13px;  --lh-meta: 18px;    /* timestamps, operator codes, secondary lines, day labels */
  --text-body: 15px;  --lh-body: 22px;    /* default for readable text */
  --text-lead: 16px;  --lh-lead: 24px;    /* plain-language status sentences */
  --text-h3: 17px;    --lh-h3: 24px;      /* section heads */
  --text-h2: 20px;    --lh-h2: 28px;
  --text-h1: 26px;    --lh-h1: 32px;      /* the region's name in its detail panel */
  --num-sm: 17px;                         /* the % in a list row */
  --num-md: 40px;                         /* the % on a card */
  --num-lg: 54px;                         /* the hero and detail % */

  /* ---- colour: surfaces and text (dark) ---- */
  --space: #02040a;
  --panel: rgba(7, 12, 22, 0.94);         /* glass over the globe: never under 0.88; 0.94 keeps the Critical red AA over the brightest city lights */
  --panel-solid: #0a101c;
  --surface-raised: #0e1626;
  --hairline: rgba(150, 190, 240, 0.16);
  --hairline-strong: rgba(150, 190, 240, 0.34);
  --text: #e8eef7;                        /* primary */
  --text-2: #a7b3c4;                      /* secondary */
  --text-3: #8592a8;                      /* tertiary: the lowest that still carries content */
  --accent: #5ac8fa;
  --accent-soft: rgba(90, 200, 250, 0.10);
  --accent-line: rgba(90, 200, 250, 0.5);
  --focus: #5ac8fa;
  --advisory: #8fb8e8;                    /* an operator's advisory (informational, not a level): its mark and its words */

  /* ---- status: colour always comes with a shape and a word ---- */
  --lv-normal: #4ade80;    /* circle */
  --lv-elevated: #f5b83d;  /* triangle */
  --lv-high: #f97316;      /* square */
  --lv-critical: #ef4444;  /* diamond */
  --lv-unknown: #8c8b83;
  /* Status-coloured text (a list %, a level word): the colour itself on dark; a deeper shade on the light theme. */
  --lv-normal-text: var(--lv-normal); --lv-elevated-text: var(--lv-elevated); --lv-high-text: var(--lv-high);
  --lv-critical-text: var(--lv-critical); --lv-unknown-text: #a8a79f;
  /* Pills: a darkened tint behind light text of the same hue (AA on the tint and on the panel). */
  --lv-normal-bg: #0f2e1b;    --lv-normal-fg: #a7f3c0;
  --lv-elevated-bg: #33260a;  --lv-elevated-fg: #fcd98a;
  --lv-high-bg: #3a1d08;      --lv-high-fg: #fdba8c;
  --lv-critical-bg: #3d1111;  --lv-critical-fg: #fca5a5;
  --lv-unknown-bg: #1f2125;   --lv-unknown-fg: #cfd3da;

  /* ---- sizing and spacing (4/8 scale) ---- */
  --target: 44px;          /* touch target, both ways */
  --target-desk: 40px;     /* pointer-only desktop controls: never under this */
  /* A control's size on this device: 40px while every pointer is fine (a mouse, a trackpad), 44px wherever a touch
     screen is present (the media query below; any-pointer, so a touchscreen laptop gets 44 too). Both pages use it. */
  --ctl: var(--target-desk);
  --text-input: var(--text-body);   /* a text field or a select: 16px on touch (below), as iOS Safari zooms into less */
  --row-min: 48px;         /* list rows */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 40px; --s-8: 48px;
  --radius-sm: 4px; --radius: 8px; --radius-lg: 12px;
  --focus-ring: 2px solid var(--focus);
}
@media (any-pointer: coarse) { :root { --ctl: var(--target); --text-input: 16px; } }

/* ---- the Charts page's light theme (public/index.html sets data-page="charts" on <html>) ----
   The globe never sets data-page, so it stays dark whatever the OS says. The Charts page follows the OS until the
   viewer picks a theme (data-theme="light" | "dark", kept in gp-theme). Status colours darken one step on white so a
   dot or bar still reaches 3:1, and their text shades reach 4.5:1; the shape and the word always come with them. */
:root[data-page="charts"][data-theme="light"] {
  color-scheme: light;
  --space: #f4f4f2;
  --panel: #fcfcfb;
  --panel-solid: #fcfcfb;
  --surface-raised: #efeeea;
  --hairline: #e2e1dc;
  --hairline-strong: #c9c8c1;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #64635e;
  --accent: #1a62b8;
  --accent-soft: rgba(26, 98, 184, 0.10);
  --accent-line: rgba(26, 98, 184, 0.5);
  --focus: #1a62b8;
  --advisory: #1a62b8;
  --lv-normal: #15803d;
  --lv-elevated: #b06d00;
  --lv-high: #e2580b;
  --lv-critical: #dc2626;
  --lv-unknown: #8a897f;
  --lv-normal-text: #166534; --lv-elevated-text: #92400e; --lv-high-text: #9a3412; --lv-critical-text: #b91c1c; --lv-unknown-text: #5f5e58;
  --lv-normal-bg: #dcfce7;    --lv-normal-fg: #14532d;
  --lv-elevated-bg: #fef3c7;  --lv-elevated-fg: #78350f;
  --lv-high-bg: #ffedd5;      --lv-high-fg: #7c2d12;
  --lv-critical-bg: #fee2e2;  --lv-critical-fg: #7f1d1d;
  --lv-unknown-bg: #ecebe7;   --lv-unknown-fg: #3f3e3a;
}
@media (prefers-color-scheme: light) {
  :root[data-page="charts"]:not([data-theme="dark"]) {
    color-scheme: light;
    --space: #f4f4f2;
    --panel: #fcfcfb;
    --panel-solid: #fcfcfb;
    --surface-raised: #efeeea;
    --hairline: #e2e1dc;
    --hairline-strong: #c9c8c1;
    --text: #0b0b0b;
    --text-2: #52514e;
    --text-3: #64635e;
    --accent: #1a62b8;
    --accent-soft: rgba(26, 98, 184, 0.10);
    --accent-line: rgba(26, 98, 184, 0.5);
    --focus: #1a62b8;
    --advisory: #1a62b8;
    --lv-normal: #15803d;
    --lv-elevated: #b06d00;
    --lv-high: #e2580b;
    --lv-critical: #dc2626;
    --lv-unknown: #8a897f;
    --lv-normal-text: #166534; --lv-elevated-text: #92400e; --lv-high-text: #9a3412; --lv-critical-text: #b91c1c; --lv-unknown-text: #5f5e58;
    --lv-normal-bg: #dcfce7;    --lv-normal-fg: #14532d;
    --lv-elevated-bg: #fef3c7;  --lv-elevated-fg: #78350f;
    --lv-high-bg: #ffedd5;      --lv-high-fg: #7c2d12;
    --lv-critical-bg: #fee2e2;  --lv-critical-fg: #7f1d1d;
    --lv-unknown-bg: #ecebe7;   --lv-unknown-fg: #3f3e3a;
  }
}

/* ---- status classes, shared by both pages ----
   .lv-<key> (GP_BOARD.levelKey) gives one level's colours short names: --lc the mark (shapes, rails, bars, bubbles), --ltx
   status-coloured text, --lbg / --lfg a pill's tint and its text. An old reading ('stale') and no reading ('none') take
   the grey. The shape comes from GP_BOARD.shapeSvg (the dashed ring for 'stale' and 'none'), in currentColor. */
.lv-normal   { --lc: var(--lv-normal);   --ltx: var(--lv-normal-text);   --lbg: var(--lv-normal-bg);   --lfg: var(--lv-normal-fg); }
.lv-elevated { --lc: var(--lv-elevated); --ltx: var(--lv-elevated-text); --lbg: var(--lv-elevated-bg); --lfg: var(--lv-elevated-fg); }
.lv-high     { --lc: var(--lv-high);     --ltx: var(--lv-high-text);     --lbg: var(--lv-high-bg);     --lfg: var(--lv-high-fg); }
.lv-critical { --lc: var(--lv-critical); --ltx: var(--lv-critical-text); --lbg: var(--lv-critical-bg); --lfg: var(--lv-critical-fg); }
.lv-stale, .lv-none { --lc: var(--lv-unknown); --ltx: var(--lv-unknown-text); --lbg: var(--lv-unknown-bg); --lfg: var(--lv-unknown-fg); }
.shp { flex: none; display: inline-block; vertical-align: -1px; }
/* The level pill: the level's tint behind light text of its hue, the shape in the level colour, then the word (Normal
   included; "Old reading" / "No live reading" in grey with the ring). One size on both pages. */
.lvp { display: inline-flex; flex: none; align-items: center; gap: var(--s-1); padding: 2px var(--s-2); border-radius: 999px;
  font: 600 var(--text-meta)/var(--lh-meta) var(--font-text); white-space: nowrap;
  background: var(--lbg, var(--lv-unknown-bg)); color: var(--lfg, var(--lv-unknown-fg)); }
.lvp .shp { color: var(--lc, var(--lv-unknown)); }
