/* ==========================================================================
   TRÁILER / VIDEO VERTICAL (9:16) — componente compartido
   Lo usan proyectos.html y material.html. Sin data-src queda desactivado
   (marcador); con data-src el script crea el <video>. Lógica en js/main.js.
   ========================================================================== */

/* --- Marcador / reproductor ----------------------------------------------- */

.trailer {
  position: relative;
  display: grid;
  place-items: center;
  align-self: start;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: linear-gradient(180deg, #7b9bbd 0%, #4a7094 48%, var(--color-steel) 100%);
  color: var(--color-white);
  /* Móvil: el reproductor ocupa todo el ancho de la pantalla (9:16) */
  margin-inline: calc(var(--gutter) * -1);
}

/* Dos planos de montañas */
.trailer::before,
.trailer::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
}

.trailer::before {
  height: 58%;
  background: color-mix(in srgb, var(--color-navy) 34%, transparent);
  clip-path: polygon(0 62%, 18% 38%, 34% 55%, 55% 20%, 76% 50%, 100% 30%, 100% 100%, 0 100%);
}

.trailer::after {
  height: 40%;
  background: color-mix(in srgb, var(--color-navy) 32%, transparent);
  clip-path: polygon(0 70%, 25% 45%, 48% 68%, 70% 40%, 100% 62%, 100% 100%, 0 100%);
}

.trailer__play {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  padding: 0;
  border: 1.5px solid color-mix(in srgb, var(--color-white) 88%, transparent);
  border-radius: 50%;
  background: rgb(8 32 47 / 0.22);
  color: inherit;
  cursor: default;
  transition: transform var(--duration-normal) var(--ease-out), background-color var(--duration-normal) var(--ease-out), color var(--duration-normal) var(--ease-out);
}

.trailer__play .icon {
  font-size: 1.35rem;
  margin-left: 0.15rem;
}

/* Con data-src el botón se activa */
.trailer.is-ready .trailer__play {
  cursor: pointer;
}

@media (hover: hover) {
  .trailer.is-ready .trailer__play:hover {
    transform: scale(1.08);
    background: var(--color-gold);
    border-color: var(--color-gold);
    color: var(--color-on-gold);
  }
}

.trailer__play:focus-visible {
  outline: 2px solid var(--color-gold-soft);
  outline-offset: 3px;
}

.trailer__label {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  padding: 1.4rem 0.5rem 0.9rem;
  background: linear-gradient(to top, rgb(8 32 47 / 0.6), transparent);
  font: 400 var(--text-sm) / 1.3 var(--font-body);
  text-align: center;
}

.trailer__status {
  display: block;
  opacity: 0.82;
}

/* Con cartel: la imagen sustituye al fondo azul; solo queda el botón de play encima */
.trailer__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trailer.has-poster::before,
.trailer.has-poster::after {
  display: none;
}

.trailer.has-poster {
  background: #05070a;
}

.trailer.has-poster .trailer__play {
  background: rgb(8 32 47 / 0.45);
}

/* El texto del marcador solo reaparece si el video falla */
.trailer.has-poster:not(.has-error) .trailer__label {
  display: none;
}

/* Reproduciendo: el video cubre el marcador */
.trailer__video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  /* contain: el video se ve completo, también en pantalla completa */
  object-fit: contain;
  background: #000;
}

.trailer.is-playing .trailer__play,
.trailer.is-playing .trailer__label {
  visibility: hidden;
}

/* --- TABLET ≥ 48rem --- */

@media (min-width: 48rem) {
  .trailer {
    margin-inline: 0;
  }

  .trailer__play {
    width: 3.4rem;
    height: 3.4rem;
  }

  .trailer__play .icon {
    font-size: 1.15rem;
  }
}
