/* Home Featured Videos - Vintage TV Single */
.home-featured-videos {
  padding: 60px 0;
}

.home-featured-videos__container {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

.home-featured-videos__intro,
.home-featured__intro {
  text-align: center;
/*  margin-bottom: 48px;*/
}

.home-featured-videos__eyebrow,
.home-featured__eyebrow {
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #e34028;
  font-weight: 800;
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.home-featured-videos__title,
.home-featured__title {
  font-size: clamp(2rem, 4.5vw, 3rem);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0 0 12px;
  font-weight: 900;
  color: #fff;
}

.home-featured-videos__subtitle,
.home-featured__subtitle {
  color: #c0c0c0;
  font-size: 1.05rem;
  margin: 0;
}

.home-featured__stack {
  padding-top: 20px;
}

/* Vintage TV Wrapper - Centrado */
.vintage-tv-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
/*  padding: 40px 0;*/
}

.vintage-tv {
  max-width: 880px;
  width: 100%;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.vintage-tv:hover {
  transform: scale(1.02);
}

/* TV Frame con imagen de fondo */
.tv-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  /* AJUSTA ESTAS VARIABLES para que .tv-screen coincida con la apertura CRT */
  /* Valores por defecto tomados de tus ajustes anteriores */
  --tv-inset-top: 28%;
  --tv-inset-right: 30%;
  --tv-inset-bottom: 16%;
  --tv-inset-left: 18%;
  isolation: isolate; /* garantiza stacking para pseudo-elemento */
}

.tv-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('/images/tele-vintage-2.avif');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 2;
  pointer-events: none;
}

/* TV Screen - área visible dentro del marco */
.tv-screen {
  position: absolute;
  inset: var(--tv-inset-top) var(--tv-inset-right) var(--tv-inset-bottom) var(--tv-inset-left);
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.9);
  z-index: 1; /* por debajo del marco ::after */
}
/* Estados de pantalla */
.tv-display {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  background: #000;
}

.tv-display.active {
  display: block;
}

.tv-display--off {
  background: #000;
}

.tv-display__surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.tv-display__surface--static {
  filter: contrast(1.1);
}

.tv-static__canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.tv-display__surface--video {
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.8);
  will-change: transform;
  animation: vhsJitter 6s ease-in-out infinite;
}

.tv-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  filter: contrast(1.1) saturate(0.85) brightness(0.96) sepia(0.08) hue-rotate(-2deg);}

/* Safari-safe: cubrir 4:3 con iframes 16:9 (YouTube/Vimeo) */
.tv-video iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 100%;
  width: 133.34%; /* 16:9 sobre 4:3 -> 1.777 / 1.333 ≈ 1.333 */
  transform: translate(-50%, -50%);
  border: 0;
}

.tv-video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* VHS overlay layers (solo en la TV, no en modal) */
.vhs-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.vhs-scanlines {
  background: repeating-linear-gradient(180deg,
    rgba(255,255,255,0.035) 0px,
    rgba(255,255,255,0.035) 1px,
    rgba(0,0,0,0.04) 1px,
    rgba(0,0,0,0.04) 2px
  );
  mix-blend-mode: overlay;
  opacity: 0.85;
  animation: vhsScan 4s linear infinite;
}

.vhs-noise {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.8' numOctaves='2' seed='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") repeat;
  mix-blend-mode: overlay;
  opacity: 0.9;
  animation: vhsNoise 2.8s steps(6) infinite;
}

.vhs-vignette {
  box-shadow: inset 0 0 80px rgba(0,0,0,0.55), inset 0 0 140px rgba(0,0,0,0.35);
}

/* Tracking noise: banda de desajuste horizontal que sube/baja */
.vhs-tracking {
  overflow: hidden;
}
.vhs-tracking::before,
.vhs-tracking::after {
  content: "";
  position: absolute;
  left: -10%;
  width: 120%;
  height: 24px;
  opacity: 0.55;
}
.vhs-tracking::before {
  top: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.35), rgba(255,255,255,0.05));
  filter: blur(0.6px);
}
.vhs-tracking::after {
  top: 0;
  background: linear-gradient(90deg, rgba(255,0,0,0.25), rgba(0,255,0,0.25), rgba(0,0,255,0.25));
  mix-blend-mode: screen;
  opacity: 0.35;
}
.vhs-tracking {
  animation: vhsTrackMove 4.2s linear infinite;
}

@keyframes vhsTrackMove {
  0% { transform: translateY(100%); }
  45% { transform: translateY(0%); }
  55% { transform: translateY(1%); }
  100% { transform: translateY(-120%); }
}

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

@keyframes vhsNoise {
  0% { transform: translate3d(0,0,0); }
  50% { transform: translate3d(0,-1px,0); }
  100% { transform: translate3d(0,0,0); }
}

@keyframes vhsJitter {
  0%, 100% { transform: translateY(0); }
  10% { transform: translateY(-0.5px); }
  20% { transform: translateY(0.4px); }
  30% { transform: translateY(-0.3px); }
  40% { transform: translateY(0.2px); }
  50% { transform: translateY(-0.6px); }
  60% { transform: translateY(0.3px); }
  70% { transform: translateY(-0.4px); }
  80% { transform: translateY(0.2px); }
  90% { transform: translateY(-0.2px); }
}

/* Info debajo de la TV */
.tv-info {
  text-align: center;
  margin-top: 24px;
  padding: 0 20px;
}

.tv-info__title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
  letter-spacing: 0.5px;
}

.tv-info__meta {
  font-size: 0.95rem;
  color: #b0b0b0;
  margin: 0;
}

/* Modal para vista expandida 16:9 */
.tv-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.tv-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.tv-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
  z-index: 0; /* explícito: debajo del contenido */
}

.tv-modal__content {
  position: relative;
  width: min(96vw, 1400px);
  aspect-ratio: 16 / 9;
  z-index: 5; /* por encima del backdrop */
  transform-origin: center center;
  /* Forzar nueva capa para Safari y respetar z-index sobre iframes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
  isolation: isolate; /* crear contexto de apilamiento propio */
}

.tv-modal__close {
  position: absolute;
  top: 44px; /* bajar para no solapar el control nativo de mute de Safari */
  right: 12px;
  border: 0;
  background: rgba(227, 64, 40, 0.9);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10; /* sobre el video e iframes en Safari */
  pointer-events: auto;
  /* Promover a capa propia para evitar quedar detrás del iframe en Safari */
  -webkit-transform: translate3d(0,0,0);
  transform: translate3d(0,0,0);
  will-change: transform;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.tv-modal__close:hover {
  background: rgba(255, 72, 48, 1);
  transform: scale(1.1);
}

.video-container-16-9 {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1; /* base del contenido */
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  /* Promover el contenedor para estabilizar el stacking con el botón en Safari */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}

.video-container-16-9 iframe,
.video-container-16-9 video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1; /* por debajo del botón de cierre */
}

/* Animaciones de zoom */
.zoom-from-tv {
  animation: zoomFromTv 500ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  z-index: 5; /* asegurar stacking del contenido durante animación */
}

.zoom-to-tv {
  animation: zoomToTv 500ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  z-index: 5;
}

@keyframes zoomFromTv {
  from {
    transform: var(--from-transform);
  }
  to {
    transform: none;
  }
}

@keyframes zoomToTv {
  from {
    transform: none;
  }
  to {
    transform: var(--to-transform);
  }
}

/* Power-on flash effect */
@keyframes powerOnFlash {
  0% {
    opacity: 0;
    filter: brightness(0);
  }
  20% {
    opacity: 1;
    filter: brightness(2) contrast(1.5);
  }
  50% {
    filter: brightness(1.2) contrast(1.2);
  }
  100% {
    opacity: 1;
    filter: brightness(1) contrast(1);
  }
}

.power-on-flash {
  animation: powerOnFlash 600ms ease-out;
}

/* Responsive */
@media (max-width: 768px) {
  .home-featured-videos {
    padding: 40px 0;
  }

  .vintage-tv {
    max-width: 500px;
  }

  .tv-modal__close {
    top: 36px; /* móvil un poco más abajo también */
    right: 10px;
    width: 40px;
    height: 40px;
  }

  .tv-frame {
    --tv-inset-top: 28%;
    --tv-inset-right: 30%;
    --tv-inset-bottom: 16%;
    --tv-inset-left: 18%;
  }
}

@media (max-width: 480px) {
  .vintage-tv {
    max-width: 100%;
  }

  .tv-frame {
    --tv-inset-top: 28%;
    --tv-inset-right: 30%;
    --tv-inset-bottom: 16%;
    --tv-inset-left: 18%;
  }

  .tv-info__title {
    font-size: 1.1rem;
  }

  .tv-info__meta {
    font-size: 0.85rem;
  }
}
