:root {
  --noche: #120a1f;
  --ciruela: #2a1240;
  --calabaza: #ff7a1a;
  --calabaza-brillante: #ff9d42;
  --hueso: #efe6d2;
  --seda: #c9bfe0;
  --seda-luz: #ebe4fa;
  --luna-brillo: #fff8d6;
  --violeta-aura: #a855f7;
}

/* ==========================================================================
   CANVAS 3D THREE.JS (MURCIÉLAGOS PROCEDURALES Y PARTÍCULAS ESPECTRALES)
   ========================================================================== */
.halloween-three-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 22;
  pointer-events: none !important;
  display: block;
}

/* ==========================================================================
   LUNA DE HALLOWEEN (ATMOSFÉRICA CON AURA DINÁMICA)
   ========================================================================== */
.luna {
  position: fixed;
  top: 76px;
  right: 36px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    #ffffff 0%,
    #fff8d6 30%,
    #efe6d2 60%,
    #c9bfe0 100%
  );
  box-shadow:
    0 0 25px rgba(255, 248, 214, 0.8),
    0 0 65px rgba(168, 85, 247, 0.35),
    0 0 110px rgba(255, 122, 26, 0.2);
  z-index: 20;
  pointer-events: none;
  animation: resplandorLuna 6s ease-in-out infinite alternate;
}

/* Cráteres sutiles en la luna */
.luna::before {
  content: "";
  position: absolute;
  top: 22px;
  left: 20px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(180, 165, 205, 0.25);
  box-shadow:
    24px 8px 0 -3px rgba(180, 165, 205, 0.2),
    14px 28px 0 -4px rgba(180, 165, 205, 0.22);
}

@keyframes resplandorLuna {
  0% {
    box-shadow:
      0 0 22px rgba(255, 248, 214, 0.75),
      0 0 55px rgba(168, 85, 247, 0.3),
      0 0 90px rgba(255, 122, 26, 0.16);
    transform: scale(1);
  }
  100% {
    box-shadow:
      0 0 32px rgba(255, 248, 214, 0.95),
      0 0 80px rgba(168, 85, 247, 0.45),
      0 0 130px rgba(255, 122, 26, 0.28);
    transform: scale(1.02);
  }
}

/* ==========================================================================
   CALABAZA DECORATIVA CON OJOS QUE SE ILUMINAN Y DEJAN DE ILUMINAR
   ========================================================================== */
.calabaza-halloween {
  position: fixed;
  bottom: 88px;
  right: 28px;
  width: 78px;
  height: 74px;
  z-index: 1400; /* Por encima del contenido, no obstruye la barra de navegación ni modales */
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  animation:
    calabazaRespiracion 5s ease-in-out infinite,
    calabazaAuraLuz 6s ease-in-out infinite;
}

.calabaza-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
  transition: filter 0.4s ease;
}

/* Flotación y respiración sutil de la calabaza */
@keyframes calabazaRespiracion {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.025);
  }
}

/* Aura y resplandor exterior de la calabaza sincronizado con los ojos */
@keyframes calabazaAuraLuz {
  /* Apagado / Penumbra (0% a 20%): Solo sombra natural */
  0%, 20% {
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.75));
  }
  /* Empieza a iluminar (22% a 32%) */
  26% {
    filter:
      drop-shadow(0 6px 14px rgba(0, 0, 0, 0.75))
      drop-shadow(0 0 10px rgba(255, 122, 26, 0.45));
  }
  /* Iluminación viva con calor de vela (34% a 68%) */
  35%, 68% {
    filter:
      drop-shadow(0 6px 16px rgba(0, 0, 0, 0.8))
      drop-shadow(0 0 16px rgba(255, 122, 26, 0.75))
      drop-shadow(0 0 32px rgba(255, 80, 0, 0.45));
  }
  /* Se apaga / deja de iluminar (70% a 80%) */
  76% {
    filter:
      drop-shadow(0 6px 14px rgba(0, 0, 0, 0.75))
      drop-shadow(0 0 8px rgba(255, 122, 26, 0.3));
  }
  /* Apagado completo (82% a 100%) */
  82%, 100% {
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.75));
  }
}

/* ==========================================================================
   ANIMACIÓN: SE ILUMINAN LOS OJOS Y DEJAN DE ILUMINAR (FUEGO DE VELA REALISTA)
   ========================================================================== */
.rasgos-fuego-luz {
  animation: ojosIluminarYApagar 6s ease-in-out infinite;
  transform-origin: 50% 55%;
}

@keyframes ojosIluminarYApagar {
  /* FASE 1: TOTALMENTE APAGADO / DEJÓ DE ILUMINAR (0% a 20%) */
  0%, 20% {
    opacity: 0;
    filter: drop-shadow(0 0 0 transparent);
  }
  
  /* FASE 2: ENCIENDE LA LLAMA Y COMIENZA A ILUMINAR (22% a 32%) */
  23% {
    opacity: 0.25;
    filter: drop-shadow(0 0 4px rgba(255, 140, 0, 0.35));
  }
  28% {
    opacity: 0.7;
    filter: drop-shadow(0 0 8px rgba(255, 180, 0, 0.7));
  }
  
  /* FASE 3: ILUMINACIÓN MÁXIMA & VELA ARDIENDO EN LOS OJOS (34% a 68%) */
  34% {
    opacity: 1;
    filter:
      drop-shadow(0 0 5px #ffffff)
      drop-shadow(0 0 12px #ffc107)
      drop-shadow(0 0 22px #ff5722);
  }
  
  /* Micro-parpadeos de llama de vela viva */
  42% {
    opacity: 0.84;
    filter:
      drop-shadow(0 0 4px #fff8d6)
      drop-shadow(0 0 9px #ff9800)
      drop-shadow(0 0 17px #ff3d00);
  }
  
  48% {
    opacity: 1;
    filter:
      drop-shadow(0 0 7px #ffffff)
      drop-shadow(0 0 16px #ffca28)
      drop-shadow(0 0 26px #ff5722);
  }
  
  56% {
    opacity: 0.88;
    filter:
      drop-shadow(0 0 4px #fff8d6)
      drop-shadow(0 0 10px #ffa000)
      drop-shadow(0 0 19px #ff3d00);
  }
  
  65% {
    opacity: 0.98;
    filter:
      drop-shadow(0 0 6px #ffffff)
      drop-shadow(0 0 13px #ffb300)
      drop-shadow(0 0 24px #ff5722);
  }
  
  /* FASE 4: SE APAGA LA LLAMA / DEJA DE ILUMINAR (69% a 80%) */
  73% {
    opacity: 0.45;
    filter: drop-shadow(0 0 5px rgba(255, 110, 0, 0.45));
  }
  78% {
    opacity: 0.12;
    filter: drop-shadow(0 0 2px rgba(255, 60, 0, 0.2));
  }
  
  /* FASE 5: APAGADO COMPLETO (81% a 100%) */
  81%, 100% {
    opacity: 0;
    filter: drop-shadow(0 0 0 transparent);
  }
}

/* ==========================================================================
   TELARAÑAS DINÁMICAS 3D (THREE.JS RUNTIME)
   Las 4 telarañas de las esquinas se generan e interactúan en WebGL (Three.js),
   reaccionando dinámicamente al cursor, viento y murciélagos con física elástica.
   Ocultamos las telarañas SVG estáticas por defecto cuando WebGL está activo.
   ========================================================================== */
.tela-halloween {
  display: none !important;
  position: fixed;
  width: 90px;
  height: 90px;
  z-index: 25;
  pointer-events: none;
  opacity: 0.65;
  filter: drop-shadow(0 0 2px rgba(168, 85, 247, 0.25));
  transition: opacity 0.4s ease;
}

body.no-webgl .tela-halloween {
  display: block !important;
}

.tela-halloween svg {
  width: 100%;
  height: 100%;
  fill: none;
  overflow: visible;
  display: block;
  transform-origin: 0 0;
  animation: brisaTelarana 9s ease-in-out infinite alternate;
}

/* Desfase de animación entre esquinas para movimiento asíncrono y orgánico */
.tela-halloween.arriba-izquierda svg {
  animation-delay: 0s;
}

.tela-halloween.arriba-derecha svg {
  animation-delay: -2.4s;
  animation-duration: 9.6s;
}

.tela-halloween.abajo-izquierda svg {
  animation-delay: -4.8s;
  animation-duration: 8.7s;
}

.tela-halloween.abajo-derecha svg {
  animation-delay: -7.1s;
  animation-duration: 10.2s;
}

/* Hilos principales de soporte (finitos, elegantes y translúcidos) */
.tela-halloween path.hilo-principal {
  stroke: rgba(235, 228, 250, 0.58);
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
}

/* Hilos espirales colgantes con elasticidad reactiva al viento */
.tela-halloween path.hilo-espiral {
  stroke: rgba(201, 191, 224, 0.45);
  stroke-width: 0.85;
  vector-effect: non-scaling-stroke;
  transform-origin: 0 0;
  animation: elasticidadHilos 7s ease-in-out infinite alternate;
}

/* Hilos pares con desfase de elasticidad para evitar movimiento en bloque rígido */
.tela-halloween path.hilo-espiral:nth-of-type(2n) {
  animation: elasticidadHilosSecundarios 8.5s ease-in-out infinite alternate -2.5s;
}

/* Gotas de rocío sutiles en las intersecciones con leve destello */
.tela-halloween circle.nodo-rocio {
  fill: rgba(255, 248, 214, 0.6);
  animation: rocioBrisa 5.5s ease-in-out infinite alternate;
}

/* Ubicación anclada a cada esquina de la pantalla */
.tela-halloween.arriba-izquierda {
  top: 0;
  left: 0;
}

.tela-halloween.arriba-derecha {
  top: 0;
  right: 0;
  transform: scaleX(-1);
}

.tela-halloween.abajo-izquierda {
  bottom: 74px; /* Por encima de la barra de acciones fija */
  left: 0;
  transform: scaleY(-1);
}

.tela-halloween.abajo-derecha {
  bottom: 74px; /* Por encima de la barra de acciones fija */
  right: 0;
  transform: scale(-1);
}

/* ==========================================================================
   ANIMACIONES DE BALANCEO SUAVE Y ELASTICIDAD DE TELARAÑAS
   ========================================================================== */
/* Balanceo pendular sutil desde el vértice de la esquina */
@keyframes brisaTelarana {
  0% {
    transform: rotate(0deg) skewX(0deg);
  }
  25% {
    transform: rotate(0.85deg) skewX(0.4deg);
  }
  50% {
    transform: rotate(-0.6deg) skewX(-0.3deg);
  }
  75% {
    transform: rotate(1.1deg) skewX(0.55deg);
  }
  100% {
    transform: rotate(-0.35deg) skewX(-0.2deg);
  }
}

/* Micro-elasticidad de los arcos de hilo (reacción natural al aire) */
@keyframes elasticidadHilos {
  0% {
    transform: scale(1) translate(0, 0);
  }
  35% {
    transform: scale(1.025, 1.018) translate(0.3px, 0.4px);
  }
  70% {
    transform: scale(0.985, 0.99) translate(-0.3px, -0.2px);
  }
  100% {
    transform: scale(1.015, 1.01) translate(0.2px, 0.3px);
  }
}

/* Elasticidad desfasada para los hilos alternos */
@keyframes elasticidadHilosSecundarios {
  0% {
    transform: scale(1) translate(0, 0);
  }
  40% {
    transform: scale(0.988, 1.022) translate(-0.25px, 0.35px);
  }
  80% {
    transform: scale(1.018, 0.985) translate(0.35px, -0.25px);
  }
  100% {
    transform: scale(1.005, 1.008) translate(0.1px, 0.2px);
  }
}

/* Leve destello y vibración en los puntos de rocío */
@keyframes rocioBrisa {
  0%, 100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.15);
  }
}

/* ==========================================================================
   TELARAÑAS SUTILES EN TARJETAS DE PRODUCTO SELECCIONADAS
   ========================================================================== */
.hw-card-cobweb {
  position: absolute;
  top: 0;
  right: 0;
  width: 42px;
  height: 42px;
  z-index: 4;
  pointer-events: none;
  opacity: 0.35;
  transition: opacity 0.4s ease, transform 0.4s ease, filter 0.4s ease;
  filter: drop-shadow(0 0 2px rgba(168, 85, 247, 0.3));
}

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

.product-card:hover .hw-card-cobweb {
  opacity: 0.85;
  transform: scale(1.08);
  filter:
    drop-shadow(0 0 4px rgba(255, 122, 26, 0.6))
    drop-shadow(0 0 8px rgba(168, 85, 247, 0.4));
}

/* ==========================================================================
   NIEBLA Y BRUMA NOCTURNA EN CAPAS (ATMOSFÉRICA, MOVIMIENTO LENTO)
   ========================================================================== */
.hw-fog-container {
  position: fixed;
  bottom: 70px;
  left: 0;
  width: 100%;
  height: 180px;
  pointer-events: none;
  z-index: 14;
  overflow: hidden;
}

.hw-fog-layer-1 {
  position: absolute;
  bottom: 0;
  left: -20%;
  width: 140%;
  height: 100%;
  background: radial-gradient(
    ellipse 65% 75% at 30% 92%,
    rgba(168, 85, 247, 0.08) 0%,
    rgba(18, 10, 31, 0.04) 50%,
    transparent 80%
  ),
  radial-gradient(
    ellipse 50% 65% at 75% 95%,
    rgba(255, 122, 26, 0.05) 0%,
    transparent 70%
  );
  filter: blur(14px);
  animation: brumaLenta1 42s ease-in-out infinite alternate;
}

.hw-fog-layer-2 {
  position: absolute;
  bottom: 0;
  left: -15%;
  width: 130%;
  height: 100%;
  background: radial-gradient(
    ellipse 75% 70% at 65% 90%,
    rgba(201, 191, 224, 0.07) 0%,
    rgba(15, 8, 25, 0.03) 55%,
    transparent 80%
  ),
  radial-gradient(
    ellipse 45% 60% at 20% 96%,
    rgba(255, 122, 26, 0.04) 0%,
    transparent 65%
  );
  filter: blur(18px);
  animation: brumaLenta2 55s ease-in-out infinite alternate;
}

@keyframes brumaLenta1 {
  0% {
    transform: translateX(0) scaleY(1);
    opacity: 0.4;
  }
  50% {
    transform: translateX(6%) scaleY(1.15);
    opacity: 0.75;
  }
  100% {
    transform: translateX(-4%) scaleY(0.95);
    opacity: 0.5;
  }
}

@keyframes brumaLenta2 {
  0% {
    transform: translateX(0) scaleY(1);
    opacity: 0.45;
  }
  50% {
    transform: translateX(-5%) scaleY(1.1);
    opacity: 0.8;
  }
  100% {
    transform: translateX(5%) scaleY(0.9);
    opacity: 0.4;
  }
}

/* ==========================================================================
   HOVER HALLOWEEN EN PRODUCTOS
   ========================================================================== */
.product-card {
  position: relative; /* Contexto de posicionamiento para la telaraña */
}

.product-card:hover {
  border-color: rgba(255, 122, 26, 0.38) !important;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.55),
    0 0 16px rgba(255, 122, 26, 0.18),
    0 0 28px rgba(168, 85, 247, 0.15) !important;
}

.hw-badge-pumpkin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 6px;
  filter: drop-shadow(0 0 6px rgba(255, 122, 26, 0.65));
}

/* ==========================================================================
   RESPONSIVE DESIGN (PC, TABLET, IPAD Y CELULAR)
   ========================================================================== */
/* Tablet & iPad (768px a 1024px) */
@media (max-width: 1024px) {
  .luna {
    width: 68px;
    height: 68px;
    top: 70px;
    right: 24px;
  }

  .calabaza-halloween {
    width: 66px;
    height: 63px;
    bottom: 82px;
    right: 20px;
  }

  .tela-halloween {
    width: 72px;
    height: 72px;
    opacity: 0.6;
  }

  .tela-halloween.abajo-izquierda,
  .tela-halloween.abajo-derecha {
    bottom: 68px;
  }

  .hw-card-cobweb {
    width: 34px;
    height: 34px;
  }

  .hw-fog-container {
    height: 135px;
    bottom: 66px;
  }
}

/* Celular / Smartphone (<= 768px) */
@media (max-width: 768px) {
  .luna {
    width: 50px;
    height: 50px;
    top: 64px;
    right: 16px;
    /* Optimización móvil: brillo estático nítido para evitar repintado continuo de box-shadow */
    animation: none !important;
    box-shadow:
      0 0 18px rgba(255, 248, 214, 0.8),
      0 0 45px rgba(168, 85, 247, 0.32),
      0 0 75px rgba(255, 122, 26, 0.18) !important;
  }

  .luna::before {
    top: 12px;
    left: 11px;
    width: 10px;
    height: 10px;
  }

  .calabaza-halloween {
    width: 54px;
    height: 51px;
    bottom: 78px;
    right: 14px;
    /* Mantener respiración fluida en transform y omitir animación pesada de drop-shadow exterior */
    animation: calabazaRespiracion 5s ease-in-out infinite !important;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.75)) !important;
  }

  /* Telarañas en celular: mantienen balanceo orgánico al viento en el SVG sin sobrecargar microhilos */
  .tela-halloween {
    width: 48px;
    height: 48px;
    opacity: 0.52;
  }

  .tela-halloween path.hilo-espiral,
  .tela-halloween circle.nodo-rocio {
    animation: none !important; /* El SVG principal sigue balanceándose fluidamente */
  }

  .tela-halloween.abajo-izquierda,
  .tela-halloween.abajo-derecha {
    bottom: 64px;
  }

  .hw-card-cobweb {
    width: 28px;
    height: 28px;
    opacity: 0.25;
  }

  /* Niebla ligera en móvil: una sola capa optimizada */
  .hw-fog-container {
    height: 95px;
    bottom: 62px;
  }

  .hw-fog-layer-1 {
    filter: blur(6px) !important;
  }

  .hw-fog-layer-2 {
    display: none !important;
  }
}

/* Celulares compactos (<= 480px, ej. iPhone SE, Galaxy, pantallas estrechas) */
@media (max-width: 480px) {
  .luna {
    width: 42px;
    height: 42px;
    top: 60px;
    right: 12px;
  }

  .calabaza-halloween {
    width: 46px;
    height: 44px;
    bottom: 74px;
    right: 10px;
  }

  .tela-halloween {
    width: 38px;
    height: 38px;
    opacity: 0.45;
  }

  .tela-halloween.abajo-izquierda,
  .tela-halloween.abajo-derecha {
    bottom: 58px;
  }

  .hw-fog-container {
    height: 70px;
    bottom: 56px;
  }
}

/* ==========================================================================
   ACCESIBILIDAD: PREFERS-REDUCED-MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .luna,
  .calabaza-halloween,
  .hw-fog-layer-1,
  .hw-fog-layer-2,
  .tela-halloween,
  .tela-halloween svg,
  .tela-halloween path.hilo-espiral,
  .tela-halloween circle.nodo-rocio {
    animation: none !important;
  }

  .halloween-three-canvas {
    opacity: 0.6;
  }
}
