/* Racing league pages (racing.js): Formula 1 and IndyCar. */

.sp-racing { display: grid; gap: 24px; }
.sp-racing > *, .racing-pair > * { min-width: 0; }

/* Section headings: the condensed face in capitals, like the box score's. */
.racing-hd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin: 0 2px 8px;
}
.racing-hd h2 {
  margin: 0;
  font: 600 17px/1.2 var(--display);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.racing-note { font-size: 13px; color: var(--muted); }
.racing-hd-t { display: inline-flex; align-items: center; gap: 4px; margin: -4px 0; }

.racing-pair { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 24px 20px; align-items: start; }
.racing-pair.racing-one { grid-template-columns: minmax(0, 640px); }

/* ─── Tables ───────────────────────────────────────────── */

.racing-t { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.racing-t th {
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.racing-t td {
  padding: 9px 8px;
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: baseline;
}
.racing-t th:first-child, .racing-t td:first-child { padding-left: 14px; }
.racing-t th:last-child, .racing-t td:last-child { padding-right: 14px; }
.racing-t .num { text-align: right; }
.racing-t a { text-decoration: none; font-weight: 600; }
.racing-t a:hover { text-decoration: underline; text-underline-offset: 3px; }
.racing-t a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }

/* Number columns are never cut: racing.js gives the table each one's widest value in digits
   (--ch-pos, --ch-pts..., a point half of one), and a column is that many digits (--dg; --dgb for
   the points, whose bold digits are wider) and its padding wide (--pad, --edge at the table's edge),
   or as wide as its head needs if that's more. */
.racing-t { --dg: 8px; --dgb: 9px; --pad: 16px; --edge: 22px; }
.racing-rd { width: 46px; }
.racing-pos { width: max(46px, calc(var(--ch-pos, 2) * var(--dg) + var(--edge))); }
td.racing-pos, td.racing-rd { color: var(--muted); font-weight: 600; }
.racing-no { width: max(50px, calc(var(--ch-no, 2) * var(--dg) + var(--pad))); }
.racing-grid { width: max(50px, calc(var(--ch-grid, 2) * var(--dg) + var(--pad))); }
.racing-laps { width: max(50px, calc(var(--ch-laps, 3) * var(--dg) + var(--pad))); }
.racing-n { width: max(54px, calc(var(--ch-n, 2) * var(--dg) + var(--pad))); }
/* The standings' wins and podiums, "W" and "Pod" on phones */
.racing-w { width: max(54px, calc(var(--ch-w, 2) * var(--dg) + var(--pad))); }
.racing-pod { width: max(76px, calc(var(--ch-pod, 2) * var(--dg) + var(--pad))); }
.racing-pts { width: max(58px, calc(var(--ch-pts, 3) * var(--dgb) + var(--edge))); }
td.racing-pts { font-weight: 700; }

/* A team's logo in a row (racing-teams.js puts its row mark in the slot): about the text's height,
   in a slot of fixed width so the names after it line up; a team without one has its plain mark
   there, as small (.rt-rowmark: its color and initials, racing-teams.css) */
.racing-tl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 18px;
  margin-right: 8px;
  vertical-align: middle;
}
.racing-tl img { display: block; max-width: 100%; max-height: 100%; }
.racing-date { width: 104px; }
.racing-tm { width: 26%; }
.racing-time { width: 118px; }
.racing-fl { width: 104px; }
.racing-qt { width: 92px; }
.racing-laps-l { width: 24%; }
td.racing-laps-l, td.racing-dur { white-space: normal; }
.racing-sched .racing-date { width: 150px; }
.racing-sched .racing-time { width: 110px; }
.racing-espn .racing-tm { width: 34%; }

td.racing-name, td.racing-win { font-weight: 600; }
/* Names wrap rather than lose their ends: a team's (two for a driver who changed teams), a
   driver's, a winner and his team, a race's, and a retirement's cause; a logo stays with its
   name's first word */
td.racing-tm, td.racing-win, td.racing-ev, td.racing-name,
.racing-cls td.racing-time { white-space: normal; }
td.racing-tm, .racing-dow, td.racing-fl, td.racing-dur { color: var(--muted); }
.racing-team { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--muted); }
.racing-best { color: var(--ink); font-weight: 700; }
.racing-short { display: none; }

/* ─── Calendar ─────────────────────────────────────────── */

/* One line a race. Wide screens set its two halves side by side, each with its own head. */
.racing-cal th { padding-top: 8px; padding-bottom: 7px; }
.racing-cal td { padding-top: 5px; padding-bottom: 5px; }
.racing-cal .racing-rd { width: 42px; }
.racing-cal .racing-date { width: 84px; }
.racing-cal .racing-win { width: 35.5%; }
.racing-cal .racing-tl { width: 28px; height: 16px; margin-right: 6px; }
.racing-cal .racing-team { margin-left: 6px; }
.racing-cal-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; align-items: start; }

/* ─── Race page ────────────────────────────────────────── */

.racing-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  margin: 0 2px -8px;
  font-size: 14px;
}
.racing-nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.racing-nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.racing-nav a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
.racing-steps { display: flex; gap: 18px; }

.racing-head { margin: 0 2px; }
.racing-meta { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; font-size: 14px; color: var(--muted); }
.racing-meta .copy-link { margin: -6px 0 -6px 4px; }
.racing-meta span + span::before { content: "·"; margin: 0 8px; color: var(--faint); }

/* ─── Narrow screens ───────────────────────────────────── */

@media (max-width: 900px) {
  .racing-pair, .racing-pair.racing-one { grid-template-columns: minmax(0, 1fr); }
  /* Columns left out on narrow screens are collapsed to nothing: a display: none cell still
     gets a share of a fixed-layout table's width in Chromium. */
  .racing-t .racing-fl { width: 0; padding: 0; font-size: 0; }
  /* The calendar's halves stack, the second without its head, and read as one table. */
  .racing-cal-split { grid-template-columns: minmax(0, 1fr); }
  .racing-cal + .racing-cal thead { display: none; }
}

@media (max-width: 600px) {
  .sp-racing { gap: 20px; }
  .racing-t { font-size: 13.5px; --dg: 7.7px; --dgb: 9px; --pad: 8px; --edge: 14px; }
  .racing-t th, .racing-t td { padding-left: 4px; padding-right: 4px; }
  .racing-t th:first-child, .racing-t td:first-child { padding-left: 10px; }
  .racing-t th:last-child, .racing-t td:last-child { padding-right: 10px; }
  .racing-t th { font-size: 10px; letter-spacing: .04em; }
  .racing-long, .racing-team, .racing-dow { display: none; }
  .racing-t .racing-no, .racing-t .racing-grid, .racing-t .racing-laps,
  .racing-q .racing-tm, .racing-pit .racing-tm { width: 0; padding: 0; font-size: 0; }
  .racing-q .racing-tm .racing-tl, .racing-pit .racing-tm .racing-tl { display: none; }
  .racing-short { display: inline; }
  .racing-rd { width: 40px; }
  .racing-pos { width: max(40px, calc(var(--ch-pos, 2) * var(--dg) + var(--edge))); }
  .racing-tl { width: 28px; height: 16px; margin-right: 6px; }
  .racing-date { width: 54px; }
  .racing-cal .racing-rd { width: 36px; }
  .racing-cal .racing-date { width: 56px; }
  .racing-cal .racing-win { width: 36%; }
  .racing-tm { width: 30%; }
  .racing-std .racing-tm { width: 34%; }
  .racing-cls .racing-tm { width: 30%; }
  .racing-time { width: 82px; }
  .racing-pts { width: max(38px, calc(var(--ch-pts, 3) * var(--dgb) + var(--edge))); }
  .racing-n { width: max(40px, calc(var(--ch-n, 2) * var(--dg) + var(--pad))); }
  .racing-w { width: max(26px, calc(var(--ch-w, 2) * var(--dg) + var(--pad))); }
  .racing-pod { width: max(34px, calc(var(--ch-pod, 2) * var(--dg) + var(--pad))); }
  .racing-qt { width: 70px; }
  .racing-pit .racing-laps-l { width: 30%; }
  .racing-sched .racing-date { width: 74px; }
  .racing-sched .racing-time { width: 74px; }
  .racing-espn .racing-tm { width: 36%; }
  .racing-meta { font-size: 13px; }
}
