/* CG - Vídeo de cabecera | Coconut Garage */

.cgv {
  position: relative;
  display: block;
  width: 100%;
  height: var(--cgv-h-desktop, 70vh);
  min-height: 320px;
  max-height: 820px;
  overflow: hidden;
  background-color: #111;
  contain: layout paint;
}

/* Rompe el contenedor del tema sin provocar scroll horizontal */
.cgv--full {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.cgv__media {
  position: absolute;
  inset: 0;
}

.cgv__video,
.cgv__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* El póster queda debajo y se oculta en cuanto el vídeo pinta el primer fotograma */
.cgv__poster {
  z-index: 1;
  transition: opacity .4s ease;
}

.cgv__video {
  z-index: 2;
  opacity: 0;
  transition: opacity .5s ease;
}

.cgv.is-playing .cgv__video {
  opacity: 1;
}

.cgv.is-playing .cgv__poster {
  opacity: 0;
}

.cgv__overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, calc(var(--cgv-overlay, .25) * .6)) 0%,
    rgba(0, 0, 0, var(--cgv-overlay, .25)) 100%
  );
  pointer-events: none;
}

.cgv__content {
  position: relative;
  z-index: 4;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.25rem;
}

.cgv__inner {
  max-width: 760px;
  color: #fff;
  text-shadow: 0 1px 18px rgba(0, 0, 0, .35);
}

.cgv__title {
  margin: 0 0 .5rem;
  color: #fff;
  font-size: clamp(1.6rem, 3.4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -.01em;
}

.cgv__subtitle {
  margin: 0 0 1.4rem;
  color: #fff;
  font-size: clamp(.95rem, 1.4vw, 1.15rem);
  line-height: 1.5;
  opacity: .95;
}

.cgv__btn {
  display: inline-block;
}

/* ---------- Móvil ---------- */
@media (max-width: 767px) {
  .cgv {
    height: var(--cgv-h-mobile, 55vh);
    min-height: 260px;
  }

  .cgv--mobile-hidden {
    display: none;
  }

  /* Solo póster: el vídeo ni se descarga (lo controla el JS) */
  .cgv--mobile-poster .cgv__video {
    display: none;
  }

  .cgv--mobile-poster .cgv__poster {
    opacity: 1;
  }
}

/* Respeta la preferencia de reducir movimiento */
@media (prefers-reduced-motion: reduce) {
  .cgv__video {
    display: none;
  }

  .cgv__poster {
    opacity: 1;
  }
}
