/* One race's full result: /results/<date>/<course>/<HH-MM>/.
 *
 * Sits on top of results.css, which it loads after: the masthead, the
 * meeting bar, the buttons, chips, podium badges and the silk sizes all
 * come from there, so the race page and the meeting page read as one
 * surface. Only what is new here is styled here.
 *
 * Same cream paper (static/css/paper.css). The one literal is the ink
 * on gold, as in results.css.
 */

/* The meeting page's faint grey and gold fall short of 4.5:1 on white
   and on the cream cards. This page darkens both, for its own content
   only (the site chrome keeps its colours). */
.page-race-result .res-bar,
.page-race-result .rr-main {
  --c-ink-40: #5F6672;
  --c-gold-ink: #7A5F0A;
}

.rr-main { padding-top: var(--space-5); padding-bottom: var(--space-7); }
.rr-main > * + * { margin-top: var(--space-4); }

/* ── Masthead additions ────────────────────────────────────── */
.rr-crumbs {
  margin: 0 0 var(--space-3); font-size: 12.5px; color: var(--c-text-55);
}
.rr-crumbs a { color: var(--c-text-100); text-decoration: none; }
.rr-crumbs a:hover { color: var(--c-gold); text-decoration: underline; }
.rr-crumbs__sep { margin: 0 6px; opacity: .6; }
.rr-title { font-size: clamp(22px, 3.6vw, 34px); }

/* The races at the meeting, the open one picked out. Same pills as the
   meeting selector on the day page. */
.rr-races .res-meet { font-variant-numeric: tabular-nums; }
.rr-races .res-meet--off { color: var(--c-ink-40); }

/* ── Cards ─────────────────────────────────────────────────── */
.rr-card {
  background: var(--c-card); border: 1px solid var(--c-rule);
  border-radius: 12px; padding: var(--space-4);
}
.rr-card > .res-tblhead { margin-bottom: var(--space-3); }

/* ── The winner ────────────────────────────────────────────── */
.rr-win {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-4); align-items: center;
  padding: var(--space-4) var(--space-5);
  background: var(--c-gold-wash); border: 1px solid var(--c-gold-bright);
  border-radius: 12px;
}
.rr-win .racecard__silk--lg { width: 56px; height: 64px; }
.rr-win__eyebrow {
  margin: 0; font-size: 10.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--c-gold-ink);
}
.rr-win__horse {
  margin: 2px 0 0; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(24px, 3.4vw, 34px); line-height: 1.1; color: var(--c-ink);
  overflow-wrap: anywhere;
}
.rr-win__sp {
  margin-left: 8px; font-family: var(--font-body); font-size: .6em;
  font-weight: 800; color: var(--c-gold-ink); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rr-win__jt { margin: 4px 0 0; font-size: 14px; color: var(--c-ink-70); }
.rr-win__note { margin: 6px 0 0; font-size: 13px; font-weight: 700; color: var(--c-ink); }
.rr-win__act { display: flex; flex-direction: column; gap: var(--space-2); }
.rr-win__act .res-btn { justify-content: center; }

@media (max-width: 720px) {
  .rr-win { grid-template-columns: auto minmax(0, 1fr); padding: var(--space-4); }
  .rr-win .racecard__silk--lg { width: 44px; height: 50px; }
  .rr-win__act { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .rr-win__act .res-btn { flex: 1 1 160px; }
}

/* ── At the line ───────────────────────────────────────────────
 * One lane per finisher. The track's right edge is the winning post;
 * a horse sits --at of the way back from it, where --at is its
 * lengths behind the winner over the scale (0 to 1). A horse past the
 * scale is pinned to the left edge and marked, so one tailed-off
 * runner 40 lengths back does not squash the rest into the post. */
.rr-line__key { margin: calc(-1 * var(--space-2)) 0 var(--space-3); font-size: 12.5px; color: var(--c-ink-40); }
.rr-line__lanes { list-style: none; margin: 0; padding: 0; }
.rr-lane, .rr-line__ruler {
  display: grid; align-items: center; gap: var(--space-3);
  grid-template-columns: 40px minmax(0, 170px) minmax(0, 1fr) 64px;
}
.rr-lane { min-height: 30px; }
.rr-lane + .rr-lane { border-top: 1px dashed var(--c-rule); }
.rr-lane__pos { font-weight: 700; font-size: 13px; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.rr-lane--1 .rr-lane__pos { color: var(--c-gold-ink); }
.rr-lane__nm {
  font-weight: 700; font-size: 13px; color: var(--c-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rr-lane__btn {
  text-align: right; font-size: 12.5px; font-weight: 700; color: var(--c-ink-70);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rr-lane--1 .rr-lane__btn { color: var(--c-gold-ink); }
.rr-lane__track {
  position: relative; align-self: stretch;
  border-right: 2px solid var(--c-gold-bright);
  margin-right: 0; padding: 0 14px;
}
/* The gap: from the horse to the post. None for the winner. */
.rr-lane__run {
  position: absolute; top: 50%; right: 0;
  width: calc(var(--at) * (100% - 28px) + 14px);
  border-top: 2px dotted var(--c-rule-strong); transform: translateY(-1px);
}
.rr-lane__silk {
  position: absolute; top: 50%;
  right: calc(var(--at) * (100% - 28px) + 14px);
  transform: translate(50%, -50%);
  display: block; line-height: 0;
}
.rr-lane__silk .racecard__silk { width: 20px; height: 23px; }
.rr-lane--far .rr-lane__track::before {
  content: '\00BB'; position: absolute; left: 0; top: 50%;
  transform: translateY(-55%); font-size: 13px; color: var(--c-ink-40);
}
.rr-line__ruler { margin-top: var(--space-2); font-size: 11px; color: var(--c-ink-40); }
.rr-line__ruler span:nth-child(3) {
  display: flex; justify-content: space-between; padding: 0 0 0 0;
}
.rr-line__ruler b { font-weight: 700; color: var(--c-gold-ink); }

@media (max-width: 560px) {
  .rr-lane, .rr-line__ruler {
    grid-template-columns: 30px minmax(0, 96px) minmax(0, 1fr) 40px;
    gap: var(--space-2);
  }
  .rr-lane__nm, .rr-lane__pos { font-size: 12px; }
  .rr-lane__btn { font-size: 11.5px; }
}

/* ── Full result ───────────────────────────────────────────── */
.rr-tbl td { vertical-align: top; }
.rr-tbl .res-horse { align-items: flex-start; }
.rr-tbl .racecard__silk { margin-top: 1px; }
.rr-sub {
  display: block; margin-top: 2px; font-size: 11.5px; font-weight: 400;
  color: var(--c-ink-40); white-space: normal;
}
.rr-horse__nm { color: var(--c-ink); font-weight: 700; text-decoration: none; }
a.rr-horse__nm:hover { color: var(--c-gold-ink); text-decoration: underline; }
.rr-out .rr-horse__nm { color: var(--c-ink-40); }
.rr-jt { color: var(--c-ink); }
.rr-sp { font-weight: 700; color: var(--c-ink); white-space: nowrap; }
.rr-move { white-space: nowrap; }
.rr-move--in { color: var(--c-green); }
.rr-move--out { color: var(--c-red); }

.rr-tag {
  display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  vertical-align: 1px; white-space: nowrap;
}
.rr-tag--fox { background: var(--c-gold-bright); color: #1a1405; }
.rr-tag--cubs { background: var(--c-card-warm); color: var(--c-ink-70); border: 1px solid var(--c-rule-strong); }
.rr-tag--you { background: var(--c-ink); color: var(--c-card); }

.rr-nr { margin: var(--space-3) 0 0; font-size: 12.5px; color: var(--c-ink-40); }
.rr-nr b { color: var(--c-ink-70); }

/* Phones: each runner becomes a two-line card. Position on the left;
   horse and price on top; connections and distance underneath. */
@media (max-width: 640px) {
  .rr-tbl { min-width: 0; }
  .rr-tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rr-tbl tr {
    display: grid; gap: 2px var(--space-3); align-items: start;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    grid-template-areas: "pos horse sp" "pos jt btn";
    padding: 10px 0; border-bottom: 1px solid var(--c-rule);
  }
  .rr-tbl tbody tr:last-child { border-bottom: 0; }
  .rr-tbl td { display: block; padding: 0; border: 0; }
  .rr-tbl .res-pos { grid-area: pos; }
  .rr-tbl .rr-c-no { display: none; }
  .rr-tbl .rr-c-horse { grid-area: horse; }
  .rr-tbl .rr-c-jt { grid-area: jt; font-size: 12px; }
  .rr-tbl .rr-c-btn { grid-area: btn; font-size: 12px; }
  .rr-tbl .rr-c-sp { grid-area: sp; }
  .rr-tbl .rr-c-btn:empty { display: none; }
  /* Jockey and trainer on one line, so a card is two lines, not four. */
  .rr-tbl .rr-c-jt .rr-sub { display: inline; font-size: inherit; }
  .rr-tbl .rr-c-jt .rr-sub::before { content: ' · '; }
}

/* Phones: the races in one row that scrolls, not two rows of pills. */
@media (max-width: 640px) {
  .rr-races { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); }
  .rr-races::-webkit-scrollbar { display: none; }
  .rr-races .res-meet { flex: 0 0 auto; }
}

/* ── How we called it, and the market ──────────────────────── */
.rr-pair {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.rr-pair > .rr-card { margin: 0; }
@media (max-width: 820px) { .rr-pair { grid-template-columns: minmax(0, 1fr); } }
.rr-main > .rr-pair { margin-top: var(--space-4); }

.rr-v--you { padding-top: var(--space-3); border-top: 1px solid var(--c-rule); }
.rr-v__note { grid-column: 1; font-size: 12px; color: var(--c-ink-40); }

.rr-mkt { margin: 0; display: grid; gap: var(--space-3); }
.rr-mkt__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--space-3); }
.rr-mkt dt {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--c-gold-ink);
}
.rr-mkt dd { margin: 0; grid-column: 1; font-size: 13.5px; color: var(--c-ink); }
.rr-mkt dd b { font-weight: 700; }
.rr-mkt .rr-mkt__fig {
  grid-column: 2; grid-row: 1 / span 2; align-self: center;
  font-weight: 800; font-size: 14px; color: var(--c-ink); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── The race, in words ────────────────────────────────────── */
.rr-story p {
  margin: 0 0 var(--space-3); font-family: var(--font-display);
  font-size: 16px; line-height: 1.65; color: var(--c-ink);
}
.rr-story p:last-child { margin-bottom: 0; }

/* ── Before / after ────────────────────────────────────────── */
.rr-steps {
  display: grid; gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}
.rr-step {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: var(--space-3) var(--space-4); border-radius: 10px;
  border: 1px solid var(--c-rule-strong); background: var(--c-card);
  color: var(--c-ink); text-decoration: none;
}
.rr-step:hover { border-color: var(--c-gold-bright); background: var(--c-gold-wash); }
.rr-step--next { text-align: right; }
.rr-step__k { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c-gold-ink); }
.rr-step__nm { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-steps__all { font-size: 13px; font-weight: 700; color: var(--c-gold-ink); white-space: nowrap; }
@media (max-width: 640px) {
  .rr-steps { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rr-steps__all { grid-column: 1 / -1; grid-row: 2; text-align: center; }
}

/* ── Not settled / abandoned ───────────────────────────────── */
.rr-wait { font-size: 14px; color: var(--c-ink-70); }
.rr-wait p { margin: 0 0 var(--space-3); }

.rr-step:focus-visible, .rr-horse__nm:focus-visible, .rr-crumbs a:focus-visible,
.rr-steps__all:focus-visible {
  outline: 2px solid var(--c-gold-ink); outline-offset: 2px;
}
