/* ==========================================================================
   MODO TEMPORADA: HALLOWEEN — overlay visual aislado.
   No depende de ningún token/variable del sitio real: capa 100% autocontenida
   para poder desactivarse sin afectar el diseño base. Ver index.html para
   el bloque de activación/desactivación.
   ========================================================================== */

#halloween-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  pointer-events: none;
  overflow: hidden;
}

#halloween-overlay * {
  pointer-events: none;
}

/* ---------- Telarañas colgantes (composición original, fuera de las esquinas exactas) ---------- */

.hw-web {
  position: absolute;
  width: 210px;
  height: 210px;
  opacity: 0.42;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.hw-web svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hw-web path {
  fill: none;
  stroke: rgba(235, 235, 240, 0.55);
  stroke-width: 1;
  stroke-linecap: round;
}

.hw-web--a {
  --hw-rot: -14deg;
  --hw-scale: 1;
  top: -18px;
  left: 6vw;
  transform-origin: top center;
  animation: hw-sway 10s ease-in-out infinite alternate;
}

.hw-web--b {
  --hw-rot: 13deg;
  --hw-scale: 1;
  bottom: -22px;
  right: 9vw;
  transform-origin: bottom center;
  animation: hw-sway 12s ease-in-out infinite alternate-reverse;
}

@keyframes hw-sway {
  0%   { transform: rotate(var(--hw-rot)) scale(var(--hw-scale)); }
  50%  { transform: rotate(calc(var(--hw-rot) + 2deg)) scale(var(--hw-scale)); }
  100% { transform: rotate(calc(var(--hw-rot) - 1.4deg)) scale(var(--hw-scale)); }
}

/* ---------- Araña colgante: red de anclaje propia + hilo + araña ---------- */

.hw-spider-rig {
  position: absolute;
  top: 0;
  left: auto;
  right: 3vw;
  width: 70px;
  height: 190px;
}

.hw-spider-anchor {
  position: absolute;
  top: 0;
  left: 0;
  width: 42px;
  height: 34px;
  opacity: 0.25;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.hw-spider-anchor svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hw-spider-anchor path {
  fill: none;
  stroke: rgba(235, 235, 240, 0.5);
  stroke-width: 1;
  stroke-linecap: round;
}

.hw-spider-thread {
  position: absolute;
  top: 22px;
  left: 14px;
  width: 1px;
  height: 100%;
  background: rgba(235, 235, 240, 0.45);
}

.hw-spider {
  position: absolute;
  top: 48px;
  left: -1px;
  width: 28px;
  height: 24px;
  animation: hw-spider-move 14s ease-in-out infinite;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.22)) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.5));
}

.hw-spider svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hw-spider-svg ellipse {
  fill: #0a0a0c;
}

.hw-spider-legs path {
  stroke: #0a0a0c;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
}

@keyframes hw-spider-move {
  0%   { transform: translateY(0); }
  38%  { transform: translateY(140px); }
  55%  { transform: translateY(140px); }
  100% { transform: translateY(0); }
}

/* ---------- Arañas paseando en diagonal cerca de las esquinas (evento independiente) ---------- */

.hw-corner-spider {
  position: absolute;
  width: 26px;
  height: auto;
  animation: hw-spider-walk 11s ease-in-out forwards;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.2)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.hw-corner-spider svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Entra por una esquina o un lateral, avanza en diagonal a paso normal y se
   pierde por arriba o por abajo (según --hw-mid-y/--hw-end-y), con deriva
   lateral y tamaño (--hw-size) distintos en cada aparición. */

@keyframes hw-spider-walk {
  0%   { transform: translate(0, 0) scale(var(--hw-size, 1)) rotate(0deg); opacity: 0; }
  8%   { opacity: 1; }
  45%  { transform: translate(var(--hw-mid-x, 0), var(--hw-mid-y, 26vh)) scale(var(--hw-size, 1)) rotate(6deg); opacity: 1; }
  80%  { transform: translate(var(--hw-end-x, 0), var(--hw-end-y, 68vh)) scale(var(--hw-size, 1)) rotate(-4deg); opacity: 0.5; }
  100% { transform: translate(var(--hw-end-x, 0), calc(var(--hw-end-y, 68vh) + 10vh)) scale(var(--hw-size, 1)) rotate(-8deg); opacity: 0; }
}

/* ---------- Grupo de calabazas Jack-o-lantern (estático, a color) ---------- */

.hw-pumpkin-group {
  position: absolute;
  bottom: 6px;
  left: 10px;
  width: 128px;
  height: 92px;
}

.hw-pumpkin-base {
  position: absolute;
  bottom: 0;
  left: -4px;
  width: 134px;
  height: 22px;
  opacity: 0.9;
}

.hw-pumpkin-base svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hw-pumpkin-base path {
  fill: #7a5a30;
}

.hw-pumpkin-base .hw-straw-line {
  fill: none;
  stroke: #5e4322;
  stroke-width: 1;
  opacity: 0.6;
}

.hw-jack {
  position: absolute;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.hw-jack svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.hw-jack .hw-jack-body {
  fill: #d9731c;
}

.hw-jack .hw-jack-stem {
  fill: #5a3a1a;
}

.hw-jack .hw-jack-ridges {
  fill: none;
  stroke: #b85a12;
  stroke-width: 1;
  opacity: 0.75;
}

.hw-jack .hw-jack-shadow {
  fill: rgba(0, 0, 0, 0.24);
}

.hw-jack .hw-jack-highlight {
  fill: rgba(255, 205, 130, 0.18);
}

.hw-jack .hw-jack-face {
  fill: #230f05;
}

/* "Bombilla" dentro de cada cuenca tallada: un halo con gradiente radial (sólido
   en el centro, desvanecido a transparente en el borde — sin recuadro duro) más
   un núcleo brillante encima. El grupo entero (halo + núcleo) parpadea como una
   bombilla vieja: varios intentos de encendido irregulares, luego se queda fija
   encendida un buen rato, y se apaga antes de reiniciar el ciclo. */

.hw-jack .hw-jack-glow {
  mix-blend-mode: screen;
}

.hw-jack .hw-jack-bulb {
  fill: #fff3c4;
}

.hw-jack .hw-jack-lamp {
  animation: hw-jack-bulb-cycle 8s ease-in-out infinite;
}

@keyframes hw-jack-bulb-cycle {
  0%   { opacity: 0; }
  3%   { opacity: 0.55; }
  6%   { opacity: 0.05; }
  9%   { opacity: 0.7; }
  12%  { opacity: 0.1; }
  16%  { opacity: 0.85; }
  19%  { opacity: 0.15; }
  24%  { opacity: 0.9; }
  27%  { opacity: 0.2; }
  32%  { opacity: 1; }
  75%  { opacity: 1; }
  80%  { opacity: 0.5; }
  84%  { opacity: 0.85; }
  87%  { opacity: 0.15; }
  90%  { opacity: 0.3; }
  94%  { opacity: 0.05; }
  100% { opacity: 0; }
}

.hw-jack--big {
  bottom: 16px;
  left: 30px;
  width: 58px;
  height: 54px;
}

.hw-jack--medium {
  bottom: 6px;
  left: 2px;
  width: 44px;
  height: 41px;
}

.hw-jack--small {
  bottom: 2px;
  left: 90px;
  width: 32px;
  height: 30px;
}

/* ---------- Criaturas voladoras (murciélagos en bandada / bruja) ---------- */

.hw-creature {
  position: absolute;
  top: 0;
  left: 0;
  width: 56px;
  opacity: 1;
}

.hw-creature svg {
  width: 100%;
  height: auto;
  display: block;
  fill: #000;
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.28)) drop-shadow(0 4px 7px rgba(0, 0, 0, 0.55));
}

.hw-bat {
  animation-name: hw-bat-prowl;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

.hw-bat .hw-bat-svg {
  animation: hw-flap 0.46s ease-in-out infinite;
  transform-origin: 50% 50%;
}

.hw-bat-svg .hw-bat-membrane {
  fill: #000;
  fill-opacity: 0.82;
}

.hw-bat-svg .hw-bat-bones {
  fill: none;
  stroke: #000;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.hw-bat-svg .hw-bat-body {
  fill: #000;
}

.hw-bat-svg .hw-bat-eye {
  fill: #ffb24d;
  filter: drop-shadow(0 0 1.5px rgba(255, 170, 60, 0.9));
}

/* Aleteo visible: el batir de alas se simula variando el ancho (scaleX), que es lo
   que más se nota en una silueta vista de frente/abajo. Cada murciélago recibe su
   propio ritmo (--hw-flap, duración y retardo) para que no se vean sincronizados. */

@keyframes hw-flap {
  0%, 100% { transform: scaleX(1); }
  50%      { transform: scaleX(var(--hw-flap, 0.5)); }
}

/* Murciélagos: avanzan desde la esquina hacia el centro y luego se retiran hacia
   abajo saliendo por un lateral que varía en cada vuelo (--hw-end-x/-y). Tamaño
   por individuo vía --hw-size. */

@keyframes hw-bat-prowl {
  0%   { transform: translate(0, 0) scale(calc(var(--hw-size, 1) * 0.85)) rotate(-4deg); opacity: 0; }
  10%  { opacity: 1; }
  40%  { transform: translate(var(--hw-mid-x, 22vw), var(--hw-mid-y, 18vh)) scale(var(--hw-size, 1)) rotate(3deg); opacity: 1; }
  72%  { transform: translate(var(--hw-end-x, 32vw), var(--hw-end-y, 34vh)) scale(calc(var(--hw-size, 1) * 0.94)) rotate(-7deg); opacity: 0.4; }
  100% { transform: translate(var(--hw-end-x, 32vw), calc(var(--hw-end-y, 34vh) + 6vh)) scale(calc(var(--hw-size, 1) * 0.9)) rotate(-10deg); opacity: 0; }
}

/* ---------- Responsive: reducir escala en móvil para no estorbar contenido ---------- */

@media (max-width: 768px) {
  .hw-web {
    width: 130px;
    height: 130px;
  }

  .hw-web--a,
  .hw-web--b {
    --hw-scale: 0.68;
  }

  .hw-spider-rig {
    transform: scale(0.72);
    transform-origin: top left;
  }

  .hw-pumpkin-group {
    transform: scale(0.72);
    transform-origin: bottom left;
  }

  .hw-creature {
    width: 38px;
  }

  .hw-corner-spider {
    width: 18px;
  }
}

/* ---------- Accesibilidad: respetar reduced-motion ---------- */

@media (prefers-reduced-motion: reduce) {
  #halloween-overlay * {
    animation: none !important;
    transition: none !important;
  }
}
