/* ==========================================================================
   Public data pages: leaderboard, matches, match, teams, team, maps, map.
   Page-specific additions on top of site.css (load after it). Uses site.css tokens only.
   ========================================================================== */

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
}
.toolbar .field { margin: 0; }
.toolbar .grow { flex: 0 1 420px; min-width: 0; }
.toolbar-count { margin-left: auto; font-family: var(--font-label); font-size: 11.5px; font-weight: 600; line-height: 1; color: var(--muted); text-transform: uppercase; letter-spacing: var(--tracking-label); padding-bottom: 16px; }
.toolbar-count strong { color: var(--text); }
.toolbar select { min-width: 200px; }
.toolbar .segmented { min-height: 44px; }
.toolbar .segmented > * { display: inline-flex; align-items: center; justify-content: center; }
input.search-input { padding-left: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23666a73' stroke-width='1.4'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 13px center; background-size: 15px 15px; }
.search-input::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.6); }
@media (max-width: 640px) {
  .toolbar { align-items: stretch; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar select { min-width: 0; }
  .toolbar-count { margin-left: 0; padding-bottom: 0; }
  .toolbar .segmented { justify-content: stretch; }
  .toolbar .segmented > * { flex: 1; }
}

/* ---------------------------------------------------------------- states */
.state-box { padding: var(--s-6) var(--s-4); display: grid; place-items: center; }
.callout .btn { margin-top: var(--s-3); }
.table td.state-cell { padding: 0; }
.table td.state-cell .empty { box-shadow: none; }
.skel-row td { padding-block: 16px; }

/* ---------------------------------------------------------------- small stars, score lines */
.stars-sm > i { width: 12px; height: 12px; }
.stars-sm { gap: 2px; }

.raid-score { display: grid; gap: 4px; min-width: 132px; }
.rs { display: flex; align-items: center; gap: 8px; padding-left: 8px; line-height: 1; box-shadow: inset 2px 0 0 var(--rs-c, var(--line-3)); white-space: nowrap; }
.rs-a { --rs-c: var(--team-a); }
.rs-b { --rs-c: var(--team-b); }
.rs-pct { font-size: 13px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; color: var(--text-dim); min-width: 4.2ch; }
.rs.is-best .rs-pct { color: var(--heading); }

/* matchup links inside tables keep the team colours */
.matchup a.a, .matchup a.b { text-decoration: none; }
.matchup a.a:hover, .matchup a.b:hover { text-decoration: underline; }
.matchup.has-winner > a:not(.is-winner) { opacity: 0.72; font-weight: 500; }
.match-id { font-size: 13px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; color: var(--muted); text-decoration: none; white-space: nowrap; }
.match-id:hover { color: var(--accent); }
.table tr[data-href] { cursor: pointer; }
.kind-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mt-sub { display: none; margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); }

/* narrow homes (team page main column): fold the map column into the teams cell */
.match-wrap { container-type: inline-size; }
@container (max-width: 980px) {
  .match-table td, .match-table th { padding-inline: 8px; }
  .match-table .mt-map { display: none; }
  .match-table .mt-sub { display: block; }
  .match-table th:nth-child(5) { display: none; }
}

/* match list table turns into stacked cards when its box is narrow (phones, tablet sidebars) */
@container (max-width: 760px) {
  .match-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .match-table, .match-table tbody { display: block; width: 100%; }
  .match-table tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "kind  status when"
      "teams teams  teams"
      "score score  replay"
      "map   map    id";
    gap: 8px 10px;
    align-items: center;
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--line);
  }
  .match-table tbody tr:last-child { border-bottom: 0; }
  .match-table td { display: block; padding: 0 !important; border: 0 !important; text-align: left !important; }
  .match-table .mt-id { grid-area: id; justify-self: end; }
  .match-table .mt-kind { grid-area: kind; }
  .match-table .mt-teams { grid-area: teams; }
  .match-table .mt-score { grid-area: score; }
  .match-table .mt-map { grid-area: map; font-size: var(--fs-xs); display: block !important; }
  .match-table .mt-sub { display: none !important; }
  .match-table .mt-map::before { content: "map "; color: var(--muted); }
  .match-table .mt-when { grid-area: when; justify-self: end; font-size: var(--fs-xs); color: var(--muted); }
  .match-table .mt-status { grid-area: status; }
  .match-table .mt-replay { grid-area: replay; justify-self: end; }
  .match-table .raid-score { min-width: 0; grid-auto-flow: column; justify-content: start; gap: 14px; }
  .match-table .state-row { display: block; padding: 0; }
  .match-table .skel-row { display: block; padding: 14px; }
  .match-table .skel-row td:not(:first-child) { display: none; }
  .match-table .matchup .a { flex-basis: auto; }
}

/* ---------------------------------------------------------------- leaderboard */
.lb-winrate { display: inline-grid; gap: 4px; justify-items: end; min-width: 72px; }
.lb-winrate .meter { width: 72px; height: 3px; }
.lb-winrate span { font-size: 13px; font-weight: 600; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.leaderboard .team-cell .tag { margin-left: 6px; vertical-align: 2px; }
.leaderboard tr.is-hidden { display: none; }
.lb-note { margin-top: var(--s-4); color: var(--muted); font-size: var(--fs-xs); max-width: 90ch; }
@media (max-width: 640px) {
  .leaderboard .rank { width: 44px; }
  .leaderboard td, .leaderboard th { padding-inline: 8px; }
  .leaderboard .rating-dev { display: block; margin: 2px 0 0; }
  .leaderboard .team-cell { gap: var(--s-2); }
  .leaderboard .team-cell .avatar { display: none; }
  .lb-winrate { min-width: 0; }
  .lb-winrate .meter { width: 48px; }
}

/* stat tiles two to a row on phones */
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-3); }
  .stats .stat { padding-left: var(--s-3); }
  .stats .stat-value { font-size: 17px; margin: 6px 0 4px; }
}

/* ---------------------------------------------------------------- team cards (teams.html) */
.team-card .team-card-head { display: flex; gap: var(--s-3); align-items: center; min-width: 0; }
.team-card .team-card-head > div { min-width: 0; display: grid; gap: 6px; }
.team-card .team-card-head .avatar { width: 44px; height: 44px; font-size: 12px; }
.team-card .card-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
.team-card .team-card-bio { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: calc(3 * 1.7em); }
.team-card .team-card-bio.is-empty { color: var(--muted); font-style: italic; }
.team-card .card-footer > span { display: inline-flex; align-items: baseline; gap: 4px; }
.team-card.is-own { --card-edge: var(--accent-line); box-shadow: inset 0 3px 0 var(--accent), var(--shadow-sm); }
.tag-house { color: var(--muted); }
.tag-own { color: var(--on-accent); background: var(--accent); box-shadow: none; }

/* ---------------------------------------------------------------- team page */
.team-hero { display: flex; gap: var(--s-5); align-items: center; flex-wrap: wrap; }
.team-hero .avatar-lg { width: 80px; height: 80px; font-size: 19px; }
.team-hero > div { flex: 1 1 200px; min-width: 0; }
@media (max-width: 640px) {
  .team-hero { gap: var(--s-4); }
  .team-hero .avatar-lg { width: 56px; height: 56px; font-size: 13.5px; }
}
.team-hero h1 { overflow-wrap: anywhere; }
.team-bio { white-space: pre-line; overflow-wrap: anywhere; }
.member-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.member-list li { display: flex; align-items: center; gap: var(--s-3); margin: 0; min-width: 0; }
.member-list li span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.challenge-result { margin-top: var(--s-4); }
.only-stacked { display: none !important; }
@media (max-width: 960px) { .only-stacked { display: inline-flex !important; } }
#challenge { scroll-margin-top: calc(var(--header-h) + 16px); }

/* rating chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-mono); }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.chart .ax-label { fill: var(--muted); font-size: 10.5px; }
.chart .end-label { fill: var(--heading); font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; }
.chart-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  min-width: 150px;
  padding: 8px 10px;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: var(--fs-xs);
  line-height: 1.5;
  white-space: nowrap;
}
.chart-tip strong { display: block; font-size: 14px; font-variant-numeric: lining-nums tabular-nums; font-weight: 600; color: var(--heading); margin: 2px 0; }
.chart-tip .muted { display: block; }
.chart-table { margin-top: var(--s-4); }
.chart-table summary { cursor: pointer; font-family: var(--font-label); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--muted); }
.chart-table summary:hover { color: var(--accent); }
.chart-table .table-wrap { margin-top: var(--s-3); max-height: 320px; overflow-y: auto; }

/* ---------------------------------------------------------------- match page */
.match-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); margin-top: var(--s-5); }
.match-actions .meta-line { color: var(--muted); font-size: var(--fs-sm); }
.match-actions .meta-line a { color: var(--text-dim); }
.match-actions .btn-lg { margin-left: auto; }
@media (max-width: 640px) { .match-actions .btn-lg { margin-left: 0; width: 100%; } }
.versus a.side-name { text-decoration: none; }
.versus a.side-name:hover { text-decoration: underline; }
.side-rating { font-size: 13px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; line-height: 1.3; color: var(--muted); }
.side-rating b { color: var(--text); font-weight: 600; }
.verdict { margin: var(--s-4) 0 0; font-size: var(--fs-lg); line-height: 1.4; color: var(--text); }
.raid-panel .panel-head p { margin: 0; color: var(--muted); font-size: var(--fs-xs); flex-basis: 100%; }
.raid-panel .raid-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.raid-panel .raid-big { font-family: var(--font-heading); font-size: clamp(22px, 2.2vw, 28px); font-weight: 500; letter-spacing: -0.01em; color: var(--heading); }
.raid-panel .meter + .meter-label { margin-top: var(--s-4); }
.raid-panel .kv { margin-top: var(--s-4); }
.map-panel .map-thumb { max-width: 320px; margin-inline: auto; }
.team-links { display: grid; gap: var(--s-3); }
.team-link { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0 var(--s-3) var(--s-3); min-width: 0; text-decoration: none; color: var(--text); box-shadow: inset 2px 0 0 var(--tl-c, var(--line-3)); }
.team-link:hover { color: var(--heading); background: rgba(255, 255, 255, 0.04); }
.team-link.tl-a { --tl-c: var(--team-a); }
.team-link.tl-b { --tl-c: var(--team-b); }
.team-link > div { min-width: 0; flex: 1; }
.team-link strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-link .xs { color: var(--muted); }
.team-link::after { content: ""; width: 12px; height: 12px; margin-right: 4px; background: var(--muted); -webkit-mask: var(--icon-arrow-ne) center / contain no-repeat; mask: var(--icon-arrow-ne) center / contain no-repeat; }

/* ---------------------------------------------------------------- maps */
.map-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 10px;
  background: var(--bg-2);
  border-radius: var(--radius);
}
.map-thumb canvas, .map-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.map-thumb > canvas { position: absolute; inset: 0; margin: auto; max-width: calc(100% - 20px); max-height: calc(100% - 20px); }
.map-thumb .thumb-empty { width: 100%; height: 100%; background: none; }
.map-gallery { --min: 220px; }
@media (max-width: 640px) { .map-gallery { --min: 150px; --grid-gap: 12px; } .map-thumb { padding: 6px; } }
.map-card .card-title { font-size: 13px; }
.map-card .card-footer { justify-content: flex-start; }
.map-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin: 0 0 var(--s-5); padding: 0; list-style: none; font-family: var(--font-label); font-size: 11.5px; font-weight: 600; line-height: 1; text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--muted); }
.map-legend li { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.map-legend .sw { width: 12px; height: 12px; flex: none; border-radius: 2px; }
.sw-rock { background: var(--map-rock); box-shadow: inset 2px 2px 0 var(--map-rock-hi), inset -2px -2px 0 var(--map-rock-lo); }
.sw-ground { background: var(--map-ground); box-shadow: inset 0 0 0 1px var(--line-2); }
.sw-deploy { background: var(--map-deploy); box-shadow: inset 0 0 0 1px var(--map-deploy-edge); }
.sw-axis { background: linear-gradient(90deg, transparent 5px, var(--map-axis) 5px 7px, transparent 7px); }

.map-stage { padding: var(--s-4); display: grid; place-items: center; }
.map-stage .map-canvas { cursor: crosshair; }
.map-readout { margin-top: var(--s-3); min-height: 1.4em; font-size: 13px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; line-height: 1.2; color: var(--muted); text-align: center; }
.map-readout b { color: var(--accent); font-weight: 600; }
.other-maps { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.other-maps a { text-decoration: none; }
.other-maps a:hover .tag { color: var(--accent); box-shadow: inset 0 0 0 1px var(--cyan-2); }
.other-maps .tag[aria-current="page"] { color: var(--on-accent); background: var(--accent); box-shadow: none; }
