/* Depends on: calendar.css -- linked as separate <link>
   tags by every template that uses this file, NOT @import-ed here.
   @import is a serialized waterfall: the browser cannot discover an
   imported file until it has downloaded and parsed the one importing
   it, so this site's deepest chain (tokens -> nav -> calendar ->
   event_detail) cost four sequential round trips before first paint.
   Separate links are all visible in the initial HTML and download in
   parallel. Templates list dependencies first, so the cascade is
   unchanged -- see core/tests/test_template_lint.py, which fails if
   an @import is reintroduced here. */
/* calendar.css supplies the shell + .cal-status. Below is circuit-detail. */

/* ---------- Hero ---------- */
.circuit-hero {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-top: 24px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(175deg, var(--surface) 0%, var(--card-gradient-end) 100%);
}
.ch-track { flex: 0 0 300px; max-width: 300px; text-align: center; }
.ch-track img { width: 100%; height: auto; max-height: 190px; object-fit: contain; display: block; }
.ch-track svg { width: 100%; height: auto; }
.ch-track .track-illustrative { display: block; font-size: 9.5px; color: var(--text-tertiary); font-style: italic; margin-top: 6px; }

.ch-id { min-width: 0; }
.ch-eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.circuit-hero h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.01em; margin-top: 4px; }
.ch-loc { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-secondary); margin-top: 8px; }
.ch-loc svg { width: 15px; height: 15px; color: var(--text-tertiary); }
/* Headline numbers: one glowing outlined block, divided into cells. */
.ch-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 18px;
  border: 1px solid var(--accent-line); border-radius: 14px; overflow: hidden;
  background: linear-gradient(160deg, var(--accent-soft), transparent 70%);
  box-shadow: 0 0 26px -10px var(--accent);
}
.ch-stats div { padding: 12px 16px; border-left: 1px solid var(--line); }
.ch-stats div:first-child { border-left: none; }
.ch-stats b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; color: var(--text-primary); }
.ch-stats span { display: block; margin-top: 3px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); }
.ch-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.ch-record {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 100px;
  background: var(--gold-soft); border: 1px solid rgba(255,201,74,0.4); color: var(--gold);
  font-size: 13px;
}
.ch-record { flex-wrap: wrap; row-gap: 2px; max-width: 100%; }
.ch-record > * { white-space: nowrap; }
.ch-record svg { width: 16px; height: 16px; flex-shrink: 0; }
.ch-record span { font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; font-size: 10.5px; }
.ch-record b { color: var(--text-primary); font-weight: 800; }
.ch-record .chr-time { color: var(--gold); font-weight: 800; }
.ch-record .chr-days { color: var(--text-tertiary); font-weight: 600; font-size: 11px; }
.ch-record:hover b { color: var(--accent); }
.ch-legend {
  background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent);
}
.ch-legend .chr-time { color: var(--accent); }
.ch-gap { margin-top: 10px; font-size: 12.5px; color: var(--text-secondary); }
.ch-gap b { color: var(--text-primary); }
.ch-gap-val { color: var(--amber); font-weight: 700; }
.ch-gap-record { color: var(--gold); font-weight: 700; }

/* ---------- Sections ---------- */
.circuit-section { margin-top: 30px; }
.circuit-section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.circuit-section-head h2 { font-size: 18px; font-weight: 800; }
.circuit-section-head .sub { font-size: 12.5px; color: var(--text-tertiary); }

/* ---------- Layouts used this season ---------- */
.layout-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.layout-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 12px 12px 11px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.layout-card:hover { border-color: var(--accent-line); transform: translateY(-2px); }
.lc-track {
  height: 84px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
  padding: 6px;
}
.lc-track img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lc-track svg { width: 100%; height: 100%; }
.lc-label { font-size: 12.5px; font-weight: 700; margin-top: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-date { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.lc-pending { color: var(--amber); font-weight: 600; }

/* ---------- Lap records ---------- */
.record-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.record-table th {
  text-align: left;
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.record-table th.num, .record-table td.num { text-align: right; }
.record-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.record-table tr:last-child td { border-bottom: none; }
.record-table tbody tr:hover { background: var(--surface); }
.rec-pos {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text-secondary);
}
.rec-pos.p1 { background: var(--gold-soft); color: var(--gold); }
.rec-pos.p1 svg { width: 14px; height: 14px; }
.record-row { background: linear-gradient(90deg, var(--gold-soft), transparent 60%); }
.rec-driver a { font-weight: 700; }
.rec-driver a:hover { color: var(--accent); }
.rec-team { display: block; margin-top: 1px; font-size: 11px; font-weight: 600; color: var(--text-tertiary); }
.rec-time { font-weight: 700; }
.rec-time.record { color: var(--purple); }
.rec-event a { color: var(--text-secondary); }
.rec-event a:hover { color: var(--accent); }
/* Which session the lap came from ("Carrera 2"): a chip under the event name. */
.rec-session {
  display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent);
}
.rec-event a { display: block; }

/* ---------- Events at circuit ---------- */
.circuit-events { display: flex; flex-direction: column; gap: 8px; }
.ce-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 0.15s ease;
}
.ce-row:hover { border-color: var(--accent-line); }
/* The event's own photo, else the championship's logo -- same rule as the
   profile's Historial de carreras; no blank slot when neither exists. */
.ce-thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--line); background: var(--surface); }
.ce-thumb.logo { object-fit: contain; padding: 6px; }
@media (max-width: 480px) { .ce-thumb { width: 40px; height: 40px; } }
.ce-info { flex: 1; min-width: 0; }
.ce-top { display: flex; align-items: center; gap: 9px; }
.ce-name { font-size: 14px; font-weight: 700; }
.ce-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; }
.ce-tag {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 3px 8px;
  border-radius: 100px;
  flex-shrink: 0;
}
.ce-arrow { color: var(--text-tertiary); flex-shrink: 0; }
.ce-row:hover .ce-arrow { color: var(--accent); }

@media (max-width: 620px) {
  .circuit-hero { flex-direction: column; text-align: center; }
  .ch-track { flex-basis: auto; max-width: none; }
  .ch-loc { justify-content: center; }
  .ch-stats { grid-template-columns: repeat(2, 1fr); text-align: center; }
  .ch-stats div:nth-child(3) { border-left: none; }
  .ch-stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ch-badges { justify-content: center; }
  .record-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Ideal line -- the circuit's own record lap, colored by accel/brake */
/* Scoped to .ideal-line-wrap, not the bare .track-map-wrap the card also
   carries: the telemetry session page loads this file next to import.css,
   which owns .track-map-wrap for its own (interactive) maps. The two
   resets undo import.css's pointer cursor and touch-action:none, which
   would otherwise make these static maps swallow a phone's page scroll. */
/* The legend under the title, not beside it: beside it, a two-line legend
   squeezed "Línea ideal" into a word per line. The map sits in a card like
   every other block on the page instead of floating in empty space. */
.ideal-line-head { flex-direction: column; align-items: flex-start; gap: 4px; }
.ideal-line-head h2 { white-space: nowrap; }
.ideal-line-wrap { display: flex; justify-content: center; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ideal-line-wrap svg { display: block; max-width: 100%; height: auto; cursor: default; touch-action: auto; }
.ideal-line-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin: 0 2px; }
/* Kept in sync by hand with core.telemetry_analysis.build_ideal_line's
   ACCEL_COLOR/BRAKE_COLOR -- the SVG segments get their color inline from
   that same function, this is only the legend dots next to the heading. */
.ideal-line-dot.ideal-line-accel { background: #00e676; }
.ideal-line-dot.ideal-line-brake { background: #ff4d4d; }
.ideal-line-context-note { color: var(--text-tertiary); }
.ideal-line-note { margin: 6px 0 0; font-size: 11.5px; color: var(--text-tertiary); max-width: 520px; }
/* Every other real lap on file, faint and uncolored, drawn under the main
   line -- where this cloud spreads wide, drivers have used more of the
   track's width there; a single thread means everyone takes the same
   line. Not the physical track edges (see build_ideal_line's docstring). */
.ideal-line-context-trace { stroke: var(--text-tertiary); stroke-opacity: 0.6; }
.ideal-line-wrap svg { overflow: visible; }
.ideal-line-corner circle { fill: var(--ink); stroke: var(--line-hover); stroke-width: 1.5; }
.ideal-line-corner text {
  fill: var(--text-primary); font-size: 8px; font-weight: 800; text-anchor: middle;
  dominant-baseline: central; font-family: var(--font-mono, monospace);
}

/* Circuit sector leaderboards (Strava segments, for motorsport) */
.ideal-lap-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px; border-radius: 14px; margin-bottom: 12px;
  background: linear-gradient(160deg, rgba(0,230,118,0.12), rgba(0,230,118,0.02) 60%), var(--surface);
  border: 1px solid var(--accent-line);
}
.il-label { font-size: 13px; font-weight: 800; }
.il-sub { font-size: 11.5px; color: var(--text-tertiary); margin-top: 3px; max-width: 46ch; }
.il-time { font-size: 26px; font-weight: 800; color: var(--accent); flex-shrink: 0; }
.il-owners { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.il-owner {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px;
  border-radius: 100px; border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.il-owner:hover { border-color: var(--accent-line); color: var(--accent); }
.il-owner-label {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 800; color: var(--accent);
  background: var(--accent-soft); padding: 2px 6px; border-radius: 5px;
}
.sector-lb-table td.sector-best { color: var(--accent); font-weight: 800; }
@media (max-width: 480px) {
  .ideal-lap-banner { flex-direction: column; align-items: flex-start; }
}

/* Circuits directory (/circuitos/) */
.circuit-dir-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
  margin: 26px 0 60px;
}
.circuit-dir-card {
  display: block; padding: 18px; border-radius: 16px; color: inherit;
  border: 1px solid var(--line); background: linear-gradient(175deg, var(--surface) 0%, var(--card-gradient-end) 100%);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.circuit-dir-card:hover { border-color: var(--accent-line); transform: translateY(-2px); }
.cd-track {
  height: 100px; display: grid; place-items: center; background: var(--surface-2);
  border-radius: 10px; overflow: hidden; padding: 8px; margin-bottom: 12px;
}
.cd-track img, .cd-track svg { max-width: 100%; max-height: 100%; }
.cd-name { font-size: 15px; font-weight: 800; }
.cd-loc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.cd-record {
  display: flex; align-items: center; gap: 6px; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line-soft); font-size: 12.5px;
}
.cd-record svg { width: 13px; height: 13px; color: var(--gold); flex-shrink: 0; }
.cd-record-time { font-weight: 800; color: var(--gold); }
.cd-record-driver { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-record-empty { color: var(--text-tertiary); font-style: italic; }
.cd-stats { display: flex; gap: 12px; margin-top: 10px; font-size: 11px; color: var(--text-tertiary); }
