/* Scene band: flat vector scenes, one palette per story, variants as classes on the band.
   The band keeps its own palette in both themes (it is an illustration, not UI). */
.scene-band {
  --sky-top: #3a3561; --sky-bot: #e8935a; --far: #5b4f7e; --mid: #43396a; --near: #2b2447;
  --rock: #4d4570; --pine: #233a3a; --ink: #1a1530; --accent: #ffd27a; --snow: #f2ecf7;
  --fog: #d9d3e6; --water: #6c5a4a; --skin: #f0c9a6; --jacket: #e0603f; --jacket2: #4f8fbf;
  position: relative; overflow: hidden; border-radius: 14px; background: var(--sky-top);
  aspect-ratio: 9 / 5; max-height: 34vh; width: 100%;
}
.scene-band svg { display: block; width: 100%; height: 100%; }
.scene-band .layer { position: absolute; inset: 0; transition: opacity .45s ease; }
.scene-band .layer.leaving { opacity: 0; }

/* Variant colours live in scenes/<story>/scene.css; variant visibility ([data-only]) is set by src/scene.js. */

/* Palette variables are registered so a variant change (dusk -> night, same drawing) fades the
   colours over 1.8 s instead of jumping: time passing on screen. */
@property --sky-top { syntax: '<color>'; inherits: true; initial-value: #3a3561; }
@property --sky-bot { syntax: '<color>'; inherits: true; initial-value: #e8935a; }
@property --far     { syntax: '<color>'; inherits: true; initial-value: #5b4f7e; }
@property --mid     { syntax: '<color>'; inherits: true; initial-value: #43396a; }
@property --near    { syntax: '<color>'; inherits: true; initial-value: #2b2447; }
@property --rock    { syntax: '<color>'; inherits: true; initial-value: #4d4570; }
@property --haze    { syntax: '<color>'; inherits: true; initial-value: #e8935a; }
.scene-band { transition: --sky-top 1.8s ease, --sky-bot 1.8s ease, --far 1.8s ease, --mid 1.8s ease, --near 1.8s ease, --rock 1.8s ease, --haze 1.8s ease; }

/* ---------- scene transitions (src/scene.js sets .enter-<kind> from index.json "enter") ----------
   settle: default, the camera comes to rest (place change).
   push:   we travel on; the new place slides in from the right.
   back:   we return or help arrives; slides in from the left.
   zoom:   cut in to a close-up (phone, map, kit). */
@keyframes sb-settle { from { transform: scale(1.045); } to { transform: none; } }
@keyframes sb-push   { from { transform: translateX(10px) scale(1.06); } to { transform: none; } }
@keyframes sb-back   { from { transform: translateX(-10px) scale(1.06); } to { transform: none; } }
@keyframes sb-zoom   { from { transform: scale(1.18); } to { transform: none; } }
.scene-band .layer.enter-settle { animation: sb-settle 1.2s cubic-bezier(.2,.7,.2,1) both; }
.scene-band .layer.enter-push   { animation: sb-push 1s cubic-bezier(.2,.7,.2,1) both; }
.scene-band .layer.enter-back   { animation: sb-back 1s cubic-bezier(.2,.7,.2,1) both; }
.scene-band .layer.enter-zoom   { animation: sb-zoom .8s cubic-bezier(.15,.8,.25,1) both; }

/* ---------- loops (transform/opacity only) ---------- */
@keyframes drift   { from { transform: translateX(-40px); } to { transform: translateX(40px); } }
@keyframes race    { from { transform: translateX(-120px); } to { transform: translateX(380px); } }
@keyframes fall    { from { transform: translate(0, -40px); } to { transform: translate(-18px, 220px); } }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: .82; } 50% { opacity: .95; } 70% { opacity: .78; } }
@keyframes glow    { 0%, 100% { opacity: .55; } 50% { opacity: .9; } }
@keyframes twinkle { 0%, 100% { opacity: .9; } 50% { opacity: .3; } }
@keyframes bob     { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(2px); } }
@keyframes shiver  { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-.8px); } 75% { transform: translateX(.8px); } }
@keyframes wander  { 0% { transform: translate(0, 0); } 50% { transform: translate(60px, -6px); } 100% { transform: translate(0, 0); } }
@keyframes climb   { from { transform: translate(0, 0); } to { transform: translate(40px, -36px); } }
@keyframes fly     { from { transform: translateX(-60px); } to { transform: translateX(120px); } }
@keyframes pulse   { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes stream  { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -40; } }
@keyframes blink   { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .25; } }

.scene-band .a-drift   { animation: drift 18s ease-in-out infinite alternate; }
.scene-band .a-drift2  { animation: drift 26s ease-in-out infinite alternate-reverse; }
.scene-band .a-race    { animation: race 14s linear infinite; }
.scene-band .a-race2   { animation: race 21s linear infinite; animation-delay: -9s; }
.scene-band .a-fall    { animation: fall .9s linear infinite; }
.scene-band .a-fall2   { animation: fall 1.1s linear infinite; animation-delay: -.5s; }
.scene-band .a-flicker { animation: flicker 3.2s ease-in-out infinite; }
.scene-band .a-glow    { animation: glow 4s ease-in-out infinite; }
.scene-band .a-twinkle { animation: twinkle 3s ease-in-out infinite; }
.scene-band .a-twinkle2{ animation: twinkle 4.5s ease-in-out infinite; animation-delay: -2s; }
.scene-band .a-bob     { animation: bob 3s ease-in-out infinite; }
.scene-band .a-shiver  { animation: shiver .35s linear infinite; }
.scene-band .a-wander  { animation: wander 9s ease-in-out infinite; }
.scene-band .a-climb   { animation: climb 12s linear infinite alternate; }
.scene-band .a-fly     { animation: fly 16s linear infinite alternate; }
.scene-band .a-pulse   { animation: pulse 2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.scene-band .a-pulse2  { animation: pulse 2s ease-out infinite; animation-delay: -1s; transform-box: fill-box; transform-origin: center; }
.scene-band .a-stream  { stroke-dasharray: 14 10; animation: stream 1.2s linear infinite; }
.scene-band .a-stream-fast { stroke-dasharray: 18 8; animation: stream .55s linear infinite; }
.scene-band .a-blink   { animation: blink 1.6s steps(1) infinite; }

/* ---------- staging and acting (added in the art pass, see docs/ART-NOTES.md) ----------
   One-shot reveals run once when a drawing or variant appears: place first, then the subject,
   then the detail (a-enter, a-enter2, a-enter3). They end on the normal drawing, so reduced
   motion simply shows the end state. */
@keyframes enter   { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes rise    { from { transform: translateY(16px); } to { transform: none; } }
@keyframes approach{ from { transform: translate(-70px, 14px) scale(.55); } to { transform: none; } }
/* sway: plants and branches, pivot at the base. gust: wind with anticipation (a small lean back),
   the push, an overshoot and a settle (follow-through). */
@keyframes sway    { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }
@keyframes gust    { 0%, 100% { transform: rotate(0); } 12% { transform: rotate(1.2deg); } 32% { transform: rotate(-5deg); }
                     44% { transform: rotate(-3deg); } 56% { transform: rotate(-4.2deg); } 80% { transform: rotate(-1deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.012, 1.03); } }
@keyframes step    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-.8px); } }
/* trek: a figure or light travels one way (--dx, --dy), fades out and starts again: progress, never back-and-forth. */
@keyframes trek    { 0% { opacity: 0; transform: translate(0, 0); } 10% { opacity: 1; } 85% { opacity: 1; }
                     100% { opacity: 0; transform: translate(var(--dx, 40px), var(--dy, -20px)); } }
@keyframes hover   { from { transform: translateY(0); } to { transform: translateY(-2.5px); } }
@keyframes sweep   { from { transform: rotate(-7deg); } to { transform: rotate(5deg); } }
@keyframes puff    { 0% { opacity: 0; transform: translate(0, 0) scale(.5); } 20% { opacity: .55; }
                     100% { opacity: 0; transform: translate(8px, -34px) scale(1.7); } }
@keyframes drip    { 0% { opacity: 0; transform: translateY(0); } 15% { opacity: .9; } 100% { opacity: 0; transform: translateY(16px); } }
@keyframes mist    { 0%, 100% { opacity: .35; transform: translateY(0) scale(1); } 50% { opacity: .6; transform: translateY(-3px) scale(1.06); } }
@keyframes buzz    { 0%, 8%, 100% { transform: rotate(0); } 2% { transform: rotate(-4deg); } 4% { transform: rotate(4deg); } 6% { transform: rotate(-3deg); } }

.scene-band .a-enter   { animation: enter .9s cubic-bezier(.2,.8,.2,1) .35s both; }
.scene-band .a-enter2  { animation: enter .9s cubic-bezier(.2,.8,.2,1) 1s both; }
.scene-band .a-enter3  { animation: enter .9s cubic-bezier(.2,.8,.2,1) 1.7s both; }
.scene-band .a-rise    { animation: rise 9s cubic-bezier(.2,.7,.3,1) both; }
.scene-band .a-approach{ animation: approach 8s cubic-bezier(.15,.7,.25,1) both; }
.scene-band .a-sway    { animation: sway 5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.scene-band .a-sway2   { animation: sway 7s ease-in-out infinite alternate-reverse; transform-box: fill-box; transform-origin: 50% 100%; }
.scene-band .a-gust    { animation: gust 6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.scene-band .a-gust2   { animation: gust 6s ease-in-out -.4s infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.scene-band .a-breathe { animation: breathe 4.5s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.scene-band .a-breathe2{ animation: breathe 5.2s ease-in-out -2s infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.scene-band .a-step    { animation: step .9s ease-in-out infinite; }
.scene-band .a-step2   { animation: step .9s ease-in-out -.45s infinite; }
.scene-band .a-trek    { animation: trek 16s cubic-bezier(.4,0,.6,1) infinite; }
.scene-band .a-hover   { animation: hover 2.6s ease-in-out infinite alternate; }
.scene-band .a-sweep   { animation: sweep 3.8s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 0% 50%; }
.scene-band .a-sweep2  { animation: sweep 4.6s ease-in-out -1.5s infinite alternate-reverse; transform-box: fill-box; transform-origin: 0% 50%; }
.scene-band .a-puff    { animation: puff 7s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.scene-band .a-puff2   { animation: puff 7s ease-out -3.5s infinite; transform-box: fill-box; transform-origin: center; }
.scene-band .a-drip    { animation: drip 3.4s cubic-bezier(.55,0,.9,.6) infinite; }
.scene-band .a-drip2   { animation: drip 4.1s cubic-bezier(.55,0,.9,.6) -1.7s infinite; }
.scene-band .a-mist    { animation: mist 6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.scene-band .a-buzz    { animation: buzz 2.4s linear infinite; transform-box: fill-box; transform-origin: center; }
.scene-band .a-drift-far { animation: drift 40s ease-in-out infinite alternate; }
.scene-band .a-race-far  { animation: race 30s linear infinite; animation-delay: -12s; }
.scene-band .a-fall-far  { animation: fall 1.7s linear infinite; animation-delay: -.8s; opacity: .5; }

/* motion off: freeze everything on its first frame */
.motion-off .scene-band *, .motion-off .scene-band { animation: none !important; transition: none !important; }
/* ---------- camera (art pass 2) ----------
   One drawing serves several scene keys. A <g class="cam"> around everything except the
   foreground framing lets each variant frame its own subject: wide to set the place, closer when
   the moment is about a person or a thing. The story css sets --cam per variant, for example
   .s-x.v-storm { --cam: scale(1.8) translate(-180px, -40px); } (viewBox units: the point (180, 40)
   of the drawing comes to the top-left corner and everything is 1.8x bigger, so the frame shows
   the area from (180, 40), 360/1.8 wide and 200/1.8 tall; keep x + 360/s <= 360 and y + 200/s <= 200).
   A change between variants of the same drawing becomes a camera move over 1.8 s. */
.scene-band .cam { transform: var(--cam, none); transition: transform 1.8s cubic-bezier(.45, 0, .25, 1); }
/* slow push-in on every scene, once: keeps a still picture alive (a "Ken Burns" move) */
@keyframes sb-dolly { from { transform: scale(1); } to { transform: scale(1.045); } }
.scene-band .layer svg { animation: sb-dolly 26s cubic-bezier(.3, 0, .4, 1) both; transform-origin: 50% 55%; }
/* surface: a faint paper grain and a soft vignette over every scene, like printed or painted
   artwork rather than clean screen vectors. Static, drawn once, does not move. */
.scene-band::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2; border-radius: inherit;
  background:
    radial-gradient(120% 95% at 50% 45%, transparent 58%, rgba(8, 6, 18, .28) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light; opacity: .55;
}

@media (prefers-reduced-motion: reduce) {
  .scene-band *, .scene-band { animation: none !important; transition: none !important; }
}
