/* The race-by-race section of a driver page (scripts/driverSeason.js): the
   driver against their teammate, a strip of the season with a column per
   round, and the power unit parts used. Tokens come from signal.css; the
   team's colour is the profile page's own --team-colour. */

.sf {
  --sf-ink: var(--sg-ink);
  --sf-muted: var(--sg-muted);
  --sf-line: var(--sg-line);
  --sf-line-strong: var(--sg-line-strong);
  --sf-mist: var(--sg-mist);
  --sf-paper: var(--sg-paper);
  --sf-ease: var(--sg-ease, cubic-bezier(0.22, 1, 0.36, 1));
  padding: 2.5rem 0;
  border-top: 1px solid var(--sf-line);
}
.sf[hidden] { display: none; }

.sf-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.sf-head h2 { margin: 0 0 1.25rem; font-size: 1.5rem; }
.sf-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--sf-ink); font-size: 0.875rem; font-weight: 650; text-decoration: underline; text-decoration-color: var(--team-colour); text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.sf-link:hover { text-decoration-color: var(--sf-ink); }

/* ---- Against the teammate ---- */

.sf-duel { display: grid; gap: 10px; margin-bottom: 28px; padding: 20px 22px 22px; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--sf-line); background: var(--sf-mist); }
.sf-duel-title { margin: 0 0 4px; color: var(--sf-muted); font-size: 0.875rem; font-weight: 600; }
.sf-duel-title a { color: var(--sf-ink); font-weight: 700; text-decoration: underline; text-decoration-color: var(--sf-line-strong); text-underline-offset: 0.3em; }
.sf-duel-title a:hover { text-decoration-color: var(--sf-ink); }
.sf-duel-row { display: grid; grid-template-columns: 7rem 2.5rem minmax(0, 1fr) 2.5rem; align-items: center; column-gap: 12px; row-gap: 2px; }
.sf-duel-label { color: var(--sf-muted); font-size: 0.875rem; }
.sf-duel-mine, .sf-duel-theirs { font-size: 1.375rem; font-weight: 720; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.sf-duel-mine { text-align: right; }
.sf-duel-theirs { color: var(--sf-muted); }
.sf-duel-bar { height: 10px; border-radius: 5px; background: var(--sf-line-strong); overflow: hidden; }
.sf-duel-bar i { display: block; width: calc(var(--sf-share) * 100%); height: 100%; border-radius: 5px 0 0 5px; background: var(--team-colour); box-shadow: inset 0 0 0 1px var(--sf-line-strong); }
.sf-duel-note { grid-column: 3 / -1; color: var(--sf-muted); font-size: 0.75rem; }

/* ---- The season, a column per round ---- */

.sf-rounds { --sf-rounds: 15; display: grid; grid-template-columns: auto repeat(var(--sf-rounds), minmax(0, 1fr)); grid-template-rows: repeat(4, auto); margin: 0; padding: 0; list-style: none; }
.sf-round { display: grid; grid-row: 1 / -1; grid-template-rows: subgrid; justify-items: center; align-items: center; min-width: 0; }
.sf-round > * { padding: 9px 2px; }
.sf-round > :nth-child(n + 2) { width: 100%; border-top: 1px solid var(--sf-line); text-align: center; }
.sf-labels { justify-items: start; padding-right: 16px; color: var(--sf-muted); font-size: 0.8125rem; font-weight: 600; }
.sf-labels > :nth-child(n + 2) { text-align: left; }
.sf-round-link { display: grid; justify-items: center; gap: 2px; width: 100%; min-height: 44px; align-content: center; border-radius: 10px; color: var(--sf-muted); text-decoration: none; transition: background-color 220ms var(--sf-ease), color 220ms var(--sf-ease); }
.sf-round-link:hover { background: var(--sf-mist); color: var(--sf-ink); }
.sf-round-link:focus-visible { outline: 2px solid var(--sg-orange); outline-offset: -2px; }
.sf-round-link b { font-size: 0.8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sf-round-link span { display: none; }
.sf-cell { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 30px; }
.sf-quali { color: var(--sf-muted); }
.sf-quali.is-pole { color: var(--sf-ink); font-weight: 720; }
/* a finish reads at a glance: a win filled, a podium ringed, points in ink, the rest quiet */
.sf-race::before, .sf-quali.is-pole::before { content: none; }
.sf-race { position: relative; z-index: 0; color: var(--sf-muted); }
.sf-race.is-points { color: var(--sf-ink); }
.sf-race.is-win, .sf-race.is-podium, .sf-quali.is-pole { position: relative; z-index: 0; color: var(--sf-ink); font-weight: 720; }
.sf-race.is-win::after, .sf-race.is-podium::after, .sf-quali.is-pole::after { content: ""; position: absolute; left: 50%; top: 50%; z-index: -1; width: 30px; height: 30px; border-radius: 50%; transform: translate(-50%, -50%); }
.sf-race.is-podium::after, .sf-quali.is-pole::after { box-shadow: inset 0 0 0 2px var(--sf-ink); }
.sf-race.is-win { color: var(--sg-night); }
.sf-race.is-win::after { background: var(--sg-orange); }
.sf-race.is-out { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.02em; }
.sf-points { color: var(--sf-ink); font-size: 0.875rem; }
.sf-points.is-none { color: var(--sf-muted); }

/* ---- Power unit parts ---- */

.sf-parts { margin-top: 32px; }
.sf-parts h3 { margin: 0 0 14px; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em; }
.sf-part-list { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.sf-part { display: grid; justify-items: center; gap: 2px; padding: 14px 4px 12px; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--sf-line); background: var(--sf-paper); color: var(--sf-muted); text-align: center; }
.sf-part abbr { font-size: 0.75rem; font-weight: 700; text-decoration: none; }
.sf-part b { color: var(--sf-ink); font-size: 1.5rem; font-weight: 720; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sf-part span { font-size: 0.75rem; }
.sf-part.is-limit { box-shadow: inset 0 0 0 2px var(--sf-ink); }
.sf-part.is-over { background: var(--sg-orange); box-shadow: none; color: var(--sg-night); }
.sf-part.is-over b { color: inherit; }
.sf-parts-note { margin: 12px 0 0; color: var(--sf-muted); font-size: 0.8125rem; }

@media (max-width: 860px) {
  /* one round to a row */
  .sf-rounds { grid-template-columns: minmax(0, 1fr) repeat(3, 4.25rem); grid-template-rows: none; }
  .sf-round { grid-row: auto; grid-column: 1 / -1; grid-template-rows: none; grid-template-columns: subgrid; justify-items: center; border-top: 1px solid var(--sf-line); }
  .sf-round > :nth-child(n + 2) { border-top: 0; }
  .sf-round > * { padding: 8px 2px; }
  .sf-labels { padding-right: 0; border-top: 0; font-size: 0.75rem; }
  .sf-labels > * { text-align: center; }
  .sf-labels > :first-child { justify-self: start; }
  .sf-round-link { grid-template-columns: auto minmax(0, 1fr); justify-items: start; gap: 12px; min-width: 0; min-height: 40px; padding-left: 4px; }
  .sf-round > .sf-round-link { justify-self: stretch; }
  .sf-round-link b { min-width: 1.5rem; }
  .sf-round-link span { display: block; justify-self: stretch; min-width: 0; overflow: hidden; color: var(--sf-ink); font-size: 0.9375rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
  .sf-part-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sf-duel { padding: 16px 16px 18px; }
  .sf-duel-row { grid-template-columns: 5.25rem 2rem minmax(0, 1fr) 2rem; column-gap: 10px; }
  .sf-duel-mine, .sf-duel-theirs { font-size: 1.125rem; }
  .sf-duel-note { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .sf-round-link { transition: none; }
}
