/* ========================================
   RACE DAY — live boards + "Your race" on an event page with `race:` front matter
   (layouts/partials/race-day.html, static/js/race-day.js). Built on app.css / events.css tokens.
   ======================================== */

.rd {
  --rd-gold: #FFC051;
  --rd-silver: #d9dfe3;
  --rd-bronze: #e3a37a;
  --rd-live: #ff6b5b;
  --rd-good: var(--ev-going, #7ee2b8);
  scroll-margin-top: var(--ev-sticky-top, 64px);
}

.rd h3, .rd h4, .rd h5 {
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

/* One card with hairline dividers between its parts: nothing inside gets a box of its own unless it means something
   (a highlight, your own row, a warning) */
.rd-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rd-card > * + * {
  border-top: 1px solid var(--border-subtle);
}

.rd-card > [hidden] + *,
.rd-card > noscript + * {
  border-top: 0;
}

.rd-time,
.rd-num,
.rd-rank,
.rd-cd,
.rd-updated,
.rd-stat-val,
.rd-twenty-clock,
.rd-climb-no,
.rd-climb-clock,
.rd-hist-year,
.rd-nn-time,
.rd-seed {
  font-variant-numeric: tabular-nums;
}

.rd-small { font-size: var(--text-xs); }
.rd-muted { color: var(--text-subtle); }
.rd-msg {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

/* ── Status strip ─────────────────────── */

.rd-status {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
}

.rd-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  min-height: 36px;
}

/* Status pills: one size for all of them (.rd-pill, the rider's .rd-chip, the offline badge) */
.rd-pill,
.rd-chip,
.rd-updated.is-offline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-default);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.rd-pill--live {
  background: var(--rd-live);
  color: #fff;
  box-shadow: 0 2px 10px rgba(239, 123, 109, 0.35);
}

.rd-pill--upcoming {
  background: rgba(255, 192, 81, 0.16);
  color: var(--yellow-light);
}

/* Finished: not a pill, one quiet line ("Final results · Updated Mon Nov 9, 3:33 PM"), and no refresh button */
.rd--finished .rd-status-row { min-height: 0; gap: var(--space-2); }
.rd--finished .rd-pill--finished {
  padding: 0;
  background: none;
  color: var(--text-default);
}
.rd--finished .rd-pill--finished i { color: var(--text-subtle); }
.rd--finished .rd-updated:not(:empty):not(.is-offline)::before { content: "\00B7"; margin-right: var(--space-2); }

.rd-pill--error {
  background: var(--ev-coral-tint);
  color: var(--coral-pale);
}

.rd-pulse {
  position: relative;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.rd-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  animation: rd-pulse 1.6s var(--ease-out) infinite;
}

@keyframes rd-pulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(2.6); opacity: 0; }
}

.rd-updated {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.rd-refresh {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-strong);
  cursor: pointer;
}

.rd-refresh[hidden] { display: none; }
.rd-refresh:hover { background: var(--surface-3); }
.rd-refresh:focus-visible,
.rd-tab:focus-visible,
.rd-gender .ev-seg-btn:focus-visible,
.rd-panel:focus-visible,
.rd-details summary:focus-visible,
.rd-climbs summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Subtle auto-refresh indicator: a ring that fills over the 20 s cadence is overkill — a soft glow will do */
.rd-refresh.is-auto { border-color: var(--ev-coral-line); }
.rd-refresh.is-busy i { animation: fa-spin 1s linear infinite; }

.rd-nownext {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-nn-label {
  display: inline-block;
  min-width: 2.6rem;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--coral-light);
}

.rd-nn strong { color: var(--text-strong); }
.rd-nn-time { font-weight: 600; color: var(--text-strong); }

/* ── Rider strip / card ───────────────── */

.rd-me {
  padding: var(--space-4);
}

.rd-login {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-login > i { color: var(--text-subtle); }
.rd-login a { color: var(--yellow-light); font-weight: 600; text-underline-offset: 3px; }

/* Not logged in: "How do you record your rides?", then just the chosen answer's button */
.rd-start {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.rd-start-lead {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
  text-wrap: pretty;
}

.rd-start .rd-you-title { margin: 0; }

.rd-choices {
  display: grid;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.rd .rd-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  min-height: 48px;
  padding: var(--space-2) var(--space-2);
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text-strong);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.rd .rd-choice > i { flex: none; font-size: 0.75em; color: var(--text-subtle); }
.rd .rd-choice + .rd-choice { border-top: 1px solid var(--border-subtle); }
.rd .rd-choice:hover { background: var(--surface-1); }
.rd .rd-choice:focus-visible { outline: 2px solid var(--yellow-light); outline-offset: 2px; }

/* "Something else": there, but quieter (lighter type, same row) */
.rd .rd-choice--minor {
  color: var(--text-default);
  font-weight: 500;
}

.rd-chosen {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-strong);
}

.rd-chosen > i { color: var(--rd-good); }

.rd-choice-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.rd-choice-panel p { margin: 0; }
.rd-choice-panel:focus { outline: none; }
.rd-choice-panel a:not(.ev-btn) { color: var(--yellow-light); font-weight: 600; text-underline-offset: 3px; }

.rd-choice-why {
  font-size: var(--text-sm);
  color: var(--text-default);
  text-wrap: pretty;
}

.rd-choice-panel .rd-small { font-size: var(--text-xs); text-wrap: pretty; }

.rd-login-btn {
  align-self: stretch;
  justify-content: center;
}

/* "Log in with RideWithGPS" over "free club membership" */
.rd-login-btn-text { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.2; }
.rd-login-btn-sub { font-size: var(--text-xs); font-weight: 500; opacity: 0.85; }

/* Race over, logged out: "Rode it? See every climb you rode. [Find my climbs]", the page's one sign-in prompt */
.rd-start-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-start-line > span { flex: 1 1 12rem; text-wrap: pretty; }
.rd .rd-start-open { min-height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); }

/* Race on: the question folds into one line under the status strip */
.rd-start-fold > .rd-start { padding-bottom: var(--space-2); }

/* Logged in, but no RideWithGPS access stored: rides can't be read */
.rd-reconnect {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--yellow-light);
  border-radius: var(--radius-md);
}

.rd-reconnect p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-reconnect .ev-btn { justify-content: center; }

/* Strava: connect (anyone), status / renew (signed in). Brand: #FC5200 with white text, no logo;
   "View on Strava" is bold + underlined (#FC5200 is too low-contrast on our green surfaces) */
.rd-strava {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rd-strava p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-strava p.rd-small { font-size: var(--text-xs); color: var(--text-subtle); }
.rd-strava a:not(.ev-btn) { color: var(--yellow-light); font-weight: 600; text-underline-offset: 3px; }
.rd-strava p > i { color: var(--yellow-light); }

.rd .rd-strava-btn {
  align-self: stretch;
  background: #FC5200;
  border-color: #FC5200;
  color: #fff;
  font-weight: 600;
}

.rd .rd-strava-btn:hover { background: #e34a00; border-color: #e34a00; color: #fff; }
.rd .rd-strava-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Strava: a quiet text line under the main connect button (its API lets only a handful of riders connect) */
.rd-strava p.rd-conn-minor { margin-top: 10px; }

/* Wahoo: same block (.rd-strava is the shared connect block), brand blue #1A6AFF with white text (4.6:1) */
.rd .rd-wahoo-btn {
  background: #1A6AFF;
  border-color: #1A6AFF;
  color: #fff;
  font-weight: 600;
}

.rd .rd-wahoo-btn:hover { background: #0f58e0; border-color: #0f58e0; color: #fff; }
.rd .rd-wahoo-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Garmin: brand rules want a black button with white text and no logo; label is "Connect with Garmin Connect™" */
.rd .rd-garmin-btn {
  background: #000;
  border-color: #000;
  color: #fff;
  font-weight: 600;
}

.rd .rd-garmin-btn:hover { background: #262626; border-color: #262626; color: #fff; }
.rd .rd-garmin-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Connect buttons: full width alone, side by side when more than one service is offered (stacking on narrow phones) */
.rd-connect-btns {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.rd-connect-btns > .ev-btn {
  flex: 1 1 9.5rem;
  justify-content: center;
  /* long labels ("Connect with Garmin Connect™") wrap on the narrowest phones instead of overflowing */
  min-width: 0;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.rd .rd-nowrap { white-space: nowrap; }

.rd-strava--renew {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--yellow-light);
  border-radius: var(--radius-md);
}

.rd-strava-status {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-strava-status i { color: var(--rd-good); }

/* Naming a Garmin rider (Garmin shares no name) */
.rd-name-form { margin: var(--space-3) 0 0; display: grid; gap: var(--space-2); }
.rd-name-form label { color: var(--text-default); }
.rd-name-row { display: flex; gap: var(--space-2); }
.rd-name-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  font: inherit;
  font-size: 16px; /* no zoom-on-focus on iPhone */
}
.rd-name-row input::placeholder { color: rgba(255, 255, 255, 0.6); }
.rd-name-row input:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.rd .rd-name-save { flex: 0 0 auto; }
.rd-strava p.rd-name-msg { color: var(--yellow-light); margin: 0; }
.rd-strava p.rd-conn-name { margin: var(--space-2) 0 0; }

/* Disconnect: a quiet text button after "Wahoo connected" / in the renew prompt */
.rd .rd-link-btn {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-subtle);
  font: inherit;
  font-size: var(--text-xs);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.rd .rd-link-btn:hover { color: var(--text-default); }
.rd .rd-link-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.rd .rd-link-btn[disabled] { cursor: default; text-decoration: none; }
.rd-strava p.rd-small .rd-link-btn { margin-left: 0; }

.rd .rd-strava-link {
  color: var(--yellow-light);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

/* One-time notice after the Strava round trip */
.rd-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-default);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.rd-notice > i { margin-top: 3px; color: var(--yellow-light); }
.rd-notice-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.rd-notice-action { display: flex; flex-direction: column; gap: var(--space-2); }
.rd-notice-action p { margin: 0; }
.rd-notice-action a:not(.ev-btn) { color: var(--yellow-light); font-weight: 600; text-underline-offset: 3px; }
.rd-notice--action { padding: var(--space-3); }
.rd-notice strong { color: var(--text-strong); }
.rd-notice--ok { background: rgba(126, 226, 184, 0.12); }
.rd-notice--ok > i { color: var(--rd-good); }
.rd-notice--err { background: var(--ev-coral-tint); }
.rd-notice--err > i { color: var(--coral-light); }

.rd-notice-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -6px -8px -6px auto;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--text-subtle);
  cursor: pointer;
}

.rd-notice-x:hover { color: var(--text-strong); background: var(--surface-3); }

.rd-you {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.rd-you-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.rd .rd-you-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-strong);
  margin-right: auto;
}

.rd-chip { color: var(--text-subtle); }

.rd-chip--racer { background: var(--ev-coral-tint); color: var(--coral-pale); }
.rd-chip--pending { background: var(--yellow-muted); color: var(--yellow-light); }

.rd-note {
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.rd-note--top {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
}

.rd-stat {
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.rd-stat dt {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.rd-stat dd {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.rd-stat-val {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-strong);
}

.rd-stat-sub {
  font-size: var(--text-xs);
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rd-ko {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-strong);
}

.rd-ko i { color: var(--text-subtle); }
.rd-ko.is-in { background: rgba(255, 192, 81, 0.14); }
.rd-ko.is-in i { color: var(--rd-gold); }

/* Self check-in */
.rd-register {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.rd .rd-register-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-strong);
}

.rd-register-title i { color: var(--coral-light); }

.rd-register p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-register .rd-small { font-size: var(--text-xs); color: var(--text-subtle); }

.rd-register-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-1);
}

.rd .ev-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* The Twenty */
.rd-twenty-start {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rd-twenty-start p { margin: 0; }

.rd-twenty-btn {
  min-height: 56px;
  width: 100%;
  font-size: var(--text-base);
}

.rd-twenty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--ev-coral-tint);
  border: 1px solid var(--ev-coral-line);
  text-align: center;
}

.rd-twenty p { margin: var(--space-1) 0 0; }

.rd-twenty-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--coral-pale);
}

.rd-twenty-clock {
  font-size: clamp(3rem, 2rem + 6vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.rd-twenty-laps { font-size: var(--text-sm); color: var(--text-default); }
.rd-twenty-laps strong { font-size: var(--text-lg); color: var(--text-strong); }

.rd-twenty.is-done {
  flex-direction: row;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface-2);
  border-color: var(--border-subtle);
  font-size: var(--text-sm);
}

.rd-twenty-soon { margin: 0; }

/* Check my ride + trips */
.rd-check {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rd-check > p { margin: 0; }

.rd-check-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.rd-trips {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rd-trip {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-trip i { flex: none; width: 1rem; text-align: center; }
.rd-trip--ok i { color: var(--rd-good); }
.rd-trip--warn i { color: var(--yellow-light); }
.rd-trip--err i { color: var(--coral-light); }
.rd-trip--info i { color: var(--text-subtle); }

/* Climbs (collapsible) */
.rd-climbs,
.rd-details {
  min-width: 0;
}

.rd-climbs summary,
.rd-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 48px;
  font-weight: 600;
  color: var(--text-strong);
  cursor: pointer;
  list-style: none;
}

.rd-climbs summary { border-top: 1px solid var(--border-subtle); }

.rd-climbs summary span,
.rd-details summary span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.rd-climbs summary::-webkit-details-marker,
.rd-details summary::-webkit-details-marker { display: none; }

.rd-climbs summary > i,
.rd-details summary > i {
  flex: none;
  font-size: var(--text-xs);
  color: var(--text-subtle);
  transition: transform var(--dur-base) var(--ease-out);
}

.rd-climbs[open] summary > i,
.rd-details[open] summary > i { transform: rotate(180deg); }

.rd-climb-list {
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
}

.rd-climb {
  display: grid;
  grid-template-columns: 1.75rem 4rem minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 4px 0;
  font-size: var(--text-sm);
}

.rd-climb + .rd-climb { border-top: 1px solid var(--border-subtle); }

.rd-climb-no { color: var(--text-faint); font-size: var(--text-xs); }
.rd-climb-time { font-weight: 700; color: var(--text-strong); }
.rd-climb-clock { color: var(--text-subtle); font-size: var(--text-xs); white-space: nowrap; }

.rd-climb-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.rd-climb.is-excluded .rd-climb-time { color: var(--text-faint); font-weight: 500; }
.rd-climb.is-excluded .rd-climb-clock { color: var(--text-faint); }

.rd-tag,
.rd-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-subtle);
  white-space: nowrap;
}

.rd-tag--best { background: rgba(255, 192, 81, 0.16); color: var(--yellow-light); }
.rd-tag--out { background: transparent; border: 1px solid var(--border-default); }
.rd-flag { background: var(--yellow-muted); color: var(--yellow-light); }

/* History */

.rd-sub {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase !important;
  color: var(--text-subtle);
}

.rd-hist-list {
  max-width: 36rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
}

.rd-hist-row {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) 4.25rem; /* fixed laps column: every bar track the same length */
  grid-template-areas: "year bar laps" ". delta delta";
  align-items: center;
  column-gap: var(--space-2);
  row-gap: 2px;
  font-size: var(--text-sm);
}

.rd-hist-year { grid-area: year; font-weight: 600; color: var(--text-subtle); }
.rd-hist-row.is-current .rd-hist-year { color: var(--text-strong); }

.rd-hist-bar {
  grid-area: bar;
  position: relative;
  display: flex;
  align-items: center;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  overflow: hidden;
}

.rd-hist-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}

.rd-hist-row.is-current .rd-hist-fill { background: var(--ev-coral-line); }
.rd-hist-fill.is-pb { box-shadow: inset -3px 0 0 var(--rd-gold); }

.rd-hist-time {
  position: relative;
  padding: 0 var(--space-2);
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.rd-pb {
  margin-left: 4px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--rd-gold);
  color: var(--ev-ink);
  font-size: 0.625rem;
  font-weight: 700;
  vertical-align: 1px;
}

.rd-hist-laps { grid-area: laps; color: var(--text-subtle); font-size: var(--text-xs); white-space: nowrap; text-align: right; }
.rd-hist-delta { grid-area: delta; font-size: var(--text-xs); }
.rd-delta { color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.rd-delta.is-better { color: var(--rd-good); }
.rd-delta.is-worse { color: var(--coral-light); }

/* ── Boards ───────────────────────────── */

.rd-boards {
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.rd-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-subtle);
}

.rd-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 52px;
  padding: var(--space-1) 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: inset 0 -2px 0 transparent;
  color: var(--text-subtle);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}

.rd-tab i { font-size: var(--text-sm); }
.rd-tab:hover { color: var(--text-strong); }

.rd-tab[aria-selected="true"] {
  color: var(--text-strong);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--coral);
}

.rd-tab[aria-selected="true"] i { color: var(--coral); }

@media (min-width: 640px) {
  .rd-tab {
    flex-direction: row;
    gap: var(--space-2);
    min-height: 42px;
    font-size: var(--text-sm);
  }
}

.rd-panel {
  margin-top: var(--space-3);
  border-radius: var(--radius-sm);
}

.rd-panel-head {
  display: flex;
  margin-bottom: var(--space-3);
}

.rd-panel-head[hidden] { display: none; }

/* Women / Men: filter chips, the same as the photo gallery's (.sp-gal-chip), not a boxed segmented control */
.rd .rd-gender {
  flex: 0 0 auto;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: none;
}

.rd .rd-gender .ev-seg-btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-default);
  font-size: var(--text-xs);
  font-weight: 600;
  box-shadow: none;
}

.rd .rd-gender .ev-seg-btn:hover { background: var(--surface-2); }

.rd .rd-gender .ev-seg-btn[aria-pressed="true"] {
  border-color: var(--coral);
  background: var(--coral);
  color: var(--ev-ink);
}

.rd-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rd-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 48px;
  padding: 6px var(--space-2);
  border-radius: var(--radius-sm);
}

.rd-row + .rd-row { box-shadow: inset 0 1px 0 var(--border-subtle); }

.rd-rank {
  justify-self: center;
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-subtle);
}

.rd-row--p1 .rd-rank { background: var(--rd-gold); color: var(--ev-ink); }
.rd-row--p2 .rd-rank { background: var(--rd-silver); color: var(--ev-ink); }
.rd-row--p3 .rd-rank { background: var(--rd-bronze); color: var(--ev-ink); }

.rd-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rd-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-strong);
}

.rd-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.rd-val {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.rd-val .rd-time,
.rd-val .rd-num {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-strong);
}

.rd-unit { font-size: var(--text-xs); color: var(--text-subtle); }

.rd-row.is-me {
  background: var(--ev-coral-tint);
  box-shadow: inset 0 0 0 1px var(--ev-coral-line);
}

.rd-row.is-me + .rd-row { box-shadow: none; }

.rd-you-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--coral);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 2px;
}

.rd-g {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-default);
}

.rd-g .sr-only-app { font-size: 1rem; }

.rd-running {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--coral-light);
  font-weight: 600;
}

.rd-row.is-running .rd-pulse { color: var(--rd-live); }

/* Knockout cut divider */
.rd-cut {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 6px 0;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--coral-light);
}

.rd-cut::before,
.rd-cut::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--ev-coral-line);
}

.rd-cut + .rd-row { box-shadow: none; }

/* Knockout bracket */
.rd-bracket {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .rd-bracket {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: var(--space-3);
  }
}

.rd-round-title {
  margin: 0 0 var(--space-2) !important;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase !important;
  color: var(--text-subtle);
}

.rd-heats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.rd-round:last-child .rd-heats { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 768px) {
  .rd-heats { grid-template-columns: minmax(0, 1fr); }
}

.rd-heat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.rd-heat-no {
  padding: 0 6px 2px;
  font-size: 0.6875rem;
  color: var(--text-faint);
}

.rd-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: var(--text-sm);
  color: var(--text-default);
}

.rd-slot + .rd-slot { box-shadow: inset 0 1px 0 var(--border-subtle); }

.rd-seed {
  flex: none;
  min-width: 1rem;
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.rd-slot-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rd-slot.is-tbd .rd-slot-name { color: var(--text-faint); font-style: italic; }
.rd-slot.is-winner { background: rgba(255, 192, 81, 0.14); color: var(--text-strong); font-weight: 700; }
.rd-slot.is-winner i { color: var(--rd-gold); }
.rd-slot.is-out { color: var(--text-faint); }
.rd-slot.is-me { box-shadow: inset 0 0 0 1px var(--ev-coral-line); }

.rd-champ {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(255, 192, 81, 0.14);
  color: var(--text-default);
  font-size: var(--text-sm);
}

.rd-champ i { color: var(--rd-gold); }
.rd-champ strong { color: var(--text-strong); font-size: var(--text-base); }

/* Empty states / totals */
.rd-empty {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-4) 0;
  font-size: var(--text-sm);
  color: var(--text-subtle);
}

.rd-empty i { margin-top: 3px; font-size: var(--text-lg); color: var(--text-faint); }
.rd-empty p { margin: 0; }
.rd-empty strong { color: var(--text-strong); }

.rd-totals {
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.rd-totals:empty { display: none; }

/* Garmin's attribution under the tabs (brand rules: on screen, readable, not a footnote) */
.rd-attrib {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-subtle);
  text-wrap: pretty;
}

.rd-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  font-size: var(--text-sm);
}

.rd-error p { margin: 0; }
.rd-error i { color: var(--coral-light); }

/* ── Poor signal ──────────────────────── */

.rd-updated.is-offline {
  background: var(--yellow-muted);
  color: var(--yellow-light);
}

.rd-updated.is-offline::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid currentColor;
}

.rd-sync {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--yellow-muted);
  color: var(--text-default);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-align: left;
}

.rd-sync i { margin-top: 3px; color: var(--yellow-light); }
.rd-sync strong { color: var(--text-strong); }
.rd-sync--err { background: var(--ev-coral-tint); }

/* Race morning, nothing recorded yet: the one thing that makes timing work */
.rd-tip {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--yellow-muted);
  color: var(--text-default);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-wrap: pretty;
}

.rd-tip i { margin-top: 3px; color: var(--yellow-light); }
.rd-tip strong { color: var(--text-strong); }

/* Logged out while the race is live: one line and a button, so spectators reach the boards */
.rd-sync--err i { color: var(--coral-light); }
.rd-twenty.is-local { border-color: var(--border-strong); }

/* ── Explainers ───────────────────────── */

.rd-more {
  padding: 0 var(--space-4);
}

.rd-details + .rd-details { border-top: 1px solid var(--border-subtle); }

.rd-details summary span i { color: var(--text-subtle); font-size: var(--text-sm); }

.rd-details-body {
  padding: 0 0 var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-default);
}

.rd-details-body p { margin: var(--space-2) 0 0; }
.rd-details-body a { color: var(--yellow-light); }

.rd-steps {
  margin: 0;
  padding-left: 1.25rem;
}

/* How timing works: the words used everywhere, then where rides come from */
.rd-defs { display: grid; gap: var(--space-2); margin: 0; }
.rd-defs dt { font-weight: 700; color: var(--text-strong); }
.rd-defs dd { margin: 0; }
.rd-sub--gap { margin: var(--space-4) 0 var(--space-2); }
.rd-sources { margin: 0; padding-left: 1.25rem; }
.rd-sources li + li { margin-top: var(--space-1); }
.rd-sources strong { color: var(--text-strong); }

.rd-steps li + li { margin-top: var(--space-1); }
.rd-steps strong { color: var(--text-strong); }

/* Past results */
.rd-past-year + .rd-past-year {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.rd .rd-past-title {
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-strong);
}

.rd-past-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

@media (min-width: 560px) {
  .rd-past-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.rd-past-col .rd-sub { margin-bottom: 4px; }

.rd-past-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rd-past-list li {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
}

.rd-past-list .rd-rank {
  min-width: 1.375rem;
  height: 1.375rem;
  font-size: var(--text-xs);
}

.rd-past-list li:nth-child(1) .rd-rank { background: var(--rd-gold); color: var(--ev-ink); }
.rd-past-list li:nth-child(2) .rd-rank { background: var(--rd-silver); color: var(--ev-ink); }
.rd-past-list li:nth-child(3) .rd-rank { background: var(--rd-bronze); color: var(--ev-ink); }
.rd-past-list .rd-name { font-weight: 500; }
.rd-past-list .rd-val { font-size: var(--text-sm); color: var(--text-subtle); }
.rd-past-list .rd-time { font-weight: 700; color: var(--text-strong); }

/* ── Twenty confirm dialog ────────────── */

.rd-dialog {
  width: min(26rem, calc(100vw - 2rem));
  padding: var(--space-5);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary, #4a5d4f);
  color: var(--text-default);
  box-shadow: var(--shadow-3);
}

.rd-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

.rd-dialog h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-strong);
}

.rd-dialog p {
  margin: var(--space-2) 0 var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.rd-dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── Schedule card: highlight what's on now (class added by race-day.js) ── */

.evf-schedule-item.rd-sched-now {
  margin: 0 calc(-1 * var(--space-3));
  padding-left: var(--space-3);
  padding-right: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--ev-coral-tint);
}

.evf-schedule-item.rd-sched-now + .evf-schedule-item { border-top-color: transparent; }

.evf-schedule-item.rd-sched-now .evf-schedule-title::after {
  content: "Now";
  margin-left: var(--space-2);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--rd-live, #ff6b5b);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .rd-pulse::after { animation: none; }
  .rd-refresh.is-busy i { animation: none; }
  .rd-climbs summary > i,
  .rd-details summary > i { transition: none; }
}

/* Snake climbs on other days (not on race day) in the rider's history */
.rd-offday {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.rd-offday p { margin: 0; }
.rd-offday-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-strong); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.rd-offday.is-alone { margin-top: 0; padding-top: 0; border-top: 0; }
.rd-offday .rd-hist-list { margin: 0; }

/* Signed in: other ride sources (Wahoo, Strava) folded into one line under Check my ride */
.rd-more-conn summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-default);
  cursor: pointer;
  list-style: none;
}

.rd-more-conn summary::-webkit-details-marker { display: none; }
.rd-more-conn summary > i { font-size: 0.75em; color: var(--text-subtle); transition: transform 0.15s ease; }
.rd-more-conn[open] summary > i { transform: rotate(180deg); }
.rd-more-conn summary:focus-visible { outline: 2px solid var(--yellow-light); outline-offset: 2px; border-radius: var(--radius-sm); }
.rd-more-conn > .rd-strava { padding-bottom: var(--space-2); }

/* Inside it, the connect buttons size to the longest label instead of filling the row: stacked at one width on
   phones, side by side at equal widths on wider screens */
.rd-strava--compact .rd-connect-btns {
  display: inline-grid;
  grid-auto-flow: row;
  grid-template-columns: minmax(0, max-content);
  align-self: flex-start;
  max-width: 100%;
}

@media (min-width: 640px) {
  .rd-strava--compact .rd-connect-btns { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .rd-more-conn summary > i { transition: none; }
}

/* Inside the disclosure, the lead reads as a caption under its summary */
.rd-more-conn .rd-strava > p:first-child { font-size: var(--text-sm); color: var(--text-subtle); }
.rd-more-conn .rd-strava p,
.rd-register .rd-small { text-wrap: pretty; }

/* "Pick Women or Men first." reads as a prompt, not body text */
.rd-register .rd-msg { color: var(--yellow-light); font-weight: 600; }

/* Signed in, before race day: logged in · checked in · rides reach us */
.rd-ready {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.rd-ready-list {
  display: grid;
  gap: 4px;
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--text-default);
}
.rd-ready-item { display: flex; align-items: baseline; gap: var(--space-2); text-wrap: pretty; }
.rd-ready-item.is-ok i { color: var(--rd-good); }
.rd-ready-item.is-todo i { color: var(--text-subtle); }
.rd-ready-item.is-no i { color: var(--coral-light); }

/* Race day, not checked in: the next step, so a coral edge instead of the quiet one */
.rd-register--due { border-style: solid; border-color: var(--coral-light); }

/* Connected on this phone without a login: how to check in */
.rd-strava p.rd-conn-login { margin: var(--space-2) 0 0; color: var(--text-default); }
