/* ============================================================
   FEATURE CSS: STATS
   Colours, fonts and corners all come from the active theme.
   ============================================================ */

.st-page { gap: var(--s-4); }

.st-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.st-tiles .stat { padding: var(--s-3) var(--s-2); text-align: center; }
.st-tiles .stat-value { font-size: 1.05rem; }
.st-tiles .stat-label { font-size: 0.64rem; }

/* ── Chips ────────────────────────────────────────────────── */
.st-chart-card { padding: var(--s-4); display: grid; gap: var(--s-3); }
.st-chart-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.st-chips { display: flex; gap: 4px; }
.st-chip {
  padding: 5px 11px; border: var(--border-w) solid var(--rim); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-dimmer);
  font-size: 0.72rem; font-weight: var(--body-weight-strong);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.st-chip:hover { color: var(--text); border-color: var(--rim-strong); }
.st-chip.is-active {
  color: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ── Line chart ───────────────────────────────────────────── */
.st-plot { touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.st-line { display: block; width: 100%; height: auto; overflow: visible; }
.st-grid { stroke: var(--rim); stroke-width: 1; stroke-dasharray: 2 4; }
.st-tick { fill: var(--text-dimmer); font-size: 9px; font-variant-numeric: tabular-nums; }
.st-cursor { stroke: color-mix(in srgb, var(--accent) 50%, transparent); stroke-width: 1; }
.st-path {
  fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: st-draw 0.9s var(--ease, ease-out) 0.05s forwards;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 60%, transparent));
}
.st-area { opacity: 0; animation: st-fade 0.7s ease-out 0.5s forwards; }
.st-dot {
  fill: var(--bg); stroke: var(--accent); stroke-width: 1.6;
  opacity: 0; animation: st-fade 0.3s ease-out calc(0.4s + var(--i) * 0.025s) forwards;
  transition: r 0.15s ease;
}
.st-dot.is-on { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
@keyframes st-draw { to { stroke-dashoffset: 0; } }
@keyframes st-fade { to { opacity: 1; } }
.st-chart-empty { padding: var(--s-6) 0; text-align: center; }

/* ── Selected workout (the finish popup's numbers) ────────── */
.st-detail { display: grid; gap: 6px; padding-top: var(--s-3); border-top: var(--border-w) solid var(--rim); }
.st-detail-score { display: flex; align-items: baseline; gap: 4px; }
.st-detail-score b {
  font-family: var(--font-display, inherit); font-weight: var(--display-weight, 700);
  font-size: calc(2.2rem * var(--display-scale, 1)); line-height: 1; color: var(--text); font-variant-numeric: tabular-nums;
}
.st-detail-score small { font-size: 0.8rem; color: var(--text-dimmer); }
.st-grade { margin-left: auto; font-size: 0.8rem; color: var(--text-dimmer); }
.st-grade i {
  font-style: normal; margin-left: 3px; font-size: 1.15rem; color: var(--gc);
  font-family: var(--font-display, inherit); font-weight: var(--display-weight, 700);
}
.st-detail-date { margin: 0; font-size: 0.72rem; color: var(--text-dimmer); }
.st-detail-stats { margin: 4px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.st-detail-stats b { display: block; font-size: 0.95rem; font-variant-numeric: tabular-nums; color: var(--text); }
.st-detail-stats span { display: block; margin-top: 2px; font-size: 0.68rem; color: var(--text-dimmer); }

/* ── Donuts ───────────────────────────────────────────────── */
.st-pies { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.st-pies > div { min-width: 0; display: flex; }
.st-pie { width: 100%; padding: var(--s-4) var(--s-3); display: grid; gap: var(--s-3); align-content: start; justify-items: center; }
.st-pie .section-label { justify-self: start; margin: 0; }
.st-pie-empty { padding: var(--s-4) 0; }

.st-donut { position: relative; width: min(100%, 132px); aspect-ratio: 1; }
.st-donut svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.st-donut circle { fill: none; stroke-width: 5.2; }
.st-donut-track { stroke: color-mix(in srgb, var(--text) 8%, transparent); }
.st-slice {
  stroke: var(--c); cursor: pointer; transition: opacity 0.2s ease, stroke-width 0.2s ease;
  animation: st-slice-in 0.8s var(--ease, ease-out) calc(var(--i) * 0.08s) backwards;
}
.st-slice.is-on { stroke-width: 6.6; }
.st-slice.is-dim { opacity: 0.28; }
@keyframes st-slice-in { from { stroke-dasharray: 0 100; opacity: 0; } }
.st-donut-in { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; pointer-events: none; }
.st-donut-in b { font-family: var(--font-display, inherit); font-weight: var(--display-weight, 700); font-size: 1.35rem; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.st-donut-in span { margin-top: 3px; font-size: 0.62rem; color: var(--text-dimmer); }

.st-legend { margin: 0; padding: 0; list-style: none; width: 100%; display: grid; gap: 2px; }
.st-legend-row {
  width: 100%; display: flex; align-items: center; gap: 7px; padding: 4px 6px;
  border: 0; border-radius: var(--r-sm); background: transparent; text-align: left;
  font-size: 0.72rem; color: var(--text-dim);
}
.st-legend-row i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.st-legend-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-legend-row b { font-variant-numeric: tabular-nums; color: var(--text); }
.st-legend-row.is-on { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }

.st-note { margin: 0; text-align: center; font-size: 0.7rem; color: var(--text-dimmer); }
.st-retry { align-self: center; }

/* ── Loading ──────────────────────────────────────────────── */
.st-skeleton { display: grid; gap: var(--s-3); padding: var(--s-5); }
.st-sk { border-radius: var(--r-md); background: color-mix(in srgb, var(--text) 7%, transparent); animation: st-pulse 1.3s ease-in-out infinite; }
.st-sk-tiles { height: 62px; } .st-sk-chart { height: 250px; } .st-sk-donuts { height: 210px; }
@keyframes st-pulse { 50% { opacity: 0.5; } }

/* Motion off / reduced: charts just appear. */
:root[data-motion="off"] .st-page *, :root[data-motion="reduced"] .st-page * { animation: none !important; transition: none !important; }
:root[data-motion="off"] .st-path, :root[data-motion="reduced"] .st-path { stroke-dashoffset: 0; }
:root[data-motion="off"] :is(.st-area, .st-dot), :root[data-motion="reduced"] :is(.st-area, .st-dot) { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .st-path, .st-area, .st-dot, .st-slice, .st-sk { animation: none; }
  .st-path { stroke-dashoffset: 0; } .st-area, .st-dot { opacity: 1; }
}
