/* Few, quiet movements. Transform and opacity only. */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { 50% { transform: scale(1.04); } }
.stagger > * { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.stagger > :nth-child(2) { animation-delay: .08s; }
.stagger > :nth-child(3) { animation-delay: .16s; }
.stagger > :nth-child(4) { animation-delay: .24s; }
.stagger > :nth-child(5) { animation-delay: .32s; }
.hero-art { animation: rise .8s cubic-bezier(.2, .7, .2, 1) .1s both; }
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .5s, transform .5s; }
.reveal.shown { opacity: 1; transform: none; }
.view { animation: rise .35s ease-out; }
details[open] > p { animation: rise .25s ease-out; }
#demo-result.pop { animation: pop .35s ease-out; }
#look-board.swap { animation: swap .3s ease-out; }
@keyframes swap { from { opacity: 0; } }

/* Confetti, only for a board solved in the demo. */
.demo { position: relative; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 7px; height: 7px; animation: fall 1.8s ease-in both; }
@keyframes fall { to { transform: translate(var(--sway), 420px) rotate(360deg); opacity: 0; } }

/* Scroll story: the board stays in place while the page scrolls past it. */
.story { background: var(--bg); }
.story-pin { padding-block: 64px; text-align: center; }
.story-pin p { color: var(--muted); }
#story-board { display: block; width: 100%; height: min(48vh, 440px); margin-block: 24px 16px; }
.story .meter { max-width: 320px; margin-inline: auto; }
.story.live { height: 170vh; height: 170svh; }
.story.live .story-pin { position: sticky; top: 61px; height: calc(100vh - 61px); height: calc(100svh - 61px); display: flex; align-items: center; padding-block: 8px; }

/* Bars grow into view. */
.grow.armed .track i { transform: scaleX(0); transition: transform .8s cubic-bezier(.2, .7, .2, 1); }
.grow.armed.lit .track i { transform: scaleX(var(--share)); }
.grow.armed li > i { transform: scaleY(0); transition: transform .5s cubic-bezier(.2, .7, .2, 1) var(--wait, 0s); }
.grow.armed.lit li > i { transform: scaleY(1); }

.paused .confetti { display: none; }
.paused .fly svg { animation-play-state: paused; }

/* Arrows crossing the background, as the app's arrows leave a board. */
.sky { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; container-type: size; }
.fly { position: absolute; width: var(--len); translate: calc(var(--px, 0) * var(--depth) * 1px) calc(var(--py, 0) * var(--depth) * 1px); transition: translate .4s ease-out; }
.fly svg, .shot svg { display: block; width: 100%; height: auto; fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.fly svg { opacity: .2; animation: var(--secs) linear var(--wait) infinite; }
.fly-right { top: var(--pos); left: 0; }
.fly-right svg { animation-name: go-right; }
.fly-left { top: var(--pos); left: 0; }
.fly-left svg { animation-name: go-left; }
.fly-up { left: var(--pos); top: 0; }
.fly-up svg { animation-name: go-up; }
.fly-down { left: var(--pos); top: 0; }
.fly-down svg { animation-name: go-down; }
@keyframes go-right { from { transform: translateX(-160px); } to { transform: translateX(calc(100cqw + 40px)); } }
@keyframes go-left { from { transform: translateX(calc(100cqw + 40px)) rotate(180deg); } to { transform: translateX(-160px) rotate(180deg); } }
@keyframes go-up { from { transform: translateY(calc(100cqh + 80px)) rotate(-90deg); } to { transform: translateY(-120px) rotate(-90deg); } }
@keyframes go-down { from { transform: translateY(-120px) rotate(90deg); } to { transform: translateY(calc(100cqh + 80px)) rotate(90deg); } }
[data-section="S11"] .fly svg { stroke: var(--on-accent); opacity: .22; }
.shot { position: absolute; z-index: -1; width: 90px; margin: -9px 0 0 -45px; pointer-events: none; }
@media (max-width: 859px) { .wide-only { display: none; } .fly svg { opacity: .14; } }

/* Headline, list cascades, win stars, spark shake, button arrow. */
.hero-band h1 .word { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.cascade > * { transition: opacity .3s calc(var(--n, 0) * 25ms), transform .3s calc(var(--n, 0) * 25ms); }
.cascade.waiting > * { opacity: 0; transform: translateY(14px); }
#demo-stars svg.won { animation: star .45s ease-out backwards; }
#demo-stars svg:nth-child(2) { animation-delay: .22s; }
#demo-stars svg:nth-child(3) { animation-delay: .44s; }
@keyframes star { from { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.35); } }
.lives.shake { animation: shake .35s ease-in-out; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.nudge { display: inline-block; transition: transform .2s; }
.btn:hover .nudge { transform: translateX(5px); }

@media (prefers-reduced-motion: reduce) {
  .sky, .shot { display: none; }
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  [data-aos], .reveal { opacity: 1 !important; transform: none !important; }
  .confetti, .read { display: none; }
}
