/* #demo — phone view ↔ top-down replay, neutral scrubber with orange playhead + pots. All SVG content is drawn by demo.js. */
#demo { position: relative; overflow: hidden; }
#demo::before { /* felt spill behind the stage */
  content: ""; position: absolute; inset: 30% -20% auto; height: 60%;
  background: radial-gradient(50% 50% at 50% 50%, color-mix(in srgb, var(--felt) 22%, transparent), transparent 70%);
  pointer-events: none;
}
#demo .wrap { position: relative; }

#demo .demo-head { margin-bottom: var(--s6); }
#demo .demo-head .display { font-size: clamp(2.2rem, 8vw, 6rem); margin-top: var(--s3); overflow-wrap: anywhere; }
#demo .demo-hl { color: var(--accent-ink); white-space: nowrap; }
#demo .demo-lede { color: var(--muted); font-size: 1.15rem; margin: var(--s4) 0 0; max-width: 40ch; }

/* stage: two views and the warp arrow */
#demo .demo-stage { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s4); }
#demo .demo-view { margin: 0; min-width: 0; }
#demo .demo-view figcaption {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem;
  margin-top: var(--s3);
  font: 600 .78rem/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
}
#demo .demo-k { color: var(--muted); }
#demo .demo-svg { width: 100%; height: auto; aspect-ratio: 16 / 9; }

#demo .demo-device {
  padding: 10px 10px 10px 22px; /* thicker left bezel: landscape phone */
  border-radius: 30px;
  background: var(--rail);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ball) 14%, var(--rail)), 0 40px 90px -40px var(--felt);
  position: relative;
}
#demo .demo-device::before { /* camera pill */
  content: ""; position: absolute; left: 8px; top: 50%; width: 5px; height: 34px; translate: 0 -50%;
  border-radius: 9px; background: color-mix(in srgb, var(--ball) 18%, var(--rail));
}
#demo .demo-screen {
  position: relative; border-radius: 20px; overflow: hidden;
  background: radial-gradient(70% 70% at 55% 75%, color-mix(in srgb, var(--felt) 30%, var(--rail)), var(--rail) 75%);
}
#demo .demo-rec, #demo .demo-stamp {
  position: absolute; top: 10px;
  font: 600 .62rem/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ball);
}
#demo .demo-rec { left: 12px; display: flex; align-items: center; gap: .4em; }
#demo .demo-rec::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: demo-blink 1.2s steps(2, jump-none) infinite; }
#demo .demo-stamp { right: 10px; padding: .35em .55em; border: 1.5px solid var(--ball); border-radius: 4px; }

#demo .demo-board {
  position: relative; padding: 10px; border-radius: 30px;
  background: var(--surface); border: 2px solid var(--line);
  box-shadow: 0 30px 80px -50px var(--shadow);
}

#demo .demo-warp { display: grid; justify-items: center; gap: .6rem; }
#demo .demo-warp-dot {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); box-shadow: 0 0 0 0 var(--accent);
  animation: demo-ping 2.4s var(--ease-out) infinite;
}
#demo .demo-warp-dot svg { width: 30px; fill: none; stroke: var(--on-accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; animation: demo-nudge 2.4s var(--ease-out) infinite; }
#demo .demo-warp-label { font: 600 .68rem/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* SVG table */
#demo .d-rail { fill: var(--rail); stroke: color-mix(in srgb, var(--ball) 22%, var(--rail)); stroke-width: 1; stroke-linejoin: round; }
#demo .d-cushion { fill: color-mix(in srgb, var(--felt) 72%, var(--rail)); }
#demo .d-felt { fill: var(--felt); }
#demo .d-diamond { fill: var(--ball); opacity: .7; }
#demo .d-pocket { fill: var(--rail); }
#demo .d-burst { fill: none; stroke: var(--ball); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
#demo .d-burst.go { animation: demo-burst .9s var(--ease-out); }
#demo .d-grid { opacity: 0; transition: opacity .5s var(--ease-out); }
#demo:not(.no-grid) .d-grid { opacity: 1; }
#demo .d-grid line { stroke: var(--rail); stroke-width: .7; stroke-dasharray: 3 2.5; opacity: .5; }
#demo .d-grid text { font: 600 6px var(--font-mono); fill: var(--ball); text-anchor: middle; letter-spacing: .05em; }
#demo .d-anchor { fill: var(--accent); stroke: var(--ball); stroke-width: .8; }
#demo .d-trails { transition: opacity .3s; }
#demo.no-trails .d-trails { opacity: 0; }
#demo .d-trail { fill: none; stroke: var(--rail); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 4 3; opacity: .8; }
#demo .d-trail.is-cue { stroke: var(--ball); stroke-dasharray: none; opacity: .95; }
#demo .d-ball circle { fill: var(--rail); }
#demo .d-ball.is-cue circle { fill: var(--ball); stroke: var(--rail); stroke-width: .6; }
#demo .d-ball .d-shine { fill: var(--ball); opacity: .55; stroke: none; }
#demo .d-ball.is-cue .d-shine { fill: var(--surface); opacity: .9; }
#demo .d-ball text { font: 800 5.6px var(--font-text); fill: var(--ball); text-anchor: middle; }
#demo .d-box { fill: none; stroke: var(--ball); stroke-width: 1; opacity: .85; }

/* live scoreboard over the stage; demo.js fills the numbers */
#demo .demo-score { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2) var(--s5); margin: 0 0 var(--s4); font: 800 clamp(1.1rem, 2.6vw, 1.7rem)/1 var(--font-display); font-stretch: 112%; font-variation-settings: "wdth" 112; text-transform: uppercase; color: var(--muted); }
#demo .demo-score b { color: var(--fg); font-variant-numeric: tabular-nums; margin-left: .25em; }
#demo .demo-score .is-pot b { color: var(--accent-ink); }

/* pot toast over the top-down board */
#demo .demo-toast {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  padding: .45em .8em; border-radius: 10px;
  background: var(--on-accent); color: var(--accent);
  font: 900 clamp(1rem, 2.6vw, 1.6rem)/1 var(--font-display); font-stretch: 125%; font-variation-settings: "wdth" 125;
  text-transform: uppercase; white-space: nowrap;
  opacity: 0; pointer-events: none;
}
#demo .demo-toast.go { animation: demo-toast 1.6s var(--ease-spring); }

#demo .demo-status { margin-left: auto; display: inline-flex; align-items: center; gap: .45em; color: var(--muted); }
#demo .demo-status b { color: var(--fg); font-weight: 600; }
#demo .demo-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background-color .2s; }
#demo .demo-status.is-moving i { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }

/* controls: neutral surface; orange is only the play button, playhead and pots.
   Re-points --on-accent (the ink of the marks, track and chips) at --fg so it reads in both themes. */
#demo .demo-controls {
  --on-accent: var(--fg);
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: var(--s4);
  margin-top: var(--s5); padding: var(--s3) var(--s4);
  border-radius: var(--radius-lg);
  background: var(--surface); color: var(--fg);
  border: 2px solid var(--line);
}
#demo .demo-controls :focus-visible { outline-color: var(--accent); }
#demo .demo-play {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--accent); color: var(--rail);
  transition: transform .3s var(--ease-spring);
}
#demo .demo-play:hover { transform: scale(1.08); }
#demo .demo-play:active { transform: scale(.94); }
#demo .demo-play svg { width: 24px; fill: currentColor; }
#demo .i-pause, #demo.is-playing .i-play { display: none; }
#demo.is-playing .i-pause { display: block; }

#demo .demo-track { position: relative; padding-top: 22px; min-width: 0; }
#demo .demo-marks { position: absolute; inset: 0 11px; pointer-events: none; }
#demo .demo-mark {
  position: absolute; top: 0; left: calc(var(--x) * 100%); translate: -50% 0;
  padding: 2px 5px; border: 0; border-radius: 5px; cursor: pointer; pointer-events: auto;
  background: none; color: var(--on-accent);
  font: 700 .66rem/1 var(--font-mono); letter-spacing: .06em;
  transition: transform .25s var(--ease-spring);
}
#demo .demo-mark::after { /* tick down onto the track */
  content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 16px; translate: -50% 2px;
  background: var(--on-accent); border-radius: 2px;
}
#demo .demo-mark:hover { transform: translateY(-2px); }
#demo .demo-mark.is-pot { background: var(--accent); color: var(--rail); }

#demo .demo-scrub {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 30px; margin: 0; background: transparent; cursor: pointer;
}
#demo .demo-scrub::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--on-accent) var(--p, 0%), color-mix(in srgb, var(--on-accent) 25%, transparent) var(--p, 0%));
}
#demo .demo-scrub::-moz-range-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--on-accent) var(--p, 0%), color-mix(in srgb, var(--on-accent) 25%, transparent) var(--p, 0%));
}
#demo .demo-scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 5px solid var(--on-accent);
  transition: transform .2s var(--ease-spring);
}
#demo .demo-scrub::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 5px solid var(--on-accent);
}
#demo .demo-scrub:active::-webkit-slider-thumb { transform: scale(1.25); }
#demo .demo-scrub:focus-visible { outline-offset: 4px; }

#demo .demo-time { font: 700 1.05rem/1 var(--font-mono); font-variant-numeric: tabular-nums; min-width: 5.5ch; }
#demo .demo-toggles { display: flex; gap: var(--s2); }
#demo .demo-chip {
  display: inline-flex; align-items: center; gap: .45em;
  padding: .55em .9em; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--on-accent); background: transparent; color: var(--on-accent);
  font: 800 .78rem/1 var(--font-text); text-transform: uppercase; letter-spacing: .05em;
  transition: background-color .2s, color .2s, transform .3s var(--ease-spring);
}
#demo .demo-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid currentColor; }
#demo .demo-chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
#demo .demo-chip[aria-pressed="true"]::before { background: currentColor; }
#demo .demo-chip:hover { transform: translateY(-2px); }

/* event log */
#demo .demo-log { list-style: none; padding: 0; margin: var(--s4) 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
#demo .demo-log button {
  width: 100%; text-align: left; cursor: pointer;
  display: grid; gap: .3rem; padding: .7rem .2rem 0;
  border: 0; border-top: 3px solid var(--line); background: none;
  color: var(--muted); opacity: .55;
  font: 700 .85rem/1.1 var(--font-mono); letter-spacing: .04em;
  transition: opacity .3s, color .3s, border-color .3s;
}
#demo .demo-log time { font-weight: 400; font-size: .72rem; }
#demo .demo-log .is-past button { opacity: 1; color: var(--fg); border-top-color: var(--fg); }
#demo .demo-log .is-now button { color: var(--accent-ink); border-top-color: var(--accent); }
#demo .demo-log .is-pot.is-past span::before { content: "● "; color: var(--accent); }
#demo .demo-note { margin: var(--s4) 0 0; color: var(--muted); font-size: .85rem; }

@keyframes demo-blink { 50% { opacity: 0; } }
@keyframes demo-ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 22px transparent; } }
@keyframes demo-nudge { 0%, 100% { translate: -3px 0; } 50% { translate: 3px 0; } }
@keyframes demo-burst { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(3.4); } }
@keyframes demo-toast {
  0% { opacity: 0; scale: .6; rotate: -6deg; }
  18% { opacity: 1; scale: 1; rotate: -3deg; }
  80% { opacity: 1; scale: 1; rotate: -3deg; }
  100% { opacity: 0; scale: .9; rotate: -3deg; }
}
/* nothing animates while the section is off screen */
#demo:not(.is-live) *, #demo:not(.is-live) *::before { animation-play-state: paused; }

@media (max-width: 760px) {
  #demo .demo-stage { grid-template-columns: 1fr; gap: var(--s3); }
  #demo .demo-warp { grid-auto-flow: column; align-items: center; justify-content: center; }
  #demo .demo-warp-dot { width: 48px; height: 48px; rotate: 90deg; }
  #demo .demo-warp-dot svg { width: 24px; }
  #demo .demo-device, #demo .demo-board { border-radius: 22px; }
  #demo .demo-screen { border-radius: 14px; }
  #demo .demo-controls { grid-template-columns: auto 1fr auto; gap: var(--s3); padding: var(--s3); }
  #demo .demo-track { grid-column: 1 / -1; grid-row: 2; }
  #demo .demo-play { width: 48px; height: 48px; }
  #demo .demo-time { justify-self: start; }
  #demo .demo-log { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  #demo .demo-warp-dot, #demo .demo-warp-dot svg, #demo .demo-rec::before { animation: none; }
}
