/* The design tokens: one definition of each. Every stylesheet reads its
 * colours, weights and sizes from here, with exceptions: styles.css still
 * writes a few colours of its own (some 20 hex values, most in dark-mode
 * rules), which test_stylesheet_tokens holds to no repeated neutral and no
 * redeclared token (AUT-387: this said "the only place", which it was not).
 *
 * They used to be declared in FOUR blocks - two :root blocks in styles.css
 * (the second quietly overriding the first), one in refactored.css, and a
 * dark-mode block in each file. refactored.css loads last, so ITS values were
 * the ones the browser used and the others were dead text that read as if
 * they applied. Since AUT-246 the older names below are aliases of the design
 * system's, so changing a value here changes every page.
 *
 * Loaded before the stylesheets, which hold rules and read these and define
 * none of their own. `theme_init.js` sets data-theme on <html>; dark mode is
 * the same names with different values, so a rule is written once. The
 * email body is the stated exception: mail clients need literal colours.
 */
:root {

    /* The design system (AUT-246; the approved proposal of 2026-10-08).
     * Colour says what to do, never where a value came from: the four
     * states below are the only colours with a meaning, and the brand's
     * own colours stay on the documents. The older names further down
     * read these, so a page written before the design system takes it up
     * without being edited. */
    --ink-900: #121a24;      /* text */
    --ink-700: #2d3a48;      /* secondary text */
    --ink-500: #5b6673;      /* labels, 5.8 : 1 on white */
    --ink-300: #9aa4af;      /* placeholders, disabled */
    --line: #e3e7ec;
    --line-soft: #eef1f4;    /* a hairline between rows: there, not noticed */
    --line-strong: #c9d0d8;  /* the edge of a control */
    /* The chevron of a drop-down, drawn as a mask so its colour is a token (AUT-489). */
    --chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --hover: #eef1f5;
    /* The one accent (AUT-444): a deep green, for the primary action of a
     * view, the current place in the navigation and a selected row. Nothing
     * else on a page is coloured except the four states below. It is a
     * ground (a button) and stays dark in both themes. The --navy names are
     * what the stylesheets and pages written before the redesign still say;
     * they read the accent, so one value here changes every page. */
    --accent: #1e5a46;
    --accent-700: #164535;
    --accent-100: #e4efe9;
    --on-accent-ground: #ffffff;
    --navy: var(--accent);
    --navy-700: var(--accent-700);
    --navy-100: var(--accent-100);
    --on-navy: var(--on-accent-ground);
    /* The accent written AS TEXT: a chip's words on --accent-100, a ticker,
     * a key figure. Not --accent itself, which is a ground and stays dark in
     * both themes: as text on the dark theme's surfaces it read 1.4 : 1
     * (AUT-427). */
    --navy-text: var(--accent);
    --link: #1e5a46;
    --focus: #6fae96;
    --info: #3a4a5c;
    --info-bg: #eef1f5;
    --info-line: #b6c1cd;
    /* The environment marker: amber, the same in both themes, so a test
     * server never passes for production. */
    --env-bg: #f2b552;
    --env-fg: #2b1d00;

    /* Type: 11 eyebrow, 12 label, 13 table, 14 body, 16 section, 24 page,
     * 28 key figure (20 is a figure inside a table or a header). Tabular figures wherever numbers line up. */
    --t-11: 11px;
    --t-12: 12px;
    --t-13: 13px;
    --t-14: 14px;
    --t-16: 16px;
    --t-20: 20px;
    --t-24: 24px;
    --t-28: 28px;

    /* Space: a 4-point scale. Radius: 6 for controls, 10 for cards. */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;
    --s-7: 48px;
    --s-8: 64px;
    /* Between two groups on a page: space, not a rule. */
    --section-gap: var(--s-6);
    --r-1: 6px;
    --r-2: 10px;
    --r-pill: 999px;
    /* Only what floats has a shadow: menus, dialogs, toasts. */
    --shadow-overlay: 0 8px 28px rgba(18, 26, 36, .14);

    /* Type */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-body: 'Inter', -apple-system, system-ui, sans-serif;

    /* One name per weight: a second set, --weight-*, said the same (AUT-387). */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.125rem;
    --text-2xl: 1.5rem;

    /* Surfaces and text */
    --bg-body: var(--bg);
    --bg-surface: var(--surface);
    --bg-surface-secondary: var(--surface-2);
    --bg-hover: var(--hover);
    --text-primary: var(--ink-900);
    --text-secondary: var(--ink-500);
    --text-muted: var(--ink-300);
    --border-color: var(--line);
    --input-bg: var(--surface);
    --input-border: var(--line-strong);

    /* Brand */
    --primary-navy: var(--navy);
    --primary-color: var(--navy);
    --primary-hover: var(--navy-700);
    --accent-slate: var(--navy);
    --accent-color: var(--link);

    /* States. Bootstrap's palette, named once so a template does not have to
     * remember the hex. */
    --success-forest: #2e7d32;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --on-warning: #212529;
    /* Text printed ON a filled accent - a select2 chip, a primary button.
     * White in BOTH themes: the ground it sits on is the accent, not the page,
     * so it must not follow the surface the way --text-primary does. */
    --on-accent: #ffffff;

    /* Review states (AUT-244). Colour says what a person has to do, and
     * only that: check (amber), missing (red), confirmed (green). Where a
     * value came from is a label, never a colour. Text colours are AA on
     * their own grounds. */
    --state-check: #8a5200;
    --state-check-bg: #fff3dc;
    --state-check-line: #e3a23b;
    --state-missing: #a3241a;
    --state-missing-bg: #fdecea;
    --state-missing-line: #d5574a;
    --state-ok: #22682c;
    --state-ok-bg: #e5f2e7;
    --state-ok-line: #4b9a57;
    /* Field labels: 5.8 : 1 on white, where --text-muted is 2.1 : 1. */
    --text-label: var(--ink-500);

    /* Elevation */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    /* Shape and rhythm. New names, so nothing reads them yet - they exist so
     * the next radius or gap has somewhere to go other than a rule. */
    --radius-sm: 0.25rem;
    --radius: var(--r-1);
    --radius-lg: var(--r-2);
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 3rem;

    /* The KID (AUT-209). The PDF KID's own palette (kid_template_1), the
       same in both themes: a KID is a comparison document and is read on
       paper, so it does not take the brand or the dark theme. */
    --kid-paper: #ffffff;
    --kid-ink: #2B2F36;
    --kid-muted: #7A7F87;
    --kid-bar: #4C5666;
    --kid-head: #E4E6E9;
    --kid-band: #F0F1F3;
    --kid-alt: #F7F8F9;
    --kid-rule: #C9CDD3;
    --kid-highlight: #F0A22E;
    --kid-down: #D2691E;
    --kid-up: #5B9B3E;
    --kid-aside: #FAFBFC;

  /* The open film page (AUT-476): dark whatever the visitor's theme, like a cinema. */
  --film-bg: #0e1116;
  --film-ink: #e8ebee;
  --film-muted: #9aa3ab;
}

/* Bootstrap 5 reads its own --bs-* variables for body, links, borders, the
 * modal, the dropdown and the table. They are set here, from the tokens above,
 * so a Bootstrap component takes the design system without a rule per page.
 * The selector list matches Bootstrap's own (`:root` and `[data-bs-theme]`) so
 * this wins by coming later; the dark theme needs no copy, because the tokens
 * it reads change. The -rgb triples are what Bootstrap's utilities
 * (.bg-primary, .text-bg-*) fade with; they repeat the hex of the token. */
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
    --bs-body-font-family: var(--font-family);
    --bs-body-font-size: var(--t-14);
    --bs-body-line-height: 1.5;
    --bs-body-color: var(--ink-900);
    --bs-body-bg: var(--bg);
    --bs-emphasis-color: var(--ink-900);
    --bs-secondary-color: var(--ink-500);
    --bs-tertiary-color: var(--ink-300);
    --bs-secondary-bg: var(--surface-2);
    --bs-tertiary-bg: var(--surface-2);
    --bs-border-color: var(--line);
    --bs-border-color-translucent: var(--line);
    --bs-border-radius: var(--r-1);
    --bs-border-radius-sm: var(--r-1);
    --bs-border-radius-lg: var(--r-2);
    --bs-border-radius-pill: var(--r-pill);
    --bs-link-color: var(--link);
    --bs-link-hover-color: var(--accent-700);
    --bs-link-color-rgb: 30, 90, 70;
    --bs-link-hover-color-rgb: 22, 69, 53;
    --bs-primary: var(--accent);
    --bs-primary-rgb: 30, 90, 70;
    --bs-success: var(--state-ok);
    --bs-danger: var(--state-missing);
    --bs-warning: var(--state-check);
    --bs-info: var(--info);
    --bs-focus-ring-color: var(--accent-100);
    --bs-code-color: var(--ink-700);
}

/* Only what differs. Everything above still applies. */
[data-theme="dark"] {
    color-scheme: dark;      /* a native <select>'s list, scrollbars and date pickers draw dark (AUT-491) */
    --ink-900: #e6e9ed;
    --ink-700: #c4cbd3;
    --ink-500: #a7b0ba;
    --ink-300: #6b7580;
    --line: #2c333b;
    --line-strong: #3a434d;
    --bg: #0f1317;
    --surface: #171c21;
    --surface-2: #1d2329;
    --hover: #232a31;
    --accent: #2a7a5f;
    --accent-700: #329070;
    --accent-100: #1a2b25;
    --navy-text: #8fd0b6;    /* AA on --accent-100 and on --surface */
    --link: #8fd0b6;
    --focus: #4f9d80;
    --line-soft: #222a31;
    --info: #b9c4d0;
    --info-bg: #1b222a;
    --info-line: #4a5866;
    --shadow-overlay: 0 8px 28px rgba(0, 0, 0, .5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --state-check: #f2b552;
    --state-check-bg: #2d2313;
    --state-check-line: #c98b2a;
    --state-missing: #f2897d;
    --state-missing-bg: #321a1a;
    --state-missing-line: #c4544a;
    --state-ok: #86c992;
    --state-ok-bg: #17291b;
    --state-ok-line: #4f9a5b;
}
