/* ============================================================
   Modal de video de la home (js/video-modal.js)
   Reproduce en la misma página los videos de YouTube de los botones
   "Ver el video de la historia" (Documental 01 / 02 / 03).
   Cargar DESPUÉS de css/documental.css: hereda sus tokens (--doc-*) y sus
   fuentes (Neulis Neue y Nunito). Los valores tras la coma son respaldo.
   Media queries con sintaxis clásica (max-width) por compatibilidad.
   ============================================================ */
/* stylelint-disable media-feature-range-notation */

/* Bloquea el scroll de la página mientras el modal está abierto
   (Lenis no se puede detener desde fuera: ver js/video-modal.js). */
html.im-video-open {
  overflow: hidden;
}

.im-video {
  --im-video-cream: 255 252 249;
  --im-video-ink-deep: 13 10 11;
  --im-video-pink: var(--doc-pink, #ff4e9b);

  position: fixed;
  inset: 0;
  z-index: 1000; /* por encima del skip-link (400), el navbar (190) y el hilo (180) */
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 34px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.im-video.is-open {
  opacity: 1;
}

/* Mismo lenguaje que el panel del menú móvil de la home */
.im-video__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(var(--im-video-ink-deep) / 92%);
  backdrop-filter: blur(10px);
}

.im-video__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vh, 20px);

  /* 16:9 que siempre cabe en alto (240px = cabecera + pie + márgenes) */
  width: min(100%, 1120px, calc((100vh - 240px) * 16 / 9));
  width: min(100%, 1120px, calc((100dvh - 240px) * 16 / 9));
  transform: translateY(18px) scale(0.985);
  transition: transform 0.45s cubic-bezier(0.19, 0.9, 0.22, 1);
}

.im-video.is-open .im-video__panel {
  transform: none;
}

.im-video__head {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
}

.im-video__kicker {
  margin: 0 0 6px;
  font-family: Nunito, sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--doc-pink-light, #ff7fb6);
}

.im-video__title {
  margin: 0;
  font-family: "Neulis Neue", sans-serif;
  font-size: clamp(1.4rem, 2.8vw, 2.4rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.03em;
  color: rgb(var(--im-video-cream));
  text-wrap: balance;
}

/* Misma "×" y mismos estados que el burger del navbar y el botón play */
.im-video__close {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  cursor: pointer;
  background: none;
  border: 1px solid rgb(var(--im-video-cream) / 45%);
  border-radius: 50%;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.im-video__close span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 1.6px;
  margin: -0.8px 0 0 -8px;
  background: rgb(var(--im-video-cream));
}

.im-video__close span:first-child {
  transform: rotate(45deg);
}

.im-video__close span:last-child {
  transform: rotate(-45deg);
}

.im-video__close:hover {
  background: rgb(224 23 111 / 22%);
  border-color: var(--im-video-pink);
}

.im-video__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0d0a0b;
  border: 1px solid rgb(var(--im-video-cream) / 14%);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgb(0 0 0 / 50%);
}

/* El "hilo" del documental (rosa → coral → menta) recorre el borde superior */
.im-video__frame::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, #ff4e9b, #f97c6b 48%, #12b98c);
}

/* Anillo con pulso mientras carga el reproductor (queda detrás del iframe) */
.im-video__halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border: 1px solid rgb(255 78 155 / 60%);
  border-radius: 50%;
  animation: im-video-halo 2.8s ease-out infinite;
}

@keyframes im-video-halo {
  0% {
    opacity: 0.5;
    transform: scale(1);
  }

  70% {
    opacity: 0;
    transform: scale(2.5);
  }

  100% {
    opacity: 0;
  }
}

.im-video__iframe {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
}

.im-video__yt {
  align-self: flex-end;
  font-family: Nunito, sans-serif;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: rgb(var(--im-video-cream) / 70%);
}

.im-video__yt:hover {
  color: rgb(var(--im-video-cream));
}

/* documental.css pone border-radius:4px a todo :focus-visible: el botón redondo lo conserva */
.im-video :focus-visible {
  outline: 2px solid var(--im-video-pink);
  outline-offset: 3px;
}

.im-video__close:focus-visible {
  border-radius: 50%;
}

@media (max-width: 640px) {
  .im-video {
    padding: 14px;
  }

  .im-video__title {
    font-size: clamp(1.2rem, 6vw, 1.6rem);
  }
}

/* Móvil apaisado / pantallas bajas: todo el espacio para el video */
@media (max-height: 520px) {
  .im-video__panel {
    gap: 10px;
    width: min(100%, 1120px, calc((100vh - 100px) * 16 / 9));
    width: min(100%, 1120px, calc((100dvh - 100px) * 16 / 9));
  }

  .im-video__head {
    justify-content: flex-end;
  }

  .im-video__kicker,
  .im-video__title,
  .im-video__yt {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .im-video__panel {
    transform: none;
    transition: none;
  }

  .im-video__halo {
    animation: none;
  }
}
/* stylelint-enable media-feature-range-notation */
