/* ═══════════════════════════════════════════════════
   TrackLab — Individual Race Page
   Loaded only on /races/<venue>/<date>/<time>/
   ═══════════════════════════════════════════════════ */

.race-page { max-width: 960px; margin: 0 auto; padding-bottom: 40px; }

/* ═══ Race Header ═══ */
.race-header { margin-bottom: 20px; }

.rh-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 14px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.rh-venue {
  font-family: 'Outfit', sans-serif; font-weight: 900;
  font-size: 32px; letter-spacing: -0.03em; line-height: 1.05;
}
.rh-date-time { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.rh-date-time time { font-weight: 600; color: var(--text-primary); }
.rh-race-name {
  font-family: 'Outfit', sans-serif; font-weight: 700;
  font-size: 17px; color: var(--accent-amber); margin-top: 4px;
}

.rh-status-block { text-align: right; flex-shrink: 0; }
.rh-status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600;
  padding: 5px 12px; border-radius: 8px; letter-spacing: 0.04em;
}
.rh-status-badge.upcoming {
  background: none; border: none;
  color: var(--text-muted); padding: 0;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
}
.rh-status-badge.live {
  background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.25);
  color: var(--accent-red);
}
.rh-status-badge.resulted {
  background: rgba(100,116,139,0.08); border: 1px solid rgba(100,116,139,0.2);
  color: var(--text-secondary);
}
.rh-status-badge .dot {
  width: 5px; height: 5px; border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}
.rh-status-badge.live .dot { background: var(--accent-red); }
.rh-countdown {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  margin-top: 4px; line-height: 1;
}
.rh-countdown-label { font-size: 10px; color: var(--text-muted); }

.rh-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.rh-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px; font-size: 12px;
  color: var(--text-secondary);
}
.rh-pill strong { color: var(--text-primary); font-weight: 600; }


.rh-course-note {
  font-size: 13px; color: var(--accent-amber);
  font-style: italic; margin-top: 8px;
}

/* ═══ Top Pick Callout ═══ */
.top-pick-callout {
  background: var(--bg-card); border: 1px solid rgba(200,255,0,0.15);
  border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 24px; position: relative; overflow: hidden;
  transition: all 0.2s;
}
.top-pick-callout:hover {
  border-color: rgba(200,255,0,0.3);
  transform: translateY(-1px);
}
.top-pick-callout::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-lime), var(--accent-green));
}
.tpc-header {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-lime); margin-bottom: 10px;
}
.tpc-body { display: flex; align-items: center; gap: 14px; }
.tpc-silk {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.tpc-silk img { width: 100%; height: 100%; object-fit: contain; }
.tpc-info { flex: 1; min-width: 0; }
.tpc-name {
  font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 20px;
  letter-spacing: -0.02em; display: flex; align-items: center; gap: 6px;
}
.tpc-name a { color: inherit; text-decoration: none; transition: color 0.15s; }
.tpc-name a:hover { color: var(--accent-lime); }
.tpc-connections { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.tpc-connections a { color: var(--text-secondary); text-decoration: none; transition: color 0.15s; }
.tpc-connections a:hover { color: var(--text-primary); }
.tpc-score {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 40px;
  color: var(--accent-lime); line-height: 1; flex-shrink: 0;
}
.tpc-tags { display: flex; gap: 5px; margin-top: 10px; flex-wrap: wrap; }
.tpc-tag {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 6px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  color: var(--text-secondary);
}
.tpc-tag.green { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.15); color: var(--accent-green); }
.tpc-tag.value { background: rgba(200,255,0,0.08); border-color: rgba(200,255,0,0.15); color: var(--accent-lime); }

/* ═══ Content Grid ═══ */
.content-grid {
  display: grid; grid-template-columns: 1fr 260px;
  gap: 20px; align-items: start;
}
.main-col { min-width: 0; }
.section-heading {
  font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 14px;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-heading::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ═══ Runner Table ═══ */
.race-page .runner-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 24px;
}
.race-page .runner-table thead th {
  text-align: left; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
}
.race-page .runner-table thead th.right { text-align: right; }
.race-page .runner-table thead th.center { text-align: center; }
.race-page .runner-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.1s;
}
.race-page .runner-table tbody tr:last-child { border-bottom: none; }
.race-page .runner-table tbody tr:hover { background: var(--bg-card-hover); }

/* Clickable runner rows with insights */
.race-page .runner-table tbody tr.has-insight { cursor: pointer; }

/* Insight sub-row — hidden by default, expand on click */
.race-page .runner-table tbody tr.insight-row {
  border-bottom: none;
}
.race-page .runner-table tbody tr.insight-row:hover { background: transparent; }
.race-page .runner-table tbody tr.insight-row td { padding: 0; }
.race-page .runner-table tbody tr.insight-row .insight-box {
  max-height: 0; opacity: 0; overflow: hidden;
  padding: 0; margin: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease, margin 0.3s ease;
}
.race-page .runner-table tbody tr.insight-row.visible .insight-box {
  max-height: 200px; opacity: 1;
  padding: 8px 12px; margin: 0;
}
.race-page .runner-table tbody tr.insight-row .insight-box {
  background: rgba(59,130,246,0.04);
  border-left: 3px solid var(--accent-blue);
  border-radius: 0 6px 6px 0;
}
.race-page .runner-table tbody tr.insight-row .ib-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent-blue); margin-bottom: 2px;
}
.race-page .runner-table tbody tr.insight-row .insight-box p {
  font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin: 0;
}
.race-page .runner-table tbody tr.insight-row .ib-markers {
  list-style: none; margin: 6px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.race-page .runner-table tbody tr.insight-row .ib-markers li {
  font-size: 10px; font-weight: 600; color: var(--accent-blue);
  background: rgba(59,130,246,0.08); padding: 2px 8px; border-radius: 10px;
}
.race-page .runner-table tbody tr.top-runner { background: rgba(200,255,0,0.02); }
.race-page .runner-table tbody tr.top-runner:hover { background: rgba(200,255,0,0.04); }
.race-page .runner-table td {
  padding: 10px 12px; font-size: 13px; vertical-align: middle;
}

/* Cloth + silk */
.r-cloth { display: flex; align-items: center; gap: 8px; }
.r-silk {
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 11px; color: #fff;
  flex-shrink: 0;
}
.r-silk img { width: 100%; height: 100%; object-fit: contain; }

/* Horse name */
.r-horse-name { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 14px; }
.r-horse-name a { color: inherit; text-decoration: none; transition: color 0.15s; }
.r-horse-name a:hover { color: var(--accent-lime); }
.r-age-weight { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* Connections */
.r-connection { font-size: 12px; color: var(--text-muted); }
.r-connection a { color: var(--text-secondary); }
.r-connection a:hover { color: var(--text-primary); }

/* Score */
.r-score {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 18px;
  text-align: center;
}
.r-score.s-great { color: var(--score-great, #22c55e); }
.r-score.s-good { color: var(--score-good, #84cc16); }
.r-score.s-mid { color: var(--score-mid, #f59e0b); }
.r-score.s-low { color: var(--score-low, #ef4444); }

/* Odds */
.r-odds {
  font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 13px;
  text-align: right;
}

/* Edge label */
.r-edge {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 4px; text-align: center; white-space: nowrap;
}
.r-edge.great { background: rgba(34,197,94,0.12); color: var(--accent-green); }
.r-edge.good { background: rgba(132,204,22,0.12); color: var(--score-good, #84cc16); }
.r-edge.empty { visibility: hidden; }

/* ═══ Sidebar ═══ */
.sidebar-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 14px;
}
.sc-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 13px;
  color: var(--text-secondary);
}
.sc-body { padding: 14px; }

/* Conditions list */
.cond-list { display: flex; flex-direction: column; gap: 8px; }
.cond-row { display: flex; justify-content: space-between; font-size: 13px; }
.cond-key { color: var(--text-muted); }
.cond-val { color: var(--text-primary); font-weight: 500; text-align: right; }
.cond-val .desc { color: var(--text-muted); font-weight: 400; font-size: 11px; display: block; }

/* Related races */
.related-list { display: flex; flex-direction: column; gap: 4px; }
.related-race {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  transition: background 0.15s; cursor: pointer;
  text-decoration: none; color: inherit;
}
.related-race:hover { background: rgba(255,255,255,0.03); }
.related-race.current {
  background: rgba(200,255,0,0.04);
  border: 1px solid rgba(200,255,0,0.1);
}
.rr-t {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600;
  color: var(--accent-lime); min-width: 40px;
}
.rr-n {
  font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 13px;
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rr-s {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px;
  color: var(--accent-lime); flex-shrink: 0;
}

.related-nav { display: flex; gap: 6px; margin-top: 10px; }
.related-nav a {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: 6px; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-decoration: none; transition: all 0.15s;
}
.related-nav a:hover { color: var(--text-primary); border-color: var(--text-muted); }

.view-all-link {
  display: block; text-align: center; padding: 10px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-decoration: none; transition: color 0.15s; margin-top: 8px;
}
.view-all-link:hover { color: var(--accent-lime); }

/* ═══ Post-Race State ═══ */
.post-race-section {
  margin-top: 36px; padding-top: 24px;
  border-top: 1px dashed var(--border);
}
.result-outcome {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 14px; font-weight: 600;
}
.result-outcome.won {
  background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.2);
  color: var(--accent-green);
}
.result-outcome.placed {
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2);
  color: var(--accent-amber);
}
.result-outcome.missed {
  background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.15);
  color: var(--accent-red);
}
.result-outcome .ro-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
}
.result-outcome.won .ro-icon { background: rgba(34,197,94,0.2); }
.result-outcome.placed .ro-icon { background: rgba(245,158,11,0.2); }
.result-outcome.missed .ro-icon { background: rgba(239,68,68,0.15); }

/* Result table additions */
.race-page .runner-table .pos-col {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 12px;
  text-align: center; min-width: 32px;
}
.pos-col.p1 { color: var(--accent-amber); }
.pos-col.p2 { color: var(--text-secondary); }
.pos-col.p3 { color: #c8956c; }
.pos-col.other { color: var(--text-muted); }
.pos-col.dnf { color: var(--accent-red); }

.r-dist-beaten {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--text-muted); text-align: right;
}
.winner-row { background: rgba(245,158,11,0.03) !important; }
.tp-badge {
  font-size: 8px; font-weight: 700;
  background: rgba(59,130,246,0.12); color: var(--accent-blue);
  padding: 1px 5px; border-radius: 3px;
  letter-spacing: 0.04em; margin-left: 4px; vertical-align: middle;
}

/* ═══ Responsive ═══ */
@media (max-width: 800px) {
  .content-grid { grid-template-columns: 1fr; }
  .side-col { order: -1; }
  .rh-top { flex-direction: column; }
  .rh-status-block { text-align: left; }
  .race-page .runner-table { font-size: 12px; }
  .race-page .runner-table th:nth-child(3),
  .race-page .runner-table td:nth-child(3) { display: none; }
  .tpc-score { font-size: 30px; }
}
@media (max-width: 520px) {
  .rh-venue { font-size: 24px; }
  .race-page .runner-table th:nth-child(4),
  .race-page .runner-table td:nth-child(4) { display: none; }
  .tpc-body { flex-wrap: wrap; }
  .tpc-score { font-size: 28px; }
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.race-page .race-header { animation: fadeUp 0.4s ease; }
.race-page .top-pick-callout { animation: fadeUp 0.4s ease 0.05s backwards; }
.race-page .content-grid { animation: fadeUp 0.4s ease 0.1s backwards; }
