/*
  ArtikControl design tokens — the "Status Board" system.

  Every color / font-family / border-width / radius / shadow value used
  anywhere in site.css MUST come from a custom property defined here.
  site.css never contains a raw hex code — that is the restyle-safety
  contract: change the look by editing this file, not by hunting through
  components. (It is how the previous Chart Paper look was replaced.)

  Source: the customer's styling idea of 2026-11-16 — a light neutral ground,
  white rounded cards, heavy grotesque headings, and red / amber / green
  status carried by a distribution bar, edged stat tiles and banded bars.

  ---------------------------------------------------------------------
  TWO PALETTES, ONE SET OF NAMES
  ---------------------------------------------------------------------
  Each value exists once, as a --*-light / --*-dark pair. Three blocks
  below map a pair onto the token name site.css actually uses:

    :root                             light — the default
    @media (prefers-color-scheme:dark) dark — the visitor's OS preference,
                                      unless they explicitly chose light
    :root[data-theme="dark"]          dark — explicit choice, from the
                                      header toggle (stored in localStorage
                                      and re-applied before first paint by
                                      the bootstrap script in _Head.cshtml)

  The dark *mapping* appears twice because CSS can't apply one block from
  two conditions; the dark *values* are still defined in exactly one place.

  ---------------------------------------------------------------------
  STATUS COLORS COME IN TWO STRENGTHS
  ---------------------------------------------------------------------
  The mock's red, amber and green are fill colors: vivid enough to read as
  a bar or an edge from across a desk, and too light to be text — its amber
  measures 2.1:1 on white. So each status has a FILL (bars, edges, map
  pins) and a TEXT tone (words and figures) that clears WCAG AA, 4.5:1, on
  every surface a status word sits on. Use --critical for a word,
  --critical-fill for a shape; never the other way round.
*/

:root {
  /* ---- Light palette ---- */
  --ground-light: #f4f4f1;        /* page background */
  --surface-light: #ffffff;       /* cards, tiles, panels, menus */
  --band-light: #ebebe8;          /* table header band, bar tracks */
  --band-soft-light: #f6f6f3;     /* zebra rows, read-only field ground */
  --hover-light: #eeeeea;         /* row hover tint */
  --hairline-light: #e6e6e2;      /* row dividers, rules inside a card */
  --border-light: #d2d2cd;        /* control and card borders */
  --border-strong-light: #9c9c97; /* a quiet pill's outline */
  /* Three text tones, each AA on ground, surface and the zebra band:
     16.9 : 1 / 8.1 : 1 / 4.9 : 1 against the ground. */
  --ink-light: #121316;
  --muted-light: #474a50;
  --faint-light: #666a71;
  --link-light: #1d55ad;          /* links, focus ring, the chart's trace */
  --critical-light: #cf1f14;      /* status words and figures */
  --warn-light: #9a5500;
  --ok-light: #2b7a1b;
  --critical-fill-light: #ee2a1c; /* status shapes: bars, edges, pins */
  --warn-fill-light: #f2a126;
  --ok-fill-light: #4fa62f;
  /* The wordmark's two inks. */
  --brand-navy-light: #2c3167;
  --brand-coral-light: #d6432a;
  /* Categorical inks for the energy split. Deliberately not the status
     colors: fan / compressor / defrost are kinds, not verdicts. */
  --series-fan-light: #5a3d9c;
  --series-compressor-light: #b23370;
  --series-defrost-light: #b8651c;
  --series-reference-light: #2f80dc; /* the "average" bar */
  --input-bg-light: #ffffff;
  --on-ink-light: #ffffff;        /* text on an --ink-filled button */
  --shadow-raised-light: 0 1px 2px rgba(18, 19, 22, 0.05), 0 4px 14px rgba(18, 19, 22, 0.05);
  --shadow-float-light: 0 2px 6px rgba(18, 19, 22, 0.08), 0 18px 44px rgba(18, 19, 22, 0.16);
  --map-tiles-light: none;        /* OSM's own tiles already suit a light page */

  /* ---- Dark palette (the same roles, designed for a dark ground) ---- */
  --ground-dark: #131416;
  --surface-dark: #1c1e21;
  --band-dark: #26282c;
  --band-soft-dark: #202226;
  --hover-dark: #2a2d31;
  --hairline-dark: #2b2d31;
  --border-dark: #3a3d42;
  --border-strong-dark: #6c7078;
  --ink-dark: #eef0f2;
  --muted-dark: #b4b8bf;
  --faint-dark: #8d9199;
  --link-dark: #86b4f5;
  --critical-dark: #ff7468;
  --warn-dark: #f0b04a;
  --ok-dark: #7fd163;
  --critical-fill-dark: #f0483b;
  --warn-fill-dark: #eba62f;
  --ok-fill-dark: #58b337;
  --brand-navy-dark: #b9bfee;
  --brand-coral-dark: #ff7a5c;
  --series-fan-dark: #9a82e0;
  --series-compressor-dark: #e0689f;
  --series-defrost-dark: #dc8a3c;
  --series-reference-dark: #5aa2f0;
  --input-bg-dark: #141518;       /* recessed below the card — a field reads as a well */
  --on-ink-dark: #131416;         /* --ink is near-white here, so button text goes dark */
  /* A dark ground hides a soft shadow, so the raised surface leans on its
     tone step and a hairline of light instead. */
  --shadow-raised-dark: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-float-dark: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 18px 44px rgba(0, 0, 0, 0.6);
  /* OSM serves only light tiles; this turns them into a dark basemap (Map.cshtml applies it to
     the tile pane alone, so the status markers keep their own colors). */
  --map-tiles-dark: invert(0.94) hue-rotate(180deg) saturate(0.6) brightness(1.05);

  /* ---- Active palette: light ---- */
  color-scheme: light;
  --ground: var(--ground-light);
  --surface: var(--surface-light);
  --band: var(--band-light);
  --band-soft: var(--band-soft-light);
  --hover: var(--hover-light);
  --hairline: var(--hairline-light);
  --border: var(--border-light);
  --border-strong: var(--border-strong-light);
  --ink: var(--ink-light);
  --muted: var(--muted-light);
  --faint: var(--faint-light);
  --link: var(--link-light);
  --critical: var(--critical-light);
  --warn: var(--warn-light);
  --ok: var(--ok-light);
  --critical-fill: var(--critical-fill-light);
  --warn-fill: var(--warn-fill-light);
  --ok-fill: var(--ok-fill-light);
  --brand-navy: var(--brand-navy-light);
  --brand-coral: var(--brand-coral-light);
  --series-fan: var(--series-fan-light);
  --series-compressor: var(--series-compressor-light);
  --series-defrost: var(--series-defrost-light);
  --series-reference: var(--series-reference-light);
  --input-bg: var(--input-bg-light);
  --on-ink: var(--on-ink-light);
  --shadow-raised: var(--shadow-raised-light);
  --shadow-float: var(--shadow-float-light);
  --map-tiles: var(--map-tiles-light);

  /* ---- Fonts (shared by both palettes) ----
     One family doing every job: Work Sans at 800 for headings and figures,
     400–600 for everything read. The mono stack is for identifiers only —
     a MAC address, a ZigBee id — and is the reader's own system mono, so it
     costs no download. */
  --font-display: "Work Sans", "Segoe UI", system-ui, sans-serif;
  --font-body: "Work Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  /* ---- Type ramp (shared by both palettes) ----
     Six steps in rem, so the ramp answers the reader's browser font-size
     setting; the px in the comments are what each step renders at the
     default 16px root. Every step is at least 1.15x the one below it. */
  --fs-label: 0.6875rem;  /* 11px — uppercase tracked micro: column heads, tile and field
                                    labels, status words */
  --fs-small: 0.8125rem;  /* 13px — secondary UI: nav, meta lines, notes, legends */
  --fs-body: 0.9375rem;   /* 15px — base: prose, table cells, fields, buttons */
  --fs-title: 1.25rem;    /* 20px — the heading of any card or panel; the wordmark */
  --fs-figure: 1.75rem;   /* 28px — a counted figure: stat tiles, the status counts */
  --fs-display: 2.125rem; /* 34px — the page title, and a unit's current reading */

  /* ---- Tracking (shared) ---- */
  --track-label: 0.09em;  /* uppercase labels: the tracking is doing the legibility work */
  --track-tight: -0.015em; /* display and figure sizes at weight 800 */

  /* ---- Borders / radius (shared by both palettes) ---- */
  --border-thin: 1px;
  --border-thick: 1.5px;
  --border-heavy: 2px;
  --edge: 3px;            /* the status edge on a tile or a unit card */
  --radius-xs: 2px;       /* a key swatch, a signal bar */
  --radius-sm: 8px;       /* fields, selects, small controls, bar tracks */
  --radius: 14px;         /* cards, tiles, panels, menus */
  --radius-pill: 999px;   /* nav pills, buttons, bars */

  /* ---- Glyphs (shared) ----
     Shapes used as CSS masks, so they are painted in whatever color the
     element carries. The color in the SVG itself is never seen. */
  --glyph-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='M7 11l5 5 5-5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E");
}

/* The OS preference, for a visitor who hasn't chosen a side in this app. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: var(--ground-dark);
    --surface: var(--surface-dark);
    --band: var(--band-dark);
    --band-soft: var(--band-soft-dark);
    --hover: var(--hover-dark);
    --hairline: var(--hairline-dark);
    --border: var(--border-dark);
    --border-strong: var(--border-strong-dark);
    --ink: var(--ink-dark);
    --muted: var(--muted-dark);
    --faint: var(--faint-dark);
    --link: var(--link-dark);
    --critical: var(--critical-dark);
    --warn: var(--warn-dark);
    --ok: var(--ok-dark);
    --critical-fill: var(--critical-fill-dark);
    --warn-fill: var(--warn-fill-dark);
    --ok-fill: var(--ok-fill-dark);
    --brand-navy: var(--brand-navy-dark);
    --brand-coral: var(--brand-coral-dark);
    --series-fan: var(--series-fan-dark);
    --series-compressor: var(--series-compressor-dark);
    --series-defrost: var(--series-defrost-dark);
    --series-reference: var(--series-reference-dark);
    --input-bg: var(--input-bg-dark);
    --on-ink: var(--on-ink-dark);
    --shadow-raised: var(--shadow-raised-dark);
    --shadow-float: var(--shadow-float-dark);
    --map-tiles: var(--map-tiles-dark);
  }
}

/* An explicit choice from the header toggle wins over the OS preference. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: var(--ground-dark);
  --surface: var(--surface-dark);
  --band: var(--band-dark);
  --band-soft: var(--band-soft-dark);
  --hover: var(--hover-dark);
  --hairline: var(--hairline-dark);
  --border: var(--border-dark);
  --border-strong: var(--border-strong-dark);
  --ink: var(--ink-dark);
  --muted: var(--muted-dark);
  --faint: var(--faint-dark);
  --link: var(--link-dark);
  --critical: var(--critical-dark);
  --warn: var(--warn-dark);
  --ok: var(--ok-dark);
  --critical-fill: var(--critical-fill-dark);
  --warn-fill: var(--warn-fill-dark);
  --ok-fill: var(--ok-fill-dark);
  --brand-navy: var(--brand-navy-dark);
  --brand-coral: var(--brand-coral-dark);
  --series-fan: var(--series-fan-dark);
  --series-compressor: var(--series-compressor-dark);
  --series-defrost: var(--series-defrost-dark);
  --series-reference: var(--series-reference-dark);
  --input-bg: var(--input-bg-dark);
  --on-ink: var(--on-ink-dark);
  --shadow-raised: var(--shadow-raised-dark);
  --shadow-float: var(--shadow-float-dark);
  --map-tiles: var(--map-tiles-dark);
}
