/* The `graphs` figure kit (ui/figures/graphs.js): xy-graph, ladder, proportion, flow and label-card (P0g).
   Rules are `.cx-figure--<kind>` and kit-prefixed classes (`gr-`); colour tokens are declared three times, as in geo.css
   (:root, the dark preference and data-theme="dark"). Builds on the shared .cx and .cx-figure rules in styles.css.
   See docs/figures/README.md and docs/figures/graphs.md. */

/* ---- Colours -----------------------------------------------------------------------------------------------------
   The three series of a graph (--gr-s*) and the five parts of a proportion (--gr-p*). Each is at least 3:1 against the card (--surface)
   in both themes (tests/ui-figures-graphs.test.js and ui-figures-graphs-browser.test.js measure it). Colour is never the only cue: the
   second series is dashed and the third dotted (a points series has a circle, a square and a diamond), and every part of a proportion
   has its own pattern and letter. */
:root {
  --gr-s1: #3b5bdb;
  --gr-s2: #e8590c;
  --gr-s3: #1f8a4c;
  --gr-p1: #3b5bdb;
  --gr-p2: #e8590c;
  --gr-p3: #1f8a4c;
  --gr-p4: #8a4baf;
  --gr-p5: #c2255c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gr-s1: #8ea2ff;
    --gr-s2: #ff922b;
    --gr-s3: #5fd08a;
    --gr-p1: #8ea2ff;
    --gr-p2: #ff922b;
    --gr-p3: #5fd08a;
    --gr-p4: #d0a2f0;
    --gr-p5: #f783ac;
  }
}
:root[data-theme="dark"] {
  --gr-s1: #8ea2ff;
  --gr-s2: #ff922b;
  --gr-s3: #5fd08a;
  --gr-p1: #8ea2ff;
  --gr-p2: #ff922b;
  --gr-p3: #5fd08a;
  --gr-p4: #d0a2f0;
  --gr-p5: #f783ac;
}

/* ---- The picture ------------------------------------------------------------------------------------------------- */
.cx-figure--xy-graph, .cx-figure--proportion, .cx-figure--flow, .cx-figure--label-card { max-width: 440px; }
.cx-figure--ladder { max-width: 400px; }
/* Text is at least 12 units of a 320-unit picture, bold: the width estimate (textWidth in data-chart.js) is for bold text. */
.gr-text { font-size: 13px; font-weight: 600; fill: var(--text); font-family: inherit; font-variant-numeric: tabular-nums; }
.gr-text--strong { font-weight: 800; }
.gr-text--muted { fill: var(--muted); }
.gr-text--plain { font-weight: 500; } /* the regular face, narrower than the bold one the widths are estimated for */
.gr-text--title { font-size: 15px; }
.gr-text--on-badge { fill: var(--accent-text); }
/* A ring of the card's colour round a text that sits beside a line, so nothing runs through the letters. */
.gr-halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.gr-frame { fill: none; stroke: var(--wire); stroke-width: 1.5; }

/* ---- xy-graph ------------------------------------------------------------------------------------------------------
   Series 1 is solid, 2 dashed, 3 dotted. The area under a line is a tint of its colour with hatching on top. A marked point is a ring
   in the text colour with dashed guides to both axes. */
.gr-axis { stroke: var(--wire); stroke-width: 2; stroke-linecap: square; }
.gr-tick { stroke: var(--wire); stroke-width: 1.5; }
.gr-zero { stroke: var(--axis); stroke-width: 1.5; }
.gr-grid { stroke: var(--grid); stroke-width: 1; }
.gr-series { fill: none; stroke-width: 2.8; stroke-linejoin: round; stroke-linecap: round; }
.gr-series--1 { stroke: var(--gr-s1); }
.gr-series--2 { stroke: var(--gr-s2); stroke-dasharray: 9 6; }
.gr-series--3 { stroke: var(--gr-s3); stroke-width: 3.6; stroke-dasharray: 0.5 6.5; }
.gr-dot { stroke: var(--surface); stroke-width: 1.2; }
.gr-dot--1 { fill: var(--gr-s1); }
.gr-dot--2 { fill: var(--gr-s2); }
.gr-dot--3 { fill: var(--gr-s3); }
.gr-area { stroke: none; }
.gr-area--1 { fill: color-mix(in srgb, var(--gr-s1) 20%, var(--surface)); }
.gr-area--2 { fill: color-mix(in srgb, var(--gr-s2) 20%, var(--surface)); }
.gr-area--3 { fill: color-mix(in srgb, var(--gr-s3) 20%, var(--surface)); }
.gr-area-hatch { stroke: none; }
.gr-hatch-line { stroke: var(--axis); stroke-width: 1.4; }
.gr-guide { stroke: var(--text); stroke-width: 1.4; stroke-dasharray: 4 3; }
.gr-mark { fill: var(--surface); stroke: var(--text); stroke-width: 2.4; }

/* ---- ladder --------------------------------------------------------------------------------------------------------- */
.gr-tick--power { stroke-width: 2; }
.gr-leader { stroke: var(--axis); stroke-width: 1.4; }
.gr-rung { stroke: var(--user-line); stroke-width: 3.4; stroke-linecap: butt; }

/* ---- proportion ------------------------------------------------------------------------------------------------------
   Five parts: a colour, a pattern over it (the first is solid) and a letter. The patterns are drawn in the card's colour over the fill. */
.gr-fill--1 { fill: var(--gr-p1); }
.gr-fill--2 { fill: var(--gr-p2); }
.gr-fill--3 { fill: var(--gr-p3); }
.gr-fill--4 { fill: var(--gr-p4); }
.gr-fill--5 { fill: var(--gr-p5); }
.gr-segment { stroke: var(--surface); stroke-width: 2; }
/* A sliver (under about 3 %): the surface stroke would eat it, so it is outlined, and a stem joins it to its letter. */
.gr-segment--thin { stroke: var(--wire); stroke-width: 1; }
.gr-stem { stroke: var(--text); stroke-width: 1.4; }
.gr-pattern { stroke: none; }
.gr-pat-stroke { fill: none; stroke: var(--surface); stroke-width: 1.8; }
.gr-pat-stroke--wide { stroke-width: 3.6; }
.gr-pat-dot { fill: var(--surface); stroke: none; }
.gr-chip { fill: var(--surface); stroke: var(--text); stroke-width: 1.4; }

/* ---- flow ------------------------------------------------------------------------------------------------------------ */
.gr-box { fill: var(--surface-2); stroke: var(--wire); stroke-width: 1.6; rx: 8px; }
.gr-arrow { fill: none; stroke: var(--wire); stroke-width: 2.2; stroke-linejoin: round; }
.gr-head { fill: var(--wire); stroke: none; }
.gr-badge { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }

/* ---- label-card ------------------------------------------------------------------------------------------------------- */
.gr-card { fill: var(--surface-2); stroke: var(--wire); stroke-width: 2.4; }
.gr-card-inner { fill: none; stroke: var(--wire); stroke-width: 1; }
.gr-rule { stroke: var(--axis); stroke-width: 1; }
.gr-sign { fill: none; stroke: var(--text); stroke-width: 2.2; }
