/* Exercise demos (build spec update 4 §1.4, task 4.2; demos/design.md §1.1 option C) — ui/demo-player.js stacks one
   <svg class="dm-f"> per flipbook slot inside .dm.n<N>; a step-end opacity loop shows exactly one at a time:
   frame i is visible during [i·step, (i+1)·step) of every cycle (--cycle = N × --step). Each frame is rasterised once,
   then only the compositor flips opacity — zero JS and zero layout per pose. Every stop (reduced motion's global kill,
   the pause hold) leaves the key pose (.is-key). --i, --step, --cycle, --n, --ar, --dx, --dy are set by JS through
   CSSOM (+ --fw/--fh: the ring box) and always read with a fallback. Colours come from the surface (--fig, --fig-wash, --strike, --rope, --knock).
   Update 8c (F77, spec §1.7/§3.4): the slow motions of ui/demo-motion.js — swing (two frames crossfade with 20 % end-range
   holds, ease-in-out, --cycle = one rep), the orbit dot (one lap per --orbit, --odir; dimmed on a perspective back half)
   and breath (4 s up, 6 s down over --orbit); the pulse reads --pulse. Reduced motion: none of them moves.
   Update 10c (release): every loop delay sits 1 ms early, so no frame starts exactly on a step boundary — at the first
   paint frame 0 and frame N−1 both read opacity 1 there (Chrome float rounding of the step-end edge; demos.spec on m360). */

/* 1 · STAGE — frames stacked in one box; the sprite's figure fills with currentColor; overlays may leave the crop */
.dm{position:relative;display:block;flex:none;color:var(--fig,currentColor);pointer-events:none}
.dm-f,.dm-floor,.dm-pulse{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.dm-f{opacity:0;translate:calc(var(--dx,0) * 1%) calc(var(--dy,0) * 1%)}
/* an upper crop (neck isometrics) hides the cut-off legs and lets the bust fade out like a brushed vignette */
.dm.crop-upper .dm-f,.dm.crop-upper .dm-c{overflow:hidden;-webkit-mask-image:linear-gradient(#000 62%,#0000 96%);
  mask-image:linear-gradient(#000 62%,#0000 96%)}
.dm-f.is-key{opacity:1}
.dm-f.is-flip,.dm-c.is-flip{scale:-1 1}
.dm-floor{fill:var(--rope,currentColor);opacity:.55;stroke:none}
.dm-fp{color:var(--fig-wash,currentColor)}
.dm-fp.hot{color:var(--strike,currentColor)}

/* 2 · LOOPS — one rule per frame count (the keyframes name leads the shorthand; dm2…dm8 are pose swaps, not flashes) */
.dm.loop.n2 .dm-f{animation:dm2 var(--cycle,1s) step-end infinite;animation-delay:calc(var(--i,0) * var(--step,500ms) - var(--cycle,1s) - 1ms)}
.dm.loop.n3 .dm-f{animation:dm3 var(--cycle,1.02s) step-end infinite;animation-delay:calc(var(--i,0) * var(--step,340ms) - var(--cycle,1.02s) - 1ms)}
.dm.loop.n4 .dm-f{animation:dm4 var(--cycle,1.2s) step-end infinite;animation-delay:calc(var(--i,0) * var(--step,300ms) - var(--cycle,1.2s) - 1ms)}
.dm.loop.n5 .dm-f{animation:dm5 var(--cycle,1.5s) step-end infinite;animation-delay:calc(var(--i,0) * var(--step,300ms) - var(--cycle,1.5s) - 1ms)}
.dm.loop.n6 .dm-f{animation:dm6 var(--cycle,1.8s) step-end infinite;animation-delay:calc(var(--i,0) * var(--step,300ms) - var(--cycle,1.8s) - 1ms)}
.dm.loop.n7 .dm-f{animation:dm7 var(--cycle,2.1s) step-end infinite;animation-delay:calc(var(--i,0) * var(--step,300ms) - var(--cycle,2.1s) - 1ms)}
.dm.loop.n8 .dm-f{animation:dm8 var(--cycle,2.4s) step-end infinite;animation-delay:calc(var(--i,0) * var(--step,300ms) - var(--cycle,2.4s) - 1ms)}
.dm.loop .dm-f{will-change:opacity}
.is-held .dm-f,.is-held .dm.loop .dm-f,.is-held .dm-pulse{animation-play-state:paused} /* beats the loops' shorthand */
/* swing: A holds 0–20 %, moves 20–50 %, B holds 50–70 %, moves back 70–100 % — one rep per --cycle (2 × step) */
.dm.swing .dm-f.is-a{animation:dm-swa var(--cycle,5s) ease-in-out infinite}
.dm.swing .dm-f.is-b{animation:dm-swb var(--cycle,5s) ease-in-out infinite}
.dm.swing .dm-f{will-change:opacity}
/* orbit: the dot laps the overlay's ellipse once per rep; the rotation centre is the carrier circle's fill-box centre */
.dm-orbit{transform-box:fill-box;transform-origin:center;animation:dm-orbit var(--orbit,4s) linear infinite var(--odir,normal)}
.dm-orbit.mir{animation-direction:var(--odir2,reverse)} /* the mirrored side of a two-sided overlay runs the other way */
/* the dot counter-spins in step (so the ellipse's squash leaves it round) and dims on a perspective back half */
.dm-spin{transform-box:fill-box;transform-origin:center;animation:dm-orbit var(--orbit,4s) linear infinite var(--odir2,reverse)}
.dm-spin.mir{animation-direction:var(--odir,normal)}
.dm-dot{fill:var(--strike,currentColor);stroke:var(--knock,transparent);stroke-width:4px}
.dm-dot.back{animation:dm-orbit-fade var(--orbit,4s) linear infinite var(--odir,normal)}
.dm-spin.mir>.dm-dot.back{animation-direction:var(--odir2,reverse)}
.is-held :is(.dm-orbit,.dm-spin,.dm-dot){animation-play-state:paused}
/* breath: the still figure swells 4 s and settles 6 s */
.dm.breath .dm-f{transform-origin:50% 70%;animation:dm-breath var(--orbit,10s) ease-in-out infinite}

/* 3 · STILL POSES — a pulsing arrow says »press, don't move« (neck isometrics); transform only */
.dm-pulse{transform-origin:50% 38%;animation:dm-pulse var(--pulse,1.2s) ease-in-out infinite alternate}

/* 4 · STATIC STRIP — reduced motion / »Bewegungen zeigen: aus« in the ring: the distinct poses side by side (2 × 2) */
/* the grid fills the sized .dm box (absolute, so its rows are definite): a narrow pose never stretches its row */
.dm-strip{position:absolute;inset:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:minmax(0,1fr);gap:6%}
.dm-c{width:100%;height:100%;min-height:0;overflow:visible}

/* 5 · SIZES — the svgs keep their aspect inside these boxes (preserveAspectRatio meet), so every frame lines up.
   Ring: --fw/--fh (demo-player ringBox) = the box inscribed in the ensō's inner circle, a little larger for tall
   figures — a standing figure gets .74 d of height (the rope arcs stay inside), a plank or sprawl clears the band */
.dm.s-ring{width:calc(var(--d,60vw) * var(--fw,.37));height:calc(var(--d,60vw) * var(--fh,.74))}
.dm.s-ring.strip{width:calc(var(--d,60vw) * .66);height:calc(var(--d,60vw) * .66)}
.dm.s-ring.strip.n2{width:calc(var(--d,60vw) * .58);height:calc(var(--d,60vw) * .6)} /* one row of two: rope arcs clear the ring */
.dm.strip.n3 .dm-c:last-child{grid-column:1/-1} /* the odd third pose centred under the first two */
.dm.s-ring.crop-upper{height:calc(var(--d,60vw) * .6);width:min(calc(var(--d,60vw) * .6 * var(--ar,.9)),calc(var(--d,60vw) * .66));
  translate:0 8%} /* the bust sits low: head and push arrow clear the ring, the faded waist needs no room */
/* rep: the box hugs the crop — a tall one (burpee) gets real height, a wide one (push-up) the full width — so the NEU
   seal on the box corner sits at the figure */
.dm.s-rep{--rh:min(240px,26vh);width:min(300px,80vw,calc(var(--rh) * var(--ar,1.65)));
  height:min(var(--rh),calc(min(300px,80vw) / var(--ar,1.65)))}
@media (max-height:640px){.dm.s-rep{--rh:18vh}}
.dm.s-task{width:96px;height:min(130px,12vh)}
.dm.s-card{width:92px;height:146px}
.dm.s-thumb{width:40px;height:40px}

/* 6 · FIGURE RESERVE inside the ensō (D11): a stroke in the field's knock colour keeps the ring off the body */
.dial .dm-f,.dial .dm-c{stroke:var(--knock,transparent);stroke-width:10px;paint-order:stroke fill;stroke-linejoin:round}
.dial .dm-floor{stroke:none}

/* 7 · NEU — first sight of a demo / a term explained (D15): the vermilion seal presses once and stays 10 s */
.dm-new{--s:min(64px,8vh);position:absolute;top:0;right:0;z-index:2;rotate:-8deg;font:800 calc(var(--s) * .36)/1 var(--num);
  letter-spacing:.04em;animation:seal-press var(--t-stamp,520ms) var(--e-stamp,ease-out) both}
.dm-new::after{inset:11%}
.dm-new.sm{--s:min(44px,6vh);top:-8px;right:-12px} /* beside the small rep / rest-task demo */
/* integration 8e: on a short screen (320×568) the small seal sits lower and further out — at -8 px it met the block label
   above the demo (the gauge path took the top row) */
@media (max-height:640px){.dm-new.sm{top:2px;right:-26px}}
/* update 7: a wide lying loop (swimmers) lifts a limb at both ends of its box — its seal sits top centre, over the hips */
.rep-demo:has(.dm.wide)>.neu-host{inset:0 0 auto 0;width:auto}
.rep-demo:has(.dm.wide)>.neu-host>.dm-new.sm{top:-12px;right:auto;left:50%;translate:-50% 0}
/* glove-up: centred on the »Kombi des Tages« label row, between the theme and the strip — never on a move */
.kdt>.neu-host>.dm-new{--s:min(34px,5vh);top:calc(3px - var(--s) * .5);right:-4px}

/* 8 · KEYFRAMES */
@keyframes dm2{0%{opacity:1}50%,to{opacity:0}}
@keyframes dm3{0%{opacity:1}33.333%,to{opacity:0}}
@keyframes dm4{0%{opacity:1}25%,to{opacity:0}}
@keyframes dm5{0%{opacity:1}20%,to{opacity:0}}
@keyframes dm6{0%{opacity:1}16.667%,to{opacity:0}}
@keyframes dm7{0%{opacity:1}14.286%,to{opacity:0}}
@keyframes dm8{0%{opacity:1}12.5%,to{opacity:0}}
@keyframes dm-pulse{from{transform:scale(1)}to{transform:scale(1.12)}}
@keyframes dm-swa{0%,20%{opacity:1}50%,70%{opacity:0}to{opacity:1}}
@keyframes dm-swb{0%,20%{opacity:0}50%,70%{opacity:1}to{opacity:0}}
@keyframes dm-orbit{from{transform:rotate(0)}to{transform:rotate(360deg)}}
@keyframes dm-orbit-fade{0%,45%{opacity:1}55%,95%{opacity:.3}to{opacity:1}} /* front half (0–180°) full, back half dimmed */
@keyframes dm-breath{0%{transform:scale(1)}40%{transform:scale(1.06)}to{transform:scale(1)}}

/* 9 · REDUCED MOTION — the global kill (style.css) stops every loop on its key pose; the pulse arrow goes */
@media (prefers-reduced-motion:reduce){
  .dm-pulse{display:none}
  .dm-new{animation:none}
  .dm-orbit,.dm-spin,.dm-dot,.dm.breath .dm-f,.dm.swing .dm-f{animation:none}
}
