/* Formula 1 drivers (racing-drivers.js): names as links, the card on hover, the driver's page */

a.rdp-a { color: inherit; text-decoration: none; }
a.rdp-a:hover { text-decoration: underline; text-underline-offset: 3px; }
a.rdp-a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }

/* The portrait, or the driver's initials on a plain square where there is none */
.rdp-pic, .rdp-ph {
  display: block;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}
.rdp-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rdp-ph {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.rdpk .sp-flag, .rdp-hc .sp-flag, .rdp-t .sp-flag {
  display: inline-block;
  height: .85em;
  aspect-ratio: 4 / 3;
  margin-right: .4em;
  vertical-align: -.06em;
  outline: 1px solid var(--line);
}

/* ─── The card ─────────────────────────────────────────── */

.rdpk {
  position: fixed;
  z-index: 61;
  top: 0;
  left: 0;
  width: 352px;
  max-width: calc(100vw - 16px);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}
.rdpk-top { display: flex; align-items: center; gap: 12px; }
.rdpk-pic { width: 60px; height: 60px; font-size: 22px; }
.rdpk-id { min-width: 0; }
/* The newest team's logo at the right (racing-teams.css draws it on white) */
.rdpk .rdpk-tl { align-self: flex-start; width: 56px; height: 38px; margin-left: auto; padding: 5px; border-radius: 6px; }
.rdpk-n { margin: 0; font: 600 20px/1.15 var(--display); }
.rdpk-c { margin: 3px 0 0; color: var(--muted); }
/* The championship, a line each, the titles first, each with its years */
.rdpk-h { display: grid; gap: 3px; margin: 10px 0 0; padding: 0; list-style: none; line-height: 1.35; }
.rdpk-h b { font-weight: 600; }
.rdpk-h span { color: var(--muted); font-weight: 500; }
/* The season and the career in numbers: racing-cards.css */
.rdp-st dt {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
/* The career by team, a stint a line, newest first (six at most, racing-drivers.js counts them):
   the team, which may wrap, and its years in a column of their own, never cut */
.rdpk-e {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 2px 12px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  line-height: 18px;
  color: var(--muted);
}
.rdpk-e li, .rdp-htm { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: baseline; }
.rdpk-tn { min-width: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.rdpk-ty, .rdp-hty { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ─── The driver's page ────────────────────────────────── */

.rdp-nav { margin: 0 2px -8px; font-size: 14px; }
.rdp-nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.rdp-nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.rdp-nav a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }

.rdp-head { display: flex; align-items: center; gap: 20px; padding: 18px; }
.rdp-hpic { width: 132px; height: 132px; font-size: 44px; }
.rdp-hid { min-width: 0; }
.rdp-hn { margin: 0; font: 600 32px/1.1 var(--display); }
.rdp-hc { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.rdp-hc a { color: var(--ink); font-weight: 600; text-decoration: none; }
.rdp-hc a:hover { text-decoration: underline; text-underline-offset: 3px; }
.rdp-no { color: var(--muted); }
/* The career by team under it, a stint a line, newest first, every team linked: the names in one
   column, which may wrap, the years in the next, never cut */
.rdp-ht {
  display: grid;
  grid-template-columns: minmax(0, max-content) max-content;
  gap: 3px 24px;
  width: max-content;
  max-width: 100%;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  line-height: 20px;
  color: var(--muted);
  font-size: 14px;
}
.rdp-ht a { min-width: 0; color: var(--ink); font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
.rdp-ht a:hover { text-decoration: underline; text-underline-offset: 3px; }
.rdp-ht a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }
.rdp-st { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 14px 0 0; }
.rdp-st dd { margin: 0; font: 600 30px/1.05 var(--display); font-variant-numeric: tabular-nums; }
/* The newest team's logo at the right, linked to its page, on white (racing-teams.css draws it); a
   team without a logo has none here */
.rdp-tl { flex: none; margin-left: auto; border-radius: 8px; text-decoration: none; }
.rdp-tl:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.rdp-tlb { width: 144px; height: 96px; padding: 14px; }

/* The capsule: the career in a few lines, a grid of them; on phones one line runs into its detail */
.rdp-cap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px 28px;
  margin: 0;
  padding: 16px 18px;
  list-style: none;
}
.rdp-cap li { min-width: 0; }
.rdp-cap b { display: block; font: 600 19px/1.2 var(--display); }
.rdp-cap span { display: block; margin-top: 2px; font-size: 13px; line-height: 1.35; color: var(--muted); }

/* Top finishes: a row per place, each Grand Prix with its years */
.rdp-fins { margin: 0; padding: 0 14px; list-style: none; }
.rdp-fin {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: baseline;
  padding: 11px 0;
}
.rdp-fin + .rdp-fin { border-top: 1px solid var(--line); }
.rdp-fin-h { display: flex; align-items: baseline; gap: 6px; }
.rdp-fin-b { display: flex; flex-wrap: wrap; gap: 5px 18px; font-size: 14px; }
.rdp-gp { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.rdp-gp-n { font-weight: 600; }
.rdp-gp a { color: var(--muted); text-decoration: none; font-variant-numeric: tabular-nums; }
.rdp-gp a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.rdp-gp a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }
.rdp-x { color: var(--muted); font-weight: 500; }
/* A place: the win filled in the profiles' green, the podium outlined */
.rdp-f {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font: 700 11px/1.6 var(--body);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.rdp-f1 { background: #1f5130; border-color: #1f5130; color: #fff; }
.rdp-f2, .rdp-f3 { border-color: var(--ink); color: var(--ink); }

/* Track record and seasons */
.rdp-t td { vertical-align: baseline; }
.rdp-t .rdp-n { width: 62px; }
.rdp-t .rdp-pd { width: 76px; }
.rdp-t .rdp-best { width: 96px; }
.rdp-t td.rdp-ci, .rdp-t td.rdp-tms { white-space: normal; }
.rdp-ci-n { font-weight: 600; }
.rdp-loc { margin-left: 8px; font-size: 13px; color: var(--muted); }
.rdp-y { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.rdp-t td.rdp-n, .rdp-t td.rdp-pts { font-variant-numeric: tabular-nums; }
.rdp-t td.rdp-n { color: var(--muted); }
.rdp-t td.rdp-hi { color: var(--ink); font-weight: 700; }
.rdp-t td.rdp-best a, .rdp-t td.rdp-yr a { font-weight: 600; }
.rdp-t .rdp-yr { width: 74px; }
.rdp-t .rdp-pts { width: 66px; }
.rdp-t .rdp-pos { width: 60px; }
.rdp-t td.rdp-pos { font-weight: 600; }
.rdp-t td.rdp-champ { color: var(--win); font-weight: 700; }
.rdp-t td.rdp-tms a { font-weight: 500; }

/* Column headings that sort: the heading's own look, an arrow on the sorted one */
.rdp-sort {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
}
.rdp-sort:hover { color: var(--ink); }
.rdp-sort:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
.rdp-tr th[aria-sort="ascending"], .rdp-tr th[aria-sort="descending"] { color: var(--ink); }
.rdp-tr th[aria-sort="ascending"] .rdp-sort::after { content: " ↑"; }
.rdp-tr th[aria-sort="descending"] .rdp-sort::after { content: " ↓"; }

@media (max-width: 600px) {
  /* Phones: the portrait beside the name, the five numbers in a row of their own under both */
  .rdp-head { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 0 14px; align-items: center; padding: 14px; }
  .rdp-hpic { grid-row: 1 / span 2; width: 88px; height: 88px; font-size: 30px; }
  .rdp-hid { display: contents; }
  .rdp-hn { grid-column: 2; align-self: end; font-size: 25px; }
  .rdp-hc { grid-column: 2; align-self: start; font-size: 13px; gap: 2px 12px; }
  .rdp-ht { grid-column: 1 / -1; margin-top: 12px; font-size: 13px; line-height: 18px; }
  .rdp-st { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin-top: 12px; }
  /* The newest team's logo, small, at the right of the teams */
  .rdp-head.rdp-hl { grid-template-columns: 88px minmax(0, 1fr) auto; }
  .rdp-hl .rdp-hn, .rdp-hl .rdp-hc { grid-column: 2 / -1; }
  .rdp-hl .rdp-ht { grid-column: 1 / 3; align-self: start; }
  .rdp-tl { grid-column: 3; grid-row: 3; align-self: start; margin: 12px 0 0; }
  .rdp-tl, .rdp-tl .rdp-tlb { border-radius: 6px; }
  .rdp-tlb { width: 60px; height: 40px; padding: 5px; }
  .rdp-st dd { font-size: 23px; }
  .rdp-cap { grid-template-columns: 1fr; gap: 9px; padding: 12px 14px; }
  .rdp-cap b { display: inline; font-size: 17px; }
  .rdp-cap span { display: inline; margin: 0 0 0 4px; }
  .rdp-fins { padding: 0 12px; }
  .rdp-fin { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  /* Phones: podiums and poles go; the circuit's town under its name */
  .rdp-t .rdp-n { width: 52px; }
  .rdp-t .rdp-pd, .rdp-t .rdp-po { width: 0; padding: 0; font-size: 0; }
  .rdp-t .rdp-best { width: 74px; }
  .rdp-t .rdp-yr { width: 62px; }
  .rdp-t .rdp-pts { width: 48px; }
  .rdp-t .rdp-pos { width: 44px; }
  .rdp-loc { display: block; margin: 1px 0 0; font-size: 12px; }
}
