/*
 * Decorative snowfall for the Christmas theme. Unlike the clouds and spooks,
 * which drift across the full document and scroll away with it, snow is pinned
 * to the viewport (position: fixed): it keeps falling wherever the reader is.
 * It sits behind all content (z-index: -1, same layer strategy as the ambient
 * gradient overlay in typography.css) and pointer-events are off, so reading is
 * never impaired.
 *
 * Two layers of motion are composed without fighting over `transform`: the
 * outer `.flake` falls, while the inner `<span>` sways and tilts. Every flake
 * shares the same keyframes; the per-flake custom properties baked by Snow.astro
 * are what make the fall look random.
 *
 * Colours come from --snow / --snow-glow in xmas.css: white at night, a cold
 * blue tint on the light paper where white would vanish.
 */
body {
	position: relative;
}

.snow {
	position: fixed;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: -1;
}

.flake {
	position: absolute;
	top: 0;
	left: var(--x, 50%);
	animation: snow-fall var(--fall, 16s) linear var(--delay, 0s) infinite;
	will-change: transform;
}

.flake > span {
	display: block;
	animation: snow-sway var(--sway-time, 5s) ease-in-out var(--delay, 0s)
		infinite alternate;
	will-change: transform;
}

/* Far and mid layers are soft dots. */
.flake--far > span,
.flake--mid > span {
	width: var(--size, 3px);
	height: var(--size, 3px);
	border-radius: 50%;
	background-color: var(--snow, #fff);
	box-shadow: 0 0 4px var(--snow-glow, transparent);
}

.flake--far > span {
	opacity: 0.45;
}

.flake--mid > span {
	opacity: 0.75;
}

/* The near layer gets the actual crystals. */
.flake--near > span {
	font-family: system-ui, sans-serif;
	font-size: var(--size, 1rem);
	line-height: 1;
	color: var(--snow, #fff);
	text-shadow: 0 0 6px var(--snow-glow, transparent);
	opacity: 0.85;
	user-select: none;
}

@keyframes snow-fall {
	from {
		transform: translate3d(0, -5vh, 0);
	}

	to {
		transform: translate3d(0, 105vh, 0);
	}
}

@keyframes snow-sway {
	from {
		transform: translateX(calc(var(--sway, 20px) * -1)) rotate(-25deg);
	}

	to {
		transform: translateX(var(--sway, 20px)) rotate(25deg);
	}
}

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

	.flake,
	.flake > span {
		animation: none;
	}
}
