/* New Year look. Linked from components/seasonal/NewYear.tsx only while the season
   is on (see lib/seasonal.ts); outside it this file is never requested. */

html[data-season="new-year"] {
  --ny-red: #e0848b;
  --ny-gold: #e6c876;
  --ny-green: #86c99b;
  --ny-ice: #a8d4ee;
}

/* ── Falling pixel snow ─────────────────────────────────────────────────── */
.ny-snow {
  position: fixed;
  inset: 0;
  z-index: 55;
  overflow: hidden;
  pointer-events: none;
}
.ny-snow i {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  background: #fff;
  opacity: var(--o);
  animation: ny-fall var(--d) linear var(--delay) infinite;
  will-change: transform;
}
/* a few are a pixel snowflake: a plus made of five squares */
.ny-snow i.big {
  box-shadow:
    var(--s) 0 0 #fff,
    calc(var(--s) * -1) 0 0 #fff,
    0 var(--s) 0 #fff,
    0 calc(var(--s) * -1) 0 #fff;
}
@keyframes ny-fall {
  from {
    transform: translate3d(0, -5vh, 0);
  }
  50% {
    transform: translate3d(var(--sway), 55vh, 0);
  }
  to {
    transform: translate3d(0, 108vh, 0);
  }
}

/* ── A string of lights along the top edge ──────────────────────────────── */
.ny-lights {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  justify-content: space-between;
  height: 14px;
  padding: 0 0.75rem;
  pointer-events: none;
}
.ny-lights::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 3px;
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
}
.ny-lights i {
  --c: var(--ny-red);
  position: relative;
  width: 5px;
  height: 8px;
  margin-top: 4px;
  background: var(--c);
  box-shadow: 0 0 9px var(--c);
  /* stepped, so it blinks like a pixel and not like a fade */
  animation: ny-twinkle 2.4s steps(1) infinite;
  animation-delay: calc(var(--n) * 0.37s);
}
.ny-lights i:nth-child(4n + 2) {
  --c: var(--ny-gold);
}
.ny-lights i:nth-child(4n + 3) {
  --c: var(--ny-green);
}
.ny-lights i:nth-child(4n + 4) {
  --c: var(--ny-ice);
}
@keyframes ny-twinkle {
  0%,
  60% {
    opacity: 1;
  }
  61%,
  100% {
    opacity: 0.3;
  }
}

/* ── A Santa hat on the name, and a greeting in the footer ──────────────── */
html[data-season="new-year"] .topbar .brand::before {
  content: "";
  position: absolute;
  left: -7px;
  top: -10px;
  width: 20px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' shape-rendering='crispEdges'%3E%3Crect x='9' y='0' width='2' height='2' fill='%23f2f2f2'/%3E%3Crect x='6' y='1' width='4' height='1' fill='%23d9535e'/%3E%3Crect x='4' y='2' width='6' height='1' fill='%23d9535e'/%3E%3Crect x='3' y='3' width='7' height='1' fill='%23d9535e'/%3E%3Crect x='2' y='4' width='8' height='1' fill='%23d9535e'/%3E%3Crect x='1' y='5' width='9' height='1' fill='%23d9535e'/%3E%3Crect x='0' y='6' width='11' height='2' fill='%23f2f2f2'/%3E%3C/svg%3E")
    no-repeat center / contain;
  image-rendering: pixelated;
  transform: rotate(-12deg);
  pointer-events: none;
}
html[data-season="new-year"] .sitefoot-in > span::after {
  content: " · happy new year";
}

/* ── Where it does not belong ───────────────────────────────────────────── */
/* The admin panel is a work tool: no snow, no lights. */
body:has(.adm) .ny-snow,
body:has(.adm) .ny-lights,
body:has(.adm) .topbar .brand::before {
  display: none;
}
/* Fewer flakes on a phone. */
@media (max-width: 31.25rem) {
  .ny-snow i:nth-child(n + 19) {
    display: none;
  }
  .ny-lights i:nth-child(even) {
    display: none;
  }
}
/* For people who ask for less motion: no snow, and the lights stand still. */
@media (prefers-reduced-motion: reduce) {
  .ny-snow {
    display: none;
  }
  .ny-lights i {
    animation: none;
  }
}
