/*
 * Maternity edition — chart grammar. Shared by every chart in assets/js/charts/.
 *
 * Charts draw SVG in a fixed 1000-unit-wide viewBox and use these classes for
 * type and ink; colours come from tokens via style="fill: var(--cat-emph)".
 * Change a rule here and every chart in the report, lab and design system
 * follows.
 */

.chart { position: relative; }
.chart > svg { display: block; width: 100%; height: auto; overflow: visible; outline: none; }
.chart > svg:focus-visible { outline: 2px solid var(--accent2); outline-offset: 4px; }

/* axes */
.c-base, .c-tick { stroke: var(--axis-ink); stroke-width: 1px; }
.c-grid { stroke: var(--chart-line); stroke-width: 1px; }
.c-grid.soft { stroke: rgba(var(--ink-rgb), .08); }

/* reference lines (medians, benchmarks, cohort averages) */
.c-ref { stroke: var(--ref-ink); stroke-width: 1px; stroke-dasharray: 3 4; opacity: .6; }
.c-ref.strong { stroke-dasharray: none; stroke-width: 1.25px; opacity: .5; }

/* hover crosshair band */
.c-cross { fill: rgba(var(--ink-rgb), .07); pointer-events: none; transition: x .11s linear; }
@media (prefers-reduced-motion: reduce) { .c-cross { transition: none; } }

/* marks */
.c-line { fill: none; stroke-width: 1.75px; stroke-linejoin: round; stroke-linecap: butt; }
.c-wash { opacity: .5; }
.c-ink { opacity: .22; }
.c-dot { stroke: var(--bg); stroke-width: 1.5px; }
.c-conn { stroke: rgba(var(--ink-rgb), .22); stroke-width: 2px; }

/* text */
.c-lbl {
  font-family: var(--font-mono);
  font-size: var(--fs-chart-label);
  font-weight: 300;
  letter-spacing: -.02em;
  fill: var(--label-ink);
}
.c-lbl.ref { font-weight: 400; fill: var(--ref-ink); }
.c-name {
  font-family: var(--font-mono);
  font-size: var(--fs-chart-name);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.c-cat {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  fill: rgba(var(--ink-rgb), .85);
}
.c-cat.muted { fill: var(--label-ink); }
.c-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  fill: var(--ink);
}
.c-val.muted { fill: var(--label-ink); }
.c-sub {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  fill: var(--label-ink);
}

.c-val.strong { font-size: 16px; font-weight: 600; }
.c-key {
  font-family: var(--font-mono);
  font-size: var(--fs-chart-label);
  letter-spacing: .02em;
  fill: var(--label-ink);
}

/* connectors and rows (dot plots, dumbbells) */
.c-link { stroke: rgba(var(--ink-rgb), .3); stroke-width: 1.5px; transition: stroke .15s; }
.c-hit { fill: transparent; }
.c-row { transition: opacity .15s; }
.c-row .c-dot { transform-box: fill-box; transform-origin: 50%; transition: scale .15s; }
.c-row.out .c-cat { fill: var(--ink); font-weight: 700; }
.c-row.out .delta { fill: rgba(var(--ink-rgb), .75); font-weight: 400; }
.c-row.hot .c-dot { scale: 1.35; }
.c-row.hot .c-link { stroke: rgba(var(--ink-rgb), .6); }
.c-row.hot .c-cat { fill: var(--ink); font-weight: 500; }

/* Narrow containers: keep labels readable when the viewBox scales down. */
@container (width <= 820px) {
  .c-name { font-size: 15px; }
  .c-lbl, .c-key { font-size: 14px; }
  .c-cat, .c-val { font-size: 17px; }
  .c-val.strong { font-size: 19px; }
}
.chart.compact .c-name { font-size: 11px; }
.chart.compact .c-lbl { font-size: 11px; }
/* csec-tiers' stacked phone layout: sizes in viewBox units, read at about a third */
.chart.ct-compact .c-cat { font-size: 38px; }
.chart.ct-compact .c-val.strong { font-size: 42px; }
.chart.ct-compact .c-lbl { font-size: 34px; }
.chart.ct-compact .c-link { stroke-width: 4px; }
.chart.ct-compact .c-dot { stroke-width: 3px; }

/* inline sparkline inside a data paragraph (<m-spark>) — scales with the text */
.spark { display: inline-block; height: .78em; margin: 0 .19em; vertical-align: -.19em; }
.spark svg { display: block; width: var(--spark-w, 3.6em); height: 100%; overflow: visible; }
.spark.trend svg { width: 3.2em; }
.spark .stroke { fill: none; stroke: var(--ink); stroke-width: 1.4px; stroke-linejoin: round; stroke-linecap: round; }
.spark .pair { fill: none; stroke-width: 1.4px; stroke-linejoin: round; }
.spark .rule { stroke: rgba(var(--ink-rgb), .28); stroke-width: 1px; }

/* ---- charts keep their original type ---------------------------------------
 * Inside a chart's drawing area (figure, scrolly stage, reel), the display and
 * sans roles resolve to the report's original faces, Newsreader and Inter
 * (tokens.css --font-chart-*); mono stays Azeret Mono. The prose around a chart
 * (figure title, scrolly steps, captions) uses the page's GT Alpina and
 * Passenger Sans. kit/export.js embeds the same three chart faces in a PNG. */
.fig-plot, .sc-plot, .rl-plot {
  --font-display: var(--font-chart-display);
  --font-sans: var(--font-chart-sans);
  font-family: var(--font-sans);
  font-synthesis-weight: auto;   /* the chart faces are variable: real weights, nothing to synthesise */
}
