/* Xmas mode (XMAS_MODE=on; docs/XMAS-2026-CHANGES.md, Part 4). Loaded by
   the server only when Xmas mode is on; styles.css is untouched.

   Snow over the start page's world, behind the cards and under the lava,
   so it melts as it falls: it fades out towards the bottom, and fades away
   altogether as the intro heats the world up (--heat). Nothing over
   gameplay. Two layers of flakes, each a repeating tile moved by exactly
   one tile height, so the loop is seamless, on the compositor (transform
   only). Still, and lighter, for anyone who prefers reduced motion. */

[data-xmas] .xmas-snow {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: calc(1 - var(--heat, 0) * 1.1);
  transition: opacity 1.4s ease;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 82%);
  mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 82%);
}

[data-xmas] .xmas-snow::before,
[data-xmas] .xmas-snow::after,
[data-xmas] .page-world::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  will-change: transform;
}

/* Small, slow, many. */
[data-xmas] .xmas-snow::before,
[data-xmas] .page-world::after {
  top: -200px;
  height: calc(100% + 200px);
  background-image:
    radial-gradient(2.2px 2.2px at 18px 22px, rgba(255, 255, 255, .95) 60%, transparent 75%),
    radial-gradient(1.8px 1.8px at 74px 120px, rgba(255, 255, 255, .85) 60%, transparent 75%),
    radial-gradient(2.4px 2.4px at 140px 60px, rgba(255, 255, 255, .9) 60%, transparent 75%),
    radial-gradient(1.9px 1.9px at 176px 160px, rgba(255, 255, 255, .8) 60%, transparent 75%),
    radial-gradient(2.1px 2.1px at 110px 190px, rgba(255, 255, 255, .85) 60%, transparent 75%),
    radial-gradient(1.7px 1.7px at 40px 140px, rgba(255, 255, 255, .8) 60%, transparent 75%),
    radial-gradient(2px 2px at 160px 8px, rgba(255, 255, 255, .85) 60%, transparent 75%),
    radial-gradient(1.6px 1.6px at 90px 80px, rgba(255, 255, 255, .75) 60%, transparent 75%);
  background-size: 200px 200px;
  animation: xmas-fall-small 16s linear infinite;
}

/* Bigger, quicker, fewer: the near flakes. */
[data-xmas] .xmas-snow::after {
  top: -320px;
  height: calc(100% + 320px);
  background-image:
    radial-gradient(4px 4px at 60px 40px, rgba(255, 255, 255, .95) 55%, transparent 75%),
    radial-gradient(3.2px 3.2px at 250px 150px, rgba(255, 255, 255, .9) 55%, transparent 75%),
    radial-gradient(4.4px 4.4px at 150px 260px, rgba(255, 255, 255, .9) 55%, transparent 75%),
    radial-gradient(3.4px 3.4px at 290px 280px, rgba(255, 255, 255, .9) 55%, transparent 75%),
    radial-gradient(3.6px 3.6px at 20px 190px, rgba(255, 255, 255, .85) 55%, transparent 75%);
  background-size: 320px 320px;
  filter: drop-shadow(0 0 2px rgba(200, 235, 255, .6));
  animation: xmas-fall-big 10s linear infinite;
}

@keyframes xmas-fall-small { to { transform: translateY(200px); } }
@keyframes xmas-fall-big { to { transform: translateY(320px); } }

/* On phones the start card shows the practitioners in short 2:1 tiles,
   cropped from the middle; lift the crop so the hats are in it. A square
   tile (wider screens) is not cropped, so this changes nothing there. */
[data-xmas] .card--start .pick-row button canvas { object-position: 50% 18%; }

/* The leaderboard page's still world: the light layer only, fading towards the lava. */
[data-xmas] .page-world::after {
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 78%);
  mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 78%);
}

@media (prefers-reduced-motion: reduce) {
  [data-xmas] .xmas-snow::before,
  [data-xmas] .xmas-snow::after,
  [data-xmas] .page-world::after {
    animation: none;
    transform: translateY(120px);
  }
  [data-xmas] .xmas-snow { opacity: calc(.6 - var(--heat, 0) * .7); }
}
