/* Telemetry viewer: chart palette (single source for views + uPlot) and
   dark-theme overrides for the vendored uPlot stylesheet (uplot.css). */

:root {
  --tel-lap-a: #62a9ff; /* lap A: blue */
  --tel-lap-b: #f58b54; /* lap B: orange */
  --tel-delta: #199e70; /* time-delta trace: aqua */
  --tel-grid: rgba(255, 255, 255, 0.07);
  --tel-axis: #a0a0a0;
}

.tel-comparison-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 240px) minmax(0, 1fr); gap: 1rem; }
.tel-comparison-summary > * { min-width: 0; }
.tel-comparison-summary .laptime { font-size: clamp(1.5rem, 3vw, 2.25rem); }
.tel-picker { min-width: 0; max-width: 100%; }
.tel-picker select { width: 100%; max-width: 36rem; min-width: 0; }
.tel-picker label { min-width: 0; }
.tel-overview { display: flex; align-items: center; gap: 1.25rem; margin: 1rem 0; }
.tel-overview[hidden] { display: none; }
.tel-sectors { flex: 1; min-width: 0; }
.tel-sector-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.5rem; margin-top: 0.5rem; }
@media (max-width: 700px) {
  .tel-comparison-summary { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .tel-comparison-summary > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .tel-overview { flex-direction: column; align-items: stretch; }
  .tel-overview .tel-map { align-self: center; }
}

/* Legend / readout key: a short stroke of the series color (via currentColor). */
.tel-key {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.tel-key--dash {
  background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px);
}

/* uPlot on the dark surface */
.uplot {
  font-family: inherit;
  width: auto;
}

/* Drag-to-zoom selection: neon green so the region is unmistakable.
   Scoped under .uplot to outrank the vendored uplot.css rule, which loads
   after this file and would otherwise win with its near-invisible default. */
.uplot .u-select {
  background: rgba(188, 235, 33, 0.16);
  border: 1px solid var(--accent);
}

.uplot.u-hz .u-cursor-x {
  border-right: 1px solid rgba(255, 255, 255, 0.28); /* solid hairline crosshair */
}

.u-cursor-pt {
  box-shadow: 0 0 0 2px #0a0a0a; /* surface ring where hover points cross lines */
}

/* ---------- sector strip ---------- */

/* Equal-width targets keep timing labels legible at every track length. */
.tel-sector {
  min-width: 0;
  padding: 0.6rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--edge-strong);
  border-top: 3px solid var(--edge-strong);
  border-radius: calc(var(--radius) - 4px);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.tel-sector:hover { border-color: var(--ink-faint); }
.tel-sector:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tel-sector.is-active { border-color: var(--accent); background: var(--accent-soft); }
.tel-sector--a, .tel-sector--a:hover { border-top-color: var(--tel-lap-a); }
.tel-sector--b, .tel-sector--b:hover { border-top-color: var(--tel-lap-b); }

.tel-sector-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  color: var(--ink-muted);
}
/* Both labeled lap times remain readable; the border identifies the winner. */
.tel-sector-time {
  display: block;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--ink);
}

/* The gap, stated rather than left as subtraction between the two times.
   Sits under them with a hairline above, so a glance down the strip reads as
   one column of gaps. Colour is deliberately quiet: the border already shows
   who took the sector, and a loud red on a two-hundredth loss overstates it. */
.tel-sector-gap {
  display: block;
  margin-top: 0.2rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--edge);
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--ink-faint);
}
.tel-sector-gap.is-ahead { color: var(--tel-lap-a); }
.tel-sector-gap.is-behind { color: var(--tel-lap-b); }

/* Pedal toggles: quiet by default, lit when the trace is on. Deliberately
   small and beside the panel title, because they are a viewing preference,
   not a control anyone needs to find. */
.tel-toggle {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--edge-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.tel-toggle:hover { color: var(--ink-muted); border-color: var(--ink-faint); }
.tel-toggle.is-on { color: var(--ink); border-color: var(--accent-edge); background: var(--accent-soft); }
.tel-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- track map ---------- */

/* Supporting panel, never a hero: capped width, shrinks with the viewport. */
.tel-map {
  width: clamp(240px, 24vw, 360px);
  flex-shrink: 0;
  max-width: 100%;
}
.tel-map svg {
  display: block;
  width: 100%;
  height: 240px;
}

/* ---------- hover readout on the session-recap lap chart ---------- */

/* Lives inside uPlot's .u-over, which is already positioned, so it is clipped
   to the plot area and cannot spill out of the card. */
.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap;
  border: 1px solid var(--edge-strong);
  border-radius: calc(var(--radius) - 4px);
  background: var(--surface-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  line-height: 1.4;
}
/* Flipped under the point when a fast lap sits too near the top to fit above. */
.chart-tip.is-below { transform: translate(-50%, 12px); }
.chart-tip[hidden] { display: none; }

.chart-tip-lap { color: var(--ink-muted); }
.chart-tip-time { font-weight: 600; color: var(--ink); }
.chart-tip-valid { color: var(--pb); }
.chart-tip-invalid { color: var(--danger); }

.tel-map svg { overflow: hidden; }

.tel-setup-scroll { max-height: 28rem; overflow: auto; }
.tel-setup-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.tel-setup-table th, .tel-setup-table td { padding: 0.6rem; text-align: left; border-bottom: 1px solid var(--edge); overflow-wrap: anywhere; }
.tel-setup-table tbody th { font-weight: 400; color: var(--ink-muted); width: 45%; }
.tel-setup-table thead th { position: sticky; top: 0; background: var(--surface-2); }
.tel-setup-different { background: var(--warm-soft); }
