/* Movement pattern color tokens — categorical identifiers for archetype
   charts. All hues avoid the warm load ladder (25-95°) and the reserved
   readiness green (145°) so they never overlap with severity signals. */
:root {
  --pattern-push:            oklch(55% 0.18 250);  /* blue */
  --pattern-pull:            oklch(55% 0.18 300);  /* violet */
  --pattern-squat:           oklch(52% 0.18 195);  /* deep cyan */
  --pattern-hinge:           oklch(55% 0.18 170);  /* teal */
  --pattern-carry:           oklch(52% 0.16 220);  /* cyan-blue */
  --pattern-locomotion:      oklch(55% 0.18 120);  /* lime-green */
  --pattern-rotation:        oklch(52% 0.18 345);  /* rose */
  --pattern-plyometric:      oklch(50% 0.18 330);  /* pink */
  /* machine/self_propelled sit either side of locomotion's 120° -- they're
     the other two ground-covering families from the same cardio split --
     but stop short of 145° so neither reads as the reserved readiness
     green above. */
  --pattern-machine:         oklch(58% 0.17 100);  /* olive-green */
  --pattern-self_propelled:  oklch(52% 0.19 133);  /* deep spring green */
}

/* Training Analytics */

.analytics-banner {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.analytics-banner-warning {
  background: color-mix(in oklch, var(--load-light) 35%, white);
  border: 1px solid color-mix(in oklch, var(--load-moderate) 45%, white);
  color: oklch(35% 0.08 85);
}

.analytics-panel-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

@media (max-width: 768px) {
  .analytics-heatmap-row {
    grid-template-columns: 6rem repeat(4, 1fr);
  }

  .analytics-heatmap-label {
    font-size: 0.6875rem;
  }

  .analytics-table {
    font-size: 0.75rem;
  }

  .analytics-table th,
  .analytics-table td {
    padding: 0.25rem 0.375rem;
  }
}

/* Cards */
.analytics-card-subtitle {
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0.75rem 0 0.375rem;
}

/* Badges */
.analytics-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Table */
.analytics-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.analytics-table th {
  text-align: left;
  font-weight: 600;
  padding: 0.375rem 0.5rem;
  border-bottom: 2px solid oklch(90% 0 0);
}

.analytics-table td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid oklch(94% 0 0);
}

/* Diverging balance bars */
.analytics-balance-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.analytics-diverging-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.analytics-diverging-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 500;
}

.analytics-diverging-end-label {
  min-width: 4rem;
  color: oklch(45% 0 0);
}

.analytics-diverging-end-label:last-child {
  text-align: right;
}

.analytics-diverging-value {
  font-weight: 600;
}

.analytics-diverging-bar {
  position: relative;
  height: 8px;
  background: oklch(92% 0 0);
  border-radius: 4px;
}

.analytics-diverging-zone {
  position: absolute;
  left: 30%;
  right: 30%;
  top: 0;
  bottom: 0;
  background: color-mix(in oklch, var(--load-rest) 18%, white);
  border-radius: 4px;
}

.analytics-diverging-marker {
  position: absolute;
  top: -2px;
  left: var(--marker, 50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translateX(-50%);
}

.analytics-diverging-bar-balanced {
  background: var(--load-rest);
}

.analytics-diverging-bar-imbalanced {
  background: var(--load-max);
}

/* Variety card */
.analytics-variety-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 0.5rem;
}

.analytics-variety-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.analytics-variety-number {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.analytics-variety-label {
  font-size: 0.75rem;
  color: oklch(55% 0 0);
  text-transform: uppercase;
}

.analytics-repeat-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8125rem;
}

.analytics-repeat-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid oklch(94% 0 0);
}

.analytics-repeat-list li:last-child {
  border-bottom: none;
}

/* Archetype heat map */
.analytics-heatmap {
  display: flex;
  flex-direction: column;
}

.analytics-heatmap-row {
  display: grid;
  grid-template-columns: 10rem repeat(4, 1fr);
  padding: 0.125rem 0;
  align-items: center;
}

.analytics-heatmap-label {
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.5rem;
}

.analytics-heatmap-group-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: oklch(55% 0 0);
  padding: 0.375rem 0 0.125rem;
  border-bottom: 1px solid oklch(94% 0 0);
}

.analytics-heatmap-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 1.25rem;
}

.analytics-heatmap-week-label {
  font-size: 0.6875rem;
  color: oklch(55% 0 0);
}

.analytics-heatmap-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.analytics-heatmap-dot-low {
  background: color-mix(in oklch, var(--accent-cycle) 35%, white);
}

.analytics-heatmap-dot-medium {
  background: color-mix(in oklch, var(--accent-cycle) 70%, white);
}

.analytics-heatmap-dot-high {
  background: var(--accent-cycle);
}

/* Heatmap row zebra striping and hover highlight */
.analytics-heatmap-row-data {
  cursor: default;
}

.analytics-heatmap-row-even {
  background-color: white;
}

.analytics-heatmap-row-odd {
  background-color: oklch(97% 0 0);
}

.analytics-heatmap-row-data:hover {
  background-color: oklch(96% 0.02 250);
}

/* Sticky first column for long element name lists */
.analytics-heatmap-sticky-col {
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 1;
}

/* ProgressionsPanel: swimlanes */
.analytics-swimlanes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.analytics-swimlane {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.analytics-swimlane-label {
  width: 6rem;
  font-size: 0.8125rem;
  font-weight: 500;
  flex-shrink: 0;
}

.analytics-swimlane-track {
  display: flex;
  flex: 1;
  gap: 2px;
}

.analytics-swimlane-cell {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 1.5rem;
}

.analytics-heat-cell {
  border-radius: 4px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  min-height: 1.6rem;
}

.analytics-heat-cell--empty {
  background: oklch(96% 0 0);
}

.analytics-heat-cell--tier-1 {
  background: oklch(90% 0.05 250);
  color: oklch(25% 0.05 250);
}

.analytics-heat-cell--tier-2 {
  background: oklch(78% 0.09 250);
  color: oklch(22% 0.06 250);
}

.analytics-heat-cell--tier-3 {
  background: oklch(62% 0.13 250);
  color: white;
}

.analytics-heat-cell--tier-4 {
  background: oklch(48% 0.15 250);
  color: white;
}

.analytics-swimlane-axis-label {
  font-size: 0.7rem;
  color: oklch(45% 0 0);
  white-space: nowrap;
  overflow: visible;
}

/* ProgressionsPanel: progression cards */
.analytics-progression-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.analytics-progression-item {
  padding: 0.75rem;
  background: color-mix(in oklch, var(--accent-cycle) 3%, white);
  border: 1px solid color-mix(in oklch, var(--accent-cycle) 12%, white);
  border-radius: 0.375rem;
}

.analytics-progression-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.analytics-progression-icon {
  font-size: 1rem;
  color: var(--load-rest);
}

.analytics-progression-name {
  font-weight: 600;
  font-size: 0.875rem;
  flex: 1;
}

.analytics-progression-desc {
  font-size: 0.8125rem;
  color: oklch(40% 0 0);
  margin: 0.25rem 0;
}

.analytics-progression-dates {
  font-size: 0.75rem;
  color: oklch(55% 0 0);
  margin: 0;
}

/* ProgressionsPanel: stale skill groups */
.analytics-stale-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.analytics-stale-item {
  padding: 0.5rem 0.75rem;
  background: color-mix(in oklch, var(--load-light) 15%, white);
  border: 1px solid color-mix(in oklch, var(--load-moderate) 35%, white);
  border-radius: 0.375rem;
}

.analytics-stale-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.analytics-stale-name {
  font-weight: 500;
  font-size: 0.875rem;
  flex: 1;
}

/* Badge variants for progression signals — categorical identifiers.
   Volume/load/complexity use cool hues (teal/blue/violet) so none of them
   claim the warm load ladder or the reserved green. */
.analytics-badge-volume {
  background: color-mix(in oklch, oklch(55% 0.12 200) 18%, white);
  color: oklch(35% 0.1 200);
  font-size: 0.6875rem;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  font-weight: 600;
}

.analytics-badge-load {
  background: color-mix(in oklch, var(--accent-cycle) 18%, white);
  color: var(--accent-cycle);
  font-size: 0.6875rem;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  font-weight: 600;
}

.analytics-badge-complexity {
  background: color-mix(in oklch, var(--accent-skill) 18%, white);
  color: var(--accent-skill);
  font-size: 0.6875rem;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  font-weight: 600;
}

.analytics-filters {
  margin: 0.5rem 0;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.analytics-hint {
  color: var(--muted-text-color, #6b7280);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  max-width: 60ch;
}

/* The gap sentences under a coverage group: the hint's voice at the full
   panel width, since a half-width panel already bounds the line. */
.analytics-coverage-note {
  color: var(--muted-text-color, #6b7280);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.analytics-term {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: help;
}

.analytics-trend {
  font-size: 0.75rem;
  cursor: help;
}

.analytics-trend-up {
  color: oklch(55% 0.15 145);
}

.analytics-trend-down {
  color: oklch(55% 0.18 30);
}

.analytics-trend-flat {
  color: oklch(60% 0 0);
}

.analytics-coactivation-grid {
  display: grid;
  grid-template-columns: minmax(7rem, auto) repeat(var(--coactivation-columns), minmax(2.4rem, 1fr));
  gap: 2px;
  align-items: stretch;
  overflow-x: auto;
}

.analytics-coactivation-col-label,
.analytics-coactivation-row-label {
  font-size: 0.72rem;
  color: oklch(35% 0 0);
  padding: 0.2rem;
  align-self: center;
}

.analytics-coactivation-col-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  justify-self: center;
}

.analytics-coactivation-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
}

.analytics-coactivation-cell--blank {
  background: transparent;
}

.analytics-variety-low {
  color: oklch(55% 0.18 30);
  font-weight: 600;
}

/* Sentences flow two-up so the card uses its width and stays short;
   each stays a readable measure. */
.analytics-narrative {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  /* min() caps the column at the card's own width: a bare 28rem floor is
     448px, wider than a phone card, and the sentences ran off the edge. */
  grid-template-columns: repeat(auto-fit, minmax(min(28rem, 100%), 1fr));
  gap: 0.6rem 2rem;
}

.analytics-mix-uncached {
  font-size: 0.75rem;
  color: oklch(55% 0.12 70);
  margin: 0 0 0.5rem;
}

/* Cycle filter menu: fixed width whatever the window offers, so changing the
   window cannot rewrap the toolbar and shove the tabs down the page. */
.filter-menu {
  position: relative;
  display: inline-block;
}

.filter-menu-summary {
  cursor: pointer;
  list-style: none;
  min-width: 8rem;
  text-align: left;
}

.filter-menu-summary::-webkit-details-marker {
  display: none;
}

.filter-menu-summary::after {
  content: " ▾";
}

.filter-menu-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.25rem);
  left: 0;
  min-width: 14rem;
  max-height: 20rem;
  overflow-y: auto;
  padding: 0.25rem;
  border: 1px solid var(--card-border, oklch(90% 0 0));
  border-radius: 6px;
  /* Same surface and ink as .analytics-card: the page runs dark, so a panel
     that sets a light background must set its own dark ink or it inherits the
     theme's light text and disappears. */
  background: var(--card-bg, white);
  color: oklch(15% 0 0);
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.35);
}

.filter-menu-option {
  display: block;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}

.filter-menu-option:hover {
  background: oklch(95% 0 0);
}

.filter-menu-option-selected {
  background: oklch(92% 0.05 250);
  color: oklch(25% 0.1 250);
  font-weight: 600;
}

/* Says a tab reads its own fixed span rather than the window above it. */
.analytics-scope-note {
  /* Spans the panel grid's row above the tab's panels. */
  grid-column: 1 / -1;
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: oklch(60% 0 0);
}

/* Direction panel: one card per axis, a sparkline row per item showing the
   window's share/count against the prior window. */
.analytics-direction-caption {
  margin-bottom: 0.5rem;
}

.analytics-direction-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.8125rem;
}

.analytics-direction-label {
  /* A grid item's min-width is auto, so without this the label widens
     its track instead of truncating. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-direction-share {
  font-variant-numeric: tabular-nums;
  color: oklch(45% 0 0);
  font-size: 0.75rem;
}

.analytics-direction-delta {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3rem;
  text-align: right;
}

.analytics-direction-delta-up {
  color: var(--load-moderate);
}

.analytics-direction-delta-down {
  color: var(--load-rest);
}

.analytics-direction-delta-flat {
  color: oklch(60% 0 0);
}

.analytics-direction-stale {
  font-size: 0.75rem;
  color: oklch(55% 0 0);
  margin: 0.5rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid oklch(92% 0 0);
}

/* Sparkline: a bare trend polyline, no axes or grid. Tone maps to a stroke
   colour once here so callers pass a token, never a colour. */
.sparkline {
  width: 56px;
  height: 14px;
}

.analytics-table .sparkline {
  vertical-align: middle;
}

.sparkline-line {
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-phosphagen {
  stroke: var(--energy-phosphagen);
}

.sparkline-glycolytic {
  stroke: var(--energy-glycolytic);
}

.sparkline-oxidative {
  stroke: var(--energy-oxidative);
}

.sparkline-skill {
  stroke: var(--energy-skill);
}

.sparkline-neutral {
  stroke: var(--blueish-gray);
}

@media (max-width: 768px) {
  .analytics-direction-row {
    grid-template-columns: 1fr auto auto;
  }

  .analytics-direction-row .sparkline {
    display: none;
  }
}
