/* match report, player card and players pages: layout (tokens + shared components in theme.css). */

/* overview: scoreboard beside the stat tiles on wide screens, players strip under both */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 1000px) {
  #overview { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); column-gap: 24px; row-gap: 0;
    grid-template-areas: "score tiles" "pf pf"; align-items: start; }
  #overview > .hero { display: contents; }
  #overview #scoreboard { grid-area: score; }
  #overview #tiles { grid-area: tiles; }
  #overview > .pf { grid-area: pf; }
}

/* scoreboard: team colour bar, big score, winner's score in the brand gradient */
.scoreboard { padding: 10px 24px 16px; position: relative; overflow: hidden; }
.scoreboard::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand-grad); }
.sb-row { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 0; }
.sb-row + .sb-row { border-top: 1px solid var(--grid); }
.sb-row .sw { width: 4px; height: auto; align-self: stretch; min-height: 44px; border-radius: 4px; }
.sb-row .nm { font-weight: 700; font-size: 16px; letter-spacing: -0.005em; margin-bottom: 4px; }
.sb-row .ds { font-size: 13px; color: var(--muted); line-height: 1.35; }
.sb-row .sc { font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; padding-right: 2px; }
.sb-row:not(.lost) .sc { color: var(--accent-ink); }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .sb-row:not(.lost) .sc { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
}
.sb-row.lost .sc { color: var(--muted); font-weight: 700; }
.sb-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; padding-top: 12px; border-top: 1px solid var(--grid);
  font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }

/* stat tiles: one row of seven on wide screens; balanced rows below (4 + 3, 3 + 3, 2 + 2 + 2 + 1 full) */
@media (min-width: 1180px) { #tiles { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); } }
@media (min-width: 600px) and (max-width: 1179.98px) {
  #tiles { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  #tiles > * { grid-column: span 3; }
  #tiles:has(> :nth-child(7):last-child) > :nth-child(n+5) { grid-column: span 4; }
  #tiles:has(> :nth-child(6):last-child) > *, #tiles:has(> :nth-child(3):last-child) > * { grid-column: span 4; }
  #tiles:has(> :nth-child(5):last-child) > :nth-child(n+4) { grid-column: span 6; }
}
@media (max-width: 599.98px) {
  #tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tile { padding: 16px 14px 12px; }
  .tile .val { font-size: 27px; }
}

/* timeline */
.tl-chart { position: relative; margin-top: 10px; }
.tl-chart svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.tl-chart .hit { fill: transparent; cursor: pointer; }
.tl-chart .hl { fill: var(--brand); opacity: 0.12; }

/* replay */
.rp-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.rp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 300px); grid-template-areas: "video side" "list side";
  grid-template-rows: auto 1fr; gap: 0 20px; align-items: start; }
.rp-video { grid-area: video; } .rp-side { grid-area: side; } .rp-list { grid-area: list; min-width: 0; }
@media (max-width: 900px) { .rp-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "video" "side" "list"; gap: 16px; } }
.rp-side { min-width: 0; }
.court-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-size: 13.5px; font-weight: 700; margin-bottom: 8px; flex-wrap: wrap; }
.court-head .small { font-weight: 400; font-variant-numeric: tabular-nums; }
.court-box { width: 100%; display: flex; justify-content: center; }
.court-box canvas { display: block; border-radius: var(--radius-md); }
#court-legend { margin-top: 10px; gap: 4px 12px; }
@media (max-width: 900px) {
  .rp-side { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: start; }
  .rp-side .court-head { grid-column: 1 / -1; }
  .court-box { width: auto; }
  #court-legend { flex-direction: column; align-items: flex-start; margin-top: 0; }
}
.rally-list-head { display: flex; gap: 10px; align-items: baseline; margin: 18px 0 8px; flex-wrap: wrap; }
.rally-list { max-height: 250px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); -webkit-overflow-scrolling: touch; }
.rl { display: grid; grid-template-columns: 34px 68px minmax(0, 1fr) minmax(0, 1fr) 52px; gap: 8px; align-items: center; padding: 7px 12px;
  border: 0; border-bottom: 1px solid var(--grid); background: transparent; width: 100%; text-align: left; cursor: pointer; font-size: 13px; }
.rl:last-child { border-bottom: 0; }
.rl:hover { background: var(--surface-2); }
.rl.on { background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
.rl .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.rl .c { font-variant-numeric: tabular-nums; font-weight: 700; }
.rl .w, .rl .s { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl .d { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rl.switch { border-bottom: 2px solid var(--axis); }
@media (max-width: 520px) {
  .rp-side { grid-template-columns: minmax(0, 1fr); }
  .court-box { justify-content: center; }
  #court-legend { flex-direction: row; flex-wrap: wrap; margin-top: 8px; }
}
#court-legend > span { white-space: nowrap; }
@media (max-width: 520px) { .rl { grid-template-columns: 28px 58px minmax(0, 1fr) 44px; } .rl .s { display: none; } }

/* shot explorer */
.sx-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 760px) { .sx-grid { grid-template-columns: minmax(0, 1fr); } }
.sx-court svg { width: 100%; height: auto; display: block; max-height: 640px; }
.sx-court path.shot { fill: none; stroke-width: 2; stroke-linecap: round; opacity: 0.8; }
.sx-court .hitline { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.sx-list { max-height: 520px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.sx-list .tbl td, .sx-list .tbl th { padding: 7px 10px; }
.sx-list tr { cursor: pointer; }
.sx-list tbody tr:hover { background: var(--brand-tint); }
.sx-list thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
@media (max-width: 520px) {   /* phones: the six columns fit without a sideways scroll */
  .sx-list .tbl { font-size: 12.5px; }
  .sx-list .tbl td, .sx-list .tbl th { padding: 7px 5px; }
  .sx-list .tbl th { letter-spacing: 0.03em; font-size: 10.5px; }
  .sx-list .tbl td:first-child, .sx-list .tbl th:first-child { padding-left: 10px; }
  :root[lang="fr"] .sx-list .tbl th { letter-spacing: 0; }   /* French headers are longer (assets/i18n.js) */
}

/* players */
.pl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .pl-grid { grid-template-columns: minmax(0, 1fr); } }
.pl-card { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 420px) { .pl-card { grid-template-columns: minmax(0, 1fr); } }
.pl-card + .pl-card { margin-top: 0; }
.pl-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--grid); }
.pl-head h3 { font-size: 16px; }
.pl-head .sw { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.pl-head .tm { color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; margin-left: auto; white-space: nowrap; }
.pl-heat canvas { display: block; width: 100%; border-radius: var(--radius-sm); }
.pl-heat .scale { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.pl-heat .scale i { display: inline-block; height: 8px; flex: 1; border-radius: 4px; }
.metric { margin-bottom: 16px; }
.metric .lab { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.metric .val { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; margin-top: 2px; }
.metric .val small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.zbar { display: flex; gap: 2px; height: 12px; margin: 8px 0 6px; }
.zbar span { display: block; height: 100%; border-radius: 2px; min-width: 2px; }
.zbar span:first-child { border-radius: 4px 2px 2px 4px; } .zbar span:last-child { border-radius: 2px 4px 4px 2px; }
.zlab { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.zlab span { display: inline-flex; align-items: center; gap: 5px; }
.hbars { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 5px 10px; align-items: center; font-size: 12.5px; margin-top: 8px; }
.hbars .t { color: var(--ink-2); white-space: nowrap; }
.hbars .b { height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbars .v { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* team */
#team-grid > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }   /* an odd last card spans the row, no ragged hole */
.tm-chart svg { max-width: 100%; height: auto; display: block; }
.meter { display: grid; grid-template-columns: minmax(90px, auto) minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; font-size: 13px; margin: 10px 0; }
.meter .trk { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.meter .fil { height: 100%; border-radius: 0 4px 4px 0; }
.meter .v { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 520px) {   /* long values (kitchen arrival with the 10 / 12 ft alternatives) go under the bar on phones */
  .meter { grid-template-columns: minmax(80px, auto) minmax(0, 1fr); row-gap: 2px; }
  .meter .v { grid-column: 2; white-space: normal; }
}
.stack { display: flex; gap: 2px; height: 14px; margin: 4px 0; }
.stack span { display: block; height: 100%; border-radius: 2px; }

/* player photos */
.sb-pl { display: flex; align-items: center; gap: 4px; }       /* one player per line under the team name */
.cl-team { display: inline-flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.cl-pl { display: inline-flex; align-items: center; gap: 1px; font-weight: 600; color: var(--ink); }
.pl-head .av { margin: 4px 8px 4px 4px; }

/* profile strip ("Players"): athlete cards, grouped by team; the team colour is the stripe under each photo */
.pf { margin-top: 48px; }
.pf-head { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 16px; }
.pf-head h2 { margin: 0; }
.pf-head .small { color: var(--muted); }
.pf-teams { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 600px) { .pf-teams { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pf-team { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px 20px; box-shadow: var(--shadow); min-width: 0; }
.pf-tn { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 14px; }
.pf-tn .key { width: 10px; height: 10px; }
.pf-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pf-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; align-content: start; text-decoration: none; color: inherit; min-width: 0;
  border-radius: var(--radius-md); }
.pf-ph { position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px rgb(15 23 42 / 0.06); transition: box-shadow 0.2s, transform 0.2s; }
.pf-ph::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--ring, var(--axis)); }
.pf-ph img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.35s ease; }
.pf-ph.none { display: flex; align-items: center; justify-content: center; background: var(--ring, var(--axis)); }
.pf-ph.none span { color: #fff; font-size: 40px; font-weight: 800; }
.pf-card:hover .pf-ph { box-shadow: inset 0 0 0 1px rgb(15 23 42 / 0.06), var(--shadow-3); transform: translateY(-2px); }
.pf-card:hover .pf-ph img { transform: scale(1.03); }
.pf-card:hover .pf-id { color: var(--accent-ink); }
.pf-tx { min-width: 0; padding: 12px 2px 0; }
.pf-id { font-size: 20px; font-weight: 800; line-height: 1.15; letter-spacing: -0.015em; transition: color 0.15s; }
.pf-tm { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 3px 0 6px; }
.pf-ds { font-size: 13px; color: var(--ink-2); line-height: 1.4; overflow-wrap: anywhere; }
@media (min-width: 1180px) {   /* wide screens: photo beside the text keeps the strip short; still large enough to recognise */
  .pf-card { grid-template-columns: minmax(0, 132px) minmax(0, 1fr); gap: 16px; }
  .pf-tx { padding-top: 6px; }
}
@media (max-width: 899.98px) { .pf-team { padding: 14px 14px 16px; } .pf-cards { gap: 12px; } .pf-id { font-size: 18px; } }
@media (max-width: 520px) {
  .pf { margin-top: 36px; }
  .pf-team { padding: 14px 12px 14px; }
  .pf-cards { gap: 12px; }
  .pf-tx { padding: 10px 2px 0; }
  .pf-id { font-size: 18px; }
}
.pl-head .pl-link { font-size: 13px; font-weight: 600; color: var(--link); white-space: nowrap; text-decoration: none; }   /* -> player/?m=&p= */
.pl-head .pl-link:hover { color: var(--link-hover); text-decoration: underline; }

/* client additions */
.pf { margin-top: 40px; }
#overview { padding-top: 32px; }
@media (min-width: 1000px) { #overview #tiles { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } #overview #tiles > * { grid-column: auto !important; } }
.sb-foot .note { color: var(--muted); }
.court-head #ball-now { color: var(--muted); }
.tl-note { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.rp-controls .tgl { display: inline-flex; align-items: center; gap: 8px; }
.pl-head .pl-link::after { content: " \2192"; }
