/* Battery Core — module theme bridge and shared page chrome.
 *
 * The interactive modules were each authored as a standalone page with its own
 * generic light/dark token set (--background, --primary, --card, --border,
 * --viz-series-N, …). Their defaults follow the operating system's light or
 * dark mode, which would make a module look different from the course shell
 * in `site.css` around it.
 *
 * This file re-declares that same generic contract in Battery Core colours, so
 * a module adopts the course palette without any change to its own layout or
 * markup. Link it AFTER the module's own stylesheet or <style> block:
 *
 *     <link rel="stylesheet" href="styles.css">
 *     <link rel="stylesheet" href="../../assets/module-theme.css">
 *
 * Same specificity, later wins. The module keeps its structure; only the
 * colours move. Colour roles are documented in `assets/README.md`.
 *
 * This file is only for pages written against the generic contract. A page
 * with its own vocabulary — the workbench reads --muted as a text colour,
 * not a surface — must not link it. The shared header and footer live in
 * `site-chrome.css` so such a page can still have them.
 */

:root {
  color-scheme: light;

  /* Course palette — the source of truth, identical to site.css. */
  --bc-background: #ffffff;
  --bc-surface: #ffffff;
  --bc-surface-raised: #f8f9fb;
  --bc-text: #202938;
  --bc-muted: #596579;
  --bc-line: #dce1e8;
  --bc-accent: #2459a8;
  --bc-accent-strong: #1c4786;
  --bc-blue: #5b6b8a;
  --bc-orange: #9a5b13;

  /* Generic contract, restated in course colours. Names and meanings are the
     modules' own; only the values change. */
  --background: var(--bc-background);
  --foreground: var(--bc-text);
  --card: #ffffff;
  --card-foreground: var(--bc-text);
  --popover: var(--bc-surface);
  --popover-foreground: var(--bc-text);
  --primary: var(--bc-accent);
  --primary-foreground: #ffffff;
  --secondary: #ffffff;
  --secondary-foreground: var(--bc-text);
  --muted: #ffffff;
  --muted-foreground: var(--bc-muted);
  /* Generic --accent is a tinted surface, not the course blue; --bc-accent is
     the blue. Keeping the distinction stops soft washes turning saturated. */
  --accent: #eef4ff;
  --accent-foreground: var(--bc-accent-strong);
  --destructive: #c2410c;
  --red: #c0392b;
  --green: var(--bc-accent);  /* "in window" / OK states: blue, not green */
  --border: var(--bc-line);
  --input: #ffffff;
  --ring: var(--bc-accent);

  /* One categorical series, ordered by how often a module needs a colour.
     Each is legible on white and distinguishable from its neighbours. */
  --viz-series-1: var(--bc-accent);
  --viz-series-2: #c8693f;
  --viz-series-3: var(--bc-blue);
  --viz-series-4: #a16207;
  --viz-series-5: #6d28d9;
  --viz-series-6: #64748b;

  /* Every background is white: status washes and simulator surfaces too.
     State is carried by the coloured text and border, not by a tint. */
  --green-bg: #ffffff;
  --warning-bg: #ffffff;
  --destructive-bg: #ffffff;
  /* One colour per material across the course: the oxide positive electrode
     is terracotta everywhere (workbench, architecture, simulators, aging). */
  --cathode: #c8693f;

  --font-sans: Arial, Helvetica, sans-serif;

  /* Legacy aliases some modules still read. */
  --viz-bg: var(--background);
  --viz-panel: var(--card);
  --viz-border: var(--border);
  --viz-text: var(--foreground);
  --viz-muted: var(--muted-foreground);
  --viz-accent: var(--primary);
  --viz-accent-text: var(--primary-foreground);
  --viz-accent-bg: var(--accent);
  --viz-warning: var(--destructive);
  --color-background-primary: var(--background);
  --color-text-primary: var(--foreground);
  --color-border-secondary: var(--border);
}

/* Some modules opt into a host background by marking the root. On the course
   site there is no host, so the page paints its own ground. */
:root,
:root[data-visualize-standalone],
:root[data-theme="light"],
:root[data-theme="dark"] {
  color-scheme: light;
  background-color: var(--bc-background);
}
