/* Qareken — lesson and question figures in the dark theme (docs/ARCHITECTURE.md §12).
   Figures are inline SVG in content (SAT lessons, question banks, A Level lessons and questions). Their parts drawn
   with currentColor follow the text colour by themselves; the authored literal colours are mapped here.

   Every figure reaches the page through renderRich (content.js), so it sits in a .rich block (A Level adds .al-rich).
   SVG presentation attributes (fill='…', stroke='…') lose to any CSS rule, so an attribute selector repaints them.
   Light: this file has no light rules — figures keep their authored colours.
   Dark:
   - An SVG with no fill paints its unfilled parts (text, arrowheads in <marker>) black: the root gets --ink.
   - SAT figures (lessons, question banks, practice tests) use a small house palette: ink #1f2328 (or #000), white
     paper (background rect, label masks, hollow points, text halos), light grid lines, light/mid/dark grey data
     series and a few tints. Paper becomes the card and ink the ink. The grey series keep their order (the light
     series stays the lightest), because lesson text and alt text name them "the light bar" and "the dark bar".
   - A Level figures draw with currentColor; their few literal colours are data (pixel art, colour depth, a picture,
     a dark screenshot), so the palette mapping skips .al-rich and only the root fill applies there. The one
     exception is the IDE screenshot (translators and IDEs lesson): its keyword blue, error red and current-line
     highlight are remapped in the last section so the code stays legible on the dark paper. */

:root[data-theme="dark"] {
  --fig-paper: var(--card);          /* white: background rect, label masks, hollow points, text halos */
  --fig-tint: var(--fill);           /* near-white shape interiors */
  --fig-grid: var(--line-strong);    /* light grid lines */
  --fig-grid-faint: var(--line);     /* very light minor grid lines */
  --fig-grid-major: #566070;         /* mid-grey major grid lines */
  --fig-series-light: #B8C1CC;       /* light-grey data series: bars, histograms, shaded shapes */
  --fig-series-mid: #8A96A6;         /* mid-grey data series */
  --fig-series-dark: #606B7C;        /* dark-grey data series (3.2:1 on the card) */
  --fig-shade: #3D69AE;              /* light-blue solution regions of inequalities (fill-opacity .5) */
  --fig-shade-2: #4D8AEA;            /* the same at fill-opacity .35 */
  --fig-orange: #FB923C;             /* orange curve and its label */
}

/* ---------- Every figure: default fill (unfilled parts paint black otherwise) ---------- */
:root[data-theme="dark"] .rich svg:not([fill]):not(.icon) { fill: var(--ink); }
/* KaTeX draws some glyphs (roots, wide accents) as SVG coloured by its text */
:root[data-theme="dark"] .rich .katex svg:not([fill]) { fill: currentColor; }

/* ---------- SAT house palette ---------- */
/* ink */
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#1f2328' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#000' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#000000' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#111111' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#111827' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='black' i] { fill: var(--ink); }
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#1f2328' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#000' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#000000' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#111111' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#111827' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='black' i] { stroke: var(--ink); }

/* paper */
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#ffffff' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#fff' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='white' i] { fill: var(--fig-paper); }
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#ffffff' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#fff' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='white' i] { stroke: var(--fig-paper); }
/* white text on an ink shape (flowchart start pill): in dark the pill is a raised outlined box, not a white slab */
:root[data-theme="dark"] .rich:not(.al-rich) rect[fill='#1f2328' i] { fill: var(--surface-2); stroke: var(--ink); }
:root[data-theme="dark"] .rich:not(.al-rich) text[fill='#ffffff' i],
:root[data-theme="dark"] .rich:not(.al-rich) text[fill='#fff' i],
:root[data-theme="dark"] .rich:not(.al-rich) text[fill='white' i] { fill: var(--ink); }

/* near-white shape interiors and tinted boxes */
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#f2f4f7' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#f6f8fa' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#e4e7ec' i] { fill: var(--fig-tint); }
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#eaf1fb' i] { fill: var(--info-soft); }
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#fff7e0' i] { fill: var(--warn-soft); }

/* grid lines */
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#d0d5dd' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#cccccc' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#c8c8c8' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#d0d0d0' i] { stroke: var(--fig-grid); }
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#e3e3e3' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#eceef2' i] { stroke: var(--fig-grid-faint); }
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#b5b5b5' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#bbbbbb' i] { stroke: var(--fig-grid-major); }

/* grey data series: light, mid and dark keep their order */
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#d0d5dd' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#c9d3e0' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#b9c3ce' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#c9d1dc' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#c9ced6' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#c7ccd4' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#c9cfd8' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#bdbdbd' i] { fill: var(--fig-series-light); }
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#9a9a9a' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#8c9bab' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#7b8794' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#7a8696' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#6b7785' i] { fill: var(--fig-series-mid); }
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#57606a' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#4b5563' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#3b4654' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#3d4b5c' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#404040' i],
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#555555' i] { fill: var(--fig-series-dark); }

/* secondary grey lines (second series, reference lines) */
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#57606a' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#4b5563' i],
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#6b7280' i] { stroke: var(--muted); }
/* thick light-grey line under a dashed ink line (systems of equations: cross, parallel, same line) */
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#98a2b3' i] { stroke: var(--faint); }

/* light-blue solution regions (drawn at fill-opacity .5 and .35): a blue that still reads as shading on the paper */
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#9fb6d6' i] { fill: var(--fig-shade); }
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#7aa7e0' i] { fill: var(--fig-shade-2); }

/* coloured curves and their labels: deep hues lighten to stay legible on the dark paper */
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#1d4ed8' i] { fill: var(--info); }
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#1d4ed8' i] { stroke: var(--info); }
:root[data-theme="dark"] .rich:not(.al-rich) [fill='#c2410c' i] { fill: var(--fig-orange); }
:root[data-theme="dark"] .rich:not(.al-rich) [stroke='#c2410c' i] { stroke: var(--fig-orange); }

/* ---------- A Level screenshots of an IDE (translators and IDEs lesson) ---------- */
/* keyword blue, error red and the current-line highlight, so keywords stay legible on the dark paper */
:root[data-theme="dark"] .al-rich [fill='#3b82f6' i] { fill: var(--info); }
:root[data-theme="dark"] .al-rich text[fill='#dc2626' i] { fill: var(--bad); }
:root[data-theme="dark"] .al-rich [stroke='#dc2626' i] { stroke: var(--bad); }
:root[data-theme="dark"] .al-rich rect[fill='#facc15' i][fill-opacity] { fill-opacity: .22; }
