/* PORTAL WEB AC LOCAL v0.3.9
   Carrusel oficial optimitzat: una sola previsualització YouTube activa alhora. */

/* Elimina els rectangles superposats que generaven un tall horitzontal visible. */
.media-carousel::before,
.media-carousel::after {
  content: none !important;
  display: none !important;
}

/* El difuminat es fa sobre el contingut real del viewport, sense cap caixa blanca. */
.media-viewport {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.02) 3%,
    rgba(0, 0, 0, 0.12) 7%,
    rgba(0, 0, 0, 0.40) 13%,
    rgba(0, 0, 0, 0.78) 20%,
    #000 29%,
    #000 71%,
    rgba(0, 0, 0, 0.78) 80%,
    rgba(0, 0, 0, 0.40) 87%,
    rgba(0, 0, 0, 0.12) 93%,
    rgba(0, 0, 0, 0.02) 97%,
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.02) 3%,
    rgba(0, 0, 0, 0.12) 7%,
    rgba(0, 0, 0, 0.40) 13%,
    rgba(0, 0, 0, 0.78) 20%,
    #000 29%,
    #000 71%,
    rgba(0, 0, 0, 0.78) 80%,
    rgba(0, 0, 0, 0.40) 87%,
    rgba(0, 0, 0, 0.12) 93%,
    rgba(0, 0, 0, 0.02) 97%,
    transparent 100%
  );
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.media-card {
  background: #071f35;
}

.media-youtube-preview {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background-color: #071f35;
  background-image:
    linear-gradient(180deg, rgba(5, 42, 76, 0.02), rgba(5, 42, 76, 0.12)),
    var(--youtube-poster),
    var(--youtube-fallback);
  background-position: center;
  background-size: cover;
  transform: scale(1.02);
  transition: transform 0.62s cubic-bezier(0.22, 1, 0.36, 1), filter 0.35s ease;
}

.media-youtube-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 42, 76, 0.02) 40%, rgba(5, 42, 76, 0.84) 100%);
}

.media-youtube-preview iframe {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 318%;
  height: 100%;
  border: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.media-youtube-preview.is-ready iframe {
  opacity: 1;
}

.media-card:hover .media-youtube-preview,
.media-card:focus-within .media-youtube-preview {
  transform: scale(1.055);
  filter: saturate(1.04) contrast(1.04);
}

.media-card .media-play,
.media-card .media-caption {
  z-index: 4;
}

.media-caption strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  line-height: 1.08;
}

.media-caption span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.media-modal-dialog iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 82vh;
  border: 0;
  background: #000;
}

@media (max-width: 900px) {
  .media-viewport {
    -webkit-mask-image: linear-gradient(
      90deg,
      transparent 0%,
      rgba(0, 0, 0, 0.12) 8%,
      rgba(0, 0, 0, 0.72) 18%,
      #000 28%,
      #000 72%,
      rgba(0, 0, 0, 0.72) 82%,
      rgba(0, 0, 0, 0.12) 92%,
      transparent 100%
    );
    mask-image: linear-gradient(
      90deg,
      transparent 0%,
      rgba(0, 0, 0, 0.12) 8%,
      rgba(0, 0, 0, 0.72) 18%,
      #000 28%,
      #000 72%,
      rgba(0, 0, 0, 0.72) 82%,
      rgba(0, 0, 0, 0.12) 92%,
      transparent 100%
    );
  }
}

@media (prefers-reduced-motion: reduce) {
  .media-youtube-preview,
  .media-youtube-preview iframe {
    transition: none !important;
  }
}


/* Rendiment: només hi ha un reproductor actiu; la resta són pòsters lleugers. */
.media-card {
  contain: layout paint style;
}

.media-youtube-preview {
  contain: paint;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.media-youtube-preview:not(.is-active-preview) iframe {
  display: none !important;
}

.media-youtube-preview.is-active-preview {
  will-change: transform;
}

.media-youtube-preview.is-active-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.media-card.has-live-preview {
  box-shadow: 0 28px 58px rgba(5, 42, 76, 0.24);
}

html.ac-youtube-lite .media-youtube-preview iframe {
  display: none !important;
}

html.ac-youtube-lite .media-youtube-preview {
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Evita que el navegador reservi cap capa GPU per a iframes inexistents. */
.media-youtube-preview:not(.is-active-preview) {
  will-change: auto;
}
