/*
 * Theme tokens — UI surface variables that change between dark and light.
 *
 * These are NOT brand colors directly (those come from BrandingExtension and
 * vary per sponsor). These are surface/text/border tokens — but they are
 * tinted toward `var(--color-primary)` so that every neutral picks up the
 * sponsor's brand hue per DESIGN.md's Tinted-Neutral Rule. With a green-brand
 * sponsor the frame reads green-black; with an orange-brand sponsor it reads
 * warm-black; etc. Chroma stays low so the brand tint is felt, not declared.
 *
 * Default block = dark theme. [data-theme="light"] = light theme override.
 */

:root {
    color-scheme: dark;
    --frame: color-mix(in srgb, var(--color-primary) 5%, #070707);
    --frame-2: color-mix(in srgb, var(--color-primary) 11%, #0c0c0c);
    /* Page canvas. Deliberately its own token instead of reusing --frame: the
       authenticated background wants a stronger brand tint than the 26 other
       places --frame feeds (select options, modal backdrops, dropdown panels,
       table total rows, the public login/landing background). Raising --frame
       itself would move all of them at once. */
    --canvas: color-mix(in srgb, var(--color-primary) 10%, #070707);
    --surface: rgba(255, 255, 255, 0.075);
    --surface-strong: rgba(255, 255, 255, 0.12);
    --text: #f8fbff;
    --text-soft: #c7d4df;
    --muted: #8494a8;
    --line: rgba(255, 255, 255, 0.14);
    --line-strong: rgba(255, 255, 255, 0.22);
    --shadow: 0 42px 110px color-mix(in srgb, var(--color-primary) 10%, rgba(6, 6, 6, 0.44));
    --cta-text: #ffffff;
    --focus: color-mix(in srgb, var(--color-primary) 60%, transparent);
    --field: rgba(255, 255, 255, 0.075);

    /* Semantic non-brand tokens. These DO NOT vary per sponsor; they are
       fixed across the whole system so destructive/safe/warning signals
       stay legible regardless of how the sponsor configured branding. */
    --color-danger: #FF6B6B;
    --color-success: #4ECCA3;
    --color-warning: #F5B544;
    /* Blue, not the violet #845EC2 it used to be. Every design system that
       documents semantic palettes puts information on blue or cyan and reserves
       violet for decorative accents, so a violet notice read as "featured"
       rather than "neutral fact". Radix lists blue/indigo/sky/cyan for info —
       sky and cyan are out here because --color-secondary is itself a cyan
       (#1FB6C1) and carries the link color, and indigo sits only dE 14 from the
       old violet, which would not have fixed anything. This blue is dE 43 from
       the link cyan, well clear of confusion. */
    --color-info: #5681BD;

    /* Solid-fill sibling of --color-success, for surfaces that carry white text
       (the primary form action button). It cannot be folded into
       --color-success: that one is a *tint* token, spent as `color: ...` on
       backgrounds mixed at 8-18%, and the ~20 rules doing so need it bright to
       stay legible on the dark frame. As a fill it fails AA — white on #4ECCA3
       is 2.00:1, and the button label is small text (13px/850 via .btn-base,
       14px/500 via the Twig Button component), so the bar is 4.5:1. Same hue
       family (~160deg), luminance dropped until white clears AA: 5.20:1 here. */
    --color-success-strong: #0F7C56;

    /* Same story for danger and warning: as fills under white text both tint tokens
       fail AA — #FF6B6B is 2.78:1 and #F5B544 is 1.81:1, against a 4.5:1 bar (button
       text is 13px/850). Hue preserved (0deg red, ~38deg amber), luminance dropped
       until white clears AA at BOTH ends of the button gradient, since the second
       stop mixes 86-88% of the token with --frame. Ratios: #CE4343 is 4.66:1 and its
       gradient end 5.86:1; #9C6A10 is 4.68:1 and its end 5.69:1.

       Info needs one too, and the reason is worth spelling out because it is not a
       judgement call: in the dark theme the two roles are mathematically exclusive.
       Reading as TEXT on the dark canvas requires luminance >= 0.2065; carrying
       WHITE text as a fill requires <= 0.1833. The window is empty, so no single
       value can do both — the earlier note claiming info needed no strong sibling
       was only checking the fill side. Ratios: #336AB8 is 5.39:1 and its gradient
       end 6.47:1. */
    --color-danger-strong: #CE4343;
    --color-warning-strong: #9C6A10;
    --color-info-strong: #336AB8;
}

[data-theme="light"] {
    color-scheme: light;
    --frame: color-mix(in srgb, var(--color-primary) 3%, #fdfcfa);
    --frame-2: color-mix(in srgb, var(--color-primary) 8%, #f1efeb);
    --canvas: color-mix(in srgb, var(--color-primary) 10%, #fdfcfa);
    --surface: color-mix(in srgb, var(--color-primary) 7%, transparent);
    --surface-strong: color-mix(in srgb, var(--color-primary) 12%, transparent);
    --text: #101722;
    --text-soft: #405168;
    --muted: #6e7b8e;
    --line: color-mix(in srgb, var(--color-primary) 18%, transparent);
    --line-strong: color-mix(in srgb, var(--color-primary) 28%, transparent);
    --shadow: 0 34px 90px color-mix(in srgb, var(--color-primary) 18%, transparent);
    --cta-text: #ffffff;
    --focus: color-mix(in srgb, var(--color-primary) 60%, transparent);
    --field: rgba(255, 255, 255, 0.74);

    /* Light mode variants for semantic tokens. The hue stays the same;
       saturation drops slightly so they read on cream paper. */
    --color-danger: #E64545;
    --color-success: #2A9D78;
    --color-warning: #C68A1E;
    --color-info: #3064AC;

    /* Deeper still on cream paper, where the fill sits against a light frame
       and can afford the weight. White clears AA at 6.53:1. */
    --color-success-strong: #0C6B4A;

    /* Light theme needs these darker than their dark-theme siblings: here the
       gradient's second stop mixes with the near-white --frame, which LIGHTENS it,
       so the worst case is that end rather than the pure token. Ratios: #C12C2C is
       5.73:1 and its gradient end 4.63:1; #895904 is 6.01:1 and its end 4.64:1.
       Info is 7.86:1 and its end 5.86:1. Here a single value could have served both
       roles (the tint already clears 5.19:1 as text on the light canvas), but it gets
       a strong sibling anyway so the five semantic families stay structurally
       identical and no rule has to special-case info. */
    --color-danger-strong: #C12C2C;
    --color-warning-strong: #895904;
    --color-info-strong: #27528C;
}
