/* Halloween season layer, active only while <html> has .halloween (set by halloween.js from
   Oct 15 to Nov 2, or forced with ?halloween=1 / ?halloween=0). Everything here is decoration:
   remove the class and the site is exactly the everyday one. Motion is transform/opacity only. */

html.halloween { --hw-orange: #e5762e; --hw-night: #120d14; }

/* The dark band becomes a night sea with ember-tinted scales. */
html.halloween body > .dark { background: var(--hw-night); }
html.halloween .dark {
  --bg: var(--hw-night);
  --seigaiha: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 30'%3E%3Cdefs%3E%3Cg id='s'%3E%3Ccircle r='30' fill='%23120d14'/%3E%3Cg fill='none' stroke='%233a2318' stroke-width='.9'%3E%3Ccircle r='29.5'/%3E%3Ccircle r='22.5'/%3E%3Ccircle r='15'/%3E%3Ccircle r='7.5'/%3E%3C/g%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23s' x='30' y='-15'/%3E%3Cuse href='%23s' x='0' y='0'/%3E%3Cuse href='%23s' x='60' y='0'/%3E%3Cuse href='%23s' x='30' y='15'/%3E%3Cuse href='%23s' x='0' y='30'/%3E%3Cuse href='%23s' x='60' y='30'/%3E%3Cuse href='%23s' x='30' y='45'/%3E%3C/svg%3E");
}
html.halloween .sea path[fill="#141213"] { fill: var(--hw-night); }
html.halloween .sea path[fill="#262122"] { fill: #2a1a1f; }
html.halloween .dish .strip { color: var(--hw-orange); }
html.halloween .chopcard.hot { background: var(--hw-orange); color: #231f20; }

/* Moon over the night band. */
.hw-moon {
  position: absolute; top: 18px; right: clamp(16px, 8vw, 90px); width: clamp(44px, 9vw, 70px); aspect-ratio: 1;
  border-radius: 50%; background: radial-gradient(circle at 38% 36%, #fff7e4 0 40%, #f3dfb3 70%, #e9cf98 100%);
  box-shadow: 0 0 28px 8px rgba(243, 214, 160, .22); pointer-events: none; z-index: 0;
}
.hw-moon::after { /* craters */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 62% 58%, rgba(200,170,120,.35) 0 9%, transparent 10%),
              radial-gradient(circle at 40% 70%, rgba(200,170,120,.3) 0 6%, transparent 7%),
              radial-gradient(circle at 55% 30%, rgba(200,170,120,.25) 0 5%, transparent 6%);
}

/* Cobwebs in the top corners, and a spider bobbing on its thread. */
.hw-web { position: absolute; top: 0; width: clamp(80px, 16vw, 140px); height: auto; pointer-events: none; z-index: 1; opacity: .5; }
.hw-web.l { left: 0; } .hw-web.r { right: 0; transform: scaleX(-1); }
.hw-spider { position: absolute; top: 0; right: clamp(34px, 7vw, 62px); width: 22px; pointer-events: none; z-index: 1;
  transform-origin: 50% 0; animation: hw-dangle 4.5s ease-in-out infinite; }
.hw-spider svg { display: block; width: 22px; height: auto; }
@keyframes hw-dangle { 0%, 100% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(0, 26px, 0); } }

/* Bats: a few cross the screen now and then; each flaps on its own clock. */
.hw-bats { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.hw-bat { position: absolute; left: 0; width: 34px; will-change: transform; opacity: 0; animation: hw-fly var(--d, 14s) linear var(--delay, 0s) infinite; }
.hw-bat svg { display: block; width: 100%; height: auto; animation: hw-flap .32s ease-in-out infinite alternate; transform-origin: 50% 40%; }
@keyframes hw-fly {
  0%   { transform: translate3d(-60px, var(--y0), 0) scale(var(--s, 1)); opacity: 0; }
  4%   { opacity: .85; }
  50%  { transform: translate3d(50vw, var(--y1), 0) scale(var(--s, 1)); }
  60%  { opacity: .85; }
  70%  { transform: translate3d(105vw, var(--y2), 0) scale(var(--s, 1)); opacity: 0; }
  100% { transform: translate3d(105vw, var(--y2), 0) scale(var(--s, 1)); opacity: 0; }
}
@keyframes hw-flap { from { transform: scaleY(1); } to { transform: scaleY(.45); } }

/* The bird's witch hat; a chef's hat earned by chopping takes precedence. */
.hw-hat { position: absolute; left: 50%; top: -15%; width: 27%; transform: rotate(-10deg); transform-origin: 50% 100%; pointer-events: none; }
body.has-toque .hw-hat { display: none; }

@media (prefers-reduced-motion: reduce) {
  .hw-bats { display: none; }
  .hw-spider { animation: none; transform: translate3d(0, 14px, 0); }
}
