/* Great Rivalries: the country tabs, the rivalry cards, the group table, the head-to-head card and lists.
   Each rivalry's two club colors come with its data (validated for light and dark next to the draw gray). */

:root {
  --team-a: #d33a3c;
  --team-b: #245fd4;
  --draw: #b8bcc1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --draw: #56595e; }
}

:root[data-theme="dark"] { --draw: #56595e; }

/* Country tabs */

.country-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.country-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  cursor: pointer;
}

.country-tabs button:hover {
  border-color: var(--axis);
}

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

.country-tabs .flag {
  width: 22px;
  height: 16px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border);
}

.country-tabs small {
  color: var(--ink-muted);
  font-size: 12px;
}

/* Rivalry cards: one per rivalry of the country, grouped by state in Brazil. */

.rivalry-picker {
  margin-bottom: 8px;
}

.picker-region {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  margin: 14px 0 6px;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

#group-matrix {
  overflow-x: auto;
  max-width: 100%;
}

@media (max-width: 560px) {
  .picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .rivalry-picker button {
    padding: 8px 10px;
  }

  .rivalry-picker strong {
    font-size: 15px;
  }
}

.rivalry-picker button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.rivalry-picker button:hover {
  border-color: var(--axis);
}

.rivalry-picker button[aria-selected="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.rivalry-picker .crests {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rivalry-picker .crests img,
.rivalry-picker .crests .crest-badge {
  width: 24px;
  height: 24px;
}

.rivalry-picker strong {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.rivalry-picker small {
  color: var(--ink-2);
  font-size: 12px;
}

/* Head-to-head card */

.versus-card {
  margin-bottom: 12px;
}

.rv-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.rv-side {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.rv-side.right {
  flex-direction: row-reverse;
  text-align: right;
}

.rv-side img,
.rv-side .crest-badge {
  width: 56px;
  height: 56px;
  flex: none;
}

.rv-side .rv-name {
  font-weight: 650;
  font-size: 17px;
  line-height: 1.2;
}

.rv-side .rv-wins {
  font-family: var(--display);
  font-size: clamp(44px, 8vw, 72px);
  font-weight: 800;
  line-height: 0.9;
}

.rv-side .rv-label {
  color: var(--ink-2);
  font-size: 13px;
}

.rv-mid {
  text-align: center;
}

.rv-mid .rv-draws {
  font-family: var(--display);
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 700;
  line-height: 0.9;
  color: var(--ink-2);
}

.rv-mid .rv-label {
  color: var(--ink-muted);
  font-size: 13px;
}

.rv-split {
  display: flex;
  gap: 2px;
  height: 12px;
  margin: 18px 0 10px;
}

.rv-split div {
  background: var(--c);
  min-width: 2px;
}

.rv-split div:first-child {
  border-radius: 4px 0 0 4px;
}

.rv-split div:last-child {
  border-radius: 0 4px 4px 0;
}

.rv-goals {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.rv-goals strong {
  color: var(--ink);
}

.team-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
  flex: none;
}

.chart-note {
  color: var(--ink-2);
  font-size: 14px;
  margin: 10px 0 0;
}

/* Competition table: a 100% bar per row */

.wdl-bar {
  display: flex;
  gap: 2px;
  height: 10px;
  min-width: 90px;
}

.wdl-bar div {
  background: var(--c);
}

.wdl-bar div:first-child {
  border-radius: 3px 0 0 3px;
}

.wdl-bar div:last-child {
  border-radius: 0 3px 3px 0;
}

.data-table tr.group-row td {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--wash);
}

.data-table tr.total-row td {
  font-weight: 650;
  border-top: 1px solid var(--axis);
}

.data-table td.win {
  font-weight: 700;
}

/* Venue cards */

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

.venue-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  margin: 0 0 4px;
}

.venue-card h3 img,
.venue-card h3 .crest-badge {
  width: 22px;
  height: 22px;
}

.venue-card .venue-sub {
  color: var(--ink-2);
  font-size: 13px;
  margin: 0 0 12px;
}

.venue-card .rv-split {
  margin: 10px 0 8px;
}

.venue-nums {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.venue-nums span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Knockout ties */

.tie-list {
  display: grid;
}

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

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

.tie-row .tie-year {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  font-size: 14px;
}

.tie-row .tie-what {
  font-weight: 600;
  font-size: 14px;
}

.tie-row .tie-legs {
  color: var(--ink-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.tie-row .tie-winner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px 8px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 0;
}

.tie-row .tie-winner .tie-tag {
  white-space: normal;
  margin-left: 0;
}

.tie-row .tie-winner img,
.tie-row .tie-winner .crest-badge {
  width: 22px;
  height: 22px;
}

.tie-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: 1px;
}

/* Tallies (ties, finals): two big numbers */

.tally {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.tally .side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tally .side.right {
  flex-direction: row-reverse;
}

.tally .side img,
.tally .side .crest-badge {
  width: 36px;
  height: 36px;
}

.tally .num {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
}

.tally .mid {
  color: var(--ink-muted);
  font-size: 13px;
  text-align: center;
}

.tally-note {
  color: var(--ink-2);
  font-size: 13px;
  margin: 12px 0 0;
}

/* Record lists */

.rec-list {
  display: grid;
}

.rec-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.rec-row .rec-main {
  font-weight: 600;
}

.rec-row .rec-sub {
  display: block;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 400;
}

.rec-row .rec-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

/* Player leaders */

.leader-row {
  display: grid;
  grid-template-columns: 1.8em minmax(0, 1fr) minmax(60px, 1.2fr) 2.4em;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.leader-row .rank {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.leader-row .who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.leader-row .who strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-row .who span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 12px;
}

.leader-row .bar {
  height: 10px;
  background: var(--c);
  border-radius: 0 4px 4px 0;
}

.leader-row .val {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.leader-split {
  display: grid;
  gap: 16px;
}

.leader-split h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 0 0 4px;
  color: var(--ink-2);
}

.empty-note {
  color: var(--ink-2);
  font-size: 14px;
  margin: 0;
}

/* Match table */

.match-controls {
  flex-wrap: wrap;
  gap: 10px;
}

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

.data-table td.match-score {
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table td.match-score small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-2);
}

.data-table td.match-team {
  white-space: nowrap;
}

.data-table td.match-team.right {
  text-align: right;
}

.data-table td.match-team.won {
  font-weight: 700;
}

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

.data-table td.match-comp {
  font-size: 13px;
  min-width: 9em;
}

.data-table td.match-comp small {
  display: block;
  color: var(--ink-2);
  font-size: 12px;
}

@media (max-width: 860px) {
  .rivalry-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .venue-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .rv-side {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .rv-side.right {
    flex-direction: column;
    align-items: flex-end;
  }

  .rv-side img,
  .rv-side .crest-badge {
    width: 40px;
    height: 40px;
  }

  .rv-side .rv-name {
    font-size: 14px;
  }

  .tie-row {
    grid-template-columns: 4.2em minmax(0, 1fr);
  }

  .tie-row .tie-winner {
    grid-column: 2;
    justify-content: flex-start;
  }

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

/* Long competition names (Copa de Honor "Municipalidad de la Ciudad de Buenos Aires") on phones */
#comp-table {
  overflow-x: auto;
}

#match-comp {
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
}

@media (max-width: 560px) {
  #comp-table th,
  #comp-table td {
    padding: 8px 5px;
  }

  #comp-table td:first-child {
    overflow-wrap: anywhere;
    min-width: 7em;
  }
}
