/* ════════════════════════════════════════════════════════════════
   Christmas background layer — integrated into the fish-sea site.
   Sits above the sea canvases (z 0-4) and below the cian wordmark
   (z 50), Discord widget (z 1200) and dock (z 1500). The wordmark,
   widget, cursor and dock all stay on top of whichever bg is active.

   Scene choreography (christmas.js drives it by toggling classes):
     ON  : #xmas-scene.active -> the snow starts falling onto the live pond
           almost at once (as a squall), night falls (the sky fades in over
           the water) while the ground + mountains rise, the trees drop in
           and land with a squash, Kenny walks in from the right, the moon
           rises from behind the mountains and the stars sweep in.
           #xmas-scene.built  -> idle loops: sway, drift, blink, wandering.
     OFF : #xmas-scene.leaving -> everything un-builds in reverse, then the
           sky lifts to reveal the pond with the last flakes still landing
           on it; the fish are woken just before it lifts.
   ════════════════════════════════════════════════════════════════ */

/* The pond fades out under the arriving night sky (delayed a little so the
   first snow visibly lands on live water), then drops out of compositing.
   On the way out it's back instantly behind the still-opaque sky, and
   christmas.js wakes the fish just before the sky lifts. */
#app.xmas-on #koi-canvas {
  opacity: 0;
  visibility: hidden;
  transition: opacity 2.0s ease 0.5s, visibility 0s linear 2.6s;
}

/* ─── The scene container ─── */
#xmas-scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;            /* clicks pass through to the site */
  /* The container itself just toggles; the SKY (.xmas-sky) does the slow
     fades, so the scenery can build at full opacity over the ice. */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
#xmas-scene.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0s, visibility 0s;
}
/* Night sky: one vertical gradient, deep navy at the top, easing lighter
   toward the horizon as if the snow were glowing up into it. Fades in over
   the pond ("night falls"), and out again on the way out. */
#xmas-scene .xmas-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(to bottom,
    #0a1027 0%,
    #111b3a 38%,
    #1a2a52 66%,
    #2a3d6c 100%);
  opacity: 0;
  transition: opacity 2.4s ease-in;
}
#xmas-scene.active  .xmas-sky { opacity: 1; }
#xmas-scene.leaving .xmas-sky { opacity: 0; transition: opacity 2s ease 1.4s; }

/* ════════════════════════════════════════════════════════════════
   Build-in — when the scene activates each piece arrives in its own way,
   back-to-front, staggered: ground + mountains rise out of the ice, trees
   drop from the sky and land with a squash, the sign drops in, Kenny
   walks in from the right. Pieces start hidden; .active triggers the
   one-shot keyframes; the looping sway waits for .built so the two never
   fight.
   ════════════════════════════════════════════════════════════════ */

/* Hide every buildable piece until the scene is active */
#xmas-scene .xmas-build { opacity: 0; }
#xmas-scene.active .xmas-build {
  opacity: 1;
  animation-duration: 0.7s;
  animation-timing-function: cubic-bezier(0.22, 1.2, 0.36, 1);
  animation-fill-mode: both;
}

/* After the build, clear the lingering build transform on the mountains +
   ground so they no longer create a stacking context. */
#xmas-scene.built .xmas-mountains,
#xmas-scene.built .xmas-snow-layers {
  animation: none;
  transform: none;
  opacity: 1;
}

/* Ground + mountains rise up from below */
#xmas-scene.active .xmas-snow-layers,
#xmas-scene.active .xmas-mountains { animation-name: xmas-build-up; }

/* Trees drop from above and land with a squash-and-stretch. The keyframes
   carry their own timing per segment, hence linear here. (christmas.js
   kicks up a puff of snow at each touchdown.) */
#xmas-scene.active .xmas-tree {
  animation-name: xmas-tree-drop;
  animation-duration: 0.9s;
  animation-timing-function: linear;
}

/* Sign drops from above (keeps its translateX(-50%)) */
#xmas-scene.active .xmas-sign { animation-name: xmas-build-drop; }

/* Kenny walks in from the right edge (fast waddle while walking, see the
   .built block) and stops at his spot. */
#xmas-scene.active .xmas-container {
  animation-name: xmas-kenny-walk;
  animation-duration: 1.6s;
  animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1);
}

/* Stagger: ground -> mountains -> trees one-by-one -> sign -> Kenny */
#xmas-scene.active .xmas-snow-layers { animation-delay: 0.05s; }
#xmas-scene.active .xmas-mountains   { animation-delay: 0.30s; }
#xmas-scene.active .xmas-tree-1      { animation-delay: 0.55s; }
#xmas-scene.active .xmas-tree-2      { animation-delay: 0.70s; }
#xmas-scene.active .xmas-tree-3      { animation-delay: 0.85s; }
#xmas-scene.active .xmas-tree-4      { animation-delay: 1.00s; }
#xmas-scene.active .xmas-tree-5      { animation-delay: 1.15s; }
#xmas-scene.active .xmas-sign        { animation-delay: 1.35s; }
#xmas-scene.active .xmas-container   { animation-delay: 1.40s; }

@keyframes xmas-build-up {
  0%   { opacity: 0; transform: translateY(80px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes xmas-build-drop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-90px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes xmas-tree-drop {
  0%   { opacity: 1; transform: translateY(-120vh) scale(0.96, 1.08); animation-timing-function: cubic-bezier(0.5, 0, 1, 0.65); }
  58%  { transform: translateY(0) scale(1, 1);       animation-timing-function: ease-out; }
  70%  { transform: translateY(0) scale(1.16, 0.80); animation-timing-function: ease-in-out; }
  84%  { transform: translateY(0) scale(0.95, 1.07); animation-timing-function: ease-in-out; }
  100% { opacity: 1; transform: translateY(0) scale(1, 1); }
}
@keyframes xmas-kenny-walk {
  0%   { opacity: 1; transform: translateX(260px) scale(1.15); }
  100% { opacity: 1; transform: translateX(-20px) scale(1.15); }
}

/* Once the build finishes (.built), the gentle looping sway/pan
   animations kick in, and Kenny turns to look at you and starts blinking.
   Keeping them off during the build stops them fighting the build-in. */
#xmas-scene.built .xmas-bg-elements { animation: xmas-slow-pan 120s infinite ease-in-out; }
#xmas-scene.built .xmas-cloud-1     { animation: xmas-cloud-drift 38s infinite ease-in-out; }
#xmas-scene.built .xmas-cloud-2     { animation: xmas-cloud-drift 46s infinite ease-in-out -18s; }
#xmas-scene.built .xmas-cloud-3     { animation: xmas-cloud-drift 54s infinite ease-in-out -30s; }
#xmas-scene.built .xmas-tree-1 { animation: xmas-tree-sway 8s infinite ease-in-out 0s; }
#xmas-scene.built .xmas-tree-2 { animation: xmas-tree-sway 8s infinite ease-in-out -2s; }
#xmas-scene.built .xmas-tree-3 { animation: xmas-tree-sway 8s infinite ease-in-out -4s; }
#xmas-scene.built .xmas-tree-4 { animation: xmas-tree-sway 8s infinite ease-in-out -1s; }
#xmas-scene.built .xmas-tree-5 { animation: xmas-tree-sway 8s infinite ease-in-out -3s; }
#xmas-scene.built .xmas-container { animation: xmas-character-sway 20s infinite ease-in-out; }
#xmas-scene.built .xmas-kenny { --look: 0px; }                                   /* eyes to the viewer */
#xmas-scene.built .xmas-kenny .eye { animation: xmas-blink 5.5s ease-in-out 0.8s infinite; }

/* While walking (in or out): fast waddle, eyes on where he's going */
#xmas-scene.active:not(.built) .xmas-kenny,
#xmas-scene.leaving .xmas-kenny { animation: xmas-waddle-walk 0.42s ease-in-out infinite; }
#xmas-scene.active:not(.built) .xmas-kenny { --look: -3px; }
#xmas-scene.leaving .xmas-kenny { --look: 3px; }
/* wandering (christmas.js toggles .walking on the container; it also sets
   --look inline for the direction he's heading) */
#xmas-scene .xmas-container.walking .xmas-kenny { animation: xmas-waddle-walk 0.42s ease-in-out infinite; }

/* ════════════════════════════════════════════════════════════════
   Un-build (.leaving) — the story in reverse on the way out: Kenny walks
   off, the trees sink into the snow, the sign lifts away, mountains +
   ground drop, the moon sets and the stars sweep out (see their blocks),
   the snow fades, then the sky fades to reveal the pond. These follow the .built rules so they win on source
   order.
   ════════════════════════════════════════════════════════════════ */
#xmas-scene.leaving .xmas-container   { animation: xmas-kenny-leave 1.3s cubic-bezier(0.5, 0, 0.8, 0.4) both; }
#xmas-scene.leaving .xmas-tree-5      { animation: xmas-tree-sink 0.7s ease-in 0.30s both; }
#xmas-scene.leaving .xmas-tree-4      { animation: xmas-tree-sink 0.7s ease-in 0.42s both; }
#xmas-scene.leaving .xmas-tree-3      { animation: xmas-tree-sink 0.7s ease-in 0.54s both; }
#xmas-scene.leaving .xmas-tree-2      { animation: xmas-tree-sink 0.7s ease-in 0.66s both; }
#xmas-scene.leaving .xmas-tree-1      { animation: xmas-tree-sink 0.7s ease-in 0.78s both; }
#xmas-scene.leaving .xmas-sign        { animation: xmas-unbuild-lift 0.5s ease-in 0.6s both; }
#xmas-scene.leaving .xmas-mountains   { animation: xmas-unbuild-down 0.6s ease-in 1.0s both; }
#xmas-scene.leaving .xmas-snow-layers { animation: xmas-unbuild-down 0.6s ease-in 1.2s both; }
#xmas-scene.leaving .xmas-cloud       { opacity: 0 !important; transition: opacity 0.8s ease 0s !important; }
#xmas-scene .xmas-snow                { transition: opacity 0.4s ease; }
#xmas-scene.leaving .xmas-snow        { opacity: 0; transition: opacity 1.4s ease 2.0s; }   /* last flakes land on the pond */
@keyframes xmas-kenny-leave {
  0%   { opacity: 1; transform: translateX(-20px) scale(1.15); }
  100% { opacity: 1; transform: translateX(260px) scale(1.15); }
}
@keyframes xmas-tree-sink {
  0%   { opacity: 1; transform: translateY(0) scale(1, 1); }
  100% { opacity: 0; transform: translateY(28vh) scale(1.05, 0.6); }
}
/* explicit reverse of xmas-build-up / xmas-build-drop: a reversed animation
   would show its END state during the delay, so these are spelled out */
@keyframes xmas-unbuild-down {
  0%   { opacity: 1; transform: translateY(0); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(80px); }
}
@keyframes xmas-unbuild-lift {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-90px); }
}

/* ─── Snow canvases (three depth layers) ─── */
/* The scenery sits BETWEEN the snow layers for a sense of depth:
     far  (z 6)   behind the ground (7) and mountains (8)
     mid  (z 9)   in front of the mountains, behind the trees (10) + Kenny (35)
     near (z 999) in front of everything in the scene
   All three are still inside #xmas-scene (z-5), so they stay behind the
   Discord widget (z-1200) and the cian wordmark. Two ids per rule on purpose:
   styles.css has `#app canvas { z-index: 1 }` (1,0,1), which beats a lone id
   (1,0,0) and would sink the flakes under the whole scene. */
#xmas-scene .xmas-snow {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#xmas-scene #xmas-snow-far { z-index: 6; }
#xmas-scene #xmas-snow-mid { z-index: 9; }
#xmas-scene #xmas-snow-1   { z-index: 999; }

/* ─── Mountains ─── */
#xmas-scene .xmas-mountains {
  position: absolute;
  bottom: calc(24vh - 1px);
  left: 0;
  width: 100%;
  height: auto;
  z-index: 8;
  pointer-events: none;
  display: block;
}
/* Keep the SVG's original inline fills (#273832 peaks / #275539 base ridge)
   so the blue #7C8DB3 snow-cap ellipses + paths read correctly on top, exactly
   like the clean christmas.html reference. No CSS fill override here on purpose. */

/* ─── Background elements (clouds / trees / sign) ─── */
#xmas-scene .xmas-bg-elements {
  position: absolute;
  width: 100%; height: 100%;
  z-index: 10;   /* above the MID snow canvas (9) so mid flakes fall behind the trees */
  /* slow pan applied only after the build finishes (see .built rules) */
}

/* Flat paper-cutout clouds, same style as the trees / mountains / Kenny.
   Inline SVG silhouettes (a few circles on a rounded bar, one fill, so they
   merge into one shape): no image download, crisp at any size. Slightly
   lighter than the sky, as if moonlit; farther clouds a touch more see-
   through. Sized in vw on small screens so none of them swallows a phone. */
#xmas-scene .xmas-cloud {
  position: absolute;
  aspect-ratio: 2 / 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100'%3E%3Cg fill='%23354b7a'%3E%3Crect x='6' y='56' width='188' height='38' rx='19'/%3E%3Ccircle cx='52' cy='56' r='30'/%3E%3Ccircle cx='98' cy='44' r='40'/%3E%3Ccircle cx='146' cy='55' r='29'/%3E%3C/g%3E%3C/svg%3E") no-repeat center / contain;
  opacity: 0;
  pointer-events: none;
  /* Slow, gentle fade-in once the rest of the scene has built, so the
     clouds drift into existence rather than appearing abruptly. */
  transition: opacity 3s cubic-bezier(0.4, 0, 0.2, 1);
}
#xmas-scene .xmas-cloud-2 { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100'%3E%3Cg fill='%23354b7a'%3E%3Crect x='4' y='58' width='192' height='36' rx='18'/%3E%3Ccircle cx='45' cy='60' r='26'/%3E%3Ccircle cx='85' cy='48' r='36'/%3E%3Ccircle cx='135' cy='42' r='34'/%3E%3Ccircle cx='168' cy='60' r='24'/%3E%3C/g%3E%3C/svg%3E"); }
/* Start already on-screen so they drift instead of popping in from the edge */
#xmas-scene .xmas-cloud-1 { top: 13%; left: 7%;  width: min(380px, 52vw); }
#xmas-scene .xmas-cloud-2 { top: 25%; left: 56%; width: min(250px, 38vw); }
#xmas-scene .xmas-cloud-3 { top: 5%;  left: 74%; width: min(190px, 30vw); }
/* Only fade clouds in AFTER the build finishes (.built), and with a stagger,
   so they don't compete with the scene dissolve / build pop. */
#xmas-scene.built .xmas-cloud-1 { opacity: 0.92; transition-delay: 0.2s; }
#xmas-scene.built .xmas-cloud-2 { opacity: 0.78; transition-delay: 0.9s; }
#xmas-scene.built .xmas-cloud-3 { opacity: 0.66; transition-delay: 1.4s; }

/* ─── Stars ───
   Three full-screen layers; christmas.js gives each a background-image
   list of tiny radial-gradient dots (one per star, no-repeat, positioned
   in vw/vh so there's nothing to resize). A linear-gradient mask three
   screens wide sweeps across so the stars come in from the left; two of
   the layers then twinkle out of step. z 1: above the sky, below the far
   snow (6) and everything else. Behind the mountains they simply hide. */
#xmas-scene .xmas-stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(105deg, #000 0%, #000 34%, transparent 66%);
          mask-image: linear-gradient(105deg, #000 0%, #000 34%, transparent 66%);
  -webkit-mask-size: 300% 100%;  mask-size: 300% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0;  mask-position: 100% 0;     /* hidden: the transparent end covers the screen */
}
#xmas-scene.active  .xmas-stars-a { animation: xmas-stars-sweep 2.4s ease-out 2.4s both; }
#xmas-scene.active  .xmas-stars-b { animation: xmas-stars-sweep 2.4s ease-out 2.7s both, xmas-twinkle 3.6s ease-in-out 5.1s infinite; }
#xmas-scene.active  .xmas-stars-c { animation: xmas-stars-sweep 2.4s ease-out 3.0s both, xmas-twinkle 5.1s ease-in-out 5.4s infinite; }
#xmas-scene.instant .xmas-stars   { -webkit-mask-position: 0 0; mask-position: 0 0; }
#xmas-scene.instant .xmas-stars-a { animation: none; }
#xmas-scene.instant .xmas-stars-b { animation: xmas-twinkle 3.6s ease-in-out infinite; }
#xmas-scene.instant .xmas-stars-c { animation: xmas-twinkle 5.1s ease-in-out -2s infinite; }
#xmas-scene.leaving .xmas-stars   { animation: xmas-stars-sweep-out 1.6s ease-in 0.2s both; }
@keyframes xmas-stars-sweep     { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0% 0; mask-position: 0% 0; } }
@keyframes xmas-stars-sweep-out { from { -webkit-mask-position: 0% 0;   mask-position: 0% 0;   } to { -webkit-mask-position: 100% 0; mask-position: 100% 0; } }
@keyframes xmas-twinkle         { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ─── Moon ───
   A big flat cut-out full moon, upper right, with a couple of faint craters
   and a static glow (box-shadow, painted once). The focal point of the sky.
   z 2: above the stars, below the clouds (10) so a cloud can drift across it. */
#xmas-scene .xmas-moon {
  position: absolute;
  top: 9%; right: 11%;
  width: clamp(88px, 9vw, 140px);
  height: clamp(88px, 9vw, 140px);
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 36% 40%, rgba(214,206,178,0.55) 0%, rgba(214,206,178,0.55) 9%,  transparent 10%),
    radial-gradient(circle at 62% 62%, rgba(214,206,178,0.50) 0%, rgba(214,206,178,0.50) 12%, transparent 13%),
    radial-gradient(circle at 56% 28%, rgba(214,206,178,0.45) 0%, rgba(214,206,178,0.45) 6%,  transparent 7%),
    #f4eed8;
  box-shadow:
    0 0 24px 6px  rgba(244,238,216,0.28),
    0 0 90px 30px rgba(190,205,255,0.14);
  opacity: 0;
}
/* Rises from behind the mountains (it starts below the ground line, hidden
   by the ground + mountains, which sit above it) and sets on the way out. */
#xmas-scene.active  .xmas-moon { animation: xmas-moon-rise 2.6s cubic-bezier(0.22, 1, 0.36, 1) 2.0s both; }
#xmas-scene.instant .xmas-moon { animation: none; opacity: 1; }
#xmas-scene.leaving .xmas-moon { animation: xmas-moon-set 1.6s ease-in 0.2s both; }
@keyframes xmas-moon-rise {
  0%   { opacity: 0; transform: translateY(80vh); }
  12%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes xmas-moon-set {
  0%   { opacity: 1; transform: translateY(0); }
  88%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(80vh); }
}

#xmas-scene .xmas-tree {
  position: absolute;
  bottom: 0;
  z-index: 10;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
  transform-origin: bottom center;
  /* Wind lean: christmas.js writes the eased wind (about -1..1, a bit more in
     a gust) to --wind on the scene ~8x/s. The individual `rotate` property
     composes with the keyframe `transform` sway, so the idle wobble and the
     wind lean both apply; the transition smooths the updates. */
  rotate: calc(var(--wind, 0) * 5deg);
  transition: rotate 1.4s ease;
  /* sway is applied only after the build finishes (see .built rules) */
}
#xmas-scene .xmas-tree-1 { left: 10%; height: 32vh; width: auto; bottom: 7vh; }
#xmas-scene .xmas-tree-2 { right: 15%; height: 26vh; width: auto; bottom: 6vh; }
#xmas-scene .xmas-tree-3 { left: 25%; height: 22vh; width: auto; bottom: 7vh; z-index: 9; }
#xmas-scene .xmas-tree-4 { left: 40%; height: 18vh; width: auto; bottom: 6vh; z-index: 8; }
#xmas-scene .xmas-tree-5 { left: 60%; height: 20vh; width: auto; bottom: 7vh; z-index: 9; }

#xmas-scene.instant .xmas-sign { animation: none; }
#xmas-scene .xmas-sign {
  position: absolute;
  bottom: 20px;
  left: 10%;
  transform: translateX(-50%);
  height: 150px; width: auto;
  z-index: 11;
}

/* ─── Snow ground layers ─── */
#xmas-scene .xmas-snow-layers {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 24vh;
  z-index: 7;
  overflow: hidden;
  pointer-events: none;
}
#xmas-scene .xmas-snow-layer { position: absolute; width: 100%; left: 0; }
#xmas-back-snow  { height: 100%; bottom: 0; background: #8C9CC2; z-index: 21; clip-path: polygon(0 -10%, 100% -5%, 100% 100%, 0 100%); transform: translateY(-3px); animation: xmas-ground 45s infinite ease-in-out; }
#xmas-mid-snow   { height: 75%;  bottom: 0; background: #A0AFCF; z-index: 22; clip-path: polygon(0 10%, 100% 10%, 100% 100%, 0 100%); animation: xmas-ground-mid 50s infinite ease-in-out; }
#xmas-front-snow { height: 50%;  bottom: 0; background: #B4C2DF; z-index: 23; clip-path: polygon(0 20%, 100% 20%, 100% 100%, 0 100%); animation: xmas-ground-front 55s infinite ease-in-out; }

/* ─── Snow sparkle ───
   Very fine glints on the ground that twinkle, like snow catching the light.
   Each band gets two speck overlays (::before / ::after), each built from two
   tiled radial-gradient dots with mismatched tile sizes so the specks never
   line up into a grid. Every overlay pulses its opacity on its own period and
   offset, so clusters of specks glint in and out independently. Opacity-only
   animation = pure compositor work, and the band's clip-path clips the
   overlays to the snow shape. Peak brightness drops with distance (back band
   dimmest) via --sparkle-peak, which the keyframes read per element. */
#xmas-scene .xmas-snow-layer { --sparkle-peak: 0.95; }
#xmas-scene #xmas-mid-snow   { --sparkle-peak: 0.75; }
#xmas-scene #xmas-back-snow  { --sparkle-peak: 0.55; }

#xmas-scene .xmas-snow-layer::before,
#xmas-scene .xmas-snow-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.95) 0.6px, rgba(255,255,255,0) 1.9px),
    radial-gradient(circle, rgba(255,255,255,0.75) 0.4px, rgba(255,255,255,0) 1.3px);
  background-size: 127px 61px, 83px 97px;
  background-position: 0 0, 29px 13px;
  opacity: 0.1;
  animation: xmas-sparkle 3.1s ease-in-out infinite;
}
#xmas-scene .xmas-snow-layer::after {
  background-size: 101px 79px, 149px 53px;
  background-position: 47px 23px, 19px 53px;
  animation-duration: 4.3s;
  animation-delay: -1.7s;
}
#xmas-scene #xmas-mid-snow::before   { animation-duration: 3.7s; animation-delay: -0.9s; background-position: 61px 5px, 7px 43px; }
#xmas-scene #xmas-mid-snow::after    { animation-duration: 2.6s; animation-delay: -2.2s; background-position: 23px 41px, 71px 11px; }
#xmas-scene #xmas-front-snow::before { animation-duration: 2.9s; animation-delay: -1.3s; background-position: 31px 11px, 67px 41px; }
#xmas-scene #xmas-front-snow::after  { animation-duration: 3.9s; animation-delay: -0.4s; background-position: 5px 37px, 89px 17px; }

@keyframes xmas-sparkle {
  0%, 100% { opacity: 0.08; }
  50%      { opacity: var(--sparkle-peak, 0.95); }
}

/* ═══ Kenny (South Park) ═══ */
#xmas-scene .xmas-container {
  position: absolute;
  bottom: 0; right: 0;
  transform-origin: bottom right;
  transform: translateX(-20px) scale(1.15);
  z-index: 35;
  width: 660px; height: 210px;
  /* Wandering (desktop): christmas.js sets --kx to a new spot along the
     band and the transition walks him there; the individual `translate`
     composes with the keyframe `transform` (walk-in / sway / walk-off), so
     none of them fight. The duration is set inline from the distance. */
  translate: var(--kx, 0px) 0;
  transition: translate 1s linear;
  /* sway is applied only after the build finishes (see .built rules) */
}
#xmas-scene .xmas-boys { width: 100%; height: 100%; position: relative; }
#xmas-scene .xmas-kenny { position: absolute; }

#xmas-scene .xmas-kenny { left: 82%; height: 120px; width: 120px; margin-top: 84px; animation: xmas-waddle 3s ease-in-out infinite; }
#xmas-scene .xmas-kenny * { position: absolute; }

#xmas-scene .xmas-container .eye {
  left: calc(50% - 33px); top: 50px;
  height: 40px; width: 32px;
  background: #FFFFFF; border-radius: 50%;
}
#xmas-scene .xmas-container .eye:before {
  content: ""; position: absolute; top: 15px;
  height: 4px; width: 4px; border-radius: 50%; background: #333333;
  /* where he's looking: --look is set on .xmas-kenny (left while walking
     in, at you once he's stopped, right while walking off) */
  transform: translateX(var(--look, 0px));
  transition: transform 0.35s ease;
}
#xmas-scene .xmas-container .eye.left  { margin-right: 34px; transform: rotate(30deg); }
#xmas-scene .xmas-container .eye.left:before  { right: 7px; }
#xmas-scene .xmas-container .eye.right { margin-left: 34px; transform: rotate(-30deg); }
#xmas-scene .xmas-container .eye.right:before { left: 7px; }

#xmas-scene .xmas-container .body {
  top: 35px; left: 18%; width: 64%;
  perspective: 60px; perspective-origin: 50% 50%; z-index: 7;
}
#xmas-scene .xmas-container .body .inner {
  left: 0; height: 54px; width: 100%;
  background: #BB6F4F; transform: rotateX(20deg);
  border-radius: 10% 10% 50% 50% / 0 0 5% 5%;
}
#xmas-scene .xmas-container .body .inner:before {
  content: ""; position: absolute; left: 50%; height: 100%; width: 10px;
  border-left: 1px solid #333333;
}
#xmas-scene .xmas-container .body .arm {
  height: 38px; width: 14px; background: #BB6F4F; transform: rotateX(25deg);
}
#xmas-scene .xmas-container .body .arm:before {
  content: ""; position: absolute; bottom: 0; height: 10px; width: 10px;
}
#xmas-scene .xmas-container .body .arm .hand {
  bottom: -11px; height: 18px; width: 18px; background: #E33940;
}
#xmas-scene .xmas-container .body .arm.left  { left: -10px; border-radius: 0 0 30% 50% / 0 0 10% 20%; }
#xmas-scene .xmas-container .body .arm.left:before  { right: -2px; border-right: 1px solid #333333; }
#xmas-scene .xmas-container .body .arm.left .hand   { left: -1px; transform: rotateX(-30deg) skewX(14deg);  border-radius: 50% 50% 40% 60% / 50% 20% 20% 50%; }
#xmas-scene .xmas-container .body .arm.right { right: -10px; border-radius: 0 0 50% 30% / 0 0 20% 10%; }
#xmas-scene .xmas-container .body .arm.right:before { left: -2px; border-left: 1px solid #333333; }
#xmas-scene .xmas-container .body .arm.right .hand  { right: -1px; transform: rotateX(-30deg) skewX(-14deg); border-radius: 50% 50% 60% 40% / 20% 50% 50% 20%; }

#xmas-scene .xmas-container .legs {
  left: 17%; bottom: 12px; width: 66%; height: 20px; background: #5060AB;
}
#xmas-scene .xmas-container .legs .foot {
  bottom: 0; width: calc(50% + 5px); height: 5px; background: #333333;
  border-radius: 50% 50% 0 0 / 95% 95% 0 0;
}
#xmas-scene .xmas-container .legs .foot.left  { left: -5px; }
#xmas-scene .xmas-container .legs .foot.right { right: -5px; }

/* Kenny-specific */
#xmas-scene .xmas-kenny .hoodie {
  top: -60px; left: calc(50% - 62px);
  height: 122px; width: 124px; background: #F7731E;
  border-radius: 50% 50% 50% 50% / 48% 48% 50% 50%;
  z-index: 8; box-shadow: 0 1px 3px -2px rgba(0,0,0,0.5);
}
#xmas-scene .xmas-kenny .hoodie:before,
#xmas-scene .xmas-kenny .hoodie:after {
  content: ""; position: absolute; top: 90px; height: 25px; width: 1px;
  border: 1px solid transparent; border-left: 1px solid #333333;
  border-radius: 50%; transform-origin: top center; left: 50%;
}
#xmas-scene .xmas-kenny .hoodie:before { transform: rotate(20deg); }
#xmas-scene .xmas-kenny .hoodie:after  { transform: rotate(-20deg); }

#xmas-scene .xmas-kenny .head {
  top: -60px; left: 0; width: 120px; height: 120px;
  background-color: #FEDDB2;
  border-radius: 50% 50% 50% 50% / 48% 48% 50% 50%;
  clip-path: circle(28% at 50% 50%); z-index: 8;
}
#xmas-scene .xmas-kenny .head .eye { top: 39px; }

#xmas-scene .xmas-kenny .hoodie-edge {
  top: -31px; left: 20px; height: 72px; width: 80px;
  border: 1px solid #333333; border-top-color: transparent;
  border-radius: 50%; z-index: 9;
}
#xmas-scene .xmas-kenny .hoodie-edge:before,
#xmas-scene .xmas-kenny .hoodie-edge:after {
  content: ""; position: absolute; top: -5px;
  width: calc(100% - 2px); height: calc(100% - 2px);
  border-left: 14px solid #7E3821; border-radius: 50%;
}
#xmas-scene .xmas-kenny .hoodie-edge:before { left: 1px; }
#xmas-scene .xmas-kenny .hoodie-edge:after  { transform: rotate(180deg); right: 1px; }

#xmas-scene .xmas-kenny .body .inner,
#xmas-scene .xmas-kenny .body .arm { background: #F37521; }
#xmas-scene .xmas-kenny .body .inner { box-shadow: 0 1px 3px -2px rgba(0,0,0,0.5); }
#xmas-scene .xmas-kenny .body .arm .hand { background: #78341E; }
#xmas-scene .xmas-kenny .legs { background: #F07321; }

/* ─── Scene animations (prefixed to avoid clashes) ─── */
@keyframes xmas-cloud-drift {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(var(--cloud-drift, 200px)); }
  100% { transform: translateX(0); }
}
@keyframes xmas-waddle {
  0%   { transform: translateY(0)    rotate(0deg); }
  25%  { transform: translateY(-2px) rotate(1deg); }
  50%  { transform: translateY(0)    rotate(0deg); }
  75%  { transform: translateY(-2px) rotate(-1deg); }
  100% { transform: translateY(0)    rotate(0deg); }
}
/* the walking waddle: same idea, bigger and much faster */
@keyframes xmas-waddle-walk {
  0%,100% { transform: translateY(0)    rotate(0deg);  }
  25%     { transform: translateY(-5px) rotate(3deg);  }
  75%     { transform: translateY(-5px) rotate(-3deg); }
}
/* blink: the individual `scale` property, so it composes with the eyes'
   rotate() transform instead of replacing it */
@keyframes xmas-blink {
  0%, 100% { scale: 1 1; }
  4%       { scale: 1 0.08; }
  8%       { scale: 1 1; }
}
@keyframes xmas-tree-sway {
  0%,100% { transform: rotate(0deg)    scale(1,1); }
  25%     { transform: rotate(3deg)    scale(1.02,1.02); }
  50%     { transform: rotate(-2deg)   scale(1,1); }
  75%     { transform: rotate(2.5deg)  scale(1.01,1.01); }
}
@keyframes xmas-slow-pan {
  0%   { transform: translateX(0px)   scale(1); }
  50%  { transform: translateX(-30px) scale(1.02); }
  100% { transform: translateX(0px)   scale(1); }
}
@keyframes xmas-character-sway {
  0%,100% { transform: translateX(-20px) scale(1.15) rotate(0deg); }
  25%     { transform: translateX(-22px) scale(1.15) rotate(0.5deg); }
  75%     { transform: translateX(-18px) scale(1.15) rotate(-0.5deg); }
}
@keyframes xmas-ground {
  0%,100% { clip-path: polygon(0 -10%, 100% -5%, 100% 100%, 0 100%); }
  50%     { clip-path: polygon(0 -12%, 100% -7%, 100% 100%, 0 100%); }
}
@keyframes xmas-ground-mid {
  0%,100% { clip-path: polygon(0 10%, 100% 10%, 100% 100%, 0 100%); }
  50%     { clip-path: polygon(0 8%,  100% 8%,  100% 100%, 0 100%); }
}
@keyframes xmas-ground-front {
  0%,100% { clip-path: polygon(0 20%, 100% 20%, 100% 100%, 0 100%); }
  50%     { clip-path: polygon(0 22%, 100% 22%, 100% 100%, 0 100%); }
}

/* ═══ The cian wordmark is the toggle ═══ */
/* Subtle affordance: lift slightly on hover, keyboard focus ring. */
#xmas-toggle.wordmark { transition: transform 0.25s cubic-bezier(0.23,1,0.32,1); }
#xmas-toggle.wordmark:hover { transform: translateY(-4px) scale(1.03); }
#xmas-toggle.wordmark:focus-visible {
  outline: 2px solid rgba(143,188,187,0.75);
  outline-offset: 8px;
  border-radius: 8px;
}

/* Mobile: the sign just crowds the small scene — drop it. Clouds drift a
   shorter distance and the third one goes, so the sky stays airy. */
@media (max-width: 768px) {
  #xmas-scene .xmas-sign { display: none; }
  #xmas-scene .xmas-cloud { --cloud-drift: 70px; }
  #xmas-scene .xmas-cloud-3 { display: none; }
}

/* Compact Kenny on all phone widths (was 480px — desktop Kenny leaked
   through at 481–768px) */
@media (max-width: 768px) {
  #xmas-scene .xmas-container {
    width: 220px;
    height: 150px;
    right: 0;
    bottom: 52px;   /* lifted clear of the bottom edge */
    /* (no z-index bump here: it only ever ordered Kenny against his scene
       siblings, and it put him in front of the falling snow) */
    transform-origin: bottom right;
    /* fixed resting transform; beats build keyframe + sway via !important */
    transform: translateX(-6px) scale(0.7) !important;
    translate: 0 0 !important;         /* no wandering on phones either */
    animation: none !important;        /* no sway/waddle drift on mobile */
    pointer-events: none;              /* stay a decoration, don't block panel taps */
  }
  /* Push Kenny to the far right of his (now smaller) box */
  #xmas-scene .xmas-kenny {
    left: auto; right: 6px;
    animation: none !important;        /* no waddle bob */
  }
}

@media (prefers-reduced-motion: reduce) {
  #xmas-scene .xmas-bg-elements,
  #xmas-scene .xmas-cloud,
  #xmas-scene .xmas-tree,
  #xmas-scene .xmas-container,
  #xmas-scene .xmas-kenny,
  #xmas-back-snow, #xmas-mid-snow, #xmas-front-snow { animation: none !important; }
  /* sky pieces + Kenny's eyes: static, in their resting places */
  #xmas-scene .xmas-stars, #xmas-scene .xmas-moon, #xmas-scene .xmas-kenny .eye { animation: none !important; }
  #xmas-scene.active .xmas-stars { -webkit-mask-position: 0 0; mask-position: 0 0; }
  #xmas-scene.active .xmas-moon { opacity: 1; transform: none; }
  #xmas-scene .xmas-tree { transition: none; }
  #koi-canvas, #xmas-scene .xmas-sky, #xmas-scene .xmas-container { transition: none !important; }
  /* sparkle: static faint specks instead of twinkling */
  #xmas-scene .xmas-snow-layer::before,
  #xmas-scene .xmas-snow-layer::after,
  #snow-ground .sg-back::before, #snow-ground .sg-mid::before, #snow-ground .sg-front::before,
  #snow-ground .sg-back::after,  #snow-ground .sg-mid::after,  #snow-ground .sg-front::after { animation: none !important; opacity: 0.35; }
}

/* ═══ Inline comments panel (iframe overlay) ═══ */
#comments-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
}
#comments-overlay.open { display: block; }

#comments-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 5, 12, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#comments-overlay.open #comments-backdrop { opacity: 1; }

#comments-panel {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: min(640px, calc(100vw - 32px));
  height: min(80vh, 760px);
  height: min(80dvh, 760px);  /* track the REAL visible viewport on mobile */
  background: #313338;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22,1,0.36,1);
}
#comments-overlay.open #comments-panel {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

#comments-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

#comments-close {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 2;
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 50%;
  background: rgba(20,22,26,0.85);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
#comments-close:hover { background: rgba(40,44,52,0.95); transform: scale(1.08); }

@media (max-width: 480px) {
  #comments-panel {
    width: calc(100vw - 16px);
    height: 86vh;
    height: calc(94dvh - env(safe-area-inset-bottom, 0px));
    border-radius: 14px;
  }
  #comments-close { width: 40px; height: 40px; }  /* comfier tap target */
}
