/* ============================================================
   EVENTO HALLOWEEN (oct 2026) — se activa SOLO con html[data-theme="halloween"], que pone
   applyEventTheme() cuando el evento activo tiene theme_class='halloween'. Fuera del evento no
   aplica NADA de este fichero (y el wallpaper ni se descarga: solo lo pide el selector activo).
   Fichero APARTE (no dentro de styles.css) porque la versión móvil SUSTITUYE styles.css por
   styles-mobile.css: así PC y móvil comparten el tema sin duplicarlo.
   El PERFIL sigue inmune: su wrapper lleva data-theme="base" y re-deriva sus propias variables.
   Assets: bg.webp (2560px) / bg-sm.webp (1280px, pantallas estrechas) / ghost.webp = hoja del
   fantasma, celdas de 234px en rejilla 7×3 (fila 0 = giro de frente a espaldas, 7 fotogramas;
   fila 1 = vuelo de lado mirando a la DERECHA, 6; fila 2 = regala calabaza, 2).
   ============================================================ */

/* Paleta sacada del propio wallpaper: noche morada, luna naranja, niebla violeta.
   a1 calabaza · a3 brasa · a2 niebla. El degradado de marca (a1→a3→a2) queda luna→brasa→niebla. */
html[data-theme="halloween"] {
  --c-bg:#0C0712; --c-surface:#1C1024; --c-a1:#FF8A1F; --c-a3:#F2542D; --c-a2:#B07CFF; --c-text:#F8EEE4;
  --hw-ink: #2A0F02;                       /* texto oscuro sobre naranja (blanco sobre naranja no se lee) */
  --hw-glow: 0 0 24px rgba(255, 138, 31, 0.35);
}

/* ---------- WALLPAPER ----------
   Sustituye los degradados de body::before por la ilustración + un velo oscuro para que se lea el
   contenido. Capa FIJA y ESTÁTICA en su propia capa de composición (translateZ): al hacer scroll
   el navegador solo la recompone, no la repinta (ver el aviso de rendimiento sobre body::before
   en styles.css — aquí no hay NINGUNA animación). */
html[data-theme="halloween"] body { background: #0C0712; }
html[data-theme="halloween"] body::before {
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgba(12, 7, 18, 0.62) 0%, rgba(12, 7, 18, 0.18) 70%),
    linear-gradient(180deg, rgba(12, 7, 18, 0.30) 0%, rgba(12, 7, 18, 0.42) 45%, rgba(12, 7, 18, 0.80) 100%),
    url(/events/halloween/bg.webp) center 28% / cover no-repeat;
  transform: translateZ(0);
}
@media (max-width: 1100px) {
  html[data-theme="halloween"] body::before {
    background:
      radial-gradient(ellipse 80% 55% at 50% 38%, rgba(12, 7, 18, 0.62) 0%, rgba(12, 7, 18, 0.2) 70%),
      linear-gradient(180deg, rgba(12, 7, 18, 0.30) 0%, rgba(12, 7, 18, 0.45) 45%, rgba(12, 7, 18, 0.82) 100%),
      url(/events/halloween/bg-sm.webp) 62% 28% / cover no-repeat;
  }
}
/* MÓVIL (y cualquier pantalla en vertical): ilustración propia en 9:16 (bg-mobile.webp, 1080px),
   con la luna arriba en el centro. En móvil va por la clase .is-mobile (la pone la detección de
   app.js) solo en VERTICAL — un móvil apaisado usa bg-sm; la media query cubre tablets en vertical y ventanas de PC estrechas. */
@media (orientation: portrait) and (max-aspect-ratio: 4/5) {
  html[data-theme="halloween"] body::before {
    background:
      linear-gradient(180deg, rgba(12, 7, 18, 0.45) 0%, rgba(12, 7, 18, 0.50) 40%, rgba(12, 7, 18, 0.82) 100%),
      url(/events/halloween/bg-mobile.webp) center top / cover no-repeat;
  }
}
@media (orientation: portrait) {
  html.is-mobile[data-theme="halloween"] body::before {
    background:
      linear-gradient(180deg, rgba(12, 7, 18, 0.45) 0%, rgba(12, 7, 18, 0.50) 40%, rgba(12, 7, 18, 0.82) 100%),
      url(/events/halloween/bg-mobile.webp) center top / cover no-repeat;
  }
}
/* El brillo morado del hero tapaba la luna: fuera. */
html[data-theme="halloween"] .hero::before { display: none; }
html[data-theme="halloween"] .hero h1 { text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75); }
/* La parte en degradado va sobre la LUNA (naranja sobre naranja): degradado claro de fuego y la
   sombra con drop-shadow — un text-shadow se vería A TRAVÉS de las letras transparentes y las ensucia. */
html[data-theme="halloween"] .hero-title-gradient {
  background: linear-gradient(100deg, #FFE1A8 0%, #FFB347 40%, #FF7A1A 75%, #FF5A36 100%);
  -webkit-background-clip: text; background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 22px rgba(255, 122, 26, 0.35));
}
html[data-theme="halloween"] .hero p,
html[data-theme="halloween"] .hero-subtitle { color: #EADBD0; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9); }

/* ---------- CABECERA ---------- */
html[data-theme="halloween"] .header {
  background: rgba(10, 5, 15, 0.9);
  border-bottom-color: rgba(255, 138, 31, 0.22);
}

/* ---------- BANNER DEL EVENTO ----------
   Antes: degradado morado→naranja→amarillo pálido con texto blanco encima (ilegible en la mitad
   derecha). Ahora: franja oscura con brasa a los lados y el fantasmita en vez del confeti. */
html[data-theme="halloween"] .event-banner {
  background:
    radial-gradient(ellipse 40% 140% at 0% 50%, rgba(242, 84, 45, 0.35), transparent 70%),
    radial-gradient(ellipse 40% 140% at 100% 50%, rgba(176, 124, 255, 0.30), transparent 70%),
    #140A1C;
  color: #FFE2C2;
  border-bottom: 1px solid rgba(255, 138, 31, 0.35);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  font-weight: 600; letter-spacing: 0.01em;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 10px;
}
html[data-theme="halloween"] .event-banner-txt { display: inline-flex; align-items: center; gap: 8px; }
html[data-theme="halloween"] .event-banner-txt .licon { display: none; }
html[data-theme="halloween"] .event-banner-txt::before {
  content: ''; width: 26px; height: 26px; flex-shrink: 0;
  background: url(/events/halloween/ghost.webp) 0 0 / 700% 300% no-repeat; /* fotograma 0: de frente */
}
html[data-theme="halloween"] .event-banner-link { margin-left: 0; color: #FF9A3C; text-decoration-color: rgba(255, 154, 60, 0.5); text-underline-offset: 3px; }
html[data-theme="halloween"] .event-banner-link:hover { color: #FFC27A; }

/* ---------- BOTONES ----------
   Calabaza con texto oscuro (blanco sobre naranja ≈ 2,3:1, no se lee). */
html[data-theme="halloween"] .btn-primary {
  background: linear-gradient(135deg, #FFA43A 0%, #FF7A1A 55%, #F2542D 100%);
  color: var(--hw-ink);
  box-shadow: 0 4px 20px rgba(255, 122, 26, 0.28);
}
html[data-theme="halloween"] .btn-primary:hover { box-shadow: 0 8px 30px rgba(255, 122, 26, 0.42); }
html[data-theme="halloween"] .btn-primary img { filter: brightness(0) opacity(.75); }
html[data-theme="halloween"] .btn-secondary { border-color: rgba(255, 138, 31, 0.45); }

/* ---------- PANELES DE LA HOME ----------
   Ligeramente translúcidos para que el pueblo se intuya detrás. SIN backdrop-filter a propósito
   (tiraba el scroll de 165 a 96 fps, ver auditoría de rendimiento). */
html[data-theme="halloween"] .featured-section,
html[data-theme="halloween"] .ticker-section {
  background: rgba(24, 13, 31, 0.86);
  border-color: rgba(255, 138, 31, 0.16);
}

/* ============================================================
   FANTASMA QUE SIGUE AL RATÓN (#hw-ghost, lo crea/destruye startHalloweenGhost en app.js)
   El JS solo cambia transform (posición/volteo/inclinación) y background-position (fotograma);
   el tamaño de fondo 700%×300% hace que cada celda de la hoja ocupe exactamente la caja.
   ============================================================ */
#hw-ghost {
  position: fixed; left: 0; top: 0;
  width: 78px; height: 78px;
  pointer-events: none;              /* nunca bloquea un clic */
  z-index: 9000;                     /* sobre la página, bajo modales/lightbox (10000+) */
  background: url(/events/halloween/ghost.webp) 0 0 / 700% 300% no-repeat;
  opacity: 0; transition: opacity .35s ease;
  will-change: transform;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 10px rgba(255, 200, 150, 0.18));
}
#hw-ghost.on { opacity: 0.95; }

/* ---------- REGALO (toast de recompensa diaria) ----------
   El fantasma con la calabaza alterna sus 2 fotogramas. Se usa en el sitio del icono 🎁. */
.hw-gift {
  display: inline-block; width: 64px; height: 64px;
  background: url(/events/halloween/ghost.webp) 0 100% / 700% 300% no-repeat;
  animation: hwGift 0.9s steps(1) infinite;
}
@keyframes hwGift {
  0%   { background-position: 0 100%; transform: translateY(0) rotate(-3deg); }
  50%  { background-position: calc(100% / 6) 100%; transform: translateY(-3px) rotate(3deg); }
}
html[data-theme="halloween"] .daily-reward-emoji:has(.hw-gift) { font-size: 0; line-height: 0; }

@media (prefers-reduced-motion: reduce) {
  .hw-gift { animation: none; }
}
