/* Winter in the moonlit room, December 1st to Twelfth Night. Loaded only in
   winter (see the seasonal_theme context processor).

   Frost creeps in from the edges of the two painted windows. moon-phase.js
   tells us where the painting lands (--room-px is one painted pixel, --room-x
   its left edge), so the frost sits on the glass; without it the vw fallbacks
   match a wide screen. A few flakes of snow drift down, slowly. */

.wtr { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.wtr-defs { position: absolute; width: 0; height: 0; }
.wtr-flood { flood-color: rgb(var(--c-frost)); }
.wtr-mask-on { stop-color: rgb(var(--c-pure-white)); }
.wtr-mask-mid { stop-color: rgb(var(--c-pure-white) / .3); }
.wtr-mask-off { stop-color: rgb(var(--c-black)); }

.wtr-frost {
  position: absolute;
  top: calc(96 * var(--room-px, .0651vw));
  width: calc(112 * var(--room-px, .0651vw));
  height: calc(500 * var(--room-px, .0651vw));
  opacity: .5;
  background: linear-gradient(90deg, rgb(var(--c-frost) / .2), rgb(var(--c-frost) / 0) 45%);
  -webkit-mask-image: linear-gradient(180deg, transparent, rgb(var(--c-black)) 10%, rgb(var(--c-black)) 78%, transparent);
  mask-image: linear-gradient(180deg, transparent, rgb(var(--c-black)) 10%, rgb(var(--c-black)) 78%, transparent);
}
.wtr-frost-left { left: var(--room-x, 0px); }
.wtr-frost-right { right: var(--room-x, 0px); background: linear-gradient(270deg, rgb(var(--c-frost) / .2), rgb(var(--c-frost) / 0) 45%); height: calc(450 * var(--room-px, .0651vw)); }

/* The violet mist on the left cools to a frosty breath. */
.season-winter .atmo-mist-a { background: radial-gradient(closest-side, rgb(var(--c-frost) / .1), rgb(var(--c-frost) / 0)); }

/* Snow. */
.wtr-flake {
  position: absolute;
  top: -10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgb(var(--c-white));
  box-shadow: 0 0 5px 1px rgb(var(--c-frost) / .7);
  opacity: 0;
  animation: wtr-fall 28s linear infinite;
}
.wtr-flake:nth-child(1)  { left: 2%;  animation-delay: -3s; }
.wtr-flake:nth-child(2)  { left: 5%;  animation-delay: -17s; animation-duration: 34s; width: 3px; height: 3px; }
.wtr-flake:nth-child(3)  { left: 8%;  animation-delay: -9s; animation-duration: 31s; }
.wtr-flake:nth-child(4)  { left: 12%; animation-delay: -24s; animation-duration: 38s; width: 4px; height: 4px; }
.wtr-flake:nth-child(5)  { left: 21%; animation-delay: -6s; animation-duration: 36s; width: 3px; height: 3px; }
.wtr-flake:nth-child(6)  { left: 34%; animation-delay: -20s; animation-duration: 42s; }
.wtr-flake:nth-child(7)  { left: 47%; animation-delay: -12s; animation-duration: 39s; width: 3px; height: 3px; }
.wtr-flake:nth-child(8)  { left: 58%; animation-delay: -30s; animation-duration: 44s; width: 4px; height: 4px; }
.wtr-flake:nth-child(9)  { left: 69%; animation-delay: -2s; animation-duration: 37s; width: 3px; height: 3px; }
.wtr-flake:nth-child(10) { left: 80%; animation-delay: -14s; animation-duration: 33s; }
.wtr-flake:nth-child(11) { left: 88%; animation-delay: -26s; animation-duration: 30s; width: 4px; height: 4px; }
.wtr-flake:nth-child(12) { left: 91%; animation-delay: -8s; animation-duration: 35s; width: 3px; height: 3px; }
.wtr-flake:nth-child(13) { left: 94%; animation-delay: -19s; animation-duration: 29s; }
.wtr-flake:nth-child(14) { left: 97%; animation-delay: -11s; animation-duration: 40s; width: 3px; height: 3px; }
.wtr-flake:nth-child(15) { left: 99%; animation-delay: -33s; animation-duration: 32s; width: 4px; height: 4px; }
@keyframes wtr-fall {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  8%   { opacity: .85; }
  30%  { transform: translate3d(14px, 32vh, 0); }
  55%  { transform: translate3d(-8px, 58vh, 0); }
  80%  { transform: translate3d(10px, 84vh, 0); opacity: .75; }
  100% { transform: translate3d(-4px, 104vh, 0); opacity: 0; }
}

@media (max-width: 1100px) {
  .wtr-frost { display: none; }
  .wtr-flake:nth-child(3n) { display: none; }
}

html[data-sparkles='off'] .wtr-snow { display: none; }
html[data-sparkles='off'] .wtr * { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  html:not([data-sparkles='on']) .wtr-snow { display: none; }
  html:not([data-sparkles='on']) .wtr * { animation: none !important; }
}
@media print { .wtr { display: none !important; } }
