/* The shared Winter scene (WP8, docs/ROUND42-SCENE.md): markup from src/scene.ts, motion from js/fx/scene.js.
   Everything here sits behind the page's content; only transform and opacity ever animate. Phones (767 px and under) get the phone plates. */
.wscene {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  --wu: calc(min(100vw, 1440px) / 852);   /* the column unit, as css/stage.css's --u, at the scene's own phone break */
  --ws-join-a: var(--stage-join-desktop-dark-a); --ws-join-b: var(--stage-join-desktop-dark-b);
  --ws-veil: var(--veil, var(--navy-900));
}
:root[data-mode=light] .wscene { --ws-join-a: var(--stage-join-desktop-light-a); --ws-join-b: var(--stage-join-desktop-light-b); }
@media (prefers-color-scheme: light) { :root:not([data-mode]) .wscene { --ws-join-a: var(--stage-join-desktop-light-a); --ws-join-b: var(--stage-join-desktop-light-b); } }
@media (max-width: 767px) {
  .wscene { --wu: calc(min(100vw, 430px) / 390); --ws-join-a: var(--stage-join-phone-dark-a); --ws-join-b: var(--stage-join-phone-dark-b); }
  :root[data-mode=light] .wscene { --ws-join-a: var(--stage-join-phone-light-a); --ws-join-b: var(--stage-join-phone-light-b); }
}
@media (max-width: 767px) and (prefers-color-scheme: light) { :root:not([data-mode]) .wscene { --ws-join-a: var(--stage-join-phone-light-a); --ws-join-b: var(--stage-join-phone-light-b); } }

/* ---------- plates: the head (top and snow bands at their own shape, never stretched), the extension colour, the lodge at the page's end ---------- */
/* The extension between the snow band and the lodge is the colour both meet in, so no plate is ever stretched or tiled (P13). */
.ws-plate { position: absolute; inset: 0; container-type: inline-size; background: linear-gradient(var(--ws-join-a), var(--ws-join-b)); }
.ws-head { position: relative; }
.ws-plate img { display: block; width: 100%; height: auto; max-width: none; }
.ws-top { aspect-ratio: 887 / 585; }
/* The snow band's file repeats the top band's last 2 rows: percentage margins follow the width, so -200%/887 is 2 plate rows. */
.ws-mid { aspect-ratio: 887 / 439; margin-top: calc(-200% / 887); }
/* The lodge band ends the scene on pages tall enough for it (js/fx/scene.js sets data-foot; home always). */
.ws-plate .ws-foot { position: absolute; left: 0; bottom: 0; aspect-ratio: 887 / 754; display: none; }
.wscene[data-foot] .ws-foot { display: block; }
@media (max-width: 767px) {
  /* Past 430 px the phone plates keep the 430 px column's size, centred, as the hero copy does (--u), so the text never moves over the
     lodge; the sides are the sky, then the snow's colour. */
  .ws-plate { background: linear-gradient(var(--sky, var(--navy-900)) calc(var(--wu) * 300), var(--ws-join-a) calc(var(--wu) * 719), var(--ws-join-b)); }
  .ws-head { width: calc(var(--wu) * 390); margin-inline: auto; }
  .ws-plate .ws-foot { right: 0; width: calc(var(--wu) * 390); margin-inline: auto; }
  .ws-top { aspect-ratio: 724 / 607; }
  .ws-mid { aspect-ratio: 724 / 729; margin-top: calc(-200% / 724); }
  .ws-plate .ws-foot { aspect-ratio: 724 / 840; }
}
/* 431-767 px: the 430 px strip's edges fade into the sky and snow colours beside it, so it never reads as a boxed strip (WP8 F5). */
@media (min-width: 431px) and (max-width: 767px) {
  .ws-head, .ws-plate .ws-foot { -webkit-mask-image: linear-gradient(90deg, transparent, black 14%, black 86%, transparent); mask-image: linear-gradient(90deg, transparent, black 14%, black 86%, transparent); }
}
.ws-sky, .ws-lights, .ws-lift, .ws-actors { position: absolute; inset: 0; }

/* Forms: a calm head behind the header and fields (the busy light-mode art behind Register and Pay). */
.ws-veil { position: absolute; inset: 0 0 auto; height: calc(100cqw * 1022 / 887); opacity: 0; background: linear-gradient(color-mix(in srgb, var(--ws-veil) 80%, transparent), color-mix(in srgb, var(--ws-veil) 55%, transparent)); }
.wscene[data-page=form] .ws-veil { opacity: .55; }
:root[data-mode=light] .wscene[data-page=form] .ws-veil { opacity: .8; }
@media (prefers-color-scheme: light) { :root:not([data-mode]) .wscene[data-page=form] .ws-veil { opacity: .8; } }
@media (max-width: 767px) { .ws-veil { height: calc(var(--wu) * 719); } }

/* ---------- sky (dark only): a few placed stars and the moon's halo ---------- */
.ws-star { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: var(--stage-snow); opacity: .7; }
.ws-halo { position: absolute; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; opacity: .4; background: radial-gradient(closest-side, color-mix(in srgb, var(--stage-snow) 45%, transparent), transparent); }
:root[data-mode=light] .ws-sky { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-mode]) .ws-sky { display: none; } }

/* ---------- lodge lights: windows breathe (dark only), lamps glow, dim and steady in light ---------- */
.ws-window, .ws-lamp { position: absolute; translate: -50% -50%; mix-blend-mode: screen; }
.ws-window { object-fit: contain; opacity: .675; }
.ws-lamp { border-radius: 50%; opacity: .8; background: radial-gradient(closest-side, var(--stage-lamp), transparent); }
:root[data-mode=light] .ws-window { display: none; }
:root[data-mode=light] .ws-lamp { opacity: .25; animation: none; } /* light: dim and steady */
@media (prefers-color-scheme: light) { :root:not([data-mode]) .ws-window { display: none; } :root:not([data-mode]) .ws-lamp { opacity: .25; animation: none; } }

/* Running tiers only (js/fx/scene.js adds ws-run); off screen (ws-off) they hold still. */
.ws-run .ws-star { animation: ws-twinkle var(--ws-d, 4s) ease-in-out var(--ws-delay, 0s) infinite alternate; }
.ws-run .ws-halo { animation: ws-halo 7s ease-in-out infinite alternate; }
.ws-run .ws-window { animation: ws-breathe 5.5s ease-in-out var(--ws-delay, 0s) infinite alternate; }
.ws-run .ws-lamp { animation: ws-flicker var(--ws-d, 5s) ease-in-out infinite; }
.ws-off :is(.ws-star, .ws-halo, .ws-window, .ws-lamp) { animation-play-state: paused; }
@keyframes ws-twinkle { from { opacity: .25; } to { opacity: .9; } }
@keyframes ws-halo { from { opacity: .3; } to { opacity: .5; } }
@keyframes ws-breathe { from { opacity: .55; } to { opacity: .8; } }
@keyframes ws-flicker { 0%, 100% { opacity: .8; } 23% { opacity: .9; } 41% { opacity: .72; } 44% { opacity: .66; } 47% { opacity: .78; } 70% { opacity: .86; } }

/* ---------- chairlift and skiers: placed and moved by js/fx/scene.js with transforms only ---------- */
.ws-chair { position: absolute; left: 0; top: 0; height: auto; transform-origin: 50% 0; }
:root[data-mode=dark] .ws-chair { filter: brightness(.7); }
@media (prefers-color-scheme: dark) { :root:not([data-mode]) .ws-chair { filter: brightness(.7); } }
/* A skier's box stands on its feet: the pose strip's cells all end at the feet (scripts/assets/process.mjs --poses). */
.ws-skier { position: absolute; left: 0; top: 0; transform-origin: 50% 100%; }
.ws-pose { position: absolute; inset: 0; background-size: 300% 100%; background-repeat: no-repeat; opacity: 0; }
.ws-pose:nth-child(1) { background-position: 0 0; }
.ws-pose:nth-child(2) { background-position: 50% 0; opacity: 1; } /* carve: the resting pose */
.ws-pose:nth-child(3) { background-position: 100% 0; }
.ws-mark { position: absolute; left: 50%; bottom: 0; width: 0; height: 0; }
.ws-puff { position: absolute; left: 0; top: 0; border-radius: 50%; opacity: 0; background: radial-gradient(closest-side, color-mix(in srgb, var(--stage-snow) 85%, transparent), transparent); }

/* ---------- curtains (P12): one frame per state, each half at one texture scale, one mask, no filter ---------- */
/* Sizes are the stills' own 2:3 at one height per state; the ink fractions (left .0977-.865, right .111-.900, top .0586) put the closed
   halves' inner edges 2u past the centre and the open drapes' outer edges past the screen edges, so they hang from above the page. */
.ws-curtain { position: absolute; inset: 0 0 auto; height: calc(var(--wu) * 547); overflow: hidden; }
.ws-pair { position: absolute; inset: 0; }
.ws-c { position: absolute; display: block; max-width: none; }
.ws-closed { --hem: 520; -webkit-mask-image: linear-gradient(black calc(var(--wu) * (var(--hem) - 30)), transparent calc(var(--wu) * var(--hem))); mask-image: linear-gradient(black calc(var(--wu) * (var(--hem) - 30)), transparent calc(var(--wu) * var(--hem))); }
.ws-closed .ws-c { top: calc(var(--wu) * -33.5); width: calc(var(--wu) * 380.67); height: calc(var(--wu) * 571); }
.ws-closed .ws-left { left: calc(50% - var(--wu) * 327.28); }
.ws-closed .ws-right { left: calc(50% - var(--wu) * 44.25); }
/* The drapes' tails end above the lodge roof, with a short fade: no red over the lodge. */
.ws-open { --hem: 300; -webkit-mask-image: linear-gradient(black calc(var(--wu) * (var(--hem) - 30)), transparent calc(var(--wu) * var(--hem))); mask-image: linear-gradient(black calc(var(--wu) * (var(--hem) - 30)), transparent calc(var(--wu) * var(--hem))); }
.ws-open .ws-c { width: calc(var(--wu) * 286.67); height: calc(var(--wu) * 430); }
.ws-open .ws-left { left: calc(var(--wu) * -39.9); top: calc(var(--wu) * -25.8); }
.ws-open .ws-right { right: calc(var(--wu) * -38.5); top: calc(var(--wu) * -24.5); }
@media (max-width: 767px) {
  .ws-curtain { height: calc(var(--wu) * 810); }
  .ws-closed { --hem: 690; }
  .ws-closed .ws-c { top: calc(var(--wu) * -44.4); width: calc(var(--wu) * 505.3); height: calc(var(--wu) * 758); }
  .ws-closed .ws-left { left: calc(50% - var(--wu) * 435.6); }
  .ws-closed .ws-right { left: calc(50% - var(--wu) * 58.1); }
  .ws-open { --hem: 240; }
  .ws-open .ws-c { width: calc(var(--wu) * 173.3); height: calc(var(--wu) * 260); }
  .ws-open .ws-left { left: calc(var(--wu) * -28.8); top: calc(var(--wu) * -15.6); }
  .ws-open .ws-right { right: calc(var(--wu) * -35); top: calc(var(--wu) * -14.8); }
}
.ws-curtain[data-state=closed] .ws-open, .ws-curtain[data-state=open] .ws-closed { visibility: hidden; }

/* ---------- snow: one canvas fixed to the viewport, above the plates, below the content ---------- */
.ws-snow { position: fixed; inset: 0; width: 100%; height: 100%; will-change: transform; } /* its own layer: a frame of snow never repaints the plates */

/* ---------- TICKETS OUT: a glow behind the ticket button whose opacity pulses (never a scale, which the review harness bans) ---------- */
.ws-glow { position: absolute; z-index: -1; border-radius: calc(var(--wu) * 14); opacity: 0; pointer-events: none; box-shadow: 0 0 calc(var(--wu) * 22) calc(var(--wu) * 6) color-mix(in srgb, var(--gold, var(--gold-300)) 60%, transparent); }

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

/* Preview page only (/preview/scene, src/scene.ts sceneDemo). */
.ws-demo-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 16px; font-size: 16px; }
.ws-demo-nav a { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; text-decoration: underline; }
.ws-demo-copy { max-width: 640px; margin: 0 auto; padding: 32px 16px 96px; font-size: 17px; line-height: 1.55; color: var(--text); text-shadow: var(--halo); }
.ws-demo-copy p { margin: 0 0 16px; }
.ws-demo-form { display: grid; gap: 16px; }
.ws-demo-form label { display: grid; gap: 4px; }
.ws-demo-form input { min-height: 44px; font-size: 16px; }
.ws-demo-reveal { margin-top: 16px; }
