/* ============================================
   STRANGER THINGS EVENT - UPSIDE DOWN MODE
   Activo: 26 Nov - 1 Ene 2026
   ============================================ */

/* ============================================
   PORTAL BUTTON (Siempre visible) - GRIETA GRANDE EN HERO
   ============================================ */
.upside-down-portal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 300px;
  background: none !important;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  transition: all 0.3s ease;
  overflow: visible;
  filter: drop-shadow(0 0 25px rgba(215, 50, 34, 0.7)) 
          drop-shadow(0 0 50px rgba(164, 46, 75, 0.5));
  animation: portalFadeIn 3s ease-out forwards;
  opacity: 0;
  pointer-events: auto; /* Habilitado para poder hacer click */
}

.upside-down-portal::before {
  display: none;
}

.upside-down-portal::after {
  display: none;
}

/* SVG del portal (realista, sin bordes) */
.portal-crack-svg {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 15px rgba(139, 46, 46, 0.6));
  background: transparent !important;
}

.upside-down-portal:hover {
  transform: translate(-50%, -50%) scale(1.05);
  filter: drop-shadow(0 0 35px rgba(215, 50, 34, 0.9)) 
          drop-shadow(0 0 65px rgba(164, 46, 75, 0.7));
}

/* Animación de aparición orgánica */
@keyframes portalFadeIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
    filter: drop-shadow(0 0 0px rgba(139, 46, 46, 0)) 
            drop-shadow(0 0 0px rgba(74, 31, 58, 0)) 
            blur(8px);
  }
  
  40% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(0.95);
    filter: drop-shadow(0 0 20px rgba(139, 46, 46, 0.5)) 
            drop-shadow(0 0 35px rgba(74, 31, 58, 0.4)) 
            blur(3px);
  }
  
  70% {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1.02);
    filter: drop-shadow(0 0 25px rgba(139, 46, 46, 0.7)) 
            drop-shadow(0 0 45px rgba(74, 31, 58, 0.5)) 
            blur(1px);
  }
  
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: drop-shadow(0 0 25px rgba(215, 50, 34, 0.7)) 
            drop-shadow(0 0 50px rgba(164, 46, 75, 0.5)) 
            blur(0px);
  }
}

/* Efecto de ondas de choque en la página */
@keyframes shockwave {
  0% {
    box-shadow: 0 0 0 0 rgba(215, 50, 34, 0.6);
  }
  100% {
    box-shadow: 0 0 0 100px rgba(215, 50, 34, 0);
  }
}

@keyframes portalPulse {
  0%,
  100% {
    box-shadow: 
      0 0 20px rgba(255, 0, 0, 0.5),
      0 0 40px rgba(139, 0, 0, 0.3),
      inset 0 0 20px rgba(255, 0, 0, 0.2);
  }
  50% {
    box-shadow: 
      0 0 35px rgba(255, 0, 0, 0.8),
      0 0 70px rgba(139, 0, 0, 0.5),
      inset 0 0 30px rgba(255, 0, 0, 0.4);
  }
}

@keyframes portalSwirl {
  from {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.1);
  }
  to {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes portalRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes crackPulse {
  0%, 100% {
    opacity: 0.9;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Tooltip del portal */
.upside-down-portal .portal-tooltip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: #ff0000;
  padding: 8px 16px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  border: 1px solid #ff0000;
  z-index: 10;
}

.upside-down-portal:hover .portal-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(5px);
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

@media (max-width: 968px) {
  .upside-down-portal .portal-tooltip {
    display: none !important;
  }
}

/* ============================================
   UPSIDE DOWN MODE ACTIVATED
   ============================================ */
html.upside-down-active,
body.upside-down-mode {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

body.upside-down-mode {
  /* No agregar propiedades de layout que puedan conflictuar con el body base */
  max-height: none;
  overflow-y: auto;
  position: relative;
}

/* Filtro corrupto - Tonos aterradores de Stranger Things */
body.upside-down-mode::before {
  content: "";
  position: fixed;
  inset: 0;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: 
    linear-gradient(180deg, rgba(30, 7, 7, 0.22) 0%, rgba(30, 25, 60, 0.18) 50%, rgba(30, 7, 7, 0.22) 100%),
    radial-gradient(circle at 30% 30%, rgba(255, 21, 21, 0.1), transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(58, 95, 229, 0.08), transparent 60%),
    radial-gradient(ellipse at 50% 50%, rgba(30, 7, 7, 0.15), transparent 70%);
  pointer-events: none;
  z-index: 9998;
  animation: upsideDownPulse 4s ease-in-out infinite, overlayFlicker 8s ease-in-out infinite;
  mix-blend-mode: multiply;
}

/* Filtro corrupto - Colores oscuros y aterradores (sin brillo excesivo) */
body.upside-down-mode {
  filter: saturate(0.95) brightness(0.85) contrast(1.08) hue-rotate(8deg);
}

/* Venas/grietas orgánicas aterradoras con paleta Stranger Things */
body.upside-down-mode::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background:
    /* Venas ramificadas desde arriba - estilo raíces */
    radial-gradient(ellipse 80px 150px at 20% 0%, rgba(255, 21, 21, 0.4) 0%, transparent 60%),
    radial-gradient(ellipse 60px 200px at 35% 0%, rgba(255, 21, 21, 0.3) 0%, transparent 70%),
    radial-gradient(ellipse 90px 180px at 50% 0%, rgba(255, 21, 21, 0.45) 0%, transparent 65%),
    radial-gradient(ellipse 70px 160px at 65% 0%, rgba(255, 21, 21, 0.35) 0%, transparent 60%),
    radial-gradient(ellipse 85px 190px at 80% 0%, rgba(255, 21, 21, 0.4) 0%, transparent 70%),
    
    /* Venas desde abajo */
    radial-gradient(ellipse 75px 140px at 25% 100%, rgba(255, 21, 21, 0.35) 0%, transparent 65%),
    radial-gradient(ellipse 95px 170px at 50% 100%, rgba(255, 21, 21, 0.4) 0%, transparent 60%),
    radial-gradient(ellipse 65px 155px at 75% 100%, rgba(255, 21, 21, 0.3) 0%, transparent 70%),
    
    /* Venas laterales - azul eléctrico siniestro */
    radial-gradient(ellipse 120px 100px at 0% 30%, rgba(58, 95, 229, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse 140px 90px at 0% 70%, rgba(58, 95, 229, 0.2) 0%, transparent 55%),
    radial-gradient(ellipse 110px 95px at 100% 40%, rgba(58, 95, 229, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse 130px 85px at 100% 60%, rgba(58, 95, 229, 0.2) 0%, transparent 55%),
    
    /* Textura de membrana orgánica */
    repeating-radial-gradient(circle at 30% 30%, transparent 0px, transparent 50px, rgba(30, 7, 7, 0.15) 50px, rgba(30, 7, 7, 0.15) 52px);
  
  pointer-events: none;
  z-index: 9997;
  opacity: 0.8;
  filter: blur(1px);
}

@keyframes upsideDownPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

@keyframes overlayFlicker {
  0%, 100% {
    filter: brightness(1);
  }
  25% {
    filter: brightness(1.05);
  }
  75% {
    filter: brightness(0.95);
  }
}

@keyframes veinsGrow {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.02) rotate(0.5deg);
    opacity: 0.95;
  }
}

@keyframes veinsPulse {
  0%, 100% {
    filter: blur(1px) brightness(1);
  }
  50% {
    filter: blur(0.5px) brightness(1.15);
  }
}

/* Partículas flotantes (esporas) */
.upside-down-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  overflow: hidden;
  max-height: 100vh;
  max-width: 100vw !important;
  width: 100vw !important;
  left: 0 !important;
  right: 0 !important;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, rgba(200, 200, 200, 0.6), rgba(150, 150, 150, 0.3));
  border-radius: 50%;
  animation: float linear infinite;
  opacity: 0;
  box-shadow: 0 0 3px rgba(200, 200, 200, 0.4);
}

/* Algunas partículas más grandes (esporadicamente) */
.particle:nth-child(3n) {
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, rgba(180, 180, 180, 0.5), rgba(120, 120, 120, 0.2));
}

.particle:nth-child(5n) {
  width: 3px;
  height: 3px;
  opacity: 0.7;
}

@keyframes float {
  0% {
    opacity: 0;
    transform: translateY(100vh) translateX(0) rotate(0deg) scale(1);
  }
  5% {
    opacity: 0.9;
    transform: translateY(95vh) translateX(calc(var(--drift) * 0.1)) rotate(15deg) scale(1.3);
  }
  12% {
    transform: translateY(85vh) translateX(calc(var(--drift) * -0.4)) rotate(95deg) scale(0.6);
  }
  18% {
    transform: translateY(78vh) translateX(calc(var(--drift) * 0.6)) rotate(160deg) scale(1.5);
  }
  28% {
    opacity: 1;
    transform: translateY(65vh) translateX(calc(var(--drift) * -0.3)) rotate(245deg) scale(0.7);
  }
  35% {
    transform: translateY(55vh) translateX(calc(var(--drift) * 0.8)) rotate(310deg) scale(1.4);
  }
  45% {
    transform: translateY(45vh) translateX(calc(var(--drift) * -0.5)) rotate(390deg) scale(0.8);
  }
  55% {
    transform: translateY(35vh) translateX(calc(var(--drift) * 0.7)) rotate(470deg) scale(1.3);
  }
  65% {
    transform: translateY(25vh) translateX(calc(var(--drift) * -0.4)) rotate(540deg) scale(0.9);
  }
  75% {
    transform: translateY(15vh) translateX(calc(var(--drift) * 0.5)) rotate(610deg) scale(1.2);
  }
  85% {
    transform: translateY(8vh) translateX(calc(var(--drift) * -0.6)) rotate(680deg) scale(0.7);
  }
  92% {
    opacity: 0.8;
    transform: translateY(2vh) translateX(calc(var(--drift) * 0.4)) rotate(720deg) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) translateX(var(--drift)) rotate(780deg) scale(0.5);
  }
}

/* Efecto glitch en títulos */
body.upside-down-mode h1,
body.upside-down-mode h2,
body.upside-down-mode .hero-title {
  animation: glitchText 0.3s ease-in-out;
  animation-iteration-count: 1;
  animation-delay: var(--glitch-delay, 0s);
}

/* ============================================
   EFECTOS ATERRADORES EN ELEMENTOS
   ============================================ */

/* Cards desgastadas y corruptas */
body.upside-down-mode .feature-card,
body.upside-down-mode .service-card,
body.upside-down-mode .product-card {
  position: relative;
  filter: contrast(1.15) brightness(0.85);
  border: 1px solid rgba(120, 10, 10, 0.5) !important;
  background: rgba(0, 0, 0, 0.2) !important;
  box-shadow: 
    0 0 15px rgba(120, 10, 10, 0.3),
    inset 0 0 40px rgba(0, 0, 0, 0.6),
    inset 0 0 80px rgba(30, 7, 7, 0.4),
    0 4px 20px rgba(0, 0, 0, 0.7);
  animation: cardDistortion 8s ease-in-out infinite, cardFlicker 4s ease-in-out infinite;
}

/* Grietas y desgaste visual en las cards - MÁS VISIBLES */
body.upside-down-mode .feature-card::before,
body.upside-down-mode .service-card::before,
body.upside-down-mode .product-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(45deg, transparent 28%, rgba(120, 10, 10, 0.4) 30%, rgba(120, 10, 10, 0.6) 31%, transparent 33%),
    linear-gradient(-45deg, transparent 46%, rgba(80, 20, 20, 0.35) 48%, rgba(80, 20, 20, 0.5) 49%, transparent 51%),
    linear-gradient(135deg, transparent 60%, rgba(60, 15, 15, 0.3) 62%, transparent 64%),
    repeating-linear-gradient(90deg, transparent, transparent 8px, rgba(30, 7, 7, 0.4) 8px, rgba(30, 7, 7, 0.6) 9px),
    repeating-linear-gradient(0deg, transparent, transparent 12px, rgba(20, 5, 5, 0.35) 12px, rgba(20, 5, 5, 0.5) 13px);
  pointer-events: none;
  z-index: 2;
  opacity: 0.85;
  mix-blend-mode: multiply;
  animation: cracksShift 12s linear infinite;
  border-radius: inherit;
}

/* Bordes irregulares y efecto de corrosión - MÁS VISIBLE */
body.upside-down-mode .feature-card::after,
body.upside-down-mode .service-card::after,
body.upside-down-mode .product-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  background: linear-gradient(45deg, 
    rgba(120, 10, 10, 0.6) 0%, 
    rgba(80, 20, 20, 0.4) 15%,
    transparent 25%, 
    transparent 75%, 
    rgba(80, 20, 20, 0.4) 85%,
    rgba(120, 10, 10, 0.6) 100%);
  border-radius: inherit;
  filter: blur(6px) contrast(1.8);
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
  animation: corrosionPulse 6s ease-in-out infinite;
}

/* Hover en cards - efecto más errático */
body.upside-down-mode .feature-card:hover,
body.upside-down-mode .service-card:hover,
body.upside-down-mode .product-card:hover {
  transform: translateY(-8px) scale(1.02) rotate(0.5deg);
  box-shadow: 
    0 0 35px rgba(255, 21, 21, 0.4),
    inset 0 0 40px rgba(0, 0, 0, 0.5),
    0 8px 25px rgba(0, 0, 0, 0.7);
  animation: cardDistortion 8s ease-in-out infinite, cardGlitch 0.3s ease-in-out;
}

/* Textos con efecto de interferencia - menos brillante */
body.upside-down-mode .feature-title,
body.upside-down-mode .service-title,
body.upside-down-mode .product-title,
body.upside-down-mode h1,
body.upside-down-mode h2,
body.upside-down-mode h3 {
  text-shadow: 
    1px 1px 0 rgba(120, 10, 10, 0.4),
    -1px -1px 0 rgba(40, 50, 100, 0.25),
    0 0 8px rgba(80, 5, 5, 0.3);
  animation: textFlicker 5s ease-in-out infinite;
}

/* Imágenes con distorsión */
body.upside-down-mode img,
body.upside-down-mode .feature-icon,
body.upside-down-mode .service-icon {
  filter: contrast(1.3) brightness(0.85) saturate(0.8);
  animation: imageDistortion 7s ease-in-out infinite;
}

/* Botones con pulsación errática - menos brillante */
body.upside-down-mode button,
body.upside-down-mode .btn,
body.upside-down-mode a.button {
  box-shadow: 
    0 0 12px rgba(120, 10, 10, 0.25),
    inset 0 0 10px rgba(0, 0, 0, 0.4);
  animation: buttonPulse 3s ease-in-out infinite;
}

body.upside-down-mode button:hover,
body.upside-down-mode .btn:hover,
body.upside-down-mode a.button:hover {
  box-shadow: 
    0 0 18px rgba(120, 10, 10, 0.35),
    inset 0 0 15px rgba(0, 0, 0, 0.5);
  animation: buttonGlitch 0.2s ease-in-out;
}

/* Animaciones de efectos aterradores */
@keyframes cardDistortion {
  0%, 100% {
    transform: translateY(0) scale(1) rotate(0deg) skewX(0deg) skewY(0deg);
  }
  8% {
    transform: translateY(-5px) scale(1.015) rotate(1.2deg) skewX(1deg) skewY(0.3deg);
  }
  15% {
    transform: translateY(4px) scale(0.99) rotate(-0.8deg) skewX(-0.8deg) skewY(-0.5deg);
  }
  23% {
    transform: translateY(-3px) scale(1.02) rotate(1.5deg) skewX(1.2deg) skewY(0.4deg);
  }
  32% {
    transform: translateY(6px) scale(0.985) rotate(-1deg) skewX(-1deg) skewY(-0.6deg);
  }
  40% {
    transform: translateY(-4px) scale(1.018) rotate(0.9deg) skewX(0.9deg) skewY(0.2deg);
  }
  50% {
    transform: translateY(0) scale(0.992) rotate(-0.7deg) skewX(-0.7deg) skewY(-0.4deg);
  }
  58% {
    transform: translateY(5px) scale(1.012) rotate(1.1deg) skewX(1.1deg) skewY(0.5deg);
  }
  67% {
    transform: translateY(-6px) scale(0.995) rotate(-1.3deg) skewX(-0.9deg) skewY(-0.3deg);
  }
  76% {
    transform: translateY(3px) scale(1.008) rotate(0.8deg) skewX(0.6deg) skewY(0.4deg);
  }
  85% {
    transform: translateY(-4px) scale(0.997) rotate(-0.9deg) skewX(-0.8deg) skewY(-0.2deg);
  }
  93% {
    transform: translateY(2px) scale(1.005) rotate(0.5deg) skewX(0.4deg) skewY(0.2deg);
  }
}

@keyframes cardFlicker {
  0%, 100% {
    opacity: 1;
    filter: contrast(1.2) brightness(0.9) hue-rotate(0deg) saturate(1);
  }
  3% {
    opacity: 0.75;
    filter: contrast(1.6) brightness(0.6) hue-rotate(5deg) saturate(0.7);
  }
  6% {
    opacity: 1;
    filter: contrast(1.2) brightness(0.9) hue-rotate(0deg) saturate(1);
  }
  12% {
    opacity: 0.65;
    filter: contrast(1.8) brightness(0.5) hue-rotate(-4deg) saturate(0.6);
  }
  14% {
    opacity: 0.95;
    filter: contrast(1.3) brightness(0.85) hue-rotate(2deg) saturate(0.9);
  }
  18% {
    opacity: 0.7;
    filter: contrast(1.7) brightness(0.55) hue-rotate(6deg) saturate(0.65);
  }
  22% {
    opacity: 1;
    filter: contrast(1.2) brightness(0.9) hue-rotate(0deg) saturate(1);
  }
  35% {
    opacity: 0.8;
    filter: contrast(1.5) brightness(0.7) hue-rotate(-3deg) saturate(0.75);
  }
  38% {
    opacity: 1;
    filter: contrast(1.2) brightness(0.9) hue-rotate(0deg) saturate(1);
  }
  52% {
    opacity: 0.72;
    filter: contrast(1.65) brightness(0.62) hue-rotate(4deg) saturate(0.7);
  }
  56% {
    opacity: 1;
    filter: contrast(1.2) brightness(0.9) hue-rotate(0deg) saturate(1);
  }
  68% {
    opacity: 0.78;
    filter: contrast(1.55) brightness(0.68) hue-rotate(-5deg) saturate(0.72);
  }
  72% {
    opacity: 1;
    filter: contrast(1.2) brightness(0.9) hue-rotate(0deg) saturate(1);
  }
  88% {
    opacity: 0.82;
    filter: contrast(1.48) brightness(0.75) hue-rotate(3deg) saturate(0.8);
  }
  92% {
    opacity: 1;
    filter: contrast(1.2) brightness(0.9) hue-rotate(0deg) saturate(1);
  }
}

@keyframes cardGlitch {
  0%, 100% {
    transform: translateY(-8px) scale(1.02) rotate(0.5deg);
  }
  25% {
    transform: translateY(-8px) scale(1.02) rotate(0.5deg) translateX(-3px);
  }
  50% {
    transform: translateY(-8px) scale(1.02) rotate(0.5deg) translateX(3px);
  }
  75% {
    transform: translateY(-8px) scale(1.02) rotate(0.5deg) translateX(-2px);
  }
}

@keyframes cracksShift {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.6;
  }
  50% {
    transform: translate(2px, -2px);
    opacity: 0.8;
  }
}

@keyframes corrosionPulse {
  0%, 100% {
    opacity: 0;
  }
  50% {
    opacity: 0.4;
  }
}

@keyframes textFlicker {
  0%, 100% {
    opacity: 1;
  }
  5% {
    opacity: 0.9;
  }
  10% {
    opacity: 1;
  }
  15% {
    opacity: 0.95;
  }
  20%, 80% {
    opacity: 1;
  }
  85% {
    opacity: 0.92;
  }
  90% {
    opacity: 1;
  }
}

@keyframes imageDistortion {
  0%, 100% {
    transform: scale(1) rotate(0deg) skewX(0deg);
    filter: contrast(1.3) brightness(0.85) saturate(0.8) hue-rotate(0deg);
  }
  12% {
    transform: scale(1.03) rotate(1.2deg) skewX(0.8deg);
    filter: contrast(1.55) brightness(0.72) saturate(0.65) hue-rotate(5deg);
  }
  25% {
    transform: scale(0.96) rotate(-1deg) skewX(-0.9deg);
    filter: contrast(1.2) brightness(0.92) saturate(0.88) hue-rotate(-3deg);
  }
  38% {
    transform: scale(1.025) rotate(0.8deg) skewX(0.6deg);
    filter: contrast(1.48) brightness(0.78) saturate(0.7) hue-rotate(4deg);
  }
  50% {
    transform: scale(0.98) rotate(-0.7deg) skewX(-0.7deg);
    filter: contrast(1.35) brightness(0.85) saturate(0.8) hue-rotate(-2deg);
  }
  62% {
    transform: scale(1.02) rotate(0.9deg) skewX(0.7deg);
    filter: contrast(1.42) brightness(0.8) saturate(0.73) hue-rotate(3deg);
  }
  75% {
    transform: scale(0.97) rotate(-0.8deg) skewX(-0.6deg);
    filter: contrast(1.38) brightness(0.83) saturate(0.78) hue-rotate(-4deg);
  }
  88% {
    transform: scale(1.015) rotate(0.5deg) skewX(0.4deg);
    filter: contrast(1.45) brightness(0.82) saturate(0.75) hue-rotate(2deg);
  }
}

@keyframes buttonPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 
      0 0 12px rgba(120, 10, 10, 0.25),
      inset 0 0 10px rgba(0, 0, 0, 0.4);
  }
  50% {
    transform: scale(1.01);
    box-shadow: 
      0 0 15px rgba(120, 10, 10, 0.3),
      inset 0 0 12px rgba(0, 0, 0, 0.45);
  }
}

@keyframes buttonGlitch {
  0%, 100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-2px, 1px);
  }
  50% {
    transform: translate(2px, -1px);
  }
  75% {
    transform: translate(-1px, 0);
  }
}

@keyframes glitchText {
  0% {
    transform: translate(0) skewX(0deg);
    opacity: 1;
    filter: blur(0px) hue-rotate(0deg);
  }
  10% {
    transform: translate(-8px, 5px) skewX(4deg);
    opacity: 0.6;
    filter: blur(2px) hue-rotate(15deg);
  }
  15% {
    transform: translate(6px, -6px) skewX(-5deg);
    opacity: 0.75;
    filter: blur(3px) hue-rotate(-10deg);
  }
  25% {
    transform: translate(-5px, 4px) skewX(3deg);
    opacity: 0.5;
    filter: blur(4px) hue-rotate(20deg);
  }
  30% {
    transform: translate(9px, -3px) skewX(-4deg);
    opacity: 0.8;
    filter: blur(1px) hue-rotate(-15deg);
  }
  40% {
    transform: translate(-7px, -5px) skewX(5deg);
    opacity: 0.65;
    filter: blur(3px) hue-rotate(12deg);
  }
  50% {
    transform: translate(0) skewX(0deg);
    opacity: 1;
    filter: blur(0px) hue-rotate(0deg);
  }
  60% {
    transform: translate(6px, 6px) skewX(-3deg);
    opacity: 0.7;
    filter: blur(2px) hue-rotate(-18deg);
  }
  70% {
    transform: translate(-6px, -4px) skewX(4deg);
    opacity: 0.75;
    filter: blur(3px) hue-rotate(8deg);
  }
  80% {
    transform: translate(4px, 3px) skewX(-2deg);
    opacity: 0.85;
    filter: blur(1px) hue-rotate(-5deg);
  }
  90% {
    transform: translate(-3px, 5px) skewX(2deg);
    opacity: 0.8;
    filter: blur(2px) hue-rotate(10deg);
  }
  100% {
    transform: translate(0) skewX(0deg);
    opacity: 1;
    filter: blur(0px) hue-rotate(0deg);
  }
}

/* Footer - Excluir del filtro de color del body */
body.upside-down-mode footer,
body.upside-down-mode .footer {
  filter: saturate(1.05) brightness(1.18) contrast(0.93) hue-rotate(-8deg);
}

/* Logo con luces parpadeantes */
body.upside-down-mode .nav-logo img,
body.upside-down-mode .footer-logo {
  animation: flickerLights 4s ease-in-out infinite;
}

@keyframes flickerLights {
  0%,
  100% {
    filter: brightness(1) drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
  }
  5% {
    filter: brightness(0.7) drop-shadow(0 0 5px rgba(255, 0, 0, 0.3));
  }
  10% {
    filter: brightness(1) drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
  }
  50% {
    filter: brightness(1) drop-shadow(0 0 15px rgba(255, 0, 0, 0.6));
  }
  55% {
    filter: brightness(0.5) drop-shadow(0 0 5px rgba(255, 0, 0, 0.2));
  }
  60% {
    filter: brightness(1) drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
  }
}

/* Banner de evento (opcional) */
.stranger-things-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #1a0000, #0d0000, #1a0000);
  color: #ff3333;
  text-align: center;
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 700;
  z-index: 10001;
  display: none;
  animation: bannerGlow 3s ease-in-out infinite;
  border-bottom: 2px solid #8b0000;
  text-shadow: 0 0 10px rgba(255, 51, 51, 0.5);
  letter-spacing: 0.5px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
}

/* Mostrar solo versión desktop por defecto */
.banner-mobile {
  display: none;
}

.banner-desktop {
  display: inline;
}

body.upside-down-mode .stranger-things-banner {
  display: block;
}

/* Ajustar espacio para el banner */
body.upside-down-mode {
  padding-top: 48px;
}

/* Asegurar que la grieta no quede debajo del banner al hacer scroll */
body.upside-down-mode .upside-down-portal {
  margin-top: 60px;
}

/* CRÍTICO: Ocultar elementos que causan scroll infinito en Upside Down */
body.upside-down-mode .cookie-consent,
body.upside-down-mode #easter-egg-tracker {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(200%) !important;
  max-height: 0 !important;
  overflow: hidden !important;
}

/* ============================================
   EFECTO DE RELÁMPAGOS (Lightning Effect)
   ============================================ */
.lightning-effect {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.15), transparent 70%);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 0.05s;
}

@keyframes bannerGlow {
  0%,
  100% {
    box-shadow: 0 4px 20px rgba(255, 0, 0, 0.4);
  }
  50% {
    box-shadow: 0 4px 30px rgba(255, 0, 0, 0.7);
  }
}

.demogorgon-emoji {
  display: inline-block;
  font-size: 20px;
  vertical-align: middle;
  animation: demogorgonBreathe 2s ease-in-out infinite;
  filter: 
    brightness(0.25) 
    saturate(8) 
    hue-rotate(340deg) 
    contrast(2.5)
    drop-shadow(0 0 8px rgba(200, 0, 0, 0.9));
}

@keyframes demogorgonBreathe {
  0%, 100% {
    transform: scale(1);
    filter: 
      brightness(0.25) 
      saturate(8) 
      hue-rotate(340deg) 
      contrast(2.5)
      drop-shadow(0 0 8px rgba(200, 0, 0, 0.9));
  }
  50% {
    transform: scale(1.15);
    filter: 
      brightness(0.3) 
      saturate(9) 
      hue-rotate(340deg) 
      contrast(2.8)
      drop-shadow(0 0 12px rgba(220, 20, 20, 1));
  }
}

/* Transición épica al cambiar de modo */
body.portal-transition {
  animation: portalWarp 2s ease-in-out;
}

@keyframes portalWarp {
  0% {
    transform: scale(1);
    filter: blur(0) hue-rotate(0deg);
  }
  25% {
    transform: scale(0.95);
    filter: blur(5px) hue-rotate(90deg);
  }
  50% {
    transform: scale(1.05);
    filter: blur(10px) hue-rotate(180deg);
  }
  75% {
    transform: scale(0.98);
    filter: blur(5px) hue-rotate(270deg);
  }
  100% {
    transform: scale(1);
    filter: blur(0) hue-rotate(360deg);
  }
}

/* Ajustes responsive */
/* ============================================
   RESPONSIVE - TABLET & MOBILE
   ============================================ */

/* Tablet (768px - 968px) */
@media (max-width: 968px) and (min-width: 769px) {
  .upside-down-portal {
    top: 72%;
    width: 200px;
    height: 220px;
  }

  .stranger-things-banner {
    font-size: 13px;
    padding: 11px 18px;
  }

  body.upside-down-mode {
    padding-top: 46px;
  }

  body.upside-down-mode .upside-down-portal {
    margin-top: 50px;
  }

  /* Partículas menos densas */
  body.upside-down-mode .upside-down-particles {
    opacity: 0.7;
  }
}

/* Mobile grande (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
  .upside-down-portal {
    top: 70%;
    width: 240px;
    height: 260px;
  }

  .stranger-things-banner {
    font-size: 13px;
    padding: 9px 12px;
    letter-spacing: 0.3px;
  }

  .banner-desktop {
    display: none;
  }

  .banner-mobile {
    display: inline;
  }

  body.upside-down-mode {
    padding-top: 44px;
  }

  body.upside-down-mode .upside-down-portal {
    margin-top: 48px;
  }

  /* Reducir efectos pesados */
  body.upside-down-mode::after {
    opacity: 0.5;
  }

  body.upside-down-mode .upside-down-particles {
    opacity: 0.6;
  }
}

/* Mobile pequeño (≤ 480px) */
@media (max-width: 480px) {
  .upside-down-portal {
    top: 72%;
    width: 220px;
    height: 240px;
  }

  .stranger-things-banner {
    font-size: 13px;
    padding: 9px 10px;
    letter-spacing: 0.2px;
  }

  .banner-desktop {
    display: none;
  }

  .banner-mobile {
    display: inline;
  }

  body.upside-down-mode {
    padding-top: 44px;
  }

  body.upside-down-mode .upside-down-portal {
    margin-top: 48px;
  }

  /* Optimizar performance en móviles pequeños */
  body.upside-down-mode::before {
    animation: upsideDownPulse 6s ease-in-out infinite;
  }

  body.upside-down-mode::after {
    opacity: 0.4;
    animation: organicPulse 12s ease-in-out infinite;
  }

  body.upside-down-mode .upside-down-particles {
    opacity: 0.5;
  }

  /* Reducir sombras para performance */
  .upside-down-portal {
    filter: drop-shadow(0 0 15px rgba(215, 50, 34, 0.6)) 
            drop-shadow(0 0 30px rgba(164, 46, 75, 0.4));
  }

  .upside-down-portal:hover {
    filter: drop-shadow(0 0 20px rgba(215, 50, 34, 0.7)) 
            drop-shadow(0 0 40px rgba(164, 46, 75, 0.5));
  }
}

/* Landscape móvil (altura reducida) */
@media (max-height: 600px) and (orientation: landscape) {
  .upside-down-portal {
    top: 65%;
    width: 180px;
    height: 200px;
  }

  .stranger-things-banner {
    font-size: 10px;
    padding: 6px 10px;
  }

  body.upside-down-mode {
    padding-top: 32px;
  }

  /* Reducir efectos en landscape */
  body.upside-down-mode::after {
    display: none;
  }

  body.upside-down-mode .upside-down-particles {
    opacity: 0.3;
  }
}

/* Breakpoints adicionales para texto del banner */
@media (max-width: 600px) {
  .stranger-things-banner {
    font-size: 11px;
    padding: 9px 12px;
  }
}

@media (max-width: 400px) {
  .stranger-things-banner {
    font-size: 9px;
    padding: 7px 8px;
    letter-spacing: 0.1px;
  }
}

@media (max-width: 360px) {
  .stranger-things-banner {
    font-size: 8.5px;
    padding: 6px 5px;
    letter-spacing: 0;
  }
}

/* Modo oscuro compatibility */
@media (prefers-color-scheme: dark) {
  body.upside-down-mode::before {
    background: linear-gradient(
      180deg,
      rgba(139, 0, 0, 0.25) 0%,
      rgba(74, 0, 0, 0.18) 50%,
      rgba(139, 0, 0, 0.25) 100%
    );
  }
}
