/* The `diagram` figure kit (ui/figures/diagram.js): a drawing of the art contract with numbered parts (P0h).
   Rules are `.cx-figure--<kind>` and kit-prefixed classes (`dg-`); 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, docs/figures/diagram.md and docs/figures/art.md. */

/* ---- Colours -----------------------------------------------------------------------------------------------------
   The fills of the art contract. A fill that carries meaning (--dg-f4 to --dg-f6 and every named colour) is at least 3:1 against the card
   (--surface) in both themes (tests/ui-figures-diagram-browser.test.js measures it). The pale tints --dg-f1 to --dg-f3 are decoration: the
   outline (dg-line) carries the shape. A colour is never the only cue: oxygen-poor blood is dg-deoxy with dg-hatch, cold is dg-cool with
   dg-dots, the three wires differ by plain, dotted and hatched (docs/figures/art.md).
   --dg-black, --dg-shine and --dg-rim are the exception, on purpose: the same value in the light theme, the dark preference and
   data-theme="dark", for the rare object whose real colour is what the student must see (a matt black can, a shiny highlight). Every other
   fill follows the theme and flips lightness in the dark one. Each of the two is a fill with its own outline (see dg-black and dg-shine below),
   because a near-black fill alone is lost on the dark card and a near-white one on the light card. */
:root {
  --dg-f1: #f1f3f8;
  --dg-f2: #e3e7f1;
  --dg-f3: #cfd5e4;
  --dg-f4: #8a91a8;
  --dg-f5: #68708a;
  --dg-f6: #454b61;
  --dg-warm: #d9480f;
  --dg-cool: #1971c2;
  --dg-water: #0b8ea8;
  --dg-oxy: #e03131;
  --dg-deoxy: #5f3dc4;
  --dg-metal: #7b8794;
  --dg-skin: #b5774f;
  --dg-plant: #2f8f44;
  --dg-live: #8a5a2b;
  --dg-neutral: #1c7ed6;
  --dg-earth: #7a8700;
  --dg-black: #1d1f24;
  --dg-shine: #f4f6fb;
  --dg-rim: #1d1f24;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --dg-f1: #232738;
    --dg-f2: #2e3349;
    --dg-f3: #3c425d;
    --dg-f4: #7a819d;
    --dg-f5: #a3aac2;
    --dg-f6: #cfd4e6;
    --dg-warm: #ff8a4c;
    --dg-cool: #5aa9f0;
    --dg-water: #3cc4dc;
    --dg-oxy: #ff6b6b;
    --dg-deoxy: #a58bff;
    --dg-metal: #a6b0be;
    --dg-skin: #e0a77d;
    --dg-plant: #5fd08a;
    --dg-live: #c98a4f;
    --dg-neutral: #5aa9f0;
    --dg-earth: #c3d63a;
    --dg-black: #1d1f24;
    --dg-shine: #f4f6fb;
    --dg-rim: #1d1f24;
  }
}
:root[data-theme="dark"] {
  --dg-f1: #232738;
  --dg-f2: #2e3349;
  --dg-f3: #3c425d;
  --dg-f4: #7a819d;
  --dg-f5: #a3aac2;
  --dg-f6: #cfd4e6;
  --dg-warm: #ff8a4c;
  --dg-cool: #5aa9f0;
  --dg-water: #3cc4dc;
  --dg-oxy: #ff6b6b;
  --dg-deoxy: #a58bff;
  --dg-metal: #a6b0be;
  --dg-skin: #e0a77d;
  --dg-plant: #5fd08a;
  --dg-live: #c98a4f;
  --dg-neutral: #5aa9f0;
  --dg-earth: #c3d63a;
  --dg-black: #1d1f24;
  --dg-shine: #f4f6fb;
  --dg-rim: #1d1f24;
}

/* ---- The picture ------------------------------------------------------------------------------------------------- */
.cx-figure--diagram { max-width: 440px; }

/* ---- The classes of a drawing ---------------------------------------------------------------------------------------
   Each class sets a custom property, which a group hands down to everything inside it that does not set its own, and the one rule on
   `.dg-s` (the kit puts it on every shape) turns the properties into paint: --dg-fill, --dg-stroke (the outline, in ink), --dg-sw
   (its width, in units of the drawing), --dg-dash. A line (`line`, `polyline`, or a `path` with dg-arrow) has no inside, so there a fill
   class colours the stroke (a coloured wire or arrow) unless the nearest class says dg-line (see .dg-s--ink below). */
.dg-line { --dg-stroke: var(--wire); }
.dg-thin { --dg-sw: 1.2px; }
.dg-thick { --dg-sw: 4px; }
.dg-dash { --dg-dash: 7px 5px; }
.dg-arrow { --dg-arrow: 1; }
/* Theme-stable fills: the colour is the point, so it does not change with the theme (see the comment on the tokens above). Each brings its
   own outline, so the shape reads on both cards. They sit before dg-noline, so that dg-noline on the same element still removes the outline:
   do that only for a dg-shine highlight on a dg-black shape (15.2:1 by fill). On dg-metal the shine alone is 2.0:1 in the dark theme and on
   dg-fill-2 1.1:1 in the light one, so there keep the outline (with dg-thin); and on the dark card a dg-noline dg-black has nothing round it.
   Closed shapes with no dg-hatch or dg-dots only: the kit paints neither a line in these nor a pattern over them, and the art reader refuses
   both (engine/models/diagram-art.js, docs/figures/art.md). */
.dg-black { --dg-fill: var(--dg-black); --dg-stroke: var(--wire); } /* near-black; the outline is ink: dark on the light card (one with the fill), light on the dark card */
.dg-shine { --dg-fill: var(--dg-shine); --dg-stroke: var(--dg-rim); } /* near-white; the outline is near-black in both themes, so it reads on a white card and on a pale object */
.dg-noline { --dg-stroke: initial; }
.dg-fill-0 { --dg-fill: var(--surface); }
.dg-fill-1 { --dg-fill: var(--dg-f1); }
.dg-fill-2 { --dg-fill: var(--dg-f2); }
.dg-fill-3 { --dg-fill: var(--dg-f3); }
.dg-fill-4 { --dg-fill: var(--dg-f4); }
.dg-fill-5 { --dg-fill: var(--dg-f5); }
.dg-fill-6 { --dg-fill: var(--dg-f6); }
.dg-warm { --dg-fill: var(--dg-warm); }
.dg-cool { --dg-fill: var(--dg-cool); }
.dg-water { --dg-fill: var(--dg-water); }
.dg-oxy { --dg-fill: var(--dg-oxy); }
.dg-deoxy { --dg-fill: var(--dg-deoxy); }
.dg-metal { --dg-fill: var(--dg-metal); }
.dg-skin { --dg-fill: var(--dg-skin); }
.dg-plant { --dg-fill: var(--dg-plant); }
.dg-live { --dg-fill: var(--dg-live); }
.dg-neutral { --dg-fill: var(--dg-neutral); }
.dg-earth { --dg-fill: var(--dg-earth); }
.dg-soft { opacity: 0.45; }
/* dg-arrow, dg-hatch and dg-dots are marker classes: the kit lays the pattern over the shape (three layers, see ui/figures/diagram.js) and, on a line,
   adds .dg-s--hatch or .dg-s--dots below. The property only names the cue for a reader of the styles. */
.dg-hatch { --dg-cue: hatch; }
.dg-dots { --dg-cue: dots; }

.dg-s {
  fill: var(--dg-fill, none);
  stroke: var(--dg-stroke, none);
  stroke-width: var(--dg-sw, 2.2px);
  stroke-dasharray: var(--dg-dash, none);
  stroke-linejoin: round;
  stroke-linecap: round;
}
.dg-s--fill { stroke: none; }
.dg-s--stroke { fill: none; }
/* A line has no inside: a `line`, a `polyline` and a `path` with an arrowhead are lines, and the kit says how each is stroked (it knows the
   classes of the shape and of the groups round it): .dg-s--ink in ink, .dg-s--tint in the colour of its fill class, neither for no stroke. */
.dg-s--line { fill: none; stroke: none; }
.dg-s--ink { stroke: var(--wire); }
.dg-s--tint { stroke: var(--dg-fill); }
/* The second cue of a line is a line style: dotted for dg-dots, dashed for dg-hatch (a pattern needs an inside). */
.dg-s--dots { stroke-dasharray: 0.1px 7px; }
.dg-s--hatch { stroke-dasharray: 9px 5px; stroke-linecap: butt; }

/* A pattern over a fill, in the card's colour over a strong fill and in ink over a pale one or none. */
.dg-ov { stroke: none; }
.dg-pat { stroke-width: 1.7px; }
.dg-pat--strong { stroke: var(--surface); }
.dg-pat--pale { stroke: var(--wire); }
.dg-dot { stroke: none; }
.dg-dot--strong { fill: var(--surface); }
.dg-dot--pale { fill: var(--wire); }
.dg-head { fill: var(--dg-fill, var(--wire)); stroke: none; } /* ink, or the fill class the kit gives it: the colour of its line */

/* ---- Leaders and badges --------------------------------------------------------------------------------------------
   A badge is joined to its anchor by a leader line in ink with a ring of the card's colour round it, so it reads over any fill; the end on the
   drawing is a small dot with the same ring. The number is read against its badge (data-on-fill). */
.dg-leader-halo { stroke: var(--surface); stroke-width: 5px; stroke-linecap: round; }
.dg-leader { stroke: var(--wire); stroke-width: 1.6px; stroke-linecap: round; }
.dg-pin-halo { fill: var(--surface); stroke: none; }
.dg-pin { fill: var(--wire); stroke: none; }
.dg-badge { fill: var(--accent); stroke: var(--surface); stroke-width: 2px; }
.dg-num { font-size: 13px; font-weight: 800; fill: var(--accent-text); font-family: inherit; font-variant-numeric: tabular-nums; }

/* ---- The list of a Learn figure ------------------------------------------------------------------------------------- */
.dg-parts { margin: 0.5rem 0 0; padding-left: 2.1rem; font-size: 0.9rem; line-height: 1.4; overflow-wrap: anywhere; }
.dg-parts li { margin: 0.15rem 0; padding-left: 0.2rem; }
.dg-parts li::marker { font-weight: 800; color: var(--accent); }
.dg-name { font-weight: 700; }
.dg-note { color: var(--muted); }
