/**
 * Sistema de Enmascaramiento y Recorte Anti-Spoilers de YouTube
 * Asegura que el título del video, ícono de canal, sugerencias y marcas de agua
 * permanezcan 100% invisibles para el usuario.
 */

/* Contenedor principal de la pantalla de cine */
.cinema-theater-viewport {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: #050608;
  z-index: 0;
}

/* Envoltorio del reproductor: sobredimensionado y centrado */
.video-stream-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  /* Desplazamos ligeramente hacia arriba para sacar la barra de título de YouTube del viewport */
  transform: translate(-50%, calc(-50% - 25px)) scale(1.22);
  width: 100vw;
  height: 100vh;
  min-width: 177.77vh; /* Mantiene proporción 16:9 cubriendo el 100% de la pantalla */
  min-height: 56.25vw;
  pointer-events: none; /* Impide cualquier interacción con los controles nativos de YouTube */
  user-select: none;
}

.video-stream-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}

/* Escudo protector invisible sobre el video */
.video-click-shield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: default;
  pointer-events: auto; /* Atrapa clics para que no alcancen el iframe de YouTube */
}

/* Viñeta cinematográfica superior: cubre la zona superior del video */
.cinema-vignette-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 180px;
  background: linear-gradient(
    to bottom,
    rgba(5, 6, 8, 0.95) 0%,
    rgba(5, 6, 8, 0.8) 35%,
    rgba(5, 6, 8, 0.4) 70%,
    transparent 100%
  );
  z-index: 3;
  pointer-events: none;
}

/* Viñeta cinematográfica inferior: se integra armoniosamente con las opciones del juego */
.cinema-vignette-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 380px;
  background: linear-gradient(
    to top,
    rgba(5, 6, 8, 0.98) 0%,
    rgba(5, 6, 8, 0.9) 45%,
    rgba(5, 6, 8, 0.5) 80%,
    transparent 100%
  );
  z-index: 3;
  pointer-events: none;
}

/* Efecto de viñeta radial de lente de cine */
.cinema-vignette-radial {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.85);
  z-index: 3;
  pointer-events: none;
}

/* Indicador de carga de video */
.video-loading-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #07090e;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.video-loading-placeholder.active {
  opacity: 1;
  pointer-events: auto;
}

.film-reel-spinner {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(245, 158, 11, 0.2);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spinReel 0.9s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
  margin-bottom: 1rem;
}

@keyframes spinReel {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Adaptación Cinemática Panorámica para Móviles (Vertical / Portrait)
   Muestra el tráiler en formato panorámico 16:9 evitando el zoom vertical excesivo
   ========================================================================== */
@media (max-width: 768px) and (orientation: portrait), (max-width: 768px) and (max-aspect-ratio: 1/1) {
  .cinema-theater-viewport {
    height: 100dvh;
  }

  /* El reproductor se enmarca en formato panorámico 16:9 centrado en el área de cine */
  .video-stream-wrapper {
    top: calc(50dvh - 110px);
    left: 50%;
    width: 100vw;
    max-width: 540px;
    height: calc(100vw * 9 / 16);
    max-height: calc(540px * 9 / 16);
    min-width: unset;
    min-height: unset;
    transform: translate(-50%, -50%);
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.85), 0 0 20px rgba(245, 158, 11, 0.08);
  }

  .video-stream-wrapper iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    /* Escalado anti-spoilers: desplaza título y watermark fuera del contenedor visible */
    transform: translate(-50%, calc(-50% - 14px)) scale(1.18);
  }

  /* Sombra perimetral suave de lente para una integración natural con el fondo */
  .video-stream-wrapper::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(5, 6, 8, 0.6);
    border-radius: inherit;
    z-index: 1;
  }

  /* Viñetas adaptadas al marco móvil */
  .cinema-vignette-top {
    height: 80px;
    background: linear-gradient(
      to bottom,
      rgba(5, 6, 8, 0.98) 0%,
      rgba(5, 6, 8, 0.75) 45%,
      transparent 100%
    );
  }

  .cinema-vignette-bottom {
    height: 48dvh;
    background: linear-gradient(
      to top,
      rgba(5, 6, 8, 0.98) 0%,
      rgba(5, 6, 8, 0.92) 55%,
      rgba(5, 6, 8, 0.4) 85%,
      transparent 100%
    );
  }

  .cinema-vignette-radial {
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.7);
  }
}
