.halloween-bats {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}

.halloween-bat {
  position: absolute;
  left: 0;
  animation: halloween-fly var(--bat-duration, 8s) linear var(--bat-delay, 0s)
    both;
  color: color-mix(in oklch, var(--foreground) 82%, oklch(0.5 0.2 300));
}

.halloween-bat-bob {
  animation: halloween-bob 1.3s ease-in-out infinite alternate;
}

.halloween-bat-wing {
  transform-box: view-box;
  transform-origin: 32px 18px;
  animation: halloween-flap 0.24s ease-in-out infinite alternate;
}

@keyframes halloween-fly {
  from {
    transform: translateX(-80px);
  }
  to {
    transform: translateX(calc(100vw + 80px));
  }
}

@keyframes halloween-bob {
  from {
    transform: translateY(-10px) rotate(-4deg);
  }
  to {
    transform: translateY(12px) rotate(5deg);
  }
}

@keyframes halloween-flap {
  from {
    transform: scaleY(1);
  }
  to {
    transform: scaleY(-0.35);
  }
}

.halloween-ghost {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 10;
  pointer-events: none;
  /* The theme-button row is an inline-size container; 230px is roughly where
     the Dark button's centre sits plus half the ghost. */
  --ghost-travel: min(400px, 100cqw - 230px);
  filter: drop-shadow(0 6px 10px rgb(0 0 0 / 0.15));
  animation: halloween-ghost-drift 3.4s ease-in-out forwards;
}

.dark .halloween-ghost {
  filter: drop-shadow(0 0 16px rgb(170 200 255 / 0.4));
}

.halloween-ghost-float {
  display: block;
  animation: halloween-ghost-wobble 0.6s ease-in-out infinite alternate;
}

/* Pops out of the Dark button, then drifts right through the card's empty
   space and fades without leaving the card. */
@keyframes halloween-ghost-drift {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -85%) scale(1);
  }
  32% {
    transform: translate(calc(-50% + var(--ghost-travel) * 0.28), -45%);
  }
  52% {
    transform: translate(calc(-50% + var(--ghost-travel) * 0.53), -75%);
  }
  75% {
    opacity: 1;
    transform: translate(calc(-50% + var(--ghost-travel) * 0.78), -45%);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--ghost-travel)), -80%) scale(0.9);
  }
}

@keyframes halloween-ghost-wobble {
  from {
    transform: rotate(-6deg);
  }
  to {
    transform: rotate(6deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .halloween-bats,
  .halloween-ghost {
    display: none;
  }
}

.halloween-avatar {
  background: #e9e3f3;
}

.halloween-cat-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: halloween-cat-blink 4.5s ease-in-out infinite;
}

@keyframes halloween-cat-blink {
  0%,
  94%,
  100% {
    transform: scaleY(1);
  }
  97% {
    transform: scaleY(0.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .halloween-cat-eyes {
    animation: none;
  }
}
