/* Charts.
 *
 * Every chart is SVG rendered by assets/js, reserves its box with aspect-ratio
 * so mounting shifts nothing, and ships an accessible data table behind a
 * disclosure. Chart type is the same system as prose type -- Plex Sans for
 * labels, tabular figures everywhere a number sits next to another number.
 */

.chart {
  margin-block: 1.5rem;
}

/* The box is reserved before the SVG exists. Without this the page reflows on
 * mount and the CLS budget is gone. */
.chart__frame {
  aspect-ratio: var(--chart-ratio, 16 / 9);
  width: 100%;
  contain: layout paint;
}

@media (max-width: 40rem) {
  .chart__frame {
    aspect-ratio: var(--chart-ratio-sm, 4 / 3);
  }
}

.chart__frame svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart__caption {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: var(--measure);
  margin-block-start: 0.75rem;
}

.chart__title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-block-end: 0.25rem;
}

/* Axes, gridlines, ticks ------------------------------------------------- */

.axis line,
.axis path {
  stroke: var(--axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.axis text {
  fill: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
}

.gridline {
  stroke: var(--rule);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

/* Series ----------------------------------------------------------------- */

/* Colour is never the only signal: each series also carries a dash pattern and
 * a direct label at the end of its line. */
.series {
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series--dtc {
  stroke: var(--series-dtc);
  stroke-dasharray: 6 4;
}

.series--token {
  stroke: var(--series-token);
  stroke-dasharray: none;
}

.series-label {
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-sans);
}

.series-label--dtc {
  fill: var(--series-dtc);
}

.series-label--token {
  fill: var(--series-token);
}

.area--dtc {
  fill: var(--series-dtc);
  opacity: 0.1;
}

.area--token {
  fill: var(--series-token);
  opacity: 0.12;
}

/* Annotation ------------------------------------------------------------- */

.annotation line {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.annotation text {
  fill: var(--text);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
}

/* Data table disclosure -------------------------------------------------- */

.chart__data {
  margin-block-start: 0.75rem;
  font-size: var(--text-sm);
}

.chart__data > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  padding-block: 0.35rem;
  min-height: 2.25rem;
  display: flex;
  align-items: center;
}

.chart__data > summary:hover {
  color: var(--accent-strong);
}

.chart__data[open] > summary {
  margin-block-end: 0.5rem;
}

/* Stats ------------------------------------------------------------------ */

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat__value {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.015em;
}

.stat__label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
