/* efecto.css - Efectos Visuales Impactantes para YT CrossMix */

:root {
  --crossfade-duration: 15s;
  --glow-color: #ff6b35;
  --glow-secondary: #ff8a65;
  --pulse-speed: 2s;
}

/* =============================================
   REPRODUCTORES CON EFECTOS AVANZADOS
   ============================================= */
.video-player {
  position: absolute;
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%;
  background: #000;
  z-index: 1;
  border-radius: 12px;
  overflow: hidden;
  transition: filter 0.5s ease; 
  
  visibility: visible !important;
  display: block !important;
}
/* Solo aplicar transición larga de opacidad si NO estamos en medio de un crossfade JS manual */
/* Esto permite que CSS maneje efectos visuales sutiles pero no bloquee el crossfade */
.video-player:not([style*="transition: none"]) {
    transition: filter 0.5s ease, transform 0.5s ease;
}
/* =============================================
   ENTRADA VISUAL IMPACTANTE
   ============================================= */
.video-player.fade-in {
  opacity: 1;
  filter: blur(0px) brightness(1.1) saturate(1.2) contrast(1.1);
  transform: scale(1);
  z-index: 3; /* Encima del que sale */
  visibility: visible !important;
  display: block !important;
  
  box-shadow: 
    0 16px 64px rgba(255, 107, 53, 0.3),
    0 8px 32px rgba(255, 107, 53, 0.2),
    0 0 40px rgba(255, 107, 53, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
    
  /* Borde brillante */
  border: 2px solid rgba(255, 107, 53, 0.4);
  
  /* Animación de pulso sutil */
  animation: subtlePulse var(--pulse-speed) infinite alternate;
}

@keyframes subtlePulse {
  0% {
    box-shadow: 
      0 16px 64px rgba(255, 107, 53, 0.3),
      0 8px 32px rgba(255, 107, 53, 0.2),
      0 0 40px rgba(255, 107, 53, 0.15);
    filter: blur(0px) brightness(1.1) saturate(1.2);
  }
  100% {
    box-shadow: 
      0 20px 80px rgba(255, 107, 53, 0.4),
      0 12px 48px rgba(255, 107, 53, 0.3),
      0 0 60px rgba(255, 107, 53, 0.2);
    filter: blur(0px) brightness(1.15) saturate(1.25);
  }
}

/* =============================================
   SALIDA VISUAL DRAMÁTICA  
   ============================================= */
.video-player.fade-out {
  opacity: 0;
  /* ✅ CAMBIO CRÍTICO: Brightness mínimo de 0.85 en lugar de 0.7 */
  filter: blur(4px) brightness(0.85) saturate(0.9) contrast(0.95);
  transform: scale(0.98);
  z-index: 2; /* Debajo del que entra */
  
  /* ✅ MANTENER VISIBLE durante fade-out */
  visibility: visible !important;
  display: block !important;
  
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(255, 107, 53, 0.05);
    
  border: 1px solid rgba(255, 107, 53, 0.1);
  
  /* Desvanecimiento progresivo */
  animation: fadeOutEffect calc(var(--crossfade-duration) * 0.8) ease-out forwards;
}

@keyframes fadeOutEffect {
  0% {
    opacity: 1;
    filter: blur(0px) brightness(1.0) saturate(1.0);
    transform: scale(1) rotateY(0deg);
  }
  30% {
    opacity: 0.8;
    filter: blur(2px) brightness(0.95) saturate(0.95);
    transform: scale(0.99) rotateY(-1deg);
  }
  70% {
    opacity: 0.3;
    filter: blur(6px) brightness(0.8) saturate(0.85);
    transform: scale(0.97) rotateY(-3deg);
  }
  100% {
    opacity: 0;
    filter: blur(8px) brightness(0.7) saturate(0.8);
    transform: scale(0.95) rotateY(-5deg);
  }
}

/* =============================================
   OCULTAMIENTO COMPLETO
   ============================================= */
.video-player.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  z-index: -1 !important;
  display: none !important;
}

/* =============================================
   EFECTOS DE OVERLAY DINÁMICOS
   ============================================= */
.video-player::before {
  content: '';
  position: absolute;
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%;
  background: 
    radial-gradient(circle at 30% 70%, rgba(255, 107, 53, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 70% 30%, rgba(255, 138, 101, 0.06) 0%, transparent 50%),
    linear-gradient(135deg, transparent 0%, rgba(255, 107, 53, 0.02) 100%);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--crossfade-duration) ease;
}

.video-player.fade-in::before {
  opacity: 1;
  animation: overlayPulse var(--pulse-speed) infinite alternate;
}

@keyframes overlayPulse {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Efecto de partículas flotantes */
.video-player::after {
  content: '';
  position: absolute;
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%;
  background: 
    radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.1), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255, 107, 53, 0.1), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255, 138, 101, 0.1), transparent),
    radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.05), transparent);
  background-repeat: repeat;
  background-size: 150px 150px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  animation: particles 20s linear infinite;
}

.video-player.fade-in::after {
  opacity: 0.3;
}

@keyframes particles {
  0% { 
    transform: translate(0, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.3;
  }
  90% {
    opacity: 0.3;
  }
  100% { 
    transform: translate(-20px, -20px) rotate(360deg);
    opacity: 0;
  }
}
/* =============================================
   CONTENEDOR DE VIDEO: Fondo negro siempre
   ============================================= */
.video-wrapper {
background-color: #000 !important;
}
/* =============================================
   EFECTOS DE TRANSICIÓN 3D
   ============================================= */
.video-container {
  perspective: 1000px;
  transform-style: preserve-3d;
}

/* Efecto de entrada lateral */
@keyframes slideInFromRight {
  0% {
    transform: translateX(100%) rotateY(45deg) scale(0.8);
    opacity: 0;
    filter: blur(10px);
  }
  50% {
    transform: translateX(10%) rotateY(5deg) scale(0.95);
    opacity: 0.7;
    filter: blur(2px);
  }
  100% {
    transform: translateX(0) rotateY(0deg) scale(1);
    opacity: 1;
    filter: blur(0px);
  }
}

/* Efecto de salida lateral */
@keyframes slideOutToLeft {
  0% {
    transform: translateX(0) rotateY(0deg) scale(1);
    opacity: 1;
    filter: blur(0px);
  }
  50% {
    transform: translateX(-10%) rotateY(-5deg) scale(0.95);
    opacity: 0.3;
    filter: blur(5px);
  }
  100% {
    transform: translateX(-100%) rotateY(-45deg) scale(0.8);
    opacity: 0;
    filter: blur(15px);
  }
}

/* Activar animaciones 3D en crossfade */
.video-player.crossfade-enter {
  animation: slideInFromRight calc(var(--crossfade-duration) * 0.6) ease-out;
}

.video-player.crossfade-exit {
  animation: slideOutToLeft calc(var(--crossfade-duration) * 0.8) ease-in;
}

/* =============================================
   EFECTOS RESPONSIVOS
   ============================================= */
@media (max-width: 768px) {
  .video-player {
    border-radius: 8px;
  }
  
  .video-player.fade-in {
    box-shadow: 
      0 8px 32px rgba(255, 107, 53, 0.2),
      0 4px 16px rgba(255, 107, 53, 0.1);
  }
  
  /* Reducir efectos en móvil para mejor rendimiento */
  .video-player::after {
    display: none;
  }
}

@media (max-width: 480px) {
  :root {
    --crossfade-duration: 10s;
  }
  
  .video-player.fade-in {
    animation: none; /* Desactivar pulso en pantallas muy pequeñas */
  }
}

/* =============================================
   EFECTOS DE CARGA Y BUFFERING
   ============================================= */
.video-player.loading {
  position: relative;
}

.video-player.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 107, 53, 0.3);
  border-top: 3px solid var(--glow-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

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

/* =============================================
   EFECTOS DE ERROR
   ============================================= */
.video-player.error {
  border: 2px solid #f44336;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a1a1a 100%);
  
  animation: errorPulse 1s ease-in-out 3;
}

@keyframes errorPulse {
  0%, 100% { 
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.3);
    filter: brightness(1.0);
  }
  50% { 
    box-shadow: 0 0 40px rgba(244, 67, 54, 0.6);
    filter: brightness(1.2);
  }
}
/* =============================================
   LETRAS SINCRONIZADAS - EFECTO SPOTIFY
   ============================================= */

.lyrics-text.synced {
    max-height: 400px;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 20px;
    position: relative;
}

.lyrics-text.synced p {
    font-size: 1.8rem;
    line-height: 2.4;
    color: rgba(255, 255, 255, 0.3); /* Muy tenue por defecto */
    font-weight: 400;
    padding: 8px 0;
    margin: 0;
    transition: 
        color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        font-size 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
}

/* La línea ACTIVA (estilo Spotify) */
.lyrics-text.synced p.active {
    color: #FFFFFF !important;
    font-weight: 700 !important;
    font-size: 2rem !important;
    opacity: 1 !important;
    transform: translateX(8px) scale(1.02);
    text-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

/* Las 2 líneas siguientes se ven un poco */
.lyrics-text.synced p.active + p,
.lyrics-text.synced p.active + p + p {
    color: rgba(255, 255, 255, 0.5);
    opacity: 0.8;
}

/* Efecto de glow sutil en la línea activa */
.lyrics-text.synced p.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: linear-gradient(180deg, var(--primary-color), transparent);
    border-radius: 2px;
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Scrollbar personalizado para las letras */
.lyrics-text.synced::-webkit-scrollbar {
    width: 8px;
}

.lyrics-text.synced::-webkit-scrollbar-track {
    background: transparent;
}

.lyrics-text.synced::-webkit-scrollbar-thumb {
    background: rgba(255, 107, 53, 0.3);
    border-radius: 4px;
}

.lyrics-text.synced::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 53, 0.5);
}
