/* Color roles, light and dark (2026-11-13, docs/PLAN-dark-mode.md; Jason: dark mode for the web and the app).
 *
 * One file for the server pages (linked first in every head by backend/site.py theme_head, through
 * _semblen_app.html) and the analyzer (the same link, put in its index.html by backend/main.py app_shell). Pages
 * use a ROLE (what the color is for), never a color: var(--text-muted), not #64748b or var(--slate-500), so dark
 * mode is one set of values here. tests/test_theme.py pins: every role in both modes, every text-on-background pair
 * at WCAG AA (4.5:1) in both; tests/test_theme_roles_only.py keeps raw colors from coming back.
 *
 * Dark only while DARK_MODE lets this browser have it: theme_head's script marks <html> `dark-ok` before the first
 * paint. Without `dark-ok` the page is light whatever the device says, so a page not yet converted is never half dark.
 * Within it, the reader's Appearance (2026-11-14, docs/decisions/2026-11-14-theme-setting.md): Dark
 * (data-theme="dark"), Light (data-theme="light"), or System (no attribute), which follows the device; the head script
 * reads the device and marks <html> `device-dark`, so the dark values below are written once for both ways in. Screens
 * only: a page prints light (2026-11-13). */

:root {
  /* Page and surfaces */
  --bg: #ffffff;               /* the page */
  --bg-subtle: #f8fafc;        /* a quiet band or panel on the page */
  --bg-muted: #f1f5f9;         /* a filled chip, a code box, a hovered row; --text-2 on it, not --text-muted (4.34:1) */
  --surface: #ffffff;          /* a card */
  --surface-raised: #ffffff;   /* a menu, a dialog, a popover: above a card */
  --border: #e2e8f0;           /* a card's edge, a rule */
  --border-strong: #cbd5e1;    /* an input's edge, a secondary button's */
  --shadow: rgba(15, 23, 42, 0.08);

  /* Text */
  --text: #0f172a;             /* body text and headings */
  --text-2: #334155;           /* secondary text */
  --text-muted: #64748b;       /* captions, dates, hints */
  --link: #1d4ed8;
  --link-underline: #93c5fd;
  --focus: #93c5fd;            /* the focus ring */

  /* Actions */
  --accent: #2563eb;           /* the primary button */
  --accent-hover: #1d4ed8;
  --on-accent: #ffffff;        /* text on the primary button */
  --accent-subtle: #eff6ff;    /* a selected tab, an info box */

  /* The bar at the top and the footer: navy in both modes, the brand's */
  --chrome: #1e293b;
  --on-chrome: #ffffff;
  --on-chrome-muted: #cbd5e1;
  --footer: #0f172a;
  --on-footer: #94a3b8;

  /* A technique found: amber, the one color that means it (project design system) */
  --tech-bg: #fffbeb;          /* a technique card */
  --tech-evidence-bg: #fef3c7; /* the quoted words' box */
  --tech-border: #fcd34d;
  --tech-name: #92400e;        /* the technique's name */
  --tech-chip: #78350f;        /* a chip's text */
  --tech-text: #451a03;        /* the explanation */
  --tech-mark: #fde68a;        /* the picked technique's words, highlighted in the text */
  --tech-underline: #f59e0b;   /* a flagged phrase's underline, the found dot */
  --tech-arrow: #d97706;

  /* Claim results and errors */
  --danger: #b91c1c;           /* error text, "contradicted" */
  --danger-strong: #dc2626;    /* an error's icon or edge */
  --danger-bg: #fef2f2;
  --success: #047857;          /* "confirmed", "Link copied" */
  --success-bg: #ecfdf5;
  --warning: #92400e;          /* "the sources add" */
  --warning-bg: #fffbeb;

  /* Group C: civic, admin and teaching pages */
  --success-border: #86efac;   /* a "confirmed" chip's edge */
  --danger-border: #fca5a5;    /* a "contradicted" chip's edge */

  /* Group D, the analyzer (it uses Group C's success and danger borders, above) */
  --canvas: #f1f5f9;           /* the analyzer's page, under its white cards (dark: the page itself) */
  --border-subtle: #f1f5f9;    /* a faint rule inside a card: between the article's paragraphs */
  --accent-border: #bfdbfe;    /* the edge of an --accent-subtle box, the loading spinner's track */
  --warning-border: #fcd34d;   /* the edge of a --warning-bg notice, "the sources add" */
  --backdrop: rgba(15, 23, 42, 0.45);   /* behind a dialog or the app's menu */
  --on-tech: #ffffff;          /* text on a picked technique chip (its fill is --tech-name) */
  --tech-arrow-quoted: #fb923c;   /* the jump arrow of a quoted paragraph */
  --sources-1: #475569;        /* the sources bar's shades, by rank: slate, no hue (not a finding) */
  --sources-2: #94a3b8;
  --sources-3: #334155;
  --sources-4: #cbd5e1;
  --sources-5: #64748b;
  --sources-6: #1e293b;

  /* Group A: shared chrome (site.css, signup.js, the partials) */
  --shadow-raised: rgba(15, 23, 42, 0.22);  /* under a menu, a dialog, a popover, the back-to-top button */

  /* Group B: reader pages (/daily, stories, home, account, Pro, try, …) */
  --hero-bg: #0f172a;          /* the home page's dark top band */
  --on-chrome-accent: #fcd34d; /* an amber word on the bar or the band ("New", the kicker) */
  --on-chrome-em: #93c5fd;     /* an emphasised word in a headline on the bar or the band */
  /* Polish (2026-11-14, docs/decisions/2026-11-14-dark-mode-polish.md) */
  --field-bg: #ffffff;         /* a text field, a select: the browser's own white in light; dark: the page, recessed in a card */
  --footer-edge: #0f172a;      /* the footer's top edge: the footer itself in light (no line); dark: a line off the page */
  --disabled-bg: #64748b;      /* a disabled primary button */
  --tech-mark-text: #0f172a;   /* words in a --tech-mark highlight outside the article (--text in light, --tech-text in dark) */
  --tech-count: #78350f;       /* a technique chip's count on --tech-mark (--tech-chip in light, --tech-text in dark) */
  /* Polish 2 (2026-11-14, Jason's 6-9) */
  --bg-band: #f1f5f9;          /* a section band on the home page: --bg-muted in light; dark: the page, so its cards stand up */
  --on-chrome-ring: rgba(255, 255, 255, 0.4);   /* an outlined control's edge on the navy bar (Feedback), both modes */
}

/* The dark values, the only place they are written: on a choice of Dark, or on System with the device in dark. Form
 * fields and scrollbars follow (color-scheme). */
@media screen {
  :root.dark-ok[data-theme="dark"],
  :root.dark-ok.device-dark:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0f172a;
    --bg-subtle: #131c2f;
    --bg-muted: #293548;          /* its own step above --surface, so a chip or a band stands off a card */
    --surface: #1e293b;
    --surface-raised: #273449;
    --border: #334155;
    --border-strong: #475569;
    --shadow: rgba(0, 0, 0, 0.45);

    --text: #f1f5f9;
    --text-2: #cbd5e1;
    --text-muted: #94a3b8;
    --link: #93c5fd;
    --link-underline: #1d4ed8;
    --focus: #60a5fa;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --on-accent: #ffffff;
    --accent-subtle: #172554;

    --chrome: #1e293b;
    --on-chrome: #ffffff;
    --on-chrome-muted: #cbd5e1;
    --footer: #0b1120;
    --on-footer: #94a3b8;

    --tech-bg: #2a2210;
    --tech-evidence-bg: #3a2d0c;
    --tech-border: #92400e;
    --tech-name: #fcd34d;
    --tech-chip: #fde68a;
    --tech-text: #fef3c7;
    --tech-mark: #6b4a0b;
    --tech-underline: #f59e0b;
    --tech-arrow: #fbbf24;

    --danger: #fca5a5;
    --danger-strong: #f87171;
    --danger-bg: #3b1219;
    --success: #6ee7b7;
    --success-bg: #0f2e27;
    --warning: #fcd34d;
    --warning-bg: #2a2210;

    /* Group C: civic, admin and teaching pages */
    --success-border: #047857;
    --danger-border: #991b1b;

    /* Group D, the analyzer (it uses Group C's success and danger borders, above) */
    --canvas: #0f172a;
    --border-subtle: #273449;
    --accent-border: #1e40af;
    --warning-border: #92400e;
    --backdrop: rgba(0, 0, 0, 0.6);
    --on-tech: #1c1404;
    --tech-arrow-quoted: #fdba74;
    --sources-1: #94a3b8;
    --sources-2: #475569;
    --sources-3: #cbd5e1;
    --sources-4: #334155;
    --sources-5: #64748b;
    --sources-6: #e2e8f0;

    /* Group A: shared chrome */
    --shadow-raised: rgba(0, 0, 0, 0.6);

    /* Group B: reader pages */
    --hero-bg: #0b1120;
    --on-chrome-accent: #fcd34d;
    --on-chrome-em: #93c5fd;

    /* Polish */
    --field-bg: #0f172a;
    --footer-edge: #1e293b;
    --disabled-bg: #334155;
    --tech-mark-text: #fef3c7;
    --tech-count: #fef3c7;

    /* Polish 2 */
    --bg-band: #0f172a;
    --on-chrome-ring: rgba(255, 255, 255, 0.4);
  }
}

/* Text fields and selects that set no background of their own take the field role: in dark the browser's own (a
   neutral grey, #3b3b3b) sat on the slate pages like a hole (2026-11-14). :where() keeps this weaker than any rule
   of a page or component, so a field that sets its own look keeps it. */
:where(input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file], [type=button], [type=submit],
       [type=reset], [type=image]), select, textarea) { background-color: var(--field-bg); }

/* The PRO pill (2026-11-14, Jason's 7): one outlined pill, the same on the home page, /daily and the analyzer, in both
   modes; it was an inverted, white pill on the server pages in dark and the bar's navy, so only the word, in the
   analyzer. Here because every page and the analyzer load this file; site.css keeps only its place in a row. */
.rs-pro { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: var(--text-2); background: transparent;
          border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 4px; vertical-align: 1px; margin-left: 6px; }
