/**
 * Hero Hover Plugin - Estilos Frontend
 * Animaciones modernas y diseño responsive
 */

/* ========================================
   CONTENEDOR PRINCIPAL
======================================== */
.hero-hover-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
}

/* Clases para identificar el tipo de dispositivo */
.hero-hover-container.device-desktop .hero-hover-background {
  transition: background-image 0.3s ease;
}

.hero-hover-container.device-tablet .hero-hover-background {
  transition: background-image 0.3s ease;
}

.hero-hover-container.device-mobile .hero-hover-background {
  transition: background-image 0.3s ease;
}

/* ========================================
   IMAGEN DE FONDO
======================================== */
.hero-hover-background {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* Ratio base - se puede ajustar dinámicamente */
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
}

/* ========================================
   EDIFICIOS INTERACTIVOS
======================================== */
.hero-hover-building {
  position: absolute;
  z-index: 10;
  transform: translate(-50%, -50%);
  transition: z-index 0s 0s;
}

.hero-hover-building.active {
  z-index: 100;
  transition: z-index 0s 0s;
}

/* ========================================
   ICONO GIF ANIMADO
======================================== */
.hero-hover-icon {
  position: relative;
  width: 60px;
  height: 60px;
  cursor: pointer;
  animation: iconPulse 2s ease-in-out infinite;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hero-hover-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

/* Animación de pulso sutil */
@keyframes iconPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.9;
  }
}

/* Hover sobre el icono */
.hero-hover-icon:hover {
  transform: scale(1.15);
}

/* Ocultar icono cuando está activo */
.hero-hover-building.active .hero-hover-icon {
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
}

/* ========================================
   BOTÓN TRIGGER (ÁREA CLICABLE)
======================================== */
.hero-hover-trigger {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: transparent !important;
  border: none;
  cursor: pointer;
  outline: none;
  z-index: 5;
  padding: 0;
}

/* Eliminar focus visible que causaba círculo rosado */
.hero-hover-trigger:focus {
  outline: none;
  background: transparent !important;
}

.hero-hover-trigger:hover {
  background: transparent !important;
}

/* ========================================
   CONTENIDO HOVER (OVERLAY + BURBUJA)
======================================== */

/* Contenedor del contenido (overlay + burbuja) */
.hero-hover-container .hero-hover-content {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
  z-index: 20 !important;
}

/* En desktop (>1024px), permitir pointer-events para mantener el hover */
@media (min-width: 1025px) {
  .hero-hover-container .hero-hover-item:hover .hero-hover-content,
  .hero-hover-container .hero-hover-item:focus-within .hero-hover-content {
    pointer-events: auto !important;
  }
}

/* En móvil/tablet (≤1024px), mantener pointer-events: none para que clics pasen */
@media (max-width: 1024px) {
  .hero-hover-container .hero-hover-content.active {
    pointer-events: none !important;
  }
}

/* ========================================
   OVERLAY DEL EDIFICIO
======================================== */
.hero-hover-container .hero-hover-overlay {
  position: absolute !important;
  transform: translate(-50%, -50%) scale(0.85) !important;
  opacity: 0 !important;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform-origin: center center !important;
  pointer-events: none !important;
  /* Tamaño por defecto - se sobrescribe con CSS inline por edificio */
  width: clamp(280px, 35%, 650px) !important;
  z-index: 10 !important;
}

/* Tamaños específicos por edificio (se generan dinámicamente en el shortcode) */
/* Estos valores se pueden personalizar desde el backoffice */

.hero-hover-overlay img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.4));
}

/* Estado activo del overlay */
.hero-hover-container .hero-hover-item:hover .hero-hover-overlay,
.hero-hover-container .hero-hover-item:focus-within .hero-hover-overlay,
.hero-hover-container .hero-hover-content.active .hero-hover-overlay {
  opacity: 1 !important;
  transform: translate(-50%, -50%) scale(1) !important;
  animation: overlayFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
  pointer-events: auto !important;
}

@keyframes overlayFadeIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ========================================
   BURBUJA CON LOGO
======================================== */
.hero-hover-container .hero-hover-bubble {
  position: absolute !important;
  transform: translate(-50%, -50%) !important;
  opacity: 0 !important;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s,
    transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s !important;
  pointer-events: none !important;
  /* Tamaño por defecto - se sobrescribe con CSS inline por edificio */
  width: clamp(200px, 25%, 450px) !important;
  z-index: 15 !important;
}

/* Tamaños específicos por edificio (se generan dinámicamente en el shortcode) */
/* Estos valores se pueden personalizar desde el backoffice */

.hero-hover-bubble img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.3));
}

.hero-hover-bubble a {
  display: block;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.hero-hover-bubble a:hover {
  transform: scale(1.05);
}

/* Estado activo de la burbuja */
.hero-hover-container .hero-hover-item:hover .hero-hover-bubble,
.hero-hover-container .hero-hover-item:focus-within .hero-hover-bubble,
.hero-hover-container .hero-hover-content.active .hero-hover-bubble {
  opacity: 1 !important;
  pointer-events: auto !important;
  animation: bubbleSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards !important;
}

/* Overlay temporal para romper el hover en desktop */
.break-hover-overlay {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 999 !important;
  pointer-events: auto !important;
  background: transparent !important;
  cursor: default !important;
}

@keyframes bubbleSlideIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0);
  }
}

/* ========================================
   POSICIONAMIENTO ESPECÍFICO POR EDIFICIO
   (Las posiciones se controlan dinámicamente desde PHP)
======================================== */

/* ========================================
   OVERLAY DE FONDO AL ACTIVAR
======================================== */
.hero-hover-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  z-index: 5;
  pointer-events: none;
  transition: background 0.4s ease;
}

.hero-hover-container.has-active::before {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

/* ========================================
   COMPORTAMIENTO HOVER EN DESKTOP
======================================== */

/* En desktop (>1024px), usar hover en lugar de click */
@media (min-width: 1025px) {
  /* Limitar altura del contenedor a 80vh en desktop */
  .hero-hover-container {
    max-height: 80vh;
  }

  .hero-hover-background {
    max-height: 80vh;
    background-position: center center;
  }

  .hero-hover-container .hero-hover-item:hover .hero-hover-icon {
    opacity: 0 !important;
    transform: scale(0.5) !important;
    pointer-events: none !important;
  }

  .hero-hover-container .hero-hover-item:hover {
    z-index: 100 !important;
  }

  /* Activar overlay de fondo oscuro en hover (desktop) */
  .hero-hover-container:has(.hero-hover-item:hover)::before {
    background: rgba(0, 0, 0, 0.5) !important;
    pointer-events: auto !important;
  }
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */

/* Tablets y pantallas medianas */
@media (max-width: 1024px) {
  .hero-hover-icon {
    width: 50px;
    height: 50px;
  }
  /* Tamaños de overlay y burbuja manejados por clamp() global */
}

/* Móviles */
@media (max-width: 768px) {
  .hero-hover-icon {
    width: 40px;
    height: 40px;
  }

  .hero-hover-trigger {
    width: 60px;
    height: 60px;
  }
  /* Tamaños de overlay y burbuja manejados por clamp() global */
}

/* Móviles pequeños */
@media (max-width: 480px) {
  .hero-hover-icon {
    width: 35px;
    height: 35px;
  }
  /* Tamaños de overlay y burbuja manejados por clamp() global */
}

/* ========================================
   ACCESIBILIDAD
======================================== */

/* Reducir animaciones para usuarios con preferencias */
@media (prefers-reduced-motion: reduce) {
  .hero-hover-icon {
    animation: none;
  }

  .hero-hover-overlay,
  .hero-hover-bubble {
    transition-duration: 0.1s;
    animation: none;
  }
}

/* Focus visible mejorado sin círculo rosado */
.hero-hover-trigger:focus-visible {
  outline: none;
}

/* ========================================
   ESTADOS DE CARGA
======================================== */
.hero-hover-container.loading {
  min-height: 400px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
