/*
 * Token layer 2 — the dark theme.
 *
 * The matched set to theme_light.css: the same roles in the same order, taking
 * the ramp steps that read on a dark ground. The status families are re-derived
 * rather than reused — a light theme's tint is a near-white fill, which on this
 * surface is a block of glare, so each family's background and border come from
 * the deep end of its hue instead.
 *
 * This sheet is linked on every page, after theme_light.css, and wins only where
 * the document carries data-theme="dark". The head script resolves the reader's
 * preference to that attribute before first paint, so the theme is decided by one
 * attribute rather than by which stylesheet the server chose. Light stays on bare
 * :root, which is what a browser that never ran the script still gets.
 */

:root[data-theme="dark"] {
    /* --- Browser chrome --------------------------------------------------- */
    /* Scrollbars, form widgets and the unstyled controls the back office is
       built from are drawn by the browser, not from these roles. This is what
       makes it draw them dark. */

    color-scheme: dark;

    /* --- Surfaces and lines ---------------------------------------------- */

    --color-surface: var(--bl-gray-950);
    --color-surface-sunken: var(--bl-gray-900);
    --color-border: var(--bl-gray-850);
    --color-border-strong: var(--bl-gray-800);

    /* --- Text -------------------------------------------------------------*/

    --color-text-primary: var(--bl-gray-50);
    --color-text-secondary: var(--bl-gray-400);
    --color-text-muted: var(--bl-gray-600);
    --color-link: var(--bl-blue-300);

    /* --- Accent and focus -------------------------------------------------*/
    /* The accent inverts with the ground: a primary action is the far end of
       the neutral ramp from the surface it sits on, either way round. */

    --color-accent: var(--bl-gray-50);
    --color-on-accent: var(--bl-gray-1000);
    --color-focus: var(--bl-blue-300);

    /* --- Overlays ---------------------------------------------------------*/
    /* A dark ground needs a heavier scrim and a deeper shadow to read as a
       layer above the page rather than a patch of it. */

    --color-scrim: color-mix(in srgb, var(--bl-gray-1000) 65%, transparent);
    --shadow-overlay: 0 8px 24px color-mix(in srgb, var(--bl-gray-1000) 60%, transparent);

    /* --- Status families --------------------------------------------------*/

    --color-critical-fg: var(--bl-red-300);
    --color-critical-bg: var(--bl-red-950);
    --color-critical-border: var(--bl-red-800);

    --color-warn-fg: var(--bl-amber-300);
    --color-warn-bg: var(--bl-amber-950);
    --color-warn-border: var(--bl-amber-800);

    --color-ok-fg: var(--bl-green-300);
    --color-ok-bg: var(--bl-green-950);
    --color-ok-border: var(--bl-green-800);

    --color-info-fg: var(--bl-blue-300);
    --color-info-bg: var(--bl-blue-950);
    --color-info-border: var(--bl-blue-800);

    --color-neutral-fg: var(--bl-gray-400);
    --color-neutral-bg: var(--bl-gray-900);
    --color-neutral-border: var(--bl-gray-800);

    /* --- Chart series ramp ------------------------------------------------*/
    /* The same eight hues one step lighter: a series colour needs contrast
       against --color-surface, and the -500 steps vibrate on a dark ground. */

    --chart-1: var(--bl-blue-300);
    --chart-2: var(--bl-green-300);
    --chart-3: var(--bl-amber-300);
    --chart-4: var(--bl-red-300);
    --chart-5: var(--bl-violet-300);
    --chart-6: var(--bl-teal-300);
    --chart-7: var(--bl-pink-300);
    --chart-8: var(--bl-slate-300);

    /* --- Chart ramps -----------------------------------------------------*/
    /* The light theme's ramps turned over: on a dark ground the lightest step
       stands out most, so the largest value takes it. */

    --chart-channels-1: var(--bl-ramp-blue-6);
    --chart-channels-2: var(--bl-ramp-blue-5);
    --chart-channels-3: var(--bl-ramp-blue-4);
    --chart-channels-4: var(--bl-ramp-blue-3);
    --chart-channels-5: var(--bl-ramp-blue-2);
    --chart-channels-6: var(--bl-ramp-blue-1);

    --chart-classification-1: var(--bl-ramp-teal-6);
    --chart-classification-2: var(--bl-ramp-teal-5);
    --chart-classification-3: var(--bl-ramp-teal-4);
    --chart-classification-4: var(--bl-ramp-teal-3);
    --chart-classification-5: var(--bl-ramp-teal-2);
    --chart-classification-6: var(--bl-ramp-teal-1);

    --chart-flow-1: var(--bl-ramp-ink-6);
    --chart-flow-2: var(--bl-ramp-ink-5);
    --chart-flow-3: var(--bl-ramp-ink-4);
    --chart-flow-4: var(--bl-ramp-ink-3);
    --chart-flow-5: var(--bl-ramp-ink-2);
    --chart-flow-6: var(--bl-ramp-ink-1);

    /* A missing value (Unclassified, Unknown), and what a series fades to
       while another is hovered. */
    --chart-gap: var(--bl-gray-600);
    --chart-muted: var(--bl-gray-800);

    /* --- Avatar tones -----------------------------------------------------*/
    /* The same eight hues turned over: a deep ground under a light ink, so a
       tone keeps its hue without glaring off --color-surface. */

    --color-avatar-1-bg: var(--bl-red-950);
    --color-avatar-1-fg: var(--bl-red-300);
    --color-avatar-2-bg: var(--bl-amber-950);
    --color-avatar-2-fg: var(--bl-amber-300);
    --color-avatar-3-bg: var(--bl-green-950);
    --color-avatar-3-fg: var(--bl-green-300);
    --color-avatar-4-bg: var(--bl-blue-950);
    --color-avatar-4-fg: var(--bl-blue-300);
    --color-avatar-5-bg: var(--bl-gray-800);
    --color-avatar-5-fg: var(--bl-gray-200);
    --color-avatar-6-bg: color-mix(in srgb, var(--bl-violet-500) 25%, var(--bl-gray-950));
    --color-avatar-6-fg: var(--bl-violet-300);
    --color-avatar-7-bg: color-mix(in srgb, var(--bl-pink-500) 25%, var(--bl-gray-950));
    --color-avatar-7-fg: var(--bl-pink-300);
    --color-avatar-8-bg: color-mix(in srgb, var(--bl-teal-500) 25%, var(--bl-gray-950));
    --color-avatar-8-fg: var(--bl-teal-300);
}
