/*
 * Design tokens — colour.
 *
 * Values are the exact hex table from
 * design_handoff_ilifu_software_catalog/README.md ("Design Tokens"). The
 * default block carries the `idia` theme — `theming.DEFAULT_THEME` — for a
 * missing or empty `data-theme`, so the page has sane colours before any
 * theme is set; it is constrained to exactly those cases (see the comment
 * on the block itself) so an explicitly-set theme wins regardless of where
 * its block sits in this file. `[data-theme="idia"]` repeats the same
 * values explicitly so switching *back* to idia from another theme is a
 * plain attribute-selector match rather than "falls through to the
 * default", which would silently break if a future theme were ever nested
 * inside another selector.
 *
 * `--code` (terminal/code surface), `--field` (input surface) and
 * `--on-accent` (text drawn on accent fills) are kept distinct on purpose —
 * collapsing them is what breaks contrast in `idia`, where the accent is a
 * mid-tone blue but inputs and code blocks are pure white.
 *
 * `--on-code` is the fourth member of that set and the only value below that
 * the handoff's token table does not list. It has to exist: `idia` sets
 * `--code` and `--fg` to the *same* colour (#00355e), so the catalog's load
 * line — light text on a dark navy block — renders literally invisible in
 * that theme if it draws its text with `--fg`, and no other shipped token is
 * light in all three themes (`--fg` is dark in `idia`; `--on-accent` is dark
 * in `dark` and `amber`). Each value below is the theme's own existing
 * high-contrast-on-`--code` colour, not a new hue: `--fg` for `dark` and
 * `amber`, `--on-accent`/`--panel` white for `idia`. See the handoff
 * README's own warning that collapsing surface and on-surface tokens "breaks
 * contrast in light themes" — this is exactly that failure.
 *
 * `--on-code-accent`, `--on-code-warn` and `--on-code-dim` are the same idea
 * one step further, and exist for exactly one surface: the admin screen's
 * watcher log, which the handoff specifies as a `--code` block carrying
 * *four* foregrounds ("rows of `timestamp` (`--dim`, `flex: none`) +
 * message; indexing lines in `--accent`, warnings in `--warn`"). In `dark`
 * and `amber` the plain tokens are already fine on `--code` (10.7:1, 9.9:1,
 * 5.5:1 and 9.3:1, 11.6:1, 4.8:1) and these are defined equal to them, so
 * nothing changes there. In `idia`, `--code` is the same navy as `--fg` and
 * the plain tokens measure 2.60:1, 2.14:1 and 2.90:1 against it — the log is
 * the one thing on the screen whose whole job is to be read, and none of it
 * passed WCAG AA. The `idia` values below are lighter tints of that theme's
 * own accent, warn and dim hues (5.92:1, 5.93:1, 5.96:1 on `--code`), not
 * new hues. The decorative `$` prompt in the catalog's load line stays plain
 * `--accent` — it is `aria-hidden` and carries no information, and the notes
 * at `.catalog-load__prompt` / `.detail-code__prompt` explain why.
 *
 * `idia`'s accent is deliberately #0079ad rather than the IDIA brand blue
 * #009ada: #009ada fails WCAG AA for text/icons on the white `--panel`/`--bg`
 * this theme uses. Do not "correct" it back to the brand value — see
 * design_handoff_ilifu_software_catalog/README.md, "Design Tokens".
 */

[data-theme='dark'] {
  --bg: #0c0f0e;
  --panel: #131716;
  --panel2: #191e1c;
  --line: #252c29;
  --line2: #323a36;
  --fg: #dfe6e2;
  --fg2: #aab5af;
  --dim: #7d8a83;
  --accent: #5fd39a;
  --accent2: #1d3b30;
  --warn: #dcb166;
  --err: #df7a62;
  --code: #080a09;
  --field: #080a09;
  --on-accent: #080a09;
  --on-code: #dfe6e2;
  --on-code-accent: #5fd39a;
  --on-code-warn: #dcb166;
  --on-code-dim: #7d8a83;
  --sel: #1c2b25;
}

/*
 * The default block anchors on `:root` *constrained to a missing or empty
 * `data-theme`* — never bare `:root`, which ties with every
 * `[data-theme=…]` block on specificity and beats any block written above
 * it in source order (that is how `dark` briefly rendered idia). The
 * constrained forms are (0,2,0), but they apply only when no theme is set,
 * so no explicit selection ever has to out-rank them. A test pins this.
 */
:root:not([data-theme]),
:root[data-theme=''],
[data-theme='idia'] {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel2: #eef2f5;
  --line: #dde3e8;
  --line2: #c2ccd4;
  --fg: #00355e;
  --fg2: #3c5063;
  --dim: #626f7d;
  --accent: #0079ad;
  --accent2: #dcf0f9;
  --warn: #8a5b0c;
  --err: #a3301c;
  --code: #00355e;
  --field: #ffffff;
  --on-accent: #ffffff;
  --on-code: #ffffff;
  --on-code-accent: #5cbde8;
  --on-code-warn: #e0a93a;
  --on-code-dim: #9db6c8;
  --sel: #e2f2fa;
}

[data-theme='amber'] {
  --bg: #100d08;
  --panel: #171309;
  --panel2: #1d180d;
  --line: #2c2413;
  --line2: #3d331c;
  --fg: #f0d9a7;
  --fg2: #c4ab7c;
  --dim: #917f5b;
  --accent: #e8a33d;
  --accent2: #3a2a10;
  --warn: #e8c23d;
  --err: #d9694a;
  --code: #0a0805;
  --field: #0a0805;
  --on-accent: #0a0805;
  --on-code: #f0d9a7;
  --on-code-accent: #e8a33d;
  --on-code-warn: #e8c23d;
  --on-code-dim: #8d7a55;
  --sel: #332510;
}

/*
 * The editor-palette themes below map each palette's published colours onto
 * the same twenty tokens; where a role has no published colour (surface
 * steps, `--accent2`, `--sel`) the value is a tint or shade of that
 * palette's own hues. Only colour values are used — no theme's code or
 * artwork is copied, so no licence text attaches — and every palette here
 * comes from an MIT-licensed theme (dracula, tokyo night, one dark pro,
 * github, synthwave '84, catppuccin, atom one light, ayu) except classic
 * monokai, the 2006 colour scheme. Three rules carried over from the
 * blocks above:
 *
 * - Light themes keep a *dark* `--code` surface, the way `idia` does — the
 *   catalogue's terminal identity — so their `--on-code*` values are bright
 *   editor-palette colours, not darkened ones. `ayu-light` borrows ayu
 *   dark's background for it.
 * - `--dim` and `--fg2` must clear WCAG AA (4.5:1) on all three surfaces
 *   (`--bg`, `--panel`, `--panel2`) — a parametrised test holds every theme
 *   to it. Editor palettes tune their comment colour for large code text,
 *   so most are tinted (dark themes) or shaded (light themes) from the
 *   published value; `idia`'s and `amber`'s originals sat just under the
 *   line too and moved the same way. Do not "correct" any of them back.
 * - Where a palette's accent/warn/err fails WCAG AA as text on that theme's
 *   light surfaces, it is darkened, exactly as `idia`'s #0079ad is:
 *   `atom-one-light` accent #3563c4 (brand #4078f2 is 3.9:1), warn #946700,
 *   err #c53929; `ayu-light` accent #a85400 (brand #ff9940 is ~2.1:1),
 *   warn #9c6a03, err #b32d2d. Do not "correct" these back.
 * - `dracula`'s `--on-code-dim` is #7986bd, a lightened tint of its comment
 *   colour #6272a4 (3.68:1 on `--code`) — the same move as `idia`'s
 *   on-code tints. `synthwave-84` is flat colour only: the glow that
 *   defines it in an editor is a shadow, and this design system has none.
 */

[data-theme='dracula'] {
  --bg: #21222c;
  --panel: #282a36;
  --panel2: #2f313f;
  --line: #3c3f51;
  --line2: #4d5066;
  --fg: #f8f8f2;
  --fg2: #c0c2d1;
  --dim: #8d99bd;
  --accent: #bd93f9;
  --accent2: #372f4d;
  --warn: #ffb86c;
  --err: #ff5555;
  --code: #191a21;
  --field: #191a21;
  --on-accent: #21222c;
  --on-code: #f8f8f2;
  --on-code-accent: #bd93f9;
  --on-code-warn: #ffb86c;
  --on-code-dim: #7986bd;
  --sel: #44475a;
}

[data-theme='tokyo-night'] {
  --bg: #16161e;
  --panel: #1a1b26;
  --panel2: #1f2335;
  --line: #292e42;
  --line2: #3b4261;
  --fg: #c0caf5;
  --fg2: #9aa5ce;
  --dim: #848aa9;
  --accent: #7aa2f7;
  --accent2: #283457;
  --warn: #e0af68;
  --err: #f7768e;
  --code: #0f0f14;
  --field: #0f0f14;
  --on-accent: #16161e;
  --on-code: #c0caf5;
  --on-code-accent: #7aa2f7;
  --on-code-warn: #e0af68;
  --on-code-dim: #737aa2;
  --sel: #2e3c64;
}

[data-theme='one-dark-pro'] {
  --bg: #21252b;
  --panel: #282c34;
  --panel2: #2f343e;
  --line: #3a3f4b;
  --line2: #4b5263;
  --fg: #abb2bf;
  --fg2: #a1a8b2;
  --dim: #989da5;
  --accent: #61afef;
  --accent2: #253b50;
  --warn: #e5c07b;
  --err: #e06c75;
  --code: #181c21;
  --field: #181c21;
  --on-accent: #21252b;
  --on-code: #abb2bf;
  --on-code-accent: #61afef;
  --on-code-warn: #e5c07b;
  --on-code-dim: #7f8897;
  --sel: #3e4451;
}

[data-theme='github-dark'] {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2128;
  --line: #21262d;
  --line2: #30363d;
  --fg: #e6edf3;
  --fg2: #b1bac4;
  --dim: #8b949e;
  --accent: #58a6ff;
  --accent2: #132f52;
  --warn: #d29922;
  --err: #f85149;
  --code: #010409;
  --field: #010409;
  --on-accent: #0d1117;
  --on-code: #e6edf3;
  --on-code-accent: #58a6ff;
  --on-code-warn: #d29922;
  --on-code-dim: #8b949e;
  --sel: #163356;
}

[data-theme='synthwave-84'] {
  --bg: #241b2f;
  --panel: #262335;
  --panel2: #2d2545;
  --line: #3b3266;
  --line2: #4e4379;
  --fg: #f4eee4;
  --fg2: #c7c1d6;
  --dim: #878ebf;
  --accent: #ff7edb;
  --accent2: #472a44;
  --warn: #fede5d;
  --err: #fe4450;
  --code: #1a1626;
  --field: #1a1626;
  --on-accent: #241b2f;
  --on-code: #f4eee4;
  --on-code-accent: #ff7edb;
  --on-code-warn: #fede5d;
  --on-code-dim: #848bbd;
  --sel: #34294f;
}

/*
 * Classic Monokai — the 2006 colour scheme, freely reused everywhere —
 * not the commercial "Monokai Pro" product, whose palette and name are
 * proprietary (monokai.pro/license). `--dim` and `--on-code-dim` are
 * lightened tints of the comment colour #75715e (2.9:1 on `--panel`),
 * the same move as `idia`'s on-code tints.
 */
[data-theme='monokai'] {
  --bg: #1e1f1a;
  --panel: #272822;
  --panel2: #31322b;
  --line: #3e3d32;
  --line2: #55564a;
  --fg: #f8f8f2;
  --fg2: #c8c8c2;
  --dim: #9c998c;
  --accent: #e6db74;
  --accent2: #413f25;
  --warn: #fd971f;
  --err: #f92672;
  --code: #1a1b16;
  --field: #1a1b16;
  --on-accent: #272822;
  --on-code: #f8f8f2;
  --on-code-accent: #e6db74;
  --on-code-warn: #fd971f;
  --on-code-dim: #868372;
  --sel: #49483e;
}

[data-theme='catppuccin'] {
  --bg: #11111b;
  --panel: #181825;
  --panel2: #1e1e2e;
  --line: #313244;
  --line2: #45475a;
  --fg: #cdd6f4;
  --fg2: #a6adc8;
  --dim: #838699;
  --accent: #cba6f7;
  --accent2: #363053;
  --warn: #f9e2af;
  --err: #f38ba8;
  --code: #08080e;
  --field: #08080e;
  --on-accent: #11111b;
  --on-code: #cdd6f4;
  --on-code-accent: #cba6f7;
  --on-code-warn: #f9e2af;
  --on-code-dim: #7f849c;
  --sel: #313244;
}

[data-theme='github-light'] {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel2: #eaeef2;
  --line: #d0d7de;
  --line2: #afb8c1;
  --fg: #24292f;
  --fg2: #57606a;
  --dim: #646c75;
  --accent: #0969da;
  --accent2: #ddf4ff;
  --warn: #9a6700;
  --err: #cf222e;
  --code: #24292f;
  --field: #ffffff;
  --on-accent: #ffffff;
  --on-code: #f6f8fa;
  --on-code-accent: #79c0ff;
  --on-code-warn: #e3b341;
  --on-code-dim: #a5aeb8;
  --sel: #b6e3ff;
}

[data-theme='atom-one-light'] {
  --bg: #f0f0f1;
  --panel: #fafafa;
  --panel2: #eaeaeb;
  --line: #dbdbdc;
  --line2: #c5c5c7;
  --fg: #383a42;
  --fg2: #565962;
  --dim: #69696d;
  --accent: #3563c4;
  --accent2: #e2eafd;
  --warn: #946700;
  --err: #c53929;
  --code: #383a42;
  --field: #ffffff;
  --on-accent: #ffffff;
  --on-code: #fafafa;
  --on-code-accent: #82aaff;
  --on-code-warn: #e5c07b;
  --on-code-dim: #abadb3;
  --sel: #dbe7fb;
}

[data-theme='ayu-light'] {
  --bg: #f8f9fa;
  --panel: #fcfcfc;
  --panel2: #f0f1f2;
  --line: #dfe3e8;
  --line2: #c3cbd3;
  --fg: #5c6166;
  --fg2: #62676d;
  --dim: #696e74;
  --accent: #a85400;
  --accent2: #ffeadd;
  --warn: #9c6a03;
  --err: #b32d2d;
  --code: #0f1419;
  --field: #fcfcfc;
  --on-accent: #ffffff;
  --on-code: #f8f9fa;
  --on-code-accent: #ffaa33;
  --on-code-warn: #e6b450;
  --on-code-dim: #8a9199;
  --sel: #d6e6f7;
}
