/* ==========================================================================
   dealium: christmas background

   Snow falling slowly over the black page, in three layers (far, middle, near)
   that fall at different speeds, and a faint drift of settled snow at the bottom.
   The page stays black: the flakes are small and dim, and everything sits behind
   the content.

   Only on while <html> has the "christmas" class: js/season.js sets it from
   1 December to 6 January. To turn it off, remove the class (or this file).
   ========================================================================== */

html.christmas body { background: transparent; }  /* let the snow show through */

/* The three snow layers. Each is a fixed sheet one tile taller than the screen
   that slides down by exactly one tile and starts again, so it never jumps. */
html.christmas::before,
html.christmas::after,
html.christmas body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: repeat;
  will-change: transform;
  animation: christmas-snow linear infinite;
}

html.christmas::before {               /* far: many tiny flakes, slowest */
  --tile: 320px;
  top: calc(-1 * var(--tile));
  bottom: 0;
  background-image: url("../assets/christmas/snow-far.svg");
  background-size: var(--tile) var(--tile);
  animation-duration: 38s;
}

html.christmas body::before {          /* middle */
  --tile: 440px;
  top: calc(-1 * var(--tile));
  bottom: 0;
  background-image: url("../assets/christmas/snow-mid.svg");
  background-size: var(--tile) var(--tile);
  animation-duration: 30s;
  opacity: 0.9;
}

html.christmas::after {                /* near: few bigger flakes, fastest */
  --tile: 600px;
  top: calc(-1 * var(--tile));
  bottom: 0;
  background-image: url("../assets/christmas/snow-near.svg");
  background-size: var(--tile) var(--tile);
  animation-duration: 26s;
  opacity: 0.8;
}

@keyframes christmas-snow {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(calc(var(--tile) / 8), var(--tile), 0); }
}

/* Settled snow: a soft, barely-grey drift along the bottom of the screen. */
html.christmas body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 90px;
  z-index: -1;
  pointer-events: none;
  background: url("../assets/christmas/drift.svg") bottom center / 100% 100% no-repeat;
}

/* No falling snow for people who asked for less motion: the flakes stay still. */
@media (prefers-reduced-motion: reduce) {
  html.christmas::before,
  html.christmas::after,
  html.christmas body::before { animation: none; }
}
