.christmas-snow,
.christmas-controls {
  display: none;
}

[data-christmas] .christmas-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .6rem;
  padding-block: .45rem;
  font-size: .8rem;
}

.christmas-controls button {
  padding: .3rem .5rem;
  border: 1px solid var(--line);
  border-radius: .3rem;
  color: var(--blue);
  background: #f1f7fa;
  font: inherit;
  cursor: pointer;
}

.christmas-controls button:hover {
  background: #e4f0f5;
}

[data-christmas] .christmas-snow {
  position: fixed;
  z-index: 2;
  inset: 0;
  display: block;
  overflow: hidden;
  pointer-events: none;
}

.christmas-flake {
  --pixel: 2.5px;
  position: absolute;
  top: -2rem;
  left: var(--start);
  width: var(--pixel);
  height: var(--pixel);
  color: #4b92ba;
  opacity: .42;
  animation: christmas-fall var(--duration) linear var(--delay) infinite;
}

.christmas-flake:nth-child(3n) {
  --pixel: 3.5px;
  color: #8bc6e5;
  opacity: .55;
}

.christmas-flake:nth-child(4n) {
  --pixel: 1.5px;
  opacity: .32;
}

.christmas-flake::before {
  --unit: var(--pixel);
  --two: calc(2 * var(--pixel));
  --three: calc(3 * var(--pixel));
  --four: calc(4 * var(--pixel));
  --negative: calc(-1 * var(--pixel));
  --neg-two: calc(-2 * var(--pixel));
  --neg-three: calc(-3 * var(--pixel));
  --neg-four: calc(-4 * var(--pixel));
  position: absolute;
  inset: 0;
  background: currentColor;
  box-shadow:
    0 var(--negative), 0 var(--neg-two), 0 var(--neg-three), 0 var(--neg-four),
    0 var(--unit), 0 var(--two), 0 var(--three), 0 var(--four),
    var(--negative) 0, var(--neg-two) 0, var(--neg-three) 0, var(--neg-four) 0,
    var(--unit) 0, var(--two) 0, var(--three) 0, var(--four) 0,
    var(--negative) var(--neg-three), var(--unit) var(--neg-three),
    var(--negative) var(--three), var(--unit) var(--three),
    var(--neg-three) var(--negative), var(--neg-three) var(--unit),
    var(--three) var(--negative), var(--three) var(--unit);
  content: "";
}

/* An eight-point crystal, a diagonal crystal, and a compact sparkle. */
.christmas-flake:nth-child(5n + 1)::before {
  box-shadow:
    0 var(--negative), 0 var(--neg-two), 0 var(--neg-three), 0 var(--neg-four),
    0 var(--unit), 0 var(--two), 0 var(--three), 0 var(--four),
    var(--negative) 0, var(--neg-two) 0, var(--neg-three) 0, var(--neg-four) 0,
    var(--unit) 0, var(--two) 0, var(--three) 0, var(--four) 0,
    var(--negative) var(--negative), var(--neg-two) var(--neg-two),
    var(--unit) var(--negative), var(--two) var(--neg-two),
    var(--negative) var(--unit), var(--neg-two) var(--two),
    var(--unit) var(--unit), var(--two) var(--two);
}

.christmas-flake:nth-child(5n + 2)::before {
  box-shadow:
    var(--negative) var(--negative), var(--neg-two) var(--neg-two), var(--neg-three) var(--neg-three),
    var(--unit) var(--negative), var(--two) var(--neg-two), var(--three) var(--neg-three),
    var(--negative) var(--unit), var(--neg-two) var(--two), var(--neg-three) var(--three),
    var(--unit) var(--unit), var(--two) var(--two), var(--three) var(--three),
    var(--neg-three) var(--neg-two), var(--neg-two) var(--neg-three),
    var(--three) var(--neg-two), var(--two) var(--neg-three),
    var(--neg-three) var(--two), var(--neg-two) var(--three),
    var(--three) var(--two), var(--two) var(--three);
}

.christmas-flake:nth-child(5n + 4)::before {
  box-shadow:
    0 var(--negative), 0 var(--neg-two), 0 var(--unit), 0 var(--two),
    var(--negative) 0, var(--neg-two) 0, var(--unit) 0, var(--two) 0,
    var(--negative) var(--negative), var(--unit) var(--negative),
    var(--negative) var(--unit), var(--unit) var(--unit);
}

@keyframes christmas-fall {
  to { transform: translate(var(--drift), calc(100vh + 4rem)); }
}

@media (max-width: 45rem) {
  .christmas-flake:nth-child(n+20) { display: none; }
  .christmas-credit { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  [data-christmas] .christmas-snow { display: none; }
}
