/* The maths figure kit (ui/figures/maths.js): trees, outcome grids, urns, bar charts, spinners, number lines, right triangles, and squares and cubes.
   Builds on the shared .cx, .cx-figure and .cx-label rules in styles.css. */

/* ---- The wheel's sectors: shared by the spinner figure and the probability simulator --------------------------------
   Six fills, round the wheel (ui/figures/wheel.js, colourOf). The simulator's own `ps-slice--N` classes are aliases:
   the same rule serves both names. */
.wheel-slice, .ps-slice { stroke: var(--surface); stroke-width: 2; }
.wheel-slice--0, .ps-slice--0 { fill: color-mix(in srgb, var(--line) 22%, var(--surface)); }
.wheel-slice--1, .ps-slice--1 { fill: color-mix(in srgb, var(--user-line) 22%, var(--surface)); }
.wheel-slice--2, .ps-slice--2 { fill: color-mix(in srgb, var(--good) 24%, var(--surface)); }
.wheel-slice--3, .ps-slice--3 { fill: color-mix(in srgb, var(--extra) 22%, var(--surface)); }
.wheel-slice--4, .ps-slice--4 { fill: color-mix(in srgb, var(--tier-challenge) 20%, var(--surface)); }
.wheel-slice--5, .ps-slice--5 { fill: color-mix(in srgb, var(--glow) 34%, var(--surface)); }

/* ---- Colours -----------------------------------------------------------------------------------------------------
   The seven colours of an urn (and of a spinner's sectors that name one). Each fill is at least 3:1 against the card (--surface)
   in both themes, except two in the light theme: white cannot be, and yellow cannot be while still looking yellow. Those two keep
   their true fill and the strong outline (--wire, 12:1) carries the shape. (tests/ui-figures.test.js measures all of this.) Every item
   also carries its letter, so colour is never the only cue. --fig-on is the letter's colour and --fig-halo the ring round it, so a
   letter reads on any of the fills. */
:root {
  --fig-red: #d03a3a;
  --fig-blue: #2a6fdb;
  --fig-green: #2f9e44;
  --fig-yellow: #f5c400;
  --fig-purple: #9150c8;
  --fig-orange: #d9650a;
  --fig-white: #f4f5f9;
  --fig-on: #ffffff;
  --fig-halo: #1c2033;
  /* how much accent each face of a cube takes: the top is the lightest, as if lit from above (on a dark card the lightest is the strongest) */
  --fig-cube-top: 12%;
  --fig-cube-left: 26%;
  --fig-cube-right: 40%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fig-red: #ff7a7a;
    --fig-blue: #6ea8ff;
    --fig-green: #5fd08a;
    --fig-yellow: #ffd24d;
    --fig-purple: #c79bff;
    --fig-orange: #ffa15c;
    --fig-white: #e8eaf2;
    --fig-on: #12141c;
    --fig-halo: #ffffff;
    --fig-cube-top: 40%;
    --fig-cube-left: 26%;
    --fig-cube-right: 12%;
  }
}
:root[data-theme="dark"] {
  --fig-red: #ff7a7a;
  --fig-blue: #6ea8ff;
  --fig-green: #5fd08a;
  --fig-yellow: #ffd24d;
  --fig-purple: #c79bff;
  --fig-orange: #ffa15c;
  --fig-white: #e8eaf2;
  --fig-on: #12141c;
  --fig-halo: #ffffff;
  --fig-cube-top: 40%;
  --fig-cube-left: 26%;
  --fig-cube-right: 12%;
}

/* ---- The picture ------------------------------------------------------------------------------------------------- */
.cx-figure--tree, .cx-figure--outcome-grid, .cx-figure--urn, .cx-figure--bars, .cx-figure--spinner, .cx-figure--number-line, .cx-figure--right-triangle, .cx-figure--square-cube { max-width: 440px; }
/* Text is at least 12 units of a 320-unit picture, bold: the width estimate (textWidth in data-chart.js) is for bold text. */
.fig-text { font-size: 13px; font-weight: 600; fill: var(--text); font-family: inherit; font-variant-numeric: tabular-nums; }
.fig-text--small { font-size: 12px; }
.fig-text--muted { fill: var(--muted); }
.fig-text--strong { font-weight: 800; }
/* A ring of the card's colour round a text that sits on a line or a fill, so the line does not run through the letters. */
.fig-halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }

/* tree */
.fig-edge { fill: none; stroke: var(--wire); stroke-width: 1.5; }
.fig-edge.is-highlight { stroke: var(--accent); stroke-width: 4.5; stroke-linecap: round; }
.fig-pill { fill: var(--surface); stroke: var(--wire); stroke-width: 1.5; }
.fig-pill.is-highlight { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3.5; }
.fig-root { fill: var(--wire); }

/* outcome grid: set A is a tint with a solid ring, set B a tint with a dashed ring, and a cell in both is hatched with a
   heavy ring: the three differ in pattern and outline, not only in colour. */
.fig-cell { fill: var(--surface); stroke: var(--grid); stroke-width: 1; }
.fig-cell.is-a { fill: color-mix(in srgb, var(--accent) 24%, var(--surface)); stroke: var(--accent); stroke-width: 3; }
.fig-cell.is-b { fill: color-mix(in srgb, var(--user-line) 26%, var(--surface)); stroke: var(--user-line); stroke-width: 3; stroke-dasharray: 6 3; }
.fig-cell.is-both { stroke: var(--text); stroke-width: 3.5; }
.fig-hatch-a { fill: color-mix(in srgb, var(--accent) 34%, var(--surface)); }
.fig-hatch-b { fill: color-mix(in srgb, var(--user-line) 36%, var(--surface)); }

/* urn */
.fig-jar { fill: var(--surface-2); stroke: var(--wire); stroke-width: 2; }
.fig-item { stroke: var(--wire); stroke-width: 1.5; stroke-linejoin: round; }
.fig-item--red { fill: var(--fig-red); }
.fig-item--blue { fill: var(--fig-blue); }
.fig-item--green { fill: var(--fig-green); }
.fig-item--yellow { fill: var(--fig-yellow); }
.fig-item--purple { fill: var(--fig-purple); }
.fig-item--orange { fill: var(--fig-orange); }
.fig-item--white { fill: var(--fig-white); }
.fig-letter { font-size: 12px; font-weight: 800; fill: var(--fig-on); paint-order: stroke; stroke: var(--fig-halo); stroke-width: 3px; stroke-linejoin: round; }

/* bars */
.fig-grid { stroke: var(--grid); stroke-width: 1; }
.fig-zero { stroke: var(--axis); stroke-width: 1.5; }
.fig-bar { fill: color-mix(in srgb, var(--accent) 72%, var(--surface)); stroke: var(--accent); stroke-width: 1.5; }
.fig-theory { stroke: var(--user-line); stroke-width: 2.5; stroke-dasharray: 7 4; }

/* spinner: every sector has an --wire outline and the wheel a rim (3:1 on the card), whatever its fill; the pale tints are decoration */
.fig-spinner .wheel-slice { stroke: var(--wire); stroke-width: 1.5; stroke-linejoin: round; }
.fig-rim { fill: none; stroke: var(--wire); stroke-width: 2.5; }
.fig-pointer { stroke: var(--text); stroke-width: 3; stroke-linecap: round; }
.fig-pointer-head { fill: var(--text); }

/* number line */
.fig-line { stroke: var(--axis); stroke-width: 2; }
.fig-tick { stroke: var(--axis); stroke-width: 1.5; }
.fig-interval { stroke: var(--accent); stroke-width: 8; opacity: 0.55; }
.fig-interval-end { stroke: var(--accent); stroke-width: 3; }
.fig-stem { stroke: var(--muted); stroke-width: 1; }
.fig-point { fill: var(--user-line); stroke: var(--surface); stroke-width: 2; }

/* right triangle: the colours are the pythagoras explorer's (a --line, b --good, c --user-line), so the code carries over from the
   widget. Every square has a letter and an outline, and the hypotenuse is also the heavier line: colour is never the only cue. */
.fig-rt-fill { fill: var(--surface); stroke: none; }
.fig-rt-edge { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }
.fig-rt-edge.is-hypotenuse { stroke: var(--user-line); stroke-width: 4.5; }
.fig-rt-edge.is-height { stroke-width: 2; stroke-dasharray: 8 6; stroke-linecap: butt; }
.fig-rt-mark { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: miter; }
.fig-rt-square { stroke-width: 2; stroke-linejoin: round; }
.fig-rt-square--a { fill: color-mix(in srgb, var(--line) 24%, var(--surface)); stroke: var(--line); }
.fig-rt-square--b { fill: color-mix(in srgb, var(--good) 26%, var(--surface)); stroke: var(--good); }
.fig-rt-square--c { fill: color-mix(in srgb, var(--user-line) 26%, var(--surface)); stroke: var(--user-line); }
.fig-rt-square--plain { fill: color-mix(in srgb, var(--muted) 16%, var(--surface)); stroke: var(--muted); }

/* square and cube: a square of tiles and a cube of small cubes in the accent colour. The cube's three visible faces differ in tint (the top
   lightest, the right-hand one the darkest, in both themes) and every small face has its edge, so the faces and the count show without colour. A dimension line (with
   ticks) joins the side or edge label to what it measures. */
.fig-sq-body { fill: color-mix(in srgb, var(--accent) 22%, var(--surface)); stroke: none; }
.fig-sq-grid { stroke: var(--accent); stroke-width: 1.25; }
.fig-sq-frame { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.fig-cube-face { stroke: var(--accent); stroke-width: 1.25; stroke-linejoin: round; }
.fig-cube-face--top { fill: color-mix(in srgb, var(--accent) var(--fig-cube-top), var(--surface)); }
.fig-cube-face--left { fill: color-mix(in srgb, var(--accent) var(--fig-cube-left), var(--surface)); }
.fig-cube-face--right { fill: color-mix(in srgb, var(--accent) var(--fig-cube-right), var(--surface)); }
.fig-cube-frame { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.fig-dim { stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; }
