/* Casino Sausage. Visual spec: docs/DESIGN.md ("the table under the torch"). Dark only. */

:root {
  --bg: #070907; --surface: #0e1510; --felt-hi: #16241a;
  --felt-glow: rgba(44, 102, 53, .32);
  --text: #eef0e6; --text-2: #b3bcad; --text-3: #8d9789;
  --chalk: #e4d65c; --chalk-line: rgba(228, 214, 92, .7); --rule: rgba(238, 240, 230, .08);
  --win: #7fd48c; --loss: #ff8a8a; --zero: var(--text-2);
  --bronze: #c8844f; --silver: #c9ced3; --gold: #e7c55a;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Oswald", "Arial Narrow", sans-serif;
  --pad: 16px;
  --gap: 64px;
  color-scheme: dark;
}
@media (min-width: 600px) { :root { --pad: 24px; } }
@media (min-width: 1024px) { :root { --gap: 96px; } }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body::after { /* page grain */
  content: ""; position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background-image: var(--grain); background-size: 160px; opacity: .035;
}
img, svg { display: block; }
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--chalk); outline-offset: 3px; }

.vh {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.wrap { width: 100%; max-width: calc(1120px + 2 * var(--pad)); margin: 0 auto; padding: 0 var(--pad); }

.eyebrow {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--chalk);
}
.text-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--chalk); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.test-pill {
  display: none; align-self: center;
  border: 1px dashed var(--chalk); border-radius: 999px; padding: 1px 10px;
  color: var(--chalk); font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap;
}
.is-dummy .test-pill { display: inline-block; }
.dummy-note { display: none; }
.is-dummy .dummy-note { display: block; }

.win { color: var(--win); }
.loss { color: var(--loss); }
.zero { color: var(--zero); }

/* ---------- 1. Hero ---------- */

.hero-track { position: relative; }
.stage { position: relative; }
.hero {
  position: relative; height: 100vh; height: 100svh; overflow: hidden; background: var(--bg);
}
.photo, .photo-inner, .grain, .scrim, .vignette { position: absolute; inset: 0; }
.photo { transform-origin: 48% 58%; }
.photo picture, .photo img { width: 100%; height: 100%; }
.photo img { object-fit: cover; object-position: 50% 55%; }
@media (min-width: 1024px) { .photo img { object-position: 50% 45%; } }
.grain { background-image: var(--grain); background-size: 160px; opacity: .07; mix-blend-mode: overlay; }
.scrim {
  background: linear-gradient(180deg, rgba(7, 9, 7, .75) 0%, transparent 45%, transparent 70%, var(--bg) 100%);
}
.vignette { display: none; background: radial-gradient(closest-side, transparent 30%, var(--bg) 100%); }

.title-block {
  position: absolute; left: var(--pad); right: var(--pad); top: 24vh; top: 24svh;
  text-align: center; text-shadow: 0 2px 24px rgba(0, 0, 0, .6);
}
.title {
  font-size: clamp(2.5rem, 10.5vw, 5.5rem); font-weight: 900; letter-spacing: -.035em; line-height: 1;
}
.tagline { margin-top: 16px; font-size: 18px; font-weight: 300; color: var(--text-2); }
@media (min-width: 1024px) { .tagline { font-size: 24px; } }

.hint-scroll { position: absolute; left: 0; right: 0; bottom: 24px; display: flex; justify-content: center; }
.hint {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 12px; text-decoration: none; color: var(--chalk);
}
.hint .eyebrow { color: var(--text-2); }

/* ---------- 3. Miza ---------- */

.miza { position: relative; padding: 32px var(--pad) 0; outline: none; }
.miza-inner { max-width: 1120px; margin: 0 auto; display: grid; gap: 24px; }

.next-card {
  position: relative; padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, var(--felt-glow), transparent 70%);
  border-radius: 10px;
}
.outline { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.outline rect { fill: none; stroke: var(--chalk-line); stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 0; }
.next-weekday { margin-top: 12px; font-size: 16px; font-weight: 600; color: var(--text-2); }
.next-weekday:empty { display: none; }
.next-date { font: 500 40px/1.1 var(--display); margin-top: 2px; }
.next-date.is-small { font: 600 20px/1.3 var(--sans); margin-top: 12px; }
.next-time { margin-top: 4px; font-size: 16px; }
.next-time:empty { display: none; }
.next-loc { margin-top: 12px; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); }
.next-loc svg { color: var(--chalk); flex: none; }
.pill-slot { position: absolute; top: 20px; right: 20px; }
.pill {
  display: inline-block; background: var(--chalk); color: var(--bg); border-radius: 999px;
  padding: 2px 10px; font-size: 12px; font-weight: 700; line-height: 18px; text-transform: uppercase; letter-spacing: .04em;
}
.pill[hidden] { display: none; }

.numbers-pill { display: none; }
.is-dummy .numbers-pill { display: block; margin-bottom: 12px; }
.numbers-row { display: grid; grid-template-columns: repeat(3, 1fr); }
.numbers-row > .num { padding: 0 12px; border-left: 1px solid var(--rule); min-width: 0; }
.numbers-row > .num:first-child { padding-left: 0; border-left: 0; }
.big { font: 500 28px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.lbl { margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--text-2); }
.sub { font-size: 12px; line-height: 16px; color: var(--text-3); }
.dummy-note { margin-top: 16px; font-size: 14px; color: var(--text-2); }

@media (min-width: 1024px) {
  .miza-inner { grid-template-columns: repeat(12, 1fr); align-items: center; }
  .next-card { grid-column: 1 / 6; }
  .numbers { grid-column: 7 / 13; }
  .next-date { font-size: 56px; }
  .big { font-size: 48px; }
  .numbers-row > .num { padding: 0 24px; }
}

/* ---------- Sections ---------- */

main { padding-top: var(--gap); }
.block + .block, .board + .block { margin-top: var(--gap); }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 4px; margin-bottom: 16px; }
.sec-head h2 { font: 600 24px/1.2 var(--display); text-transform: uppercase; letter-spacing: .04em; }
.sec-head .aside { font-size: 14px; color: var(--text-2); }
@media (min-width: 1024px) { .sec-head h2 { font-size: 32px; } }

caption { caption-side: bottom; text-align: left; padding-top: 12px; font-size: 12px; color: var(--text-3); }

.ph {
  display: none; place-items: center; min-height: 180px;
  border: 1px solid var(--chalk-line); border-radius: 10px; color: var(--text-3);
}
.is-loading .ph { display: grid; }
.is-loading .data, .is-error .data, .is-error .ph { display: none !important; }
.is-error .board, .is-error .zadnja { display: none; }
.no-games .has-games { display: none; }
.status { padding: 24px; border: 1px solid var(--chalk-line); border-radius: 10px; margin-bottom: var(--gap); }
.status .text-btn { margin-top: 12px; }
.empty { color: var(--text-2); padding: 16px 0; }

/* ---------- 4. Lestvica ---------- */

.standings { display: flex; flex-direction: column; }
.standings thead, .standings tbody, .standings caption { display: block; }
.standings caption { order: 3; }
.standings thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.standings .row {
  display: grid; grid-template-columns: 28px 36px minmax(0, 1fr) minmax(7ch, auto);
  align-items: center; min-height: 56px; padding: 0 12px 0 8px; column-gap: 4px;
  border-bottom: 1px solid var(--rule); border-radius: 10px;
  cursor: pointer; transition: background-color 150ms;
}
.standings .row.head { cursor: default; min-height: 36px; font-size: 12px; font-weight: 600; color: var(--text-3); text-align: left; }
.standings .row.head th { font-weight: 600; }
.standings .r { text-align: right; }
.standings .games-col { display: none; }
.standings tbody .row:hover, .standings tbody .row.is-sel { background: var(--felt-hi); }
.standings .row.top { outline: 2px solid var(--chalk); outline-offset: -2px; border-bottom-color: transparent; }
.standings td { padding: 0; }
.rank { font: 500 20px/1 var(--display); }
.chg { font-size: 12px; font-weight: 700; }
.chg-same { color: var(--text-3); }
.chg-new { color: var(--chalk); }
.who { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.ini { font-size: 18px; font-weight: 700; }
.tag { display: flex; align-items: center; gap: 5px; margin-left: 18px; font-size: 12px; line-height: 16px; color: var(--text-2); }
.tag svg { flex: none; }
.tag-chef { color: var(--chalk); }
.tag-gold { color: var(--gold); }
.tag-silver { color: var(--silver); }
.tag-bronze { color: var(--bronze); }
.net-cell { text-align: right; }
.net { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.games-sub { display: block; font-size: 12px; color: var(--text-3); }

@media (min-width: 1024px) {
  .standings thead { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .standings .row { grid-template-columns: 28px 40px minmax(0, 1fr) minmax(7ch, auto) 5ch; min-height: 52px; column-gap: 8px; }
  .standings .games-col { display: block; }
  .player-cell { display: flex; align-items: center; flex-wrap: wrap; column-gap: 10px; }
  .tag { margin-left: 0; }
  .games-sub { display: none; }
  .games-cell { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
}

/* ---------- 5. Potek ---------- */

.readout { min-height: 24px; margin-bottom: 8px; font-size: 14px; color: var(--text-2); }
.readout strong { color: var(--text); }
.chart { position: relative; width: 100%; height: 300px; }
.chart svg { overflow: visible; font-family: var(--sans); }
.chart .lbl-x, .chart .lbl-y { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .zero { stroke: var(--chalk); stroke-opacity: .6; stroke-width: 1; }
.chart .zero-lbl { font-size: 11px; font-weight: 700; fill: var(--chalk); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .85; transition: opacity 150ms, stroke-width 150ms; }
.chart .hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; stroke-linejoin: round; }
.chart .end { font-size: 12px; font-weight: 700; cursor: pointer; transition: opacity 300ms; }
.chart .leader { stroke-width: 1; opacity: .5; }
.chart .ends { transition: opacity 300ms; }
.chart.is-drawing .ends { opacity: 0; }
.chart .counter { font: 500 14px var(--display); fill: var(--chalk); transition: opacity 300ms; }
.chart .counter.is-gone { opacity: 0; }
.chart .tip { transition: none; }
.chart svg.has-sel .line:not(.is-sel), .chart svg.has-sel .end-g:not(.is-sel) { opacity: .15; }
.chart .line.is-sel { stroke-width: 3; opacity: 1; }
@media (min-width: 1024px) {
  .board { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
  .lestvica { grid-column: 1 / 6; }
  .potek { grid-column: 6 / 13; margin-top: 0 !important; position: sticky; top: 24px; }
  .chart { height: 460px; }
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 999px; background: transparent; cursor: pointer;
  font-weight: 700; font-size: 14px; transition: background-color 150ms, border-color 150ms;
}
.chip:hover, .chip.is-sel { background: var(--felt-hi); }
.chip[aria-pressed="true"] { border-color: var(--chalk); }

/* ---------- 6. Zadnja igra ---------- */

.table-scroll { overflow-x: auto; }
.last { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.last th, .last td { height: 44px; padding: 0 0 0 12px; white-space: nowrap; border-bottom: 1px solid var(--rule); }
.last th:first-child, .last td:first-child { padding-left: 0; width: 56px; position: sticky; left: 0; background: var(--bg); }
.last thead th { font-size: 12px; font-weight: 600; color: var(--text-3); text-align: left; height: 36px; }
.last .r { text-align: right; }
.last tbody td:not(:first-child), .last tfoot td:not(:first-child) { text-align: right; font-size: 15px; font-weight: 700; }
.last .who .ini { font-size: 15px; }
.last tfoot td { border-top: 1px solid var(--chalk-line); border-bottom: 0; color: var(--text-2); }
.last tfoot td:first-child { font-weight: 600; }
.night { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 32px; }
.night .lbl { margin: 0 0 4px; }
@media (min-width: 1024px) {
  .zadnja-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
  .table-scroll { grid-column: 1 / 8; }
  .night { grid-column: 8 / 13; grid-template-columns: 1fr; margin-top: 0; padding-left: 24px; border-left: 1px solid var(--rule); }
}

/* ---------- 7. Footer ---------- */

.footer { margin-top: var(--gap); padding: 48px 0; border-top: 1px solid var(--rule); }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; column-gap: 16px; row-gap: 8px; font-size: 14px; color: var(--text-3); }
.footer-chip { border-radius: 6px; }

/* ---------- Motion: load sequence (any browser, motion allowed) ---------- */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .photo-inner { animation: fade-in 1200ms ease-out both; }
  .title.load-rise { animation: rise-in 800ms ease-out 400ms both; }
  .tagline.load-rise { animation: rise-in 800ms ease-out 650ms both; }
  .hint.load-rise { animation: rise-in 800ms ease-out 1400ms both; }
  .hint .chev { animation: bob 2000ms ease-in-out 2200ms infinite; }
  .photo img { animation: ambient 24s ease-in-out infinite alternate; }
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes bob { 50% { transform: translateY(6px); } }
@keyframes ambient {
  from { transform: scale(1.06) translateX(-1.5%); }
  to { transform: scale(1.10) translateX(1.5%); }
}

/* ---------- Motion: the scroll-driven transition (DESIGN.md §2) ----------
   Hidden starting states exist only inside this gate, through fill-mode both. */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) and (min-height: 540px) {
    .hero-track { height: 250vh; height: 250svh; view-timeline: --hero block; }
    .stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
    .hero { position: absolute; inset: 0; height: auto; }
    .vignette { display: block; }
    .miza {
      position: absolute; inset: 0; z-index: 1; pointer-events: none;
      display: flex; flex-direction: column; justify-content: center; padding: 24px var(--pad);
    }
    .miza-inner { width: 100%; }

    .hint-scroll, .tagline-scroll, .title-scroll, .photo, .vignette, .outline rect, .ln, .num {
      animation-duration: 1ms; animation-timing-function: linear; animation-fill-mode: both;
      animation-timeline: --hero;
    }
    .hint-scroll { animation-name: s-hint; animation-range: contain 0% contain 10%; }
    .tagline-scroll { animation-name: s-tagline; animation-range: contain 0% contain 35%; }
    .title-scroll { animation-name: s-title; animation-range: contain 15% contain 40%; }
    .photo { animation-name: s-photo; animation-range: contain 0% contain 55%; }
    .vignette { animation-name: s-vignette; animation-range: contain 30% contain 65%; }
    .outline rect { animation-name: s-outline; animation-range: contain 45% contain 75%; }
    .ln, .num { animation-name: s-rise; }
    .ln.l1 { animation-range: contain 60% contain 70%; }
    .ln.l2 { animation-range: contain 63% contain 73%; }
    .ln.l3 { animation-range: contain 66% contain 76%; }
    .ln.l4 { animation-range: contain 69% contain 79%; }
    .ln.l5 { animation-range: contain 72% contain 82%; }
    .ln.l6 { animation-range: contain 75% contain 85%; }
    .num.n1 { animation-range: contain 70% contain 85%; }
    .num.n2 { animation-range: contain 75% contain 90%; }
    .num.n3 { animation-range: contain 80% contain 95%; }
  }
}
@keyframes s-hint { to { opacity: 0; transform: translateY(8px); } }
@keyframes s-tagline { to { opacity: 0; transform: translateY(-16px); } }
@keyframes s-title { to { opacity: 0; transform: translateY(-12svh) scale(.72); } }
@keyframes s-photo {
  from { transform: scale(1); filter: blur(0) brightness(1) saturate(1); }
  to { transform: scale(1.4); filter: blur(8px) brightness(.35) saturate(.8); }
}
@keyframes s-vignette { from { transform: scale(2.2); } to { transform: scale(1); } }
@keyframes s-outline { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes s-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Motion: IntersectionObserver fallback (html.io is set by app.js) ---------- */

.io .outline rect { transition: stroke-dashoffset 900ms ease-out; }
.io .miza .ln, .io .miza .num { transition: opacity 500ms ease-out 200ms, transform 500ms ease-out 200ms; }
.io .miza .num.n1 { transition-delay: 350ms; }
.io .miza .num.n2 { transition-delay: 400ms; }
.io .miza .num.n3 { transition-delay: 450ms; }
.io .miza:not(.is-in) .outline rect { stroke-dashoffset: 1; }
.io .miza:not(.is-in) .ln, .io .miza:not(.is-in) .num { opacity: 0; transform: translateY(12px); }

/* ---------- It’s Raining Chips (public/chips.js) ---------- */

.chips-toggle {
  position: fixed; z-index: 70;
  top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 6px 14px 6px 8px;
  border: 1px solid rgba(238, 240, 230, .22); border-radius: 999px;
  background: rgba(7, 9, 7, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--text-2); font-size: 13px; font-weight: 600; letter-spacing: .04em; line-height: 1;
  cursor: pointer; transition: color .2s, border-color .2s, background-color .2s;
}
.chips-toggle:hover { color: var(--text); border-color: rgba(238, 240, 230, .45); }
.chips-toggle[aria-pressed="true"] { color: var(--chalk); border-color: var(--chalk-line); background: rgba(7, 9, 7, .8); }
.chips-toggle-chip {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle, #0e1510 0 42%, #c5282f 43% 100%),
    #c5282f;
  border: 2px dashed #f3f1ec;
  opacity: .75; transition: opacity .2s;
}
.chips-toggle[aria-pressed="true"] .chips-toggle-chip { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .chips-toggle[aria-pressed="true"] .chips-toggle-chip { animation: chip-spin 2.4s linear infinite; }
}
@keyframes chip-spin { to { transform: rotate(360deg); } }
.chips-rain { position: fixed; inset: 0; z-index: 60; width: 100%; height: 100%; pointer-events: none; }
