/* =========================================================
   SCROLL SCENES for every room (js/scenes.js)
   Each section acts out what it is about as you scroll down to it.
   A scene sets five things, and the shared rules below play them:
     --wt  how each word of the title arrives (one after another, --wg apart)
     --pk  how each piece (card, row, block) arrives
     --lk  how the small print (kicker, intro line) arrives
   Only under html.mo (JS on, motion allowed). Only transform,
   opacity, clip-path and colors move. .still = it was already on
   screen (or you scrolled back up to it): it just shows.
   ========================================================= */
.scn { --wt: sc2-rise; --wd: .7s; --wg: 70ms; --we: var(--ease-out);
       --pk: sc2-rise; --pd: .75s; --pg: 90ms; --pe: var(--ease-out);
       --lk: sc2-wipe; }
.scn .w { display: inline-block; }

.mo .scn .mv-t.in .w { animation: var(--wt) var(--wd) var(--we) calc(var(--i) * var(--wg)) backwards; }
.mo .scn .mv-l.in { animation: var(--lk) .7s var(--ease-out) .15s backwards; }
.mo .scn .mv-b.in, .mo .scn .mv-i.in { animation: var(--pk) var(--pd) var(--pe) calc(var(--k, 0) * var(--pg)) backwards; }
.mo .scn .mv-g.in > * { animation: var(--pk) var(--pd) var(--pe) calc(var(--k, 0) * var(--pg)) backwards; }
.mo .scn .mv-b.in { animation-delay: .2s; }
/* already on screen, or reached on the way back up: no movement at all */
.mo .scn .mv.still, .mo .scn .mv.still > *, .mo .scn .mv.still .w { animation: none !important; }

/* shared small-print entrances */
@keyframes sc2-wipe { from { clip-path: inset(-10% 100% -10% 0); transform: translateX(-10px); } to { clip-path: inset(-10% -2% -10% 0); transform: none; } }
@keyframes sc2-rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes sc2-type { from { clip-path: inset(-10% 100% -10% 0); } to { clip-path: inset(-10% 0 -10% 0); } }

/* =================== KEY TERMS =================== */
/* hero: the words are stamped into your stamp book, the tools thunk down */
.scn-stamp { --wt: sc2-stamp; --wd: .55s; --wg: 110ms; --pk: sc2-thunk; --pd: .5s; --pg: 70ms; }
@keyframes sc2-stamp { from { opacity: 0; transform: scale(1.9) rotate(calc(var(--s) * -9deg)); } 60% { opacity: 1; transform: scale(.94) rotate(calc(var(--s) * 1deg)); } to { opacity: 1; transform: none; } }
@keyframes sc2-thunk { from { opacity: 0; transform: translateY(-22px) scale(1.06); } 60% { opacity: 1; transform: translateY(3px) scale(.98); } to { opacity: 1; transform: none; } }

/* 1 what it is: each word comes up out of its line like a dictionary entry; the cards flip up like index cards */
.scn-define { --wt: sc2-entry; --wd: .7s; --wg: 90ms; --pk: sc2-index; --pd: .8s; --pg: 110ms; }
.scn-define .mv-i { transform-origin: 50% 0; }
@keyframes sc2-entry { from { clip-path: inset(0 -5% 100% -5%); transform: translateY(.7em); } to { clip-path: inset(-20% -5% -20% -5%); transform: none; } }
@keyframes sc2-index { from { opacity: 0; transform: perspective(900px) rotateX(-75deg); } 60% { opacity: 1; transform: perspective(900px) rotateX(8deg); } to { opacity: 1; transform: none; } }

/* 2 reads and writes: the title arrives as colored token chips that join into words; the cards are fed in like tokens */
.scn-tokens .mv-t .w { border-radius: .14em; padding: 0 .05em; margin: 0 -.05em; }
.scn-tokens { --wt: sc-tokens; --wd: 1.1s; --wg: 60ms; --pk: sc2-chip; --pd: .7s; --pg: 80ms; --lk: sc2-type; }
@keyframes sc2-chip { from { opacity: 0; transform: translateX(calc(var(--s) * 50px)) scale(.86); } 60% { opacity: 1; transform: translateX(calc(var(--s) * -5px)) scale(1.01); } to { opacity: 1; transform: none; } }

/* 3 how it gets made: the words pour in and stack; the cards fill up in steps, like training passes */
.scn-train { --wt: sc-fall; --wd: .8s; --we: linear; --wg: 110ms; --pk: sc2-epoch; --pd: .9s; --pe: steps(4, end); --pg: 120ms; }
@keyframes sc2-epoch { from { clip-path: inset(100% 0 0 0 round 18px); } to { clip-path: inset(-30px -30px -30px -30px round 18px); } }

/* 4 what it can pick up: the cards are picked up and set down */
.scn-pickup { --wt: sc2-hop; --wd: .65s; --wg: 80ms; --pk: sc2-pick; --pd: .8s; --pg: 100ms; }
@keyframes sc2-hop { from { opacity: 0; transform: translateY(.5em) scale(.7); } 55% { opacity: 1; transform: translateY(-.12em) scale(1.08); } to { opacity: 1; transform: none; } }
@keyframes sc2-pick { from { opacity: 0; transform: translateY(46px) rotate(calc(var(--s) * 5deg)); } 55% { opacity: 1; transform: translateY(-12px) rotate(calc(var(--s) * -2deg)); } to { opacity: 1; transform: none; } }

/* 5 talking to it: words pop like chat bubbles; the cards come in from alternate sides, like a conversation */
.scn-chat { --wt: sc2-bubble; --wd: .55s; --wg: 90ms; --pk: sc2-reply; --pd: .7s; --pg: 90ms; }
.scn-chat .mv-t .w { transform-origin: 0 100%; }
@keyframes sc2-bubble { from { opacity: 0; transform: scale(.25) translateY(.3em); } 60% { opacity: 1; transform: scale(1.08); } to { opacity: 1; transform: none; } }
@keyframes sc2-reply { from { opacity: 0; transform: translateX(calc(var(--s) * -64px)) scale(.92); } 65% { opacity: 1; transform: translateX(calc(var(--s) * 6px)); } to { opacity: 1; transform: none; } }

/* 6 read it critically: the title shows up struck through and gets corrected; the cards come into focus under a lens */
.scn-critic .mv-t .w { text-decoration: line-through .07em transparent; text-decoration-skip-ink: none; }
.scn-critic { --wt: sc-redline; --wd: 1.1s; --we: ease; --wg: 60ms; --pk: sc2-lens; --pd: .8s; --pg: 110ms; }
@keyframes sc2-lens { from { clip-path: circle(0% at 50% 40%); } to { clip-path: circle(110% at 50% 50%); } }

/* 7 AI that acts: each word is selected as a cursor moves along; each card gets clicked */
.scn-agent { --wt: sc2-select; --wd: .7s; --wg: 110ms; --pk: sc2-click; --pd: .8s; --pg: 140ms; }
.scn-agent .mv-t .w { border-radius: .12em; }
@keyframes sc2-select { from { opacity: 0; transform: translateX(.5em); } 30% { opacity: 1; background-color: var(--lime); transform: none; } to { opacity: 1; background-color: transparent; } }
@keyframes sc2-click { 0% { opacity: 0; transform: translateY(18px); } 45% { opacity: 1; transform: none; } 62% { transform: scale(.95); } 80% { transform: scale(1.01); } 100% { opacity: 1; transform: none; } }

/* 8 the big picture (and The Future's): zoom out from one word to the whole view */
.scn-zoom { --wt: sc2-zoomout; --wd: .8s; --wg: 70ms; --pk: sc2-spread; --pd: .8s; --pg: 90ms; }
@keyframes sc2-zoomout { from { opacity: 0; transform: scale(2.6); } to { opacity: 1; transform: none; } }
@keyframes sc2-spread { from { opacity: 0; transform: translateX(calc(var(--s) * -40px)) scale(.6); } to { opacity: 1; transform: none; } }

/* =================== LEARNING LAB =================== */
/* hero: the title opens like a book; the course list turns like pages; the toolbox opens */
.scn-book { --wt: sc2-cover; --wd: .8s; --wg: 90ms; --pk: sc2-cover; --pd: .8s; }
.scn-book .mv-t .w, .scn-book .mv-b { transform-origin: 0 50%; }
@keyframes sc2-cover { from { opacity: 0; transform: perspective(700px) rotateY(-85deg); } 60% { opacity: 1; } to { opacity: 1; transform: none; } }
.scn-pages { --pk: sc2-page; --pd: .8s; --pg: 120ms; }
.scn-pages .mv-i { transform-origin: 50% 100%; }
@keyframes sc2-page { from { opacity: 0; transform: perspective(1000px) rotateX(70deg); } 60% { opacity: 1; transform: perspective(1000px) rotateX(-6deg); } to { opacity: 1; transform: none; } }
.scn-toolbox { --wt: sc2-out; --wd: .7s; --wg: 80ms; --pk: sc2-tool; --pd: .75s; --pg: 110ms; }
@keyframes sc2-out { from { opacity: 0; transform: translateY(.8em) rotate(calc(var(--s) * -10deg)); } 60% { opacity: 1; transform: translateY(-.14em); } to { opacity: 1; transform: none; } }
@keyframes sc2-tool { from { opacity: 0; transform: translateY(56px) rotate(calc(var(--s) * 9deg)) scale(.82); } 60% { opacity: 1; transform: translateY(-8px) rotate(calc(var(--s) * -2deg)); } to { opacity: 1; transform: none; } }

/* =================== GAMES =================== */
/* hero: a pixel-stepped arcade "ready!"; the games are dealt like cards */
.scn-arcade { --wt: sc2-arcade; --wd: .6s; --we: steps(5, end); --wg: 120ms; --pk: sc2-arcade-p; --pd: .5s; --pe: steps(4, end); --pg: 80ms; }
@keyframes sc2-arcade { from { opacity: 0; transform: translateY(.5em) scale(0); } 55% { opacity: 1; transform: scale(1.25); } 80% { transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes sc2-arcade-p { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.scn-deal { --wt: sc2-dealw; --wd: .7s; --wg: 80ms; --pk: sc2-deal; --pd: .85s; --pg: 120ms; }
@keyframes sc2-dealw { from { opacity: 0; transform: translate(1.2em, -.8em) rotate(calc(var(--s) * 18deg)); } to { opacity: 1; transform: none; } }
@keyframes sc2-deal { from { opacity: 0; transform: translate(140px, -60px) rotate(18deg); } 70% { opacity: 1; transform: rotate(calc(var(--s) * -2deg)); } to { opacity: 1; transform: none; } }

/* =================== THE FUTURE =================== */
/* hero: the future comes toward you */
.scn-horizon { --wt: sc2-near; --wd: .9s; --wg: 90ms; --pk: sc2-near; --pd: .8s; --pg: 90ms; }
@keyframes sc2-near { from { opacity: 0; transform: scale(.35) translateY(-.4em); } to { opacity: 1; transform: none; } }
/* jobs: a departures board flipping */
.scn-board { --wt: sc2-flap; --wd: .7s; --wg: 70ms; --pk: sc-board; --pd: .75s; --pg: 120ms; }
.scn-board .mv-t .w, .scn-board .mv-b, .scn-board .mv-i { transform-origin: 50% 0; }
@keyframes sc2-flap { from { opacity: 0; transform: perspective(400px) rotateX(-90deg); } 50% { opacity: 1; transform: perspective(400px) rotateX(22deg); } 75% { transform: perspective(400px) rotateX(-8deg); } to { opacity: 1; transform: none; } }
/* users: people turn up from everywhere and stand up */
.scn-crowd { --wt: sc2-scatter; --wd: .7s; --wg: 70ms; --pk: sc2-stand; --pd: .7s; --pg: 90ms; }
.scn-crowd .mv-t .w { animation-delay: calc(var(--r) * 70ms) !important; }
.scn-crowd .mv-b, .scn-crowd .mv-i { transform-origin: 50% 100%; }
@keyframes sc2-scatter { from { opacity: 0; transform: translate(calc(var(--s) * .9em), calc(var(--s) * -.7em)) scale(.5); } to { opacity: 1; transform: none; } }
@keyframes sc2-stand { from { opacity: 0; transform: scaleY(.2); } 65% { opacity: 1; transform: scaleY(1.05); } to { opacity: 1; transform: none; } }
/* opinions: ballots drop in, then the results fill like poll bars */
.scn-vote { --wt: sc2-ballot; --wd: .6s; --wg: 90ms; --pk: sc2-bar; --pd: .9s; --pg: 120ms; }
.scn-vote .mv-t .w { transform-origin: 50% 100%; }
@keyframes sc2-ballot { from { opacity: 0; transform: translateY(-.9em) scaleY(1.3); } 60% { opacity: 1; transform: translateY(.04em) scaleY(.85); } to { opacity: 1; transform: none; } }
@keyframes sc2-bar { from { clip-path: inset(0 100% 0 0 round 18px); } to { clip-path: inset(-30px -30px -30px -30px round 18px); } }
/* software: typed out, and printed line by line */
.scn-code { --wt: sc2-type; --wd: .3s; --we: steps(6, end); --wg: 260ms; --pk: sc2-print; --pd: .9s; --pe: steps(7, end); --pg: 120ms; --lk: sc2-type; }
@keyframes sc2-print { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(-30px -30px -30px -30px); } }
/* robots: mechanical, in clicks, like servo motors */
.scn-servo { --wt: sc2-gear; --wd: .5s; --we: steps(4, end); --wg: 120ms; --pk: sc2-arm; --pd: .7s; --pe: steps(5, end); --pg: 120ms; }
.scn-servo .mv-t .w { transform-origin: 0 100%; }
@keyframes sc2-gear { from { opacity: 0; transform: rotate(-40deg); } 25% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes sc2-arm { from { opacity: 0; transform: translateX(calc(var(--s) * -70px)); } 20% { opacity: 1; } to { opacity: 1; transform: none; } }
/* sources: index cards filed into the drawer */
.scn-file { --wt: sc2-type; --wd: .6s; --we: steps(10, end); --pk: sc2-file; --pd: .55s; --pg: 60ms; }
@keyframes sc2-file { from { opacity: 0; transform: translateY(-26px) rotate(calc(var(--s) * 1.5deg)); } 70% { opacity: 1; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* =================== ABOUT =================== */
/* hero: slapped on like a "hello my name is" sticker */
.scn-nametag { --wt: sc-slap; --wd: .65s; --wg: 85ms; --pk: sc-slap-soft; --pd: .6s; --pg: 80ms; }
.scn-nametag .mv-t .w { animation-delay: calc(var(--r) * 85ms) !important; }
/* the instructor: written on a chalkboard; the photo slides in */
.scn-chalk { --wt: sc2-type; --wd: .45s; --we: steps(8, end); --wg: 220ms; --pk: sc2-slide; --pd: .8s; }
@keyframes sc2-slide { from { opacity: 0; transform: translateX(calc(var(--s) * 60px)) rotate(calc(var(--s) * 2deg)); } to { opacity: 1; transform: none; } }
.scn-chalk .portrait { --s: 1; }
/* the builder: words laid like bricks from both sides; the parts rise into place */
.scn-build { --wt: sc2-brick; --wd: .6s; --wg: 90ms; --pk: sc2-lift; --pd: .8s; --pg: 120ms; }
.scn-build .portrait { --k: 0; } .scn-build .builder-body { --k: 1; }
@keyframes sc2-brick { from { opacity: 0; transform: translateX(calc(var(--s) * 1.4em)); } 80% { opacity: 1; transform: translateX(calc(var(--s) * -.05em)); } to { opacity: 1; transform: none; } }
@keyframes sc2-lift { from { opacity: 0; transform: translateY(70px); } 70% { opacity: 1; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
/* for real: credentials flip over like badges */
.scn-badge { --wt: sc2-flipw; --wd: .7s; --wg: 70ms; --pk: sc2-flipw; --pd: .75s; --pg: 110ms; }
@keyframes sc2-flipw { from { opacity: 0; transform: perspective(600px) rotateY(100deg); } 50% { opacity: 1; } to { opacity: 1; transform: none; } }

/* =================== GRADE =================== */
/* hero: marked in red pen, and the report card is handed over */
.scn-report { --wt: sc2-pen; --wd: .8s; --wg: 80ms; --pk: sc2-hand; --pd: .9s; }
@keyframes sc2-pen { from { opacity: 0; color: var(--xm-red, #E5382B); transform: translateY(.2em) rotate(-3deg); } 50% { opacity: 1; color: var(--xm-red, #E5382B); transform: none; } to { opacity: 1; transform: none; } }
@keyframes sc2-hand { from { opacity: 0; transform: translate(-30px, 70px) rotate(-5deg); } 70% { opacity: 1; transform: rotate(.6deg); } to { opacity: 1; transform: none; } }
/* rooms: each room gets ticked off down the list */
.scn-tally { --wt: sc2-tick; --wd: .55s; --wg: 80ms; --pk: sc2-tickrow; --pd: .7s; --pg: 110ms; }
@keyframes sc2-tick { from { opacity: 0; transform: scale(.4) rotate(-20deg); } 60% { opacity: 1; transform: scale(1.1); } to { opacity: 1; transform: none; } }
@keyframes sc2-tickrow { from { clip-path: inset(-20px 100% -20px -20px); } to { clip-path: inset(-20px -20px -20px -20px); } }
/* what saves: the answers are sorted to either side */
.scn-sort { --wt: sc-swipe; --wd: .75s; --wg: 65ms; --pk: sc2-sorted; --pd: .65s; --pg: 80ms; }
.scn-sort .qa-row.yes { --s: -1; } .scn-sort .qa-row.no { --s: 1; } .scn-sort .qa-row.mid { --s: 0; }
@keyframes sc2-sorted { from { opacity: 0; transform: translateX(calc(var(--s) * 50px)) translateY(calc((1 - var(--s) * var(--s)) * 24px)); } to { opacity: 1; transform: none; } }

/* =================== SETTINGS =================== */
.scn-switch { --wt: sc2-flick; --wd: .5s; --wg: 70ms; --pk: sc2-flick; --pd: .55s; --pg: 90ms; }
@keyframes sc2-flick { from { opacity: 0; transform: translateX(-.9em); } 70% { opacity: 1; transform: translateX(.08em); } to { opacity: 1; transform: none; } }
.scn-snowfall { --wt: sc2-flake; --wd: 1.1s; --wg: 110ms; --pk: sc2-settle; --pd: 1s; --pg: 120ms; }
@keyframes sc2-flake { from { opacity: 0; transform: translate(calc(var(--s) * .3em), -1.3em) rotate(calc(var(--s) * 14deg)); } to { opacity: 1; transform: none; } }
@keyframes sc2-settle { from { opacity: 0; transform: translateY(-34px); } to { opacity: 1; transform: none; } }

/* =================== CURRENT EVENTS =================== */
/* hero: words slammed down by a printing press; the filters unfold like a paper */
.scn-press { --wt: sc2-press; --wd: .5s; --wg: 90ms; --pk: sc2-unfold; --pd: .8s; }
.scn-press .mv-t .w { transform-origin: 50% 0; }
@keyframes sc2-press { from { opacity: 0; transform: scaleY(0); } 60% { opacity: 1; transform: scaleY(1.12); } to { opacity: 1; transform: none; } }
@keyframes sc2-unfold { from { clip-path: inset(0 50% 0 50%); } to { clip-path: inset(-30px -30px -30px -30px); } }
/* "How this page is made": the fact-check note is pressed down like an approval stamp (smooth, not stepped) */
.scn-checked { --pk: sc2-checked; --pd: .55s; --pe: cubic-bezier(.2, .8, .2, 1); }
@keyframes sc2-checked { from { opacity: 0; transform: scale(1.06) rotate(-1.2deg); } 65% { opacity: 1; transform: scale(.992) rotate(.2deg); } to { opacity: 1; transform: none; } }
/* a story: the headline runs in like a news ticker; its picture flashes open */
.scn-breaking { --wt: sc2-ticker; --wd: .6s; --wg: 60ms; --pk: sc2-flash; --pd: .7s; --pg: 80ms; }
@keyframes sc2-ticker { from { opacity: 0; transform: translateX(2.2em); } to { opacity: 1; transform: none; } }
@keyframes sc2-flash { from { clip-path: inset(50% 0 50% 0); } to { clip-path: inset(-30px -30px -30px -30px); } }

/* =================== every room's last panel =================== */
/* across the finish line; the next rooms swing open like doors */
.scn-finish { --wt: sc2-dash; --wd: .7s; --wg: 70ms; --pk: sc2-door; --pd: .75s; --pg: 110ms; }
.scn-finish .mv-i { transform-origin: 0 50%; }
@keyframes sc2-dash { from { opacity: 0; transform: translateX(-1.6em) skewX(-14deg); } 70% { opacity: 1; transform: translateX(.08em) skewX(4deg); } to { opacity: 1; transform: none; } }
@keyframes sc2-door { from { opacity: 0; transform: perspective(800px) rotateY(-50deg); } to { opacity: 1; transform: none; } }

/* Key Terms: a card you jumped to still flashes */
.mo .scn .mv.in.flash { animation: flash 1.2s var(--ease-out); }
