/* Shared chart and layout styles for every infographic. */

/* Page header: sport label, a big condensed headline and the lede. */

.hero {
  position: relative;
  isolation: isolate;
  padding-top: 52px;
  padding-bottom: 8px;
}

/* a faint wash of the sport's color behind the header */
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: calc(-1 * var(--nav-h)) 0 0;
  background: radial-gradient(60% 90% at 85% 0%, color-mix(in srgb, var(--sport) 16%, transparent), transparent 70%);
  pointer-events: none;
}

.hero .kicker a {
  color: inherit;
  text-decoration: none;
}

.hero .kicker a:hover {
  color: var(--ink);
}

.hero h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(46px, 9vw, 92px);
  line-height: 0.92;
  letter-spacing: 0.002em;
  text-transform: uppercase;
  margin: 0 0 18px;
  max-width: 16ch;
}

.lede {
  font-size: clamp(17px, 2.2vw, 20px);
  color: var(--ink-2);
  max-width: 660px;
  margin: 0 0 32px;
}

/* Stat tiles */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--sport);
}

.stat .label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Big numbers in the display face; long values (a country's name) wrap instead of overflowing. */
.stat .value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-width: 0;
  font-family: var(--display);
  font-size: clamp(30px, 4.6vw, 42px);
  font-weight: 800;
  line-height: 1;
  overflow-wrap: anywhere;
}

.stat .detail {
  font-size: 13px;
  color: var(--ink-muted);
}

@media (max-width: 760px) {
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Sections */

.block {
  margin-top: 80px;
  scroll-margin-top: calc(var(--nav-h) + 56px);
}

.block-head h2 {
  position: relative;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(30px, 4.4vw, 42px);
  letter-spacing: 0.005em;
  line-height: 1;
  margin: 0 0 10px;
  padding-top: 14px;
}

/* the sport's color as a short rule above every section title */
.block-head h2::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--sport);
}

.block-head p {
  color: var(--ink-2);
  margin: 0 0 20px;
  max-width: 700px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

h3.sub {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.01em;
  margin: 0 0 12px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--wash);
  border: 1px solid var(--border);
}

.segmented button {
  font: inherit;
  font-size: 14px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button[aria-selected="true"] {
  background: var(--ink);
  color: var(--page);
  font-weight: 600;
}

.chart {
  width: 100%;
  position: relative;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart text {
  font-family: var(--font);
}

.axis text,
.tick-label {
  fill: var(--ink-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.gridline {
  stroke: var(--grid);
  stroke-width: 1;
}

.baseline {
  stroke: var(--axis);
  stroke-width: 1;
}

.label-name {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.label-value {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.label-muted {
  fill: var(--ink-2);
  font-size: 12px;
}

/* Legend */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--c);
}

.legend i.line {
  height: 2px;
  width: 16px;
  border-radius: 1px;
}

/* Race */

.race-date {
  margin-left: auto;
  font-family: var(--display);
  font-size: clamp(36px, 6vw, 60px);
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--ink-muted);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.race-ticker {
  min-height: 1.6em;
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}

.race-ticker strong {
  color: var(--ink);
}

.race-ticker i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  margin-right: 6px;
}

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.btn-play {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--sport);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--sport) 40%, transparent);
}

.player input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--sport);
}

.player select {
  font: inherit;
  font-size: 14px;
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

/* Tables */

.table-view {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 14px;
}

.table-view summary {
  cursor: pointer;
  color: var(--ink-2);
}

.table-view .scroll {
  overflow-x: auto;
  max-height: 360px;
  margin-top: 12px;
}

.table-view table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.table-view th,
.table-view td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-view th {
  color: var(--ink-2);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--surface);
}

/* Tooltip */

.tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  font-size: 13px;
  max-width: 280px;
  color: var(--ink-2);
}

.tooltip .tt-title {
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 6px;
}

.tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.tooltip .tt-row i {
  width: 12px;
  height: 2px;
  border-radius: 1px;
  background: var(--c);
  flex: none;
}

.tooltip .tt-row b {
  color: var(--ink);
  min-width: 18px;
}

.tooltip .tt-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-muted);
}

.hit:focus {
  outline: none;
}

.hit:focus-visible + .mark,
.mark-group:focus-visible .mark {
  stroke: var(--ink);
  stroke-width: 1.5;
}

/* Generic data table */

.data-table {
  overflow-x: auto;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
  border-bottom-color: var(--axis);
}

.data-table tbody tr:hover td,
.data-table tr:hover td {
  background: var(--wash);
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  white-space: nowrap;
}

.data-table td.strong {
  font-weight: 650;
}

.data-table td.years {
  color: var(--ink-2);
  font-size: 13px;
  min-width: 12em;
}

.data-table .who {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-weight: 600;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

/* On phones, a table's long "years" column moves under the name. */
.data-table .sub,
.data-table .short {
  display: none;
}

/* Tables whose second line (a date, a score, a share) matters at every width. */
.data-table.with-sub .sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-2);
  white-space: normal;
}

@media (max-width: 640px) {
  .data-table th,
  .data-table td {
    padding: 8px 6px;
  }

  .data-table .long {
    display: none;
  }

  .data-table .short {
    display: inline;
  }

  .data-table td.years,
  .data-table th.years {
    display: none;
  }

  .data-table .sub {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-2);
    white-space: normal;
  }
}

/* Repeated finals */

.pair-list {
  display: grid;
}

.pair-row {
  display: grid;
  grid-template-columns: 3.2em minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.pair-row:last-child {
  border-bottom: 0;
}

.pair-row .count {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.pair-row .count small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
}

.pair-row .players {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-weight: 600;
}

.pair-row .players span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pair-row .players .vs {
  color: var(--ink-muted);
  font-weight: 400;
}

.pair-row .meta {
  grid-column: 2 / -1;
  font-size: 13px;
  color: var(--ink-2);
  margin-top: -6px;
  overflow-wrap: anywhere;
}

/* On phones the head-to-head summary moves under the names. */
@media (max-width: 640px) {
  .pair-row {
    grid-template-columns: 3.2em minmax(0, 1fr);
  }

  .pair-list .pair-row .h2h {
    grid-column: 2;
    white-space: normal;
    margin-top: -6px;
  }
}

.pair-row .h2h {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 760px) {
  .card {
    padding: 16px;
  }
}

/* Toggle chips (pick up to four series), each pressed chip in its series color. */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.chips button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.chips button:hover {
  color: var(--ink);
}

.chips button[aria-pressed="true"] {
  border-color: var(--c);
  box-shadow: inset 0 0 0 1px var(--c);
  color: var(--ink);
  font-weight: 600;
}

.chips button[aria-pressed="true"]::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}

.chips .flag {
  width: 18px;
  height: 12px;
}

/* Line charts with a crosshair */

.trend-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
}

.trend-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.crosshair {
  stroke: var(--axis);
  stroke-dasharray: 3 3;
}

/* A dropdown beside the tabs (long lists of records). */
.controls > select {
  font: inherit;
  font-size: 14px;
  max-width: 100%; /* long option names would otherwise set the width */
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
}
