/* ═══════════════════════════════════════════════════════════════════════════
   CozyMon overlay on Opal Design.

   Loaded AFTER _content/Opal.Design/css/tokens.css and components.css. Everything
   CozyMon-specific lives here; the vendored design system is never edited.

   Two jobs:
     1. a blacker dark theme — the stock Opal dark is an opal, i.e. navy-tinted;
        a monitoring wall wants neutral coal;
     2. the two monitoring statuses Opal has no colour for (maintenance, unknown),
        and the one channel every status widget reads its colour from.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Coal dark theme ─────────────────────────────────────────────────────
   Derived, not eyeballed: every value below is its Opal counterpart converted to
   OKLab with chroma forced to 0 and lightness kept, so the ramp keeps its exact
   relative steps and only loses the hue. Selector specificity (0,2,0) beats the
   `:root, [data-theme="dark"]` block in tokens.css regardless of load order.

   The translucent glass tokens are here for the reason the opaque ones are: they
   are semi-transparent NAVY composited over the page. Neutralise only --bg and
   --surface and the glass keeps reading as blue smears over coal. Alphas are
   untouched — they were measured for text contrast, only the RGB moves.

   NOT neutralised, deliberately:
     --glass-border/--border/--hairline/--ring-inner — light translucent edges;
       hue is barely readable at their alphas and they are contrast-calibrated.
     --pill-tint-rgb — the primary button's body, not a page surface. It sits
       under --pill-glow-rgb (a light blue that stays, being the accent); greying
       only the tint would split one material between two palettes.
     --error-surface-1/-2 — status surfaces. They are red, so they cannot produce
       the blue patches this section exists to prevent, and the rule for statuses
       is that they stay coloured. (Neither has a consumer in the design system.)
   ────────────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg: #060606;
  --bg-2: #0f0f0f;
  --bg-3: #191919;
  --surface: #151515;
  --surface-contrast: #1f1f1f;

  --glass-bg: rgba(17, 17, 17, 0.40);
  --glass-bg-2: rgba(26, 26, 26, 0.34);
  --glass-scrim: rgba(9, 9, 9, 0.62);
  --scrim-tint: rgba(7, 7, 7, 0.42);

  --card-veil: rgba(13, 13, 13, 0.66);
  --card-veil-dense: rgba(13, 13, 13, 0.78);
  --card-veil-clear: rgba(13, 13, 13, 0.45);
  /* --card-veil-solid stays var(--surface) and follows the value above. */

  --moon-night: #131313;
  /* Declared by the design system but currently consumed by nothing in it;
     neutralised so wiring it up later cannot reintroduce a blue wash. */
  --bg-glow: rgba(132, 132, 132, 0.10);

  /* Scene ambience: .ds-stage paints four radial glows over the page. Half-alpha
     opal was tried first and still read as a blue wash top-left and a warm one
     bottom-right — on coal they are the most visible hue left on screen, and a
     page background is a surface, so the same rule applies to them as to the
     rest. Same treatment too: chroma to 0, lightness and alpha kept, which keeps
     the soft vignette and drops the tint. Restoring the opal scene is a revert
     of these four lines. */
  --glow-cobalt: rgba(122, 122, 122, 0.22);
  --glow-turquoise: rgba(187, 187, 187, 0.14);
  --glow-copper: rgba(168, 168, 168, 0.16);
  --glow-uv: rgba(150, 150, 150, 0.12);
}

/* ── 2. Monitoring statuses ─────────────────────────────────────────────────
   CozyMon has five: ok / warn / fail / maintenance / unknown. Opal ships colours
   for the first three (--success/--warn/--error-color). The other two alias
   existing palette tokens rather than inventing hues, and both of those are
   theme-aware, so the aliases resolve per theme on their own — they are declared
   on :root, the same element [data-theme="light"] redefines the palette on.

   maintenance = --op-uv: the blue the spec asks for (AC-DASH-UI-06) and the
   nearest system hue to the public page's indigo (D-023). It is not --accent:
   uv is ~290° in OKLCH against the accent's ~262°, and a maintenance badge
   always carries the word, so it is never told apart by colour alone.
   In the light theme the stock --op-uv is too light to be TEXT on the badge's
   own tint (3.71:1 over --surface), so the light theme takes a deeper step of
   the same hue — the system's own recipe for a step, an OKLCH lightness
   factor on the token (cf. the amethyst ramp in tokens.css). 0.85 keeps the
   badge text at 4.5:1 even if the tint lands on --bg rather than --surface.
   Measured in the browser (rendered pixels): badge text 5.21:1 light /
   4.82:1 dark, heartbeat segment on the card 6.47:1 / 5.80:1.
   unknown = --op-silver: the system's neutral iridescent seed.
   ────────────────────────────────────────────────────────────────────────── */
:root {
  --maintenance-color: var(--op-uv);
  --unknown-color: var(--op-silver);
}
:root[data-theme="light"] {
  --maintenance-color: oklch(from var(--op-uv) calc(l * 0.85) c h);
}

/* "No data yet" for a heartbeat day. Not a status — the absence of one — so it
   must stay recessive while still being told apart from a day that has data.
   The only new hexes in this file: neutral greys picked as the dimmest value
   clearing 3:1 against --surface in each theme (measured, see report). */
:root[data-theme="dark"] { --cm-empty: #676767; }
:root[data-theme="light"] { --cm-empty: #8c8c8c; }

/* Badge modifiers for the two extra statuses, written to the same recipe as
   .ds-badge--success/--warn/--error in components.css: a --status-fill-mix tint
   as a background-image layer, a --status-edge-mix border, colour on the text. */
.ds-badge--maintenance {
  color: var(--maintenance-color);
  --badge-bg: transparent;
  background-image:
    linear-gradient(color-mix(in srgb, var(--maintenance-color) var(--status-fill-mix), transparent),
                    color-mix(in srgb, var(--maintenance-color) var(--status-fill-mix), transparent));
  border-color: color-mix(in srgb, var(--maintenance-color) var(--status-edge-mix), transparent);
}
.ds-badge--unknown {
  color: var(--unknown-color);
  --badge-bg: transparent;
  background-image:
    linear-gradient(color-mix(in srgb, var(--unknown-color) var(--status-fill-mix), transparent),
                    color-mix(in srgb, var(--unknown-color) var(--status-fill-mix), transparent));
  border-color: color-mix(in srgb, var(--unknown-color) var(--status-edge-mix), transparent);
}

/* Alert body text on a status tint. The design system sets .ds-alert__body to
   --muted, which is calibrated against --surface, not against the raised tint the
   status variants paint: on the light error tint that lands at 4.46:1, just under
   4.5:1 (measured). The system already applies this same reasoning to links inside
   an alert (--link-on-tint); body copy simply did not get it. An alert body is the
   message itself, so it takes the primary text colour here. */
.ds-alert__body {
  color: var(--text);
}

/* One place maps a CozyMon status string onto a colour; badges, heartbeat
   segments and metric meters all read --cm-status from here. */
.cm-st-ok { --cm-status: var(--success-color); }
.cm-st-warn { --cm-status: var(--warn-color); }
.cm-st-fail { --cm-status: var(--error-color); }
.cm-st-maintenance { --cm-status: var(--maintenance-color); }
.cm-st-unknown { --cm-status: var(--unknown-color); }
.cm-st-none { --cm-status: var(--cm-empty); }

/* ── 3. Chart series ────────────────────────────────────────────────────────
   Six categorical slots for the time-series charts (10-01), assigned in this
   order and never cycled. Opal has no chart palette, so the slots are its own
   hues — cobalt, copper, turquoise, amethyst, citrine, crystal — with the status
   hues left out (emerald, amber, ruby/coral, uv mean ok/warn/fail/maintenance).
   The stock steps are pale on the coal surface (OKLCH L 0.73–0.86 against a
   0.48–0.67 band), so the dark theme takes deeper steps of the same hues, the
   oklch(from …) recipe used above. Checked with the dataviz validator
   (2026-10-15): lightness band, chroma, adjacent CVD ΔE ≥ 13.4 dark / 12.5
   light, normal-vision ΔE ≥ 19.6 / 18.5, all ≥ 3:1 on --surface.
   ────────────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --cm-series-1: var(--op-cobalt);
  --cm-series-2: oklch(from var(--op-copper) 0.64 c h);
  --cm-series-3: oklch(from var(--op-turquoise) 0.64 c h);
  --cm-series-4: var(--op-amethyst);
  --cm-series-5: oklch(from var(--op-citrine) 0.66 c h);
  --cm-series-6: oklch(from var(--op-crystal) 0.62 c h);
}
:root[data-theme="light"] {
  --cm-series-1: var(--op-cobalt);
  --cm-series-2: var(--op-copper);
  --cm-series-3: oklch(from var(--op-turquoise) 0.62 c h);
  --cm-series-4: var(--op-amethyst);
  --cm-series-5: var(--op-citrine);
  --cm-series-6: var(--op-crystal);
}
