/* chain-viz.css -- styles for chain-viz.js (the match-chains page). Scoped to
   .cv. Colours come from the site's theme tokens (theme.scss --site-*,
   --pitch-*), so both bundles work; the few values the site has no token for
   are set here per theme via Quarto's body.quarto-light class. */
.cv {
  --cv-surface: var(--site-surface-bg);
  --cv-raised: var(--site-surface-raised);
  --cv-border: var(--site-surface-border);
  --cv-ink: var(--site-body-color);
  --cv-muted: var(--site-muted-color);
  --cv-accent: #c89a3e;
  --cv-grass: var(--pitch-grass-1);
  --cv-line: rgba(var(--pitch-line-rgb), .24);
  --cv-faint: rgba(var(--site-surface-border-rgb), .45);
  --cv-good: #6fae95;
  --cv-bad: #d38a6c;
  /* Team colours: chain-viz.js sets a dark-theme value (-d) and a light-theme
     twin darkened for the kraft-paper ground (-l); these are the fallbacks. */
  --cv-home: var(--cv-home-d, #c4734a);
  --cv-away: var(--cv-away-d, #c89a3e);
  /* Disposal quality rings. Chosen by simulating protanopia, deuteranopia and
     tritanopia and maximising the smallest colour distance between the three
     classes (CIE76, worst case 35 dark / 50 light; 20+ is easy to tell apart),
     each at 3:1 or better on the ground. Shape repeats the class (dashed =
     ineffective, double ring = clanger), so colour is never the only cue. A
     red clanger beside the amber was tried on light and rejected: for
     deuteranopes the two collapse to a distance of 1. */
  --cv-d-eff: #56B4E9;
  --cv-d-ine: #F0E442;
  --cv-d-cla: #ff8f6b;
  --cv-fd: var(--font-family-display);
  --cv-fb: var(--font-family-body);
  --cv-fm: var(--font-family-data);
  color: var(--cv-ink);
}
body.quarto-light .cv {
  --cv-home: var(--cv-home-l, #a8512e);
  --cv-away: var(--cv-away-l, #9a7426);
  --cv-accent: #9a7426;
  --cv-good: #2f7a5e;
  --cv-bad: #a8512e;
  --cv-d-eff: #0072B2;
  --cv-d-ine: #A06A00;
  --cv-d-cla: #1f1c18;
}
.cv .card { background: var(--cv-surface); border: 1px solid var(--cv-border); border-radius: 4px; }
.cv-mono { font-family: var(--cv-fm); font-variant-numeric: tabular-nums; }
.cv-muted { color: var(--cv-muted); font-size: .78rem; }
.cv .cv-pos { color: var(--cv-good); }
.cv .cv-neg { color: var(--cv-bad); }
.cv-h { font-family: var(--cv-fd); font-weight: 700; font-size: 1.35rem; margin: 2.4rem 0 .15rem; display: flex; align-items: baseline; gap: .6rem; }
.cv-h .num { font-family: var(--cv-fm); font-size: .72rem; color: var(--cv-accent); letter-spacing: .1em; }
.cv-sub { font-size: .9rem; color: var(--cv-muted); margin: 0 0 .8rem; max-width: 46rem; }
.cv-term { border-bottom: 1px dotted var(--cv-muted); cursor: help; }

/* controls */
.cv-btn { font: 600 .72rem var(--cv-fm); letter-spacing: .06em; text-transform: uppercase; background: var(--cv-raised); color: var(--cv-ink); border: 1px solid var(--cv-border); border-radius: 3px; padding: .35rem .6rem; cursor: pointer; }
.cv-btn:hover { border-color: var(--cv-accent); }
.cv-btn.on { background: var(--cv-accent); color: #1c1917; border-color: var(--cv-accent); }
.cv-btn:disabled { opacity: .4; cursor: default; }
.cv-btn:focus-visible, .cv-sel:focus-visible, .cv-jump input:focus-visible, .cv-act:focus-visible, .cv-mo:focus-visible { outline: 2px solid var(--cv-accent); outline-offset: 1px; }
.cv-sel, .cv-jump input { font: 500 .78rem var(--cv-fm); background: var(--cv-raised); color: var(--cv-ink); border: 1px solid var(--cv-border); border-radius: 3px; padding: .3rem .4rem; max-width: 14rem; }
.cv-jump { display: flex; gap: .35rem; align-items: center; flex: none; }
.cv-jump input { width: 6.2rem; }
.cv-jump input.bad { border-color: var(--cv-bad); }
.cv-fpanel { padding: .7rem .8rem; margin-bottom: .6rem; }
.cv-fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .55rem .8rem; }
.cv-fgrid .fld { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.cv-fgrid .fld .cv-sel { max-width: none; width: 100%; }
.cv-flab { font: 600 .6rem var(--cv-fm); letter-spacing: .12em; text-transform: uppercase; color: var(--cv-muted); }
.cv-seg { display: flex; }
.cv-seg .cv-btn { flex: 1; border-radius: 0; margin-left: -1px; padding: .32rem .4rem; }
.cv-seg .cv-btn:first-child { border-radius: 3px 0 0 3px; margin-left: 0; }
.cv-seg .cv-btn:last-child { border-radius: 0 3px 3px 0; }
.cv-plteam { max-width: 18rem; margin-bottom: .5rem; }
.cv-ffoot { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--cv-border); }
.cv-ffoot .count { margin-left: auto; font: 500 .74rem var(--cv-fm); color: var(--cv-muted); }
.cv-ffoot .link { background: none; border: 0; color: var(--cv-accent); font: 600 .72rem var(--cv-fm); cursor: pointer; padding: 0 .2rem; }
/* Slim copy of the filters under 02 and 03 (same state as the 01 panel). */
.cv-frow { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: 0 0 .8rem; }
.cv-frow .cv-seg .cv-btn { flex: none; white-space: nowrap; }   /* "1st half" on one line, groups wrap instead */
.cv-frow .count { margin-left: auto; font: 500 .74rem var(--cv-fm); color: var(--cv-muted); }
.cv-frow .link { background: none; border: 0; color: var(--cv-accent); font: 600 .72rem var(--cv-fm); cursor: pointer; padding: 0 .2rem; }
@media (max-width: 600px) { .cv-frow .count { margin-left: 0; flex-basis: 100%; } }
.cv-nav { display: flex; gap: .4rem; align-items: center; margin: -.2rem 0 .6rem; }
.cv-nav .cv-sel { flex: 1 1 0; min-width: 0; max-width: none; }

/* scoreboard */
.cv-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem 1rem; padding: .8rem 1rem; margin: .6rem 0 1rem; }
.cv-score .t { font-family: var(--cv-fd); font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.cv-score .t.r { justify-content: flex-end; text-align: right; }
.cv .sw { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; flex: none; }
.cv-score .s { font-family: var(--cv-fm); font-weight: 600; font-size: 1.5rem; text-align: center; white-space: nowrap; }

/* strip */
.cv-strip-card { padding: .7rem .6rem .5rem; }
.cv [data-cv="strip"] { width: 100%; display: block; touch-action: pan-y; }
.cv-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .75rem; color: var(--cv-muted); padding: .3rem .4rem 0; }
.cv-legend i { display: inline-block; width: .65rem; height: .65rem; border-radius: 1px; margin-right: .3rem; vertical-align: -1px; }

/* key moments */
.cv-moments { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: .5rem; }
.cv-mo { padding: .55rem .7rem; cursor: pointer; border-left: 3px solid var(--cv-border) !important; text-align: left; font: inherit; color: inherit; width: 100%; }
.cv-mo:hover { border-color: var(--cv-accent); background: var(--cv-raised); }
.cv-mo .h { display: flex; justify-content: space-between; gap: .5rem; font-family: var(--cv-fm); font-size: .72rem; color: var(--cv-muted); }
.cv-mo .d { font-size: .88rem; margin-top: .15rem; }

/* replay */
.cv-rgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 33rem); gap: 1rem; align-items: start; }
.cv-rgrid > * { min-width: 0; }
.cv-rhead { padding: .7rem .85rem; margin-bottom: .6rem; }
.cv-rhead .line1 { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; align-items: center; }
.cv-rhead .title { font-family: var(--cv-fd); font-weight: 700; font-size: 1.08rem; }
.cv-rhead .story { font-size: .9rem; color: var(--cv-muted); margin-top: .25rem; }
.cv-rhead .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .4rem; margin-top: .55rem; }
.cv .fact { background: var(--cv-raised); border-radius: 3px; padding: .3rem .45rem; min-width: 0; }
.cv .fact .k { font: 600 .6rem var(--cv-fm); letter-spacing: .1em; text-transform: uppercase; color: var(--cv-muted); }
.cv .fact .v { font-family: var(--cv-fm); font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-ctrl { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; margin: .2rem 0 .6rem; }
.cv-ctrl .pos-txt { font-family: var(--cv-fm); font-size: .75rem; color: var(--cv-muted); margin: 0 .3rem; }
.cv-speed { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; }
.cv-speed .cv-seg .cv-btn { flex: none; min-width: 2.5rem; }
.cv-keys { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .72rem; color: var(--cv-muted); }
.cv-keys > span { display: inline-flex; align-items: center; gap: .3rem; cursor: help; }
.cv-keys kbd { font: 600 .66rem var(--cv-fm); background: var(--cv-raised); color: var(--cv-ink); border: 1px solid var(--cv-border); border-bottom-width: 2px; border-radius: 3px; padding: .05rem .38rem; transition: background .12s, color .12s; }
.cv-keys kbd.on { background: var(--cv-accent); color: #1c1917; border-color: var(--cv-accent); }
@media (hover: none) { .cv-keys { display: none; } }   /* no keyboard on a phone */
.cv-acts { max-height: 31rem; overflow: auto; }
.cv-act, .cv-acthead { display: grid; grid-template-columns: 1.5rem 3.4rem minmax(0, 1fr) 3.4rem 3.4rem 3.8rem 3.4rem; gap: .1rem .5rem; align-items: center; }
.cv-act { padding: .38rem .6rem; border-bottom: 1px solid var(--cv-faint); cursor: pointer; }
.cv-act:last-child { border-bottom: 0; }
.cv-act:hover { background: var(--cv-faint); }
.cv-act.cur { background: var(--cv-raised); box-shadow: inset 3px 0 0 var(--cv-accent); }
.cv-act.fut { opacity: .45; }
.cv-act.cv-nomatch { opacity: .4; }
.cv-dsp { display: inline-flex; align-items: center; gap: .25rem; margin-left: .45rem; font: 600 .62rem var(--cv-fm); letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; }
.cv-dsp svg, .cv-dlegend svg { flex: none; overflow: visible; }
.cv-dsp-effective { color: var(--cv-d-eff); } .cv-dsp-ineffective { color: var(--cv-d-ine); } .cv-dsp-clanger { color: var(--cv-d-cla); }
.cv-dlegend { display: inline-flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .74rem; color: var(--cv-muted); align-items: center; }
.cv-dlegend > span { display: inline-flex; align-items: center; gap: .3rem; cursor: help; }
.cv-act .n { font-family: var(--cv-fm); font-size: .7rem; color: var(--cv-muted); text-align: right; }
.cv-act .c { font-family: var(--cv-fm); font-size: .72rem; color: var(--cv-muted); }
.cv-act .w { min-width: 0; }
.cv-act .p { font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-act .a { font-size: .76rem; color: var(--cv-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-act .v { font-family: var(--cv-fm); font-size: .8rem; text-align: right; }
.cv-act .wp { font-family: var(--cv-fm); font-size: .72rem; text-align: right; color: var(--cv-muted); }
.cv-act .pre, .cv-act .post { font-family: var(--cv-fm); font-size: .74rem; text-align: right; color: var(--cv-muted); }
.cv-acthead { padding: .35rem .6rem; border-bottom: 1px solid var(--cv-border); font: 600 .6rem var(--cv-fm); letter-spacing: .1em; text-transform: uppercase; color: var(--cv-muted); }
.cv-acthead span:nth-child(n+4) { text-align: right; }
.cv .nopre .cv-act, .cv .nopre .cv-acthead { grid-template-columns: 1.5rem 3.4rem minmax(0, 1fr) 3.8rem 3.4rem; }
.cv .nopre .pre, .cv .nopre .post { display: none; }
.cv-pitchcard { position: sticky; top: 64px; padding: .5rem; }
.cv [data-cv="pitch"] { width: 100%; height: auto; display: block; }
/* The 3D ground (AFL, opt-in from the replay's View control). Same box as the
   flat ground, so switching does not move the page; three.js draws into it. */
.cv [data-cv="pitch3d"] { width: 100%; aspect-ratio: 174 / 154; position: relative; touch-action: none; }
.cv [data-cv="pitch3d"][hidden] { display: none; }
.cv [data-cv="pitch3d"] canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cv-p3note { position: absolute; left: .5rem; bottom: .4rem; font-family: var(--font-family-data); font-size: .7rem; color: var(--cv-muted); pointer-events: none; }
.cv-pbar { display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; }
/* The caption changes every step; its box keeps a fixed height so the ground
   under it never jumps (Pete 2026-10-05: on a phone it wrapped to 2-4 lines and
   the pitch moved on every step). 2 lines here; 3 on a phone, where it gets
   its own full-width row. */
.cv-pcap { font-size: .8rem; color: var(--cv-muted); padding: .2rem .3rem .1rem; line-height: 1.5; min-height: calc(2 * 1.5em + .3rem); min-width: 0; }
.cv-pcap b { font-family: var(--cv-fd); color: var(--cv-ink); }
.cv-pbtns { display: flex; gap: .25rem; flex: none; }
.cv-pbtns .cv-btn { min-width: 2.4rem; padding: .4rem .5rem; }
.cv-pkey { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .72rem; color: var(--cv-muted); padding: .1rem .3rem; }
.cv-pkey svg { vertical-align: -2px; margin-right: .25rem; }
.cv-dim .cv-pill { opacity: .5; }
.cv-pill { display: inline-block; font: 600 .64rem var(--cv-fm); padding: .05rem .35rem; border-radius: 2px; }

/* flow */
.cv-flows { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cv-flowcard { padding: .7rem .8rem; min-width: 0; }
.cv-flowcard h3 { font-family: var(--cv-fd); font-size: 1rem; margin: 0 0 .1rem; display: flex; align-items: center; gap: .45rem; }
.cv-flowcard .kpi { font-size: .82rem; color: var(--cv-muted); margin-bottom: .4rem; }
.cv-flow svg { width: 100%; height: auto; display: block; }
.cv-ftable { width: 100%; border-collapse: collapse; font-size: .8rem; margin-top: .5rem; }
.cv-ftable th, .cv-ftable td { padding: .25rem .4rem; border-bottom: 1px solid var(--cv-faint); text-align: right; white-space: nowrap; }
.cv-ftable th:first-child, .cv-ftable td:first-child { text-align: left; }
.cv-ftable thead th { font: 600 .6rem var(--cv-fm); letter-spacing: .1em; text-transform: uppercase; color: var(--cv-muted); border-bottom: 1px solid var(--cv-border); }
.cv-ftable td { font-family: var(--cv-fm); }
.cv-ftable td:first-child { font-family: var(--cv-fb); }

.cv-recon { grid-column: 1 / -1; margin: .2rem 0 0; font-size: .82rem; }
.cv-fdetail { margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--cv-border); }
.cv-fdhead { display: flex; align-items: center; gap: .45rem; font-size: .92rem; }
.cv-fdhead .link { margin-left: auto; background: none; border: 0; color: var(--cv-accent); font: 600 .72rem var(--cv-fm); cursor: pointer; }
.cv-fdmeta { font-size: .8rem; color: var(--cv-muted); margin: .4rem 0; }
.cv-fdetail .cv-btn { margin-top: .2rem; }

/* quarter table (AFL) */
.cv [hidden] { display: none !important; }
table.cv-qt { width: 100%; border-collapse: collapse; font-size: .82rem; margin: 0; }
table.cv-qt th, table.cv-qt td { padding: .3rem .5rem; border-bottom: 1px solid var(--cv-faint); text-align: right; white-space: nowrap; font-family: var(--cv-fm); }
table.cv-qt th:first-child, table.cv-qt td:first-child, table.cv-qt th:nth-child(2), table.cv-qt td:nth-child(2) { text-align: left; }
table.cv-qt thead th { font: 600 .6rem var(--cv-fm); letter-spacing: .1em; text-transform: uppercase; color: var(--cv-muted); border-bottom: 1px solid var(--cv-border); cursor: help; }
table.cv-qt tbody tr { cursor: pointer; }
table.cv-qt tbody tr:hover td, table.cv-qt tbody tr:focus-visible td { background: var(--cv-faint); }
table.cv-qt tbody tr:focus-visible { outline: 2px solid var(--cv-accent); outline-offset: -2px; }
table.cv-qt tr.grp-start td { border-top: 2px solid var(--cv-border); }
table.cv-qt td.lbl { font-family: var(--cv-fd); font-weight: 600; }
table.cv-qt td .n { color: var(--cv-muted); font-size: .72rem; }
.cv-qfoot { font-size: .78rem; color: var(--cv-muted); margin: .7rem 0 0; padding-left: 1.1rem; max-width: 62rem; }
.cv-qfoot li { margin: .15rem 0; }
.cv-qfoot b { color: var(--cv-ink); }

/* players */
table.cv-pl { width: 100%; border-collapse: collapse; font-size: .84rem; margin: 0; }
table.cv-pl th, table.cv-pl td { padding: .35rem .55rem; border-bottom: 1px solid var(--cv-faint); text-align: right; white-space: nowrap; }
table.cv-pl th:first-child, table.cv-pl td:first-child, table.cv-pl th:nth-child(2), table.cv-pl td:nth-child(2) { text-align: left; }
table.cv-pl thead th { font: 600 .62rem var(--cv-fm); letter-spacing: .1em; text-transform: uppercase; color: var(--cv-muted); border-bottom: 1px solid var(--cv-border); cursor: pointer; user-select: none; }
table.cv-pl thead th.sorted { color: var(--cv-accent); }
table.cv-pl td { font-family: var(--cv-fm); }
table.cv-pl td.nm { font-family: var(--cv-fd); font-weight: 600; }
table.cv-pl tbody tr:hover td { background: var(--cv-faint); }
table.cv-pl tfoot td { border-bottom: 0; border-top: 1px solid var(--cv-border); font-weight: 600; }
table.cv-pl tfoot tr.want td { font-weight: 400; color: var(--cv-muted); border-top: 0; padding-top: 0; }
table.cv-pl tfoot .ok { color: var(--cv-good); }
table.cv-pl tfoot .bad { color: var(--cv-bad); }

/* tooltip: styled, on-theme, fixed so it never reflows (never title=) */
.cv-tip { position: fixed; z-index: 1080; pointer-events: none; background: var(--site-surface-raised); color: var(--site-body-color); border: 1px solid var(--site-surface-border); border-radius: 3px; padding: .45rem .6rem; font-size: .78rem; max-width: 18rem; box-shadow: 2px 2px 0 rgba(var(--site-shadow-rgb), .35); opacity: 0; transition: opacity .08s; }
.cv-tip.on { opacity: 1; }
.cv-tip b { font-family: var(--font-family-display); font-size: .88rem; display: block; margin-bottom: .15rem; }
.cv-tip .r { display: flex; justify-content: space-between; gap: 1rem; }
.cv-tip .r span:last-child { font-family: var(--font-family-data); }

@media (max-width: 900px) {
  .cv-rgrid { grid-template-columns: minmax(0, 1fr); }
  .cv-pitchcard { order: -1; position: sticky; top: 56px; z-index: 5; }
  .cv [data-cv="pitch"] { max-height: 34vh; }
  .cv [data-cv="pitch3d"] { aspect-ratio: auto; height: 34vh; }
  .cv-pkey { display: none; }
  .cv-flows { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .cv-act, .cv-acthead { grid-template-columns: 3rem minmax(0, 1fr) 3.2rem 3.6rem 3.1rem; }
  .cv .nopre .cv-act, .cv .nopre .cv-acthead { grid-template-columns: 3rem minmax(0, 1fr) 3.8rem 3.2rem; }
  .cv-act .n, .cv-acthead span:first-child, .cv-act .pre, .cv-acthead .pre { display: none; }
  .cv-score .t { font-size: .9rem; }
  .cv-score .s { font-size: 1.2rem; }
  .cv-nav { flex-wrap: wrap; }
  .cv-nav .cv-sel { flex-basis: 100%; }
  .cv-pbar { flex-wrap: wrap; }
  .cv-pbtns { order: -1; margin-left: auto; }
  .cv-pcap { flex-basis: 100%; min-height: calc(3 * 1.5em + .3rem); }
}
/* AFL chains: the fast-break tag, and following a player (2026-10-13) */
.cv .cv-fast { display: inline-block; vertical-align: middle; margin-left: .45rem; font: 700 .6rem var(--cv-fm); letter-spacing: .06em; text-transform: uppercase; padding: .1rem .4rem; border: 1px solid var(--cv-accent); color: var(--cv-accent); border-radius: 2px; white-space: nowrap; }
.cv-act.mine { box-shadow: inset 3px 0 0 var(--cv-accent); background: color-mix(in srgb, var(--cv-accent) 12%, transparent); }
.cv-act.mine.cur { background: var(--cv-raised); }
.cv .cv-follow { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .5rem; font: 400 .78rem var(--cv-fm); color: var(--cv-muted); }
.cv .cv-follow .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--cv-accent); opacity: .7; flex: none; }
.cv .cv-follow .link { background: none; border: 0; color: var(--cv-accent); font: 600 .72rem var(--cv-fm); cursor: pointer; padding: 0 .2rem; }
