/* Colour themes (SPEC §2.5 Weergave, WSF-SET-1, WSF-SET-2).

   Every interface colour is named here and used nowhere else as a literal.
   Values come from `tools/design/Main.dc.html` (its `.wsroot` variable sets), which
   is normative for colours.

   Two kinds of variable, and the split is WSF-SET-2:

     neutral   surfaces, text, lines — the only thing a theme changes
     accent    weather and signal colours — the same in both themes, so they
               are declared once on `:root` and no theme block touches them

   The data colour scales (the rain gradient, the stripe's night/overcast/sun
   mix) are not here: they are computed per value, so their stops live in
   their own DOM-free modules where they are tested.

   A theme reaches the page by two routes: the device's media query, so first
   paint is right before any script runs, and the `data-theme` attribute that
   theme.js sets for an explicit choice. For `auto` the attribute is absent,
   and the media query below is guarded on that absence so an explicit choice
   always wins.

   The light values are written once as a `--light-*` palette and assigned
   from it in both routes, because plain CSS has no mixins and the two routes
   need different selectors; a theme written twice is one that eventually gets
   updated in only one place. Copied pattern from CasaFluxFE's theme.css. */

:root {
  /* --- accents: identical in both themes --- */
  --now: #ff9f1c;            /* the now line, selection check marks */
  --sun: #ffb703;            /* sun glyphs, sunrise, sun dot by day */
  --sunset: #ff8a4d;
  --sun-down: #6b7280;       /* the sun dot outside daylight */
  --rain-bar: #4f9bf0;       /* Verwachting day totals */
  --drops: #5aa8ff;          /* rain drops in the weather icon */
  --wind-calm: #9fc3e8;      /* Beaufort < 4 */
  --wind-fresh: #ffb703;     /* Beaufort 4–5 */
  --wind-strong: #ff6b5e;    /* Beaufort ≥ 6 */
  --switch-on: #34c759;
  --danger: #e5372e;         /* the swipe-to-delete box */
  --danger-soft: #ff8a80;    /* the hover trash glyph */
  --tag-past: #c8c8cd;       /* radar: gemeten */
  --tag-future: #8ec2ff;     /* radar: voorspeld */
  --t-max: #e5233a;          /* Verwachting: daily maximum line, dots, week bars */
  --t-min: #5aa0e6;          /* Verwachting: daily minimum */
  --night-shade: rgba(8, 10, 28, 0.55); /* the night over every stripe, days and weeks (nightShade.js) */
  /* The radar map is dark in both themes (SPEC §2.5), so its colours are
     accents, not neutrals. */
  --map-bg: #16283c;
  --map-text: #f4f4f4;
  --map-muted: #9aa0a8;
  --map-pin: #ffe14a;
  --map-shadow: #000;
  --bubble: #0b1a5c;         /* the radar chart's time bubble */
  --on-accent: #fff;         /* text and knobs drawn on an accent */
  --backdrop: rgba(0, 0, 0, 0.4);
  --panel-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);

  /* --- the light palette, assigned by both light routes below --- */
  --light-bg: #eceef2;
  --light-card: #ffffff;
  --light-card2: #e2e5eb;
  --light-fg: #17181c;
  --light-fg2: #2b2d33;
  --light-mut: #6a6d76;
  --light-mut2: #53565e;
  --light-col1: #ffffff;
  --light-col2: #f5f6f9;
  --light-axis: #a8abb3;
  --light-bg-rgb: 236, 238, 242;
  --light-line-rgb: 0, 0, 0;
  --light-past: rgba(236, 238, 242, 0.55);
  --light-blue-text: #1f6fd6;
  --light-cloud: #7d889c;
  --light-moon: #5b66b3;
  --light-ice: #5aa7e6;
  --light-sun-left: #fff1d6;
  --light-sun-right: #ffe3dc;
}

/* --- Dark: the default, and what an unknown data-theme falls back to. --- */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #1b1b1d;
  --card: #2a2a2d;
  --card2: #3c3c40;
  --fg: #f4f4f4;
  --fg2: #e4e4e8;
  --mut: #9a9a9f;
  --mut2: #c8c8cc;
  --col1: #262628;           /* Verwachting column, alternating */
  --col2: #1e1e20;
  --axis: #666;
  --bg-rgb: 27, 27, 29;
  --line-rgb: 255, 255, 255; /* hairlines are rgba(var(--line-rgb), a) */
  --past: rgba(20, 20, 22, 0.45); /* dims the elapsed part of today */
  --blue-text: #8ec1ff;      /* "Huidige locatie" */
  --cloud: #f4f4f4;
  --moon: #e9ecff;
  --ice: #cfe6ff;
  --sun-left: #322c25;       /* the sun card's warm ends */
  --sun-right: #302728;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: var(--light-bg);
  --card: var(--light-card);
  --card2: var(--light-card2);
  --fg: var(--light-fg);
  --fg2: var(--light-fg2);
  --mut: var(--light-mut);
  --mut2: var(--light-mut2);
  --col1: var(--light-col1);
  --col2: var(--light-col2);
  --axis: var(--light-axis);
  --bg-rgb: var(--light-bg-rgb);
  --line-rgb: var(--light-line-rgb);
  --past: var(--light-past);
  --blue-text: var(--light-blue-text);
  --cloud: var(--light-cloud);
  --moon: var(--light-moon);
  --ice: var(--light-ice);
  --sun-left: var(--light-sun-left);
  --sun-right: var(--light-sun-right);
}

/* `auto` on a light device. Guarded on the attribute's absence: theme.js
   removes it for `auto`, so this decides only when nothing explicit was
   chosen. Without the guard a light device would override an explicit
   "Donker". */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: var(--light-bg);
    --card: var(--light-card);
    --card2: var(--light-card2);
    --fg: var(--light-fg);
    --fg2: var(--light-fg2);
    --mut: var(--light-mut);
    --mut2: var(--light-mut2);
    --col1: var(--light-col1);
    --col2: var(--light-col2);
    --axis: var(--light-axis);
    --bg-rgb: var(--light-bg-rgb);
    --line-rgb: var(--light-line-rgb);
    --past: var(--light-past);
    --blue-text: var(--light-blue-text);
    --cloud: var(--light-cloud);
    --moon: var(--light-moon);
    --ice: var(--light-ice);
    --sun-left: var(--light-sun-left);
    --sun-right: var(--light-sun-right);
  }
}
