/* ============================================================
   RACE ARENA — analysis.css
   Analysis tab: telemetry charts + resizable track-map side panel
   ============================================================ */

/* ── LAYOUT: charts (scroll) | resizer | map panel ───────── */
.analysis-body {
  flex: 1;
  min-height: 0;
  display: flex;
  --map-width: 380px;        /* set from JS when the panel is resized */
}

/* ── TRACK MAP PANEL ─────────────────────────────────────── */
.analysis-map {
  width: var(--map-width);
  min-width: 260px;
  max-width: 60%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg);
}
.track-canvas-wrap {
  aspect-ratio: 1 / 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}
#trackCanvas { max-width: 100%; max-height: 100%; }

.track-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border);
}
.speed-scale { display: flex; flex-direction: column; gap: 4px; }
.speed-gradient {
  height: 8px;
  background: linear-gradient(to right, #0040ff, #00c4ff, #00e076, #ffd700, #ff6b35, #e84c1e);
}
.speed-scale-labels {
  display: flex;
  flex-direction: row-reverse;      /* DOM order is max, mid, min */
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--silver);
  font-variant-numeric: tabular-nums;
}
#trackLapLegend { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-item span { font-weight: 600; }
.legend-swatch { width: 16px; height: 3px; flex-shrink: 0; }
.track-legend-hint { font-size: 13px; color: var(--muted2); line-height: 1.5; }

/* ── RESIZER — drag the map panel's edge ─────────────────── */
.map-resizer {
  width: 9px;
  margin: 0 -4px;
  flex-shrink: 0;
  cursor: col-resize;
  position: relative;
  z-index: 5;
  touch-action: none;
}
.map-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 3px;
  width: 3px;
  height: 36px;
  transform: translateY(-50%);
  background: var(--border2);
  transition: background 0.15s, height 0.15s;
}
.map-resizer:hover::after,
.map-resizer:focus-visible::after,
.analysis-body.is-resizing .map-resizer::after { background: var(--ink); height: 56px; }
.map-resizer:focus-visible { box-shadow: none; }
.analysis-body.is-resizing { cursor: col-resize; user-select: none; }

/* ── CHARTS ──────────────────────────────────────────────── */
.charts-grid {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 8px 24px 24px;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
}
.chart-card {
  border-top: 1px solid var(--border);
  padding: 18px 0 10px;
  display: flex;
  flex-direction: column;
}
.chart-card:first-child { border-top: none; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-title {
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-unit {
  font-family: var(--font);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 14px;
  color: var(--muted2);
}
.chart-container { position: relative; height: 160px; }
.chart-card.wide .chart-container { height: 180px; }

/* ── NARROW: map on top, smaller ─────────────────────────── */
@media (max-width: 900px) {
  .analysis-body { flex-direction: column-reverse; }
  .map-resizer { display: none; }
  .analysis-map { width: auto; min-width: 0; max-width: none; border-left: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow: visible; }
  .track-canvas-wrap { aspect-ratio: auto; height: 200px; flex: 1; }
  .track-legend { width: 170px; border-top: none; border-left: 1px solid var(--border); padding: 12px 14px; }
  .track-legend-hint { display: none; }
  .speed-scale-labels { font-size: 11.5px; white-space: nowrap; gap: 6px; }
  .charts-grid { padding: 4px 16px 24px; }
}

/* ── LINE COLOURING TOGGLE ───────────────────────────────── */
.map-mode { display: flex; align-items: center; gap: 4px; }
.map-mode .section-label { margin-right: 8px; }
.map-mode-btn {
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 10px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.map-mode-btn.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.speed-scale[hidden] { display: none; }
