/* The rivalry pages: /rivalries/ and /rivalries/<a>-vs-<b>/.
   Type, colour and figures come from the roles (roles.css); this sheet owns
   only layout. A pair's page reuses Player Stats' tiles, bar, keyed shares
   and rows (study_player_stats.html) and the player index's cards, so its
   blocks share one centred column rather than hugging the left of a wide
   page. Section titles already draw their own rules, so no block here adds a
   border beside one. */

.rivalry-jump {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 24px;
}

.rivalry-section {
  margin: 0 auto 36px;
}

/* The record, matches and players share the Player Stats dossier's width,
   centred under their headings; the games table keeps the page's width. */
.rivalry-record-tiles,
.rivalry-section > .player-stats-distribution,
.rivalry-record-actions,
.rivalry-match-list,
.rivalry-player-grid {
  max-width: 1080px;
  margin-inline: auto;
}

.rivalry-note {
  max-width: 62ch;
  margin: -4px auto 18px;
  text-align: center;
}

/* Four tiles fill whole rows at every width: two by two on a phone, one row
   from a tablet up. */
.stats-grid.rivalry-record-tiles {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 600px) {
  .stats-grid.rivalry-record-tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
}

/* The record's one picture is a step taller than a row's bar, as on Player
   Stats; the section scope outranks the role's themed height. */
.rivalry-section .rivalry-record-bar.result-distribution {
  height: 14px;
}

.rivalry-record-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

/* Match rows flow into as many columns as fit, each ruled below rather than
   above, so no column starts with a rule (Player Stats' champion rows). */
.rivalry-match-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  column-gap: 40px;
}

.rivalry-match-list .stats-opening-row,
.rivalry-match-list .stats-opening-row:first-of-type {
  border-top: 0;
  border-bottom: 1px solid rgba(var(--tint-rgb), 0.14);
  padding: 10px 0;
}

.rivalry-match-list .stats-opening-main strong {
  max-width: none;
}

/* Results by year: a narrow numeric table at a reading width. */
.rivalry-years {
  max-width: 48rem;
  margin: 0 auto;
}

.rivalry-years-table {
  font-variant-numeric: tabular-nums;
}

.rivalry-years-table th,
.rivalry-years-table td {
  padding: 8px 12px;
  vertical-align: middle;
}

.rivalry-years-table .is-numeric {
  text-align: right;
}

/* A year heads its row as a cell does, not as a column header. */
.rivalry-years-table th[scope="row"] {
  font-family: inherit;
  font-size: inherit;
  letter-spacing: 0;
  text-transform: none;
  text-shadow: none;
  background: none;
  color: var(--white);
  border-bottom: 1px solid var(--border);
}

.rivalry-years-table .rivalry-year-bar-cell {
  width: 32%;
  padding-left: 20px;
}

.rivalry-section .rivalry-year-bar.result-distribution {
  min-width: 3px;
}

/* On a phone the counts fill the screen without panning: the bar, which
   repeats them, leaves, and the headings wrap and tighten. */
@media (max-width: 599px) {
  /* The games table's phone floor (680px) is for a list of games; five
     short counts fit the screen. */
  .games-table.rivalry-years-table {
    min-width: 0;
  }

  .rivalry-years-table .rivalry-year-bar-cell {
    display: none;
  }

  .rivalry-years-table th,
  .rivalry-years-table td {
    padding: 8px 6px;
  }

  /* The phone games table keeps each heading on one line
     (site-theme-charcoal.css); a player's "won" column may take two here. */
  body.site-theme-charcoal .games-table.rivalry-years-table thead th {
    letter-spacing: 0.5px;
    white-space: normal;
    vertical-align: bottom;
  }

  .rivalry-section > .player-stats-distribution .player-stats-shares {
    justify-content: flex-start;
    column-gap: 16px;
  }
}

/* The shell is edge to edge on a phone, so the blocks carry their own inset
   (design-system.md, Phone). The tables keep their edge-to-edge scroll. */
@media (max-width: 720px) {
  .rivalry-note,
  .rivalry-record-tiles,
  .rivalry-section > .player-stats-distribution,
  .rivalry-record-actions,
  .rivalry-match-list,
  .rivalry-player-grid {
    padding-inline: 14px;
  }
}

/* The two players side by side once two cards fit. */
@media (min-width: 760px) {
  .rivalry-player-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.rivalry-index-table .is-numeric {
  text-align: right;
}
