/* YunoPuck: shared layout and components. Tokens live in tokens.css.
   Rules (good-css + web interface guidelines, pinned in tests/test_site_frontend_rules.py):
   - every :hover sits in @media (hover: hover) and (pointer: fine); every pressable thing has :active
   - anything that moves animates only inside @media (prefers-reduced-motion: no-preference)
   - focus is an outline on :focus-visible, never removed
   - logical properties (inline/block) instead of left/right/top/bottom */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  color-scheme: dark;
  accent-color: var(--accent);
  caret-color: var(--accent-text);
  scrollbar-color: var(--line-strong) var(--boards);
  scrollbar-gutter: stable;
  scroll-padding-block-start: calc(var(--nav-h) + var(--s4));   /* sticky nav never covers a focused element */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
::selection { background: color-mix(in oklch, var(--accent) 45%, transparent); color: var(--ice); }
html:has(dialog:modal) { overflow: hidden; }                     /* page stays put behind the dialog */
@media (hover: hover) and (pointer: fine) { html { overscroll-behavior-y: none; } }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--ice);
  background: var(--boards);
  min-block-size: 100vh;
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;                     /* replaced by the :active states below */
}
a, button, select, input, summary { touch-action: manipulation; }
a { color: var(--link); text-underline-offset: 3px; }
a:active { color: var(--ice); }
@media (hover: hover) and (pointer: fine) { a:hover { color: var(--ice); } }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
img { display: block; max-inline-size: 100%; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; overflow: clip; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: var(--s4); inset-block-start: -48px; z-index: 100; background: var(--accent);
  color: var(--accent-ink); padding: var(--s2) var(--s4); border-radius: var(--radius); font-weight: 700; }
.skip-link:focus-visible { inset-block-start: var(--s2); outline-color: var(--ice); }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}
p { text-wrap: pretty; }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h2.h2-small { font-size: var(--text-xl); }
h3 { font-size: var(--text-xl); font-weight: 700; }
.lede { font-size: var(--text-lg); color: var(--muted); max-inline-size: 62ch; }

.container { inline-size: 100%; max-inline-size: var(--max); margin-inline: auto; padding-inline: var(--s5); }
main { flex: 1; padding-block-end: var(--s8); }

/* ---- navigation ---------------------------------------------------- */
/* The nav is the team's color block (D28): a solid band in one team color with jersey-hem stripes under it in two
   others. Solid, so text never shows through; pinned only where it fits on one row (a phone wraps it to three). */
.site-nav { position: relative; z-index: 50; padding-block-end: 9px;
  background: linear-gradient(to top, var(--stripe-2) 0 3px, var(--stripe-1) 3px 9px, var(--band) 9px); }
@media (min-width: 48rem) { .site-nav { position: sticky; inset-block-start: 0; } }
.site-nav .container { display: flex; align-items: center; gap: var(--s5); min-block-size: var(--nav-h); flex-wrap: wrap; }
.wordmark { display: flex; align-items: center; gap: var(--s2); color: var(--band-ink); text-decoration: none; }
.wordmark svg { block-size: 30px; inline-size: auto; }
.nav-links { display: flex; gap: var(--s1); list-style: none; margin-inline-end: auto; }
.nav-links a { display: block; padding: var(--s3); color: var(--band-muted); text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-md); letter-spacing: 0.06em;
  text-transform: uppercase; border-block-end: 3px solid transparent; transition: color var(--fast) var(--ease); }
.nav-links a:active { color: var(--band-ink); }
.nav-links a[aria-current="page"] { color: var(--band-ink); border-block-end-color: var(--band-mark); }
.site-nav :focus-visible { outline-color: var(--band-ink); }
.team-picker { display: flex; align-items: center; gap: var(--s2); color: var(--band-muted); font-size: var(--text-sm); }
.team-picker select { background-color: color-mix(in oklch, var(--band-ink) 12%, var(--band)); color: var(--band-ink);
  border: 1px solid color-mix(in oklch, var(--band-ink) 45%, var(--band)); border-radius: var(--radius);
  padding: var(--s2) var(--s3); font: inherit; min-block-size: 44px; cursor: pointer; }
.team-picker option { background-color: var(--surface-2); color: var(--ice); }
@media (hover: hover) and (pointer: fine) {
  .wordmark:hover { opacity: 0.9; }
  .nav-links a:hover { color: var(--band-ink); }
  .team-picker select:hover { border-color: var(--band-ink); }
}

/* ---- page header with rink lines -------------------------------------- */
.page-head { position: relative; overflow: clip; padding-block: var(--s7) var(--s6); border-block-end: 1px solid var(--line);
  background: linear-gradient(180deg, var(--head-top) 0%, var(--boards) 100%); }
.page-head::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.07;
  background: url("/static/img/rink-lines.svg") center / cover no-repeat; }
.page-head::after { content: ""; position: absolute; inset-inline: 0; inset-block-end: 0; block-size: 4px; background: var(--accent); }
.page-head .container { position: relative; display: grid; gap: var(--s3); }

/* ---- buttons -------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-block-size: 44px;
  padding: var(--s2) var(--s5); border-radius: var(--radius); border: 2px solid transparent; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-md); letter-spacing: 0.08em;
  text-transform: uppercase; text-decoration: none;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), filter var(--fast) var(--ease); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:focus-visible { outline-color: var(--ice); }
.btn-secondary { background: transparent; color: var(--ice); border-color: var(--line-strong); }
.btn:active { transform: scale(0.97); }
.btn-primary:active { filter: brightness(0.92); }
.btn-secondary:active { border-color: var(--accent); }
.btn:disabled { opacity: 0.6; cursor: progress; transform: none; }
.btn-block { inline-size: 100%; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
  .btn-secondary:hover { border-color: var(--accent); color: var(--ice); }
}
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    filter var(--fast) var(--ease), transform 160ms var(--ease); }
}

/* ---- scoreboard (accuracy banner, stat tiles) --------------------------- */
.scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s2);
  margin-block: var(--s5); }
.tile { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s4); min-inline-size: 0; }
/* standalone big numbers keep proportional figures (dataviz); tabular-nums is for columns and tables */
.tile-value { font-family: var(--font-display); font-weight: 800; font-size: var(--text-2xl); line-height: 1; }
.tile-label { margin-block-start: var(--s2); color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
.tile-note { margin-block-start: var(--s1); color: var(--muted); font-size: var(--text-sm); }

/* ---- controls --------------------------------------------------------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-block: var(--s5); }
.controls label { color: var(--muted); font-size: var(--text-sm); }
.picks-note { margin-block: calc(-1 * var(--s3)) var(--s4); color: var(--muted); font-size: var(--text-sm); }
.controls input[type="date"] { background-color: var(--surface-2); color: var(--ice); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: var(--s2) var(--s3); font: inherit; min-block-size: 44px; }
.date-badge { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); letter-spacing: 0.04em;
  text-transform: uppercase; margin-inline-end: auto; }
.btn-group { display: flex; gap: var(--s2); }

/* ---- games ------------------------------------------------------------ */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: var(--s4); }
/* the card itself isn't clickable, so it has no hover lift; its buttons carry the interaction */
.game-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--s5); display: grid; gap: var(--s4); min-inline-size: 0; }
.matchup { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--s3); }
.team { display: grid; justify-items: center; gap: var(--s2); text-align: center; min-inline-size: 0; }
.team-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); line-height: 1.1;
  text-transform: uppercase; overflow-wrap: anywhere; }
.team-badge { color: var(--muted); font-size: var(--text-sm); }
.vs { font-family: var(--font-display); font-weight: 800; color: var(--muted); font-size: var(--text-lg); }
.game-time { color: var(--muted); font-size: var(--text-sm); text-align: center; font-variant-numeric: tabular-nums; }

/* team logo component: fixed box so nothing shifts while it loads */
.logo { position: relative; flex: none; display: inline-grid; place-items: center; }
.logo img { inline-size: 100%; block-size: 100%; object-fit: contain; padding: 4%; }
.logo-24 { inline-size: 24px; block-size: 24px; }
.logo-48 { inline-size: 56px; block-size: 56px; }
.logo-96 { inline-size: 96px; block-size: 96px; }
.logo-badge { inline-size: 100%; block-size: 100%; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; letter-spacing: 0.02em; font-size: 0.36em; }
.logo-48 .logo-badge { font-size: 16px; }
.logo-24 .logo-badge { font-size: 9px; }
.logo-96 .logo-badge { font-size: 28px; }

/* prediction */
.prediction { display: grid; gap: var(--s3); padding-block-start: var(--s4); border-block-start: 1px solid var(--line); }
.prob-labels { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--text-sm); color: var(--muted);
  font-variant-numeric: tabular-nums; }
.pick-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); font-variant-numeric: tabular-nums; }
.pick-line strong { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; }
.pick-label { color: var(--muted); font-size: var(--text-sm); }
.pick-missing { color: var(--muted); font-size: var(--text-sm); padding-block-start: var(--s4); border-block-start: 1px solid var(--line); }
.pill-win { color: var(--win); border-color: var(--win); }
.pill-loss { color: var(--muted); }
.prob-labels strong { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; display: block;
  font-variant-numeric: tabular-nums; }
.prob-bar { display: flex; block-size: 12px; border-radius: 2px; overflow: clip; background: var(--surface-2); }
.prob-bar span { display: block; block-size: 100%; inline-size: 0; }
.prob-bar span + span { border-inline-start: 2px solid var(--surface); }
@media (prefers-reduced-motion: no-preference) {
  .prob-bar span { transition: inline-size 600ms var(--ease); }
}
.pill { display: inline-flex; align-items: center; gap: var(--s1); padding: 2px var(--s2); border-radius: 999px;
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--line-strong); color: var(--muted); }
.pill-live { color: var(--goal-red-text); border-color: var(--goal-red); }
.pill-live::before { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--goal-red); }
@keyframes goal-light { 50% { opacity: 0.25; } }
.meta-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: space-between; }
.live-score { display: flex; justify-content: center; align-items: center; gap: var(--s4);
  font-family: var(--font-display); font-weight: 800; font-size: var(--text-2xl); font-variant-numeric: tabular-nums; }
.notice { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: var(--s3) var(--s4);
  color: var(--muted); font-size: var(--text-sm); }
.notice strong { color: var(--ice); }
.notice-error { border-style: solid; border-color: var(--goal-red); }
.no-games { grid-column: 1 / -1; text-align: center; padding: var(--s8) var(--s4); color: var(--muted); }

/* loading */
.loading { text-align: center; padding: var(--s8) var(--s4); color: var(--muted); }
.spinner { inline-size: 40px; block-size: 40px; margin: 0 auto var(--s4); border-radius: 50%; border: 3px solid var(--line-strong);
  border-block-start-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) {
  .pill-live::before { animation: goal-light 1.2s ease-in-out infinite; }
  .spinner { animation: spin 0.8s linear infinite; }
}

/* ---- "Why this pick": native <dialog> opened with showModal() -------------- */
dialog.modal { margin: auto; padding: 0; border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--ice);
  inline-size: min(720px, calc(100% - 2 * var(--s4))); max-block-size: 85dvh; overflow: auto;
  overscroll-behavior: contain; opacity: 0;
  transition: opacity 0.2s var(--ease), display 0.2s allow-discrete, overlay 0.2s allow-discrete; }
dialog.modal::backdrop { background: color-mix(in srgb, color-mix(in srgb, black 55%, var(--boards)) 80%, transparent); opacity: 0;
  transition: opacity 0.2s var(--ease), display 0.2s allow-discrete, overlay 0.2s allow-discrete; }
dialog.modal[open], dialog.modal[open]::backdrop { opacity: 1; }
@starting-style { dialog.modal[open], dialog.modal[open]::backdrop { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  dialog.modal { translate: 0 0.5rem; transition: opacity 0.2s var(--ease), translate 0.2s var(--ease),
    display 0.2s allow-discrete, overlay 0.2s allow-discrete; }
  dialog.modal[open] { translate: 0 0; }
  @starting-style { dialog.modal[open] { translate: 0 0.5rem; } }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s5); border-block-end: 1px solid var(--line); }
.modal-title { font-family: var(--font-display); font-weight: 800; font-size: var(--text-xl); text-transform: uppercase; text-wrap: balance; }
.modal-close { background: none; border: 1px solid var(--line-strong); color: var(--ice); border-radius: var(--radius);
  inline-size: 44px; block-size: 44px; flex: none; font-size: 24px; cursor: pointer; transition: border-color var(--fast) var(--ease); }
.modal-close:active { border-color: var(--accent); transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) { .modal-close:hover { border-color: var(--accent); } }
.modal-body { padding: var(--s5); display: grid; gap: var(--s3); }
.modal-body h4 { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; margin-block-start: var(--s3); }
.modal-body ul { padding-inline-start: var(--s5); }

/* ---- footer ----------------------------------------------------------- */
.site-footer { border-block-start: 1px solid var(--line); padding-block: var(--s6); color: var(--muted); font-size: var(--text-sm); }
.site-footer .container { display: grid; gap: var(--s3); }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--s4); }
.fine-print { font-size: var(--text-xs); max-inline-size: 80ch; }
.backtest-note { font-size: var(--text-xs); max-inline-size: 80ch; color: var(--muted); margin-block: var(--s3) var(--s4); }

/* ---- Our Model page ---------------------------------------------------- */
.section { padding-block-start: var(--s7); display: grid; gap: var(--s5); }
.section-head { display: grid; gap: var(--s2); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--s4);
  list-style: none; counter-reset: step; }
.steps li { counter-increment: step; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--s5); display: grid; gap: var(--s2); align-content: start; }
.steps li::before { content: counter(step, decimal-leading-zero); font-family: var(--font-display); font-weight: 800;
  font-size: var(--text-2xl); color: var(--accent-text); line-height: 1; }
.steps h3 { font-size: var(--text-lg); }
.steps p { color: var(--muted); }
.callout { background: color-mix(in oklch, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in oklch, var(--accent) 40%, var(--line)); border-radius: var(--radius);
  padding: var(--s5); display: grid; gap: var(--s3); }
.callout p { color: var(--muted); max-inline-size: 75ch; }
.callout strong { color: var(--ice); }
details.deep { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
details.deep + details.deep { margin-block-start: var(--s2); }
details.deep summary { cursor: pointer; list-style: none; padding: var(--s4) var(--s5); display: flex;
  justify-content: space-between; align-items: center; gap: var(--s4); border-radius: var(--radius-lg);
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); text-transform: uppercase; letter-spacing: 0.04em;
  transition: background-color var(--fast) var(--ease); }
details.deep summary::-webkit-details-marker { display: none; }
details.deep summary::after { content: "+"; font-size: var(--text-xl); color: var(--accent-text); }
details.deep[open] summary::after { transform: rotate(45deg); }
details.deep summary:active { background-color: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { details.deep summary:hover { background-color: var(--surface-2); } }
@media (prefers-reduced-motion: no-preference) {
  details.deep summary::after { transition: transform var(--fast) var(--ease); }
}
details.deep .deep-body { padding: 0 var(--s5) var(--s5); display: grid; gap: var(--s3); color: var(--muted); }
details.deep .deep-body strong, details.deep .deep-body code { color: var(--ice); }
.table-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.data-table { inline-size: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: start; padding: var(--s2) var(--s3); border-block-end: 1px solid var(--line); }
.data-table th { color: var(--muted); font-weight: 600; font-size: var(--text-sm); }
.data-table td.right, .data-table th.right { text-align: end; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: var(--s4); }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s5);
  display: grid; gap: var(--s3); min-inline-size: 0; }
.chart-card h3 { font-size: var(--text-lg); }
.chart-card p { color: var(--muted); font-size: var(--text-sm); }
.chart-box { position: relative; block-size: 280px; }
/* table view of a chart (dataviz: every chart has a table twin) */
.chart-data summary { cursor: pointer; color: var(--link); font-size: var(--text-sm); inline-size: fit-content; }
.chart-data summary:active { color: var(--ice); }
@media (hover: hover) and (pointer: fine) { .chart-data summary:hover { color: var(--ice); } }
.chart-data[open] summary { margin-block-end: var(--s2); }
.pipeline { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: stretch; list-style: none; }
.pipeline li { flex: 1 1 140px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s3); font-size: var(--text-sm); position: relative; }
.pipeline li strong { display: block; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.04em;
  font-size: var(--text-md); color: var(--ice); }
.pipeline li span { color: var(--muted); }
.cta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: var(--s4); }
.cta { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s5); display: grid; gap: var(--s3); align-content: start; }
.cta p { color: var(--muted); }
.cta .btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.result-win { color: var(--win); font-weight: 600; }
.result-loss { color: var(--loss); font-weight: 600; }

@media (max-width: 768px) {
  .site-nav .container { gap: var(--s2); padding-block: var(--s2); }
  .nav-links { order: 3; inline-size: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  .date-badge { inline-size: 100%; }
}
@media (max-width: 480px) {
  .container { padding-inline: var(--s4); }
  .game-card { padding: var(--s4); }
}

/* ---- Tonight: the record leads the page (D27) ------------------------------ */
.record { display: grid; gap: var(--s4); padding-block: var(--s6) var(--s4); }
.record-main { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2) var(--s5); }
.record-value { font-family: var(--font-display); font-weight: 800; line-height: 0.85; color: var(--ice);
  font-size: clamp(3.75rem, 2.5rem + 5vw, 6rem); }
.record-text { display: grid; gap: var(--s1); padding-block-end: var(--s1); }
.record-text h1 { font-size: var(--text-2xl); }
.record-text p { color: var(--muted); }
.season-strip { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s3) var(--s6); padding-block-start: var(--s4);
  border-block-start: 1px solid var(--line); }
.season-strip li { display: grid; gap: 2px; }
.season-strip strong { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; }
.season-name, .season-strip li > span:last-child { color: var(--muted); font-size: var(--text-sm); }
.record-links { color: var(--muted); font-size: var(--text-sm); }
/* a short link never breaks across lines ("How / it works") */
.lede a, .record-links a { white-space: nowrap; }
.record-empty { display: grid; gap: var(--s3); padding-block: var(--s6) var(--s4); }
.inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: var(--s3); margin-block: var(--s4); }
.inputs > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4); }
.inputs dt { font-weight: 700; color: var(--ice); }
.inputs dd { margin: var(--s1) 0 0; color: var(--muted); max-inline-size: 60ch; }
.section-lede, .section-note { color: var(--muted); max-inline-size: 75ch; }
