/* ==========================================================================
   Charts — mark specs follow the dataviz standard:
   2px lines · ≤24px bars with 4px rounded data-ends · ≥8px markers with a
   2px surface ring · 10% area washes · hairline solid gridlines · recessive axes
   ========================================================================== */

.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; display: block; }

/* Recessive grid & axes */
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text {
  fill: var(--text-3);
  font-size: 11px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;   /* columns of numbers align */
}

/* Marks */
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .10; }                       /* a wash, never a block */
.chart .bar  { transition: opacity var(--t-fast) var(--ease); }
.chart .dot  { stroke: var(--surface); stroke-width: 2; }  /* 2px surface ring */

.chart .bar:hover, .chart .slice:hover { opacity: .82; }

/* Draw-in animations */
.chart .line.animate {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: draw 1.1s var(--ease-out) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.chart .area.animate { animation: fade-up .9s var(--ease-out) .2s backwards; }
@keyframes fade-up { from { opacity: 0; } to { opacity: .10; } }

.chart .bar.animate { animation: grow .7s var(--ease-out) backwards; transform-origin: bottom; }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Crosshair + hover layer */
.chart .crosshair { stroke: var(--border-2); stroke-width: 1; pointer-events: none; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .focus-dot { pointer-events: none; }

.chart-tip {
  position: absolute;
  z-index: 20;
  min-width: 132px;
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--e-3);
  font-size: var(--fs-xs);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity var(--t-fast) var(--ease);
}
.chart-tip.is-on { opacity: 1; }
.chart-tip .tip-label { color: var(--text-2); font-weight: var(--fw-medium); }
.chart-tip .tip-row { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-2); }
.chart-tip .tip-key { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.chart-tip .tip-name { color: var(--text-2); }
.chart-tip .tip-val { margin-left: auto; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }

/* Legend — always present for ≥2 series; identity never by colour alone */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  margin-top: var(--s-4);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-2);          /* text wears text tokens, never the series colour */
}
.legend-key { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend-key.is-line { height: 3px; width: 16px; border-radius: 2px; }

/* Progress ring */
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-track { fill: none; stroke: var(--chart-track); }
.ring .ring-fill {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.1s var(--ease-out);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.ring-value { font-size: 1.5rem; font-weight: var(--fw-bold); letter-spacing: -.03em; line-height: 1.1; }
.ring-label { font-size: var(--fs-2xs); color: var(--text-2); margin-top: 2px; }

/* On a gradient card the ink flips to white — text tokens would vanish. */
.card-grad .ring-value { color: #fff; }
.card-grad .ring-label { color: rgba(255, 255, 255, .85); }

/* Sparkline */
.spark { display: block; width: 100%; height: 40px; }
.spark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Table view — the relief channel that keeps values reachable */
.chart-table-toggle {
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-weight: var(--fw-medium);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-xs);
}
.chart-table-toggle:hover { background: var(--surface-3); color: var(--text); }
.chart-table { margin-top: var(--s-4); max-height: 240px; overflow: auto; }
.chart-table table { font-size: var(--fs-xs); }
.chart-table th, .chart-table td { padding: var(--s-2) var(--s-3); }

/* Body diagram */
.body-map { max-width: 260px; margin: 0 auto; }
.body-map .region {
  fill: var(--brand-100);
  stroke: var(--brand-300);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill var(--t-fast) var(--ease), stroke var(--t-fast) var(--ease);
}
.body-map .region:hover { fill: var(--brand-300); }
.body-map .region[aria-pressed="true"] { fill: var(--brand-600); stroke: var(--brand-800); }
.body-map .region:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
