/* ========================================
   Neuma Fader - Styles
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  text-align: center;
  background-color: transparent; /* Fondo transparente para iframe */
  color: white;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  padding: 0;
  margin: 0;
  height: 100vh;
  overflow: hidden; /* Elimina scroll del body */
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
  overflow: hidden; /* Elimina scroll del wrapper */
}

/* Video Container */
#video-container {
  position: relative;
  width: 100%;
  max-width: 960px;
  max-height: calc(100vh - 160px); /* Deja espacio para el fader y padding */
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  background-color: #000;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Fullscreen optimizations */
#video-container:fullscreen,
#video-container:-webkit-full-screen,
#video-container:-moz-full-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  background-color: #000;
}

video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain; /* Mantiene aspect ratio sin estirar */
  pointer-events: none;
  transform: translateZ(0); /* Force GPU acceleration */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Safari-specific optimizations */
  -webkit-transform: translateZ(0);
  will-change: transform;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  z-index: 15;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(181, 207, 207, 0.2);
  border-top: 3px solid #b5cfcf;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* When loading, hide play/pause button */
.loading-overlay:not(.hidden) ~ .play-pause-overlay {
  opacity: 0;
  pointer-events: none;
}

/* Play/Pause Overlay Button */
.play-pause-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  transition: opacity 0.3s, background 0.3s;
  pointer-events: none;
  z-index: 10;
}

.play-pause-overlay svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

#video-container:hover .play-pause-overlay {
  background: rgba(0, 0, 0, 0.7);
}

/* Hide PAUSE icon specifically */
#pause-icon {
  opacity: 0 !important;
  display: none !important;
}

/* When playing, hide the entire overlay (circle + icons) */
#video-container.playing .play-pause-overlay {
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 0.5s;
}

/* Auto-hide controls after 1 second */
#video-container.playing.hide-controls .play-pause-overlay {
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 1s;
}

#video-container.playing.hide-controls .fullscreen-button {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s;
}

#video-container.playing.hide-controls .video-timeline {
  opacity: 0.3;
}

/* Show on hover/touch */
#video-container.playing:hover .play-pause-overlay,
#video-container.playing video:hover ~ .play-pause-overlay {
  opacity: 1;
  pointer-events: all;
}

#video-container:hover .fullscreen-button,
#video-container.playing:not(.hide-controls) .fullscreen-button {
  opacity: 1;
  pointer-events: all;
}

/* Fullscreen Button */
.fullscreen-button {
  position: absolute;
  bottom: 15px;
  right: 15px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #00ffc3;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 20;
  padding: 0;
}

.fullscreen-button:hover {
  background: rgba(0, 255, 195, 0.2);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(0, 255, 195, 0.4);
}

.fullscreen-button:active {
  transform: scale(0.95);
}

.fullscreen-button svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* ========================================
   VIDEO TIMELINE CONTROLS
   ======================================== */

/* Timeline (works for both normal and fullscreen) */
.video-timeline {
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  z-index: 15;
  transition: height 0.2s ease, opacity 0.3s ease;
  opacity: 0.7;
}

/* Increase touch area with invisible padding */
.video-timeline::before {
  content: '';
  position: absolute;
  top: -12px;
  bottom: -12px;
  left: 0;
  right: 0;
  cursor: pointer;
}

.video-timeline:hover {
  height: 6px;
  opacity: 1;
}

.timeline-buffered {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  width: 0%;
  pointer-events: none;
}

.timeline-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #00ffc3 0%, #04b98f 100%);
  width: 0%;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(0, 255, 195, 0.5);
}

/* Timeline Time Tooltip */
.timeline-time-tooltip {
  position: absolute;
  top: -35px;
  left: 0;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #00ffc3;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.2s ease;
  border: 1px solid rgba(0, 255, 195, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.video-timeline:hover .timeline-time-tooltip {
  opacity: 1;
}

/* Fullscreen adjustments */
#video-container:fullscreen .video-timeline {
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 1;
}

/* Larger touch area in fullscreen */
#video-container:fullscreen .video-timeline::before {
  top: -15px;
  bottom: -15px;
}

#video-container:fullscreen .video-timeline:hover {
  height: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

#video-container:fullscreen .timeline-buffered,
#video-container:fullscreen .timeline-progress {
  border-radius: 3px;
}

#video-container:fullscreen .timeline-progress {
  box-shadow: 0 0 12px rgba(0, 255, 195, 0.6);
}

#video-container:fullscreen .video-timeline:hover .timeline-progress {
  box-shadow: 0 0 16px rgba(0, 255, 195, 0.8);
}

/* Fader Controls in Fullscreen */
.fader-controls-fullscreen {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translate3d(-50%, 0, 0); /* Use 3D transform for GPU */
  width: 80%;
  max-width: 600px;
  padding: 0 20px;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  will-change: opacity; /* Hint browser to optimize */
}

/* Show fader in fullscreen */
#video-container:fullscreen .fader-controls-fullscreen {
  opacity: 1;
  pointer-events: all;
}

/* Style for fullscreen fader */
#audio-fader-fullscreen {
  width: 100%;
  display: block;
  appearance: none;
  height: 12px;
  background: linear-gradient(to right, #357f82 0%, #00ffc3 25%, #357f82 50%, #00ffc3 75%, #357f82 100%);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: none; /* Remove transition to reduce lag */
}

#audio-fader-fullscreen:hover {
  opacity: 0.9;
}

#audio-fader-fullscreen::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 50px;
  height: 50px;
  background: #333333 url('../assets/images/image01.png') no-repeat center;
  background-size: 70%;
  border: 2px solid #b5cfcf;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  transition: none; /* Remove transition to reduce lag */
}

#audio-fader-fullscreen::-webkit-slider-thumb:hover {
  width: 54px;
  height: 54px;
  box-shadow: 0 4px 16px rgba(0, 255, 195, 0.6);
}

#audio-fader-fullscreen::-webkit-slider-thumb:active {
  cursor: grabbing;
  width: 56px;
  height: 56px;
}

#audio-fader-fullscreen::-moz-range-thumb {
  width: 50px;
  height: 50px;
  background: #333333 url('../assets/images/image01.png') no-repeat center;
  background-size: 70%;
  border: 2px solid #b5cfcf;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  transition: none; /* Remove transition to reduce lag */
}

#audio-fader-fullscreen::-moz-range-thumb:hover {
  width: 54px;
  height: 54px;
  box-shadow: 0 4px 16px rgba(0, 255, 195, 0.6);
}

#audio-fader-fullscreen::-moz-range-thumb:active {
  cursor: grabbing;
  width: 56px;
  height: 56px;
}

/* Fader Controls Container */
.fader-controls {
  width: 100%;
  max-width: 960px;
  margin: 30px auto 0 auto;
  padding: 0 10px;
  position: relative;
  z-index: 20;
}

/* FADER HINT (burbuja "Puedes arrastrar") */
.fader-hint {
  position: absolute;
  bottom: 100%; /* encima del fader */
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease;
  z-index: 30;
  width: auto;
}

.fader-hint.visible {
  opacity: 1;
}

/* La burbuja de texto */
.fader-hint-bubble {
  background-color: #1f2937; /* bg-gray-800 */
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid #00ffc3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Labels de Music y SFX */
.fader-hint-label {
  color: #b5cfcf; /* color neuma */
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}

/* Separador central */
.fader-hint-separator {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 400;
}

/* Icono de flechas izq-der */
.fader-hint-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Triángulo/Flecha que apunta hacia abajo */
.fader-hint-arrow {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #1f2937; /* bg-gray-800 */
}

/* Animación de pulso para llamar la atención */
@keyframes fader-pulse {
  0%, 100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateX(-50%) scale(1.05);
    opacity: 0.95;
  }
}

.fader-hint.pulsing.visible {
  animation: fader-pulse 2s ease-in-out infinite;
}

/* Audio Fader */
#audio-fader {
  width: 100%;
  display: block;
  appearance: none;
  height: 10px;
  background: linear-gradient(to right, #357f82 0%, #04b98f 25%, #357f82 50%, #04b98f 75%, #357f82 100%);
  border-radius: 5px;
  outline: none;
  cursor: pointer;
  margin-bottom: 20px;
  transition: opacity 0.2s;
}

#audio-fader:hover {
  opacity: 0.9;
}

#audio-fader:active {
  opacity: 1;
}

/* Styling for WebKit browsers (Chrome, Safari, Edge) */
#audio-fader::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 44px;
  height: 44px;
  background: #333333 url('../assets/images/image01.png') no-repeat center;
  background-size: 70%;
  border: 2px solid #b5cfcf;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}

#audio-fader::-webkit-slider-thumb:hover {
  width: 48px;
  height: 48px;
  box-shadow: 0 4px 12px rgba(0, 255, 195, 0.5);
}

#audio-fader::-webkit-slider-thumb:active {
  cursor: grabbing;
  width: 50px;
  height: 50px;
}

/* Styling for Firefox */
#audio-fader::-moz-range-thumb {
  width: 44px;
  height: 44px;
  background: #333333 url('../assets/images/image01.png') no-repeat center;
  background-size: 70%;
  border: 2px solid #b5cfcf;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}

#audio-fader::-moz-range-thumb:hover {
  width: 48px;
  height: 48px;
  box-shadow: 0 4px 12px rgba(0, 255, 195, 0.5);
}

#audio-fader::-moz-range-thumb:active {
  cursor: grabbing;
  width: 50px;
  height: 50px;
}

/* ========================================
   RESPONSIVE - Mobile First
   ======================================== */

/* Mobile devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
  body {
    overflow: hidden;
  }

  .content-wrapper {
    padding: 15px 10px;
  }

  #video-container {
    border-radius: 8px;
    max-height: calc(100vh - 140px);
  }
  
  /* Timeline larger on mobile for easier touch */
  .video-timeline {
    height: 6px;
    bottom: 10px;
  }
  
  .video-timeline::before {
    top: -15px; /* Larger touch area */
    bottom: -15px;
  }
  
  .video-timeline:hover,
  .video-timeline:active {
    height: 8px;
  }

  .fader-controls {
    margin-top: 25px;
  }

  /* Fader más grande y táctil en móviles */
  #audio-fader {
    height: 14px;
    margin-bottom: 25px;
  }

  #audio-fader::-webkit-slider-thumb {
    width: 44px;
    height: 44px;
  }

  #audio-fader::-webkit-slider-thumb:hover,
  #audio-fader::-webkit-slider-thumb:active {
    width: 48px;
    height: 48px;
  }

  #audio-fader::-moz-range-thumb {
    width: 44px;
    height: 44px;
  }

  #audio-fader::-moz-range-thumb:hover,
  #audio-fader::-moz-range-thumb:active {
    width: 48px;
    height: 48px;
  }
  
  /* Fullscreen button - positioned slightly higher to avoid timeline overlap */
  .fullscreen-button {
    width: 44px;
    height: 44px;
    bottom: 28px; /* Just above the timeline */
    right: 8px;
    top: auto;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffc3;
  }
  
  .fullscreen-button svg {
    width: 22px;
    height: 22px;
  }
}

/* Tablets (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
  #audio-fader {
    height: 12px;
  }

  #audio-fader::-webkit-slider-thumb,
  #audio-fader::-moz-range-thumb {
    width: 38px;
    height: 38px;
  }
}

/* Small laptops and tablets (768px and up) */
@media (min-width: 768px) {
  .fader-controls {
    padding: 0 20px;
  }
}

/* Large devices (desktops, 1200px and up) */
@media (min-width: 1200px) {
  .content-wrapper {
    padding: 40px;
  }

  .fader-controls {
    margin-top: 40px;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  /* Para dispositivos táctiles, hacer todos los controles más grandes */
  #audio-fader {
    height: 16px;
  }

  #audio-fader::-webkit-slider-thumb,
  #audio-fader::-moz-range-thumb {
    width: 48px;
    height: 48px;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
  .content-wrapper {
    padding: 10px;
  }

  #video-container {
    max-height: calc(100vh - 100px);
  }
  
  /* Fullscreen button higher in landscape to avoid timeline */
  .fullscreen-button {
    bottom: 28px;
  }

  .subtitle {
    margin-bottom: 15px;
  }

  .fader-controls {
    margin-top: 15px;
  }
}
