/* ==============================================================
   ENTRANCE dark theme. scripts/theme.js sets data-theme on <html>
   before the page paints: the reader's choice on this device, or
   the system setting. Nothing here applies to the light theme.

   Two parts: the shared tokens and the night surfaces, written by
   hand; then, generated, one token per literal colour the other
   stylesheets carry (see scripts/buildDarkTheme.cjs).
   ============================================================== */

:root[data-theme="dark"] {
  color-scheme: dark;
  /* paper, text and rules */
  --paper: #161615;
  --ivory: #161615;
  --surface: #222221;
  --soft: #222221;
  --ink: #ecebe7;
  --muted: #9c9c99;
  --line: #343432;
  --orange-dark: #f47427;
  --green: #09a693;
  --blue: #6182f7;
  --tc-unknown: #5a5a57;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-raised: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* The night surfaces (header, heroes, footer) go one step deeper so the
   paper sheets that pass over them still read as sheets. */
:root[data-theme="dark"] body:not(.hx-home) { --sg-night: #0a0a09; --sg-night-2: #121211; }
:root[data-theme="dark"] .hx-home { --hx-night: #0a0a09; --hx-night-2: #121211; --hx-night-3: #1a1a18; }
html[data-theme="dark"]:has(> body:not(.hx-home)) { background: #0a0a09; }
:root[data-theme="dark"] body:not(.hx-home) .site-header,
:root[data-theme="dark"] body:not(.hx-home) .site-footer { background: var(--sg-night); }

/* The circuit drawings are images coloured for paper (a dark road, dark
   labels on a pale halo). On the dark ground they are turned over: the road
   and labels go light, the halo dark, and the hues come back round. */
:root[data-theme="dark"] .rw-circuit-map .rw-circuit-guide { filter: invert(0.92) hue-rotate(180deg); }

/* Single fixes. :where() keeps each at its original rule's weight, so the
   hover and state rules written after it still win as they do in light. */
:root[data-theme="dark"] .hx-home .hx-skip { color: #141414; }
/* segmented controls: the chosen segment rises above its trough */
:root[data-theme="dark"] .theme-choices input:checked + span,
:root[data-theme="dark"] .auth-modes button[aria-selected="true"] { background: #3a3a37; box-shadow: none; }
/* panels that are dark by design in the light theme keep their light-theme tokens */
:root[data-theme="dark"] .stats-circuit-layout { --ink: #1a1a1a; --stats-ink: #1a1a1a; --paper: #fcfcfc; --stats-paper: #fcfcfc; --dk-inv-ffffff: #ffffff; }
:where(:root[data-theme="dark"]) .stats-circuit-card { background: rgba(255, 255, 255, 0.03); }

/* ---- generated by scripts/buildDarkTheme.cjs; edit the script, not below ---- */
/* 134 tokens from literal colours in the stylesheets */
:root[data-theme="dark"] {
  --dk-abg-20-20-20-120: rgba(255, 255, 255, 0.16);
  --dk-abg-20-20-20-180: rgba(255, 255, 255, 0.16);
  --dk-abg-20-20-20-25: rgba(255, 255, 255, 0.035);
  --dk-abg-20-20-20-30: rgba(255, 255, 255, 0.042);
  --dk-abg-20-20-20-45: rgba(255, 255, 255, 0.063);
  --dk-abg-20-20-20-60: rgba(255, 255, 255, 0.084);
  --dk-abg-20-20-20-80: rgba(255, 255, 255, 0.112);
  --dk-abg-26-26-26-60: rgba(255, 255, 255, 0.084);
  --dk-aln-0-0-0-200: rgba(255, 255, 255, 0.22);
  --dk-aln-136-136-136-267: rgba(255, 255, 255, 0.22);
  --dk-aln-26-26-26-90: rgba(255, 255, 255, 0.126);
  --dk-bg-252-252-252-940: rgba(22, 22, 21, 0.94);
  --dk-bg-252-252-252-950: rgba(22, 22, 21, 0.95);
  --dk-bg-252-252-252-960: rgba(22, 22, 21, 0.96);
  --dk-bg-255-244-232-500: rgba(51, 39, 26, 0.5);
  --dk-bg-255-255-255-550: rgba(30, 30, 29, 0.55);
  --dk-bg-c7c7c7: #333331;
  --dk-bg-dadada: #333331;
  --dk-bg-e3e3e3: #2a2a28;
  --dk-bg-e3f4e9: #1c3023;
  --dk-bg-e4e4df: #2a2a28;
  --dk-bg-e5e5e5: #2a2a28;
  --dk-bg-e7e7e7: #2a2a28;
  --dk-bg-e8e8e5: #2a2a28;
  --dk-bg-e8e8e8: #2a2a28;
  --dk-bg-e9e9e6: #2a2a28;
  --dk-bg-e9e9e9: #2a2a28;
  --dk-bg-ebebeb: #2a2a28;
  --dk-bg-ececec: #2a2a28;
  --dk-bg-eceee8: #2a2a28;
  --dk-bg-eeeee9: #222221;
  --dk-bg-eeeeee: #222221;
  --dk-bg-efefec: #222221;
  --dk-bg-efefef: #222221;
  --dk-bg-f0f0f0: #222221;
  --dk-bg-f1f1ed: #222221;
  --dk-bg-f1f1ee: #222221;
  --dk-bg-f1f1f1: #222221;
  --dk-bg-f2f2f2: #222221;
  --dk-bg-f3f3f1: #222221;
  --dk-bg-f3f3f3: #222221;
  --dk-bg-f4f4f4: #222221;
  --dk-bg-f5e9dc: #33271a;
  --dk-bg-f5f5f2: #222221;
  --dk-bg-f5f5f5: #222221;
  --dk-bg-f6f6f6: #222221;
  --dk-bg-f7f7f5: #222221;
  --dk-bg-f8f8f6: #161615;
  --dk-bg-f9f9f8: #161615;
  --dk-bg-fafafa: #161615;
  --dk-bg-fbf0d3: #332c1a;
  --dk-bg-fce8e6: #331c1a;
  --dk-bg-fcfcfc: #161615;
  --dk-bg-ffd4a1: #33271a;
  --dk-bg-ffe697: #332d1a;
  --dk-bg-ffe8d8: #33241a;
  --dk-bg-fff0d6: #332a1a;
  --dk-bg-fff0e3: #33251a;
  --dk-bg-fff2e5: #33261a;
  --dk-bg-fff2e8: #33251a;
  --dk-bg-fff3e8: #33261a;
  --dk-bg-fff4e8: #33271a;
  --dk-bg-fff6ed: #33261a;
  --dk-bg-fff7ef: #33261a;
  --dk-bg-fff9eb: #332b1a;
  --dk-bg-fffaf5: #161615;
  --dk-bg-ffffff: #1e1e1d;
  --dk-fg-111111: #e8e8e8;
  --dk-fg-141414: #e8e8e8;
  --dk-fg-16-16-16-450: #e8e8e8;
  --dk-fg-161616: #e8e8e8;
  --dk-fg-171717: #e8e8e8;
  --dk-fg-1a1a1a: #e8e8e8;
  --dk-fg-1c1b18: #e8e8e8;
  --dk-fg-1e6b3f: #31ae66;
  --dk-fg-1f1f1f: #e8e8e8;
  --dk-fg-1f6a3c: #33af63;
  --dk-fg-202222: #e8e8e8;
  --dk-fg-222222: #e8e8e8;
  --dk-fg-333333: #d5d5d5;
  --dk-fg-42230a: #f7ddc7;
  --dk-fg-444444: #bcbcbc;
  --dk-fg-533300: #f7c26d;
  --dk-fg-555555: #a5a5a5;
  --dk-fg-5a5a5a: #9e9e9e;
  --dk-fg-5c5c5a: #9c9c9c;
  --dk-fg-5f5f5f: #989898;
  --dk-fg-606060: #979797;
  --dk-fg-616161: #959595;
  --dk-fg-626262: #949494;
  --dk-fg-666666: #8f8f8f;
  --dk-fg-707070: #848484;
  --dk-fg-7a5a00: #c0900a;
  --dk-fg-8a2e1d: #e79c8e;
  --dk-fg-8c3a0b: #f28d54;
  --dk-fg-9b3000: #f68653;
  --dk-fg-a22222: #e78c8c;
  --dk-fg-a22e20: #e5877b;
  --dk-fg-a3341a: #e7826a;
  --dk-fg-a33d00: #f47427;
  --dk-fg-a52222: #e78989;
  --dk-fg-b3261e: #e87973;
  --dk-fg-b94a48: #c66c6a;
  --dk-fg-c40500: #f76763;
  --dk-fg-e10600: #f53e38;
  --dk-inv-f3f2ee: var(--paper);
  --dk-inv-ffffff: var(--paper);
  --dk-ln-247-244-237-300: rgba(44, 44, 42, 0.3);
  --dk-ln-247-244-237-550: rgba(44, 44, 42, 0.55);
  --dk-ln-255-255-255-350: rgba(44, 44, 42, 0.35);
  --dk-ln-255-255-255-400: rgba(44, 44, 42, 0.4);
  --dk-ln-255-255-255-500: rgba(44, 44, 42, 0.5);
  --dk-ln-c7c7c7: #42423f;
  --dk-ln-c9c9c4: #42423f;
  --dk-ln-c9c9c5: #42423f;
  --dk-ln-cccccc: #42423f;
  --dk-ln-cfcfcb: #42423f;
  --dk-ln-d3d3d3: #42423f;
  --dk-ln-d6d6d2: #42423f;
  --dk-ln-d8d8d8: #42423f;
  --dk-ln-dadada: #343432;
  --dk-ln-dddddd: #343432;
  --dk-ln-dededa: #343432;
  --dk-ln-e2e2de: #343432;
  --dk-ln-e2e2df: #343432;
  --dk-ln-e4e4e4: #343432;
  --dk-ln-e6e6e6: #343432;
  --dk-ln-ececea: #343432;
  --dk-ln-ededed: #343432;
  --dk-ln-eeeeee: #2c2c2a;
  --dk-ln-f7f4ed: #2c2c2a;
  --dk-ln-ffffff: #2c2c2a;
  --dk-on-accent: #141414;
  --dk-on-paper: #f3f2ee;
}
