/* ===================================================================
   SPLASH SCREEN - LEAD INMOBILIARIA
   Pantalla de carga profesional con animación del logo
   =================================================================== */

/* ===== OCULTAR LOADER ANTIGUO ===== */
.site-loader {
  display: none !important; /* ← Ocultar el loader antiguo feo */
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ===== VARIABLES DE MARCA ===== */
:root {
  --splash-bg: #f8fbf0;           /* Fondo verde muy claro */
  --splash-overlay: rgba(244, 247, 232, 0.98);
  --lead-primary: #6e8e00;
  --lead-accent: #F4FE81;
}

/* ===== CONTENEDOR DEL SPLASH SCREEN ===== */
#lead-splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #ffffff 0%, var(--splash-bg) 50%, #ffffff 100%);
  z-index: 999999; /* ← Aumentado para estar sobre TODO */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              backdrop-filter 0.4s ease-out;
  pointer-events: none;
  backdrop-filter: blur(0px);
  /* CRÍTICO: Asegurar que sea visible desde el primer frame */
  opacity: 1;
  visibility: visible;
}

/* Durante el splash, evitar interacciones pero permitir carga de imágenes */
#lead-splash-screen:not(.hidden) {
  pointer-events: all;
  backdrop-filter: blur(8px);
}

/* Estado: splash screen oculto - transición más suave */
#lead-splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  backdrop-filter: blur(0px);
  transform: scale(1.05);
}

/* ===== CONTENEDOR DEL LOGO ===== */
.splash-logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: logoFadeIn 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  will-change: transform, opacity;
  position: relative;
  /* Estado inicial y final: centrado y escala 1 */
  transform: translate(0, 0) scale(1);
  opacity: 0; /* Comienza invisible */
}

/* Después de logoFadeIn, mantener estado estable hasta que comience el movimiento */
.splash-logo-container:not(.splash-logo-container-moving) {
  /* Asegurar que después de logoFadeIn, el contenedor esté en estado neutral */
  animation-fill-mode: forwards;
}

/* Animación de entrada del logo - suave sin escalas extremas */
@keyframes logoFadeIn {
  0% {
    opacity: 0;
    transform: translate(0, 20px) scale(0.9);
  }
  70% {
    opacity: 1;
    transform: translate(0, -3px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

/* ===== LOGO DE LEAD INMOBILIARIA ===== */
.splash-logo {
  width: 200px; /* Reducido para que se vea completo */
  max-width: 90vw; /* Responsive */
  height: auto;
  margin-bottom: 30px;
  animation: logoBreathe 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(110, 142, 0, 0.15));
  will-change: transform, filter;
  /* CRÍTICO: Heredar opacity del contenedor para evitar flash del logo gigante */
  opacity: inherit;
}

/* Animación de respiración del logo - suave y sutil */
@keyframes logoBreathe {
  0%, 100% {
    transform: scale(1) translateY(0);
    filter: drop-shadow(0 8px 24px rgba(110, 142, 0, 0.15));
  }
  50% {
    transform: scale(1.04) translateY(-4px);
    filter: drop-shadow(0 12px 32px rgba(110, 142, 0, 0.25));
  }
}

/* ===== TEXTO DEBAJO DEL LOGO ===== */
.splash-text {
  font-family: 'Georgia Pro', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--lead-primary);
  letter-spacing: 2px;
  margin-bottom: 20px;
  animation: textPulse 3s ease-in-out infinite;
  will-change: opacity, transform;
}

@keyframes textPulse {
  0%, 100% {
    opacity: 0.7;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* ===== SPINNER ELEGANTE ===== */
.splash-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(110, 142, 0, 0.1);
  border-top-color: var(--lead-primary);
  border-right-color: var(--lead-accent);
  border-radius: 50%;
  animation: spin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  box-shadow: 0 4px 12px rgba(110, 142, 0, 0.2);
  will-change: transform;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ===== ANIMACIÓN: LOGO SE MUEVE A LA ESQUINA ===== */
/* Animación fluida solo con transform (acelerada por GPU) */

/* CRÍTICO: Detener TODAS las animaciones secundarias cuando comienza el movimiento */
#lead-splash-screen.moving .splash-logo {
  animation: none !important; /* Detener logoBreathe para evitar conflicto */
  transform: scale(1) translateY(0) !important; /* Estado neutral */
  /* Transición suave de 200ms para evitar salto brusco */
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#lead-splash-screen.moving .splash-text {
  animation: fadeOutText 0.8s ease-out forwards !important; /* Solo fade out, sin textPulse */
}

#lead-splash-screen.moving .splash-spinner {
  animation: fadeOutSpinner 0.8s ease-out 0.1s forwards, spin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite !important;
}

#lead-splash-screen.moving .splash-logo-container {
  /* Calcular offset desde centro a esquina superior izquierda */
  /* Centro está en 50vw, 50vh. Esquina está en ~50px, ~20px */
  animation: moveToCorner 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards !important;
  animation-fill-mode: forwards;
}

@keyframes moveToCorner {
  0% {
    /* Estado inicial: centrado, tamaño normal, visible */
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  20% {
    /* Pausa más larga para que se vea bien el logo */
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    /* Estado final: esquina superior izquierda, más pequeño */
    transform: translate(calc(-50vw + 100px), calc(-50vh + 60px)) scale(0.45);
    opacity: 1;
  }
}

/* Fade out de elementos secundarios (solo progress-bar y particles, otros ya están arriba) */
#lead-splash-screen.moving .splash-progress-bar {
  animation: fadeOutProgress 0.8s ease-out 0.2s forwards;
}

#lead-splash-screen.moving .splash-particles {
  animation: fadeOutParticles 0.6s ease-out forwards;
}

@keyframes fadeOutText {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
}

@keyframes fadeOutSpinner {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.5);
  }
}

@keyframes fadeOutProgress {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes fadeOutParticles {
  0% {
    opacity: 0.3;
  }
  100% {
    opacity: 0;
  }
}

/* ===== RESPONSIVE PARA MÓVILES ===== */
@media (max-width: 768px) {
  .splash-logo {
    width: 160px;
  }

  .splash-text {
    font-size: 14px;
    letter-spacing: 1px;
  }

  .splash-spinner {
    width: 40px;
    height: 40px;
  }

  /* Asegurar que el logo no tenga animación de respiración en mobile cuando se mueve */
  #lead-splash-screen.moving .splash-logo {
    animation: none !important;
    transform: scale(1) translateY(0) !important;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  @keyframes moveToCorner {
    0%, 20% {
      transform: translate(0, 0) scale(1);
      opacity: 1;
    }
    100% {
      transform: translate(calc(-50vw + 70px), calc(-50vh + 50px)) scale(0.5);
      opacity: 1;
    }
  }
}

@media (max-width: 480px) {
  .splash-logo {
    width: 140px;
  }

  .splash-text {
    font-size: 12px;
  }

  /* Asegurar que el logo no tenga animación de respiración en mobile cuando se mueve */
  #lead-splash-screen.moving .splash-logo {
    animation: none !important;
    transform: scale(1) translateY(0) !important;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  @keyframes moveToCorner {
    0%, 20% {
      transform: translate(0, 0) scale(1);
      opacity: 1;
    }
    100% {
      transform: translate(calc(-50vw + 60px), calc(-50vh + 45px)) scale(0.55);
      opacity: 1;
    }
  }
}

/* ===== ANIMACIÓN DE REVELACIÓN DE CONTENIDO ===== */
.content-reveal {
  animation: contentFadeIn 0.4s ease-out;
}

@keyframes contentFadeIn {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== NUEVO ENFOQUE: NO OCULTAR EL CONTENIDO ===== */
/* Permitir que el contenido se cargue normalmente en el fondo */
/* El splash simplemente se superpone con z-index alto */

body.splash-active {
  overflow: hidden; /* Prevenir scroll durante el splash */
}

/* NO ocultar el .site-wrap - dejarlo cargar normalmente en el fondo */
body.splash-active .site-wrap {
  /* El contenido se carga normalmente pero el splash lo tapa */
  position: relative;
  z-index: 1;
}

body.splash-complete .site-wrap {
  /* Cuando termina el splash, todo ya está cargado */
  position: relative;
  z-index: 1;
  animation: contentFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animación de entrada del contenido completo */
@keyframes contentFadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== ARREGLO PARA STELLAR.JS / PARALLAX ===== */
/* Forzar que los fondos estén centrados siempre */
.site-blocks-cover,
.inner-page-cover {
  background-position: center center !important;
  background-size: cover !important;
  background-attachment: scroll !important;
}

/* Prevenir que stellar.js aplique background-position negativo */
[data-stellar-background-ratio] {
  background-position: center center !important;
}

/* ===== EFECTOS ADICIONALES ===== */

/* Partículas decorativas (opcional) */
.splash-particles {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.splash-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--lead-primary);
  border-radius: 50%;
  opacity: 0.3;
  animation: particleFloat 4s ease-in-out infinite;
}

@keyframes particleFloat {
  0%, 100% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  50% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(-100px) translateX(50px);
    opacity: 0;
  }
}

/* Posiciones aleatorias para partículas */
.splash-particle:nth-child(1) {
  left: 10%;
  animation-delay: 0s;
}

.splash-particle:nth-child(2) {
  left: 30%;
  animation-delay: 0.5s;
}

.splash-particle:nth-child(3) {
  left: 50%;
  animation-delay: 1s;
}

.splash-particle:nth-child(4) {
  left: 70%;
  animation-delay: 1.5s;
}

.splash-particle:nth-child(5) {
  left: 90%;
  animation-delay: 2s;
}

/* ===== BARRA DE PROGRESO ===== */
.splash-progress-bar {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 4px;
  background: rgba(110, 142, 0, 0.15);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.splash-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--lead-primary), var(--lead-accent), var(--lead-primary));
  background-size: 200% 100%;
  border-radius: 10px;
  animation: progressFill 2s cubic-bezier(0.4, 0, 0.2, 1) forwards,
             progressShimmer 1.5s ease-in-out infinite;
  box-shadow: 0 0 15px rgba(110, 142, 0, 0.5);
  will-change: width;
}

@keyframes progressFill {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

@keyframes progressShimmer {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* ===== ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
  .splash-logo,
  .splash-text,
  .splash-spinner,
  .splash-particle,
  .splash-progress-fill,
  .splash-logo-container,
  #lead-splash-screen {
    animation: none !important;
    transition: none !important;
  }
  
  .splash-logo {
    transform: none !important;
  }
}

/* ===== MENSAJES DE ESTADO ===== */
.splash-status-message {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Georgia Pro', Georgia, serif;
  font-size: 14px;
  color: var(--lead-primary);
  opacity: 0.7;
  letter-spacing: 1px;
  animation: textPulse 2s ease-in-out infinite;
}

