/* ==========================================================================
   GALLERY SECTION
========================================================================== */

.section:has(.swiper.is--gallery) {
  overflow: hidden;
}

/* ==========================================================================
   SOURCE VIDEO EMBED
========================================================================== */

/*
 * Avant l'initialisation JS, l'embed vidéo CMS est placé
 * au-dessus du slider.
 *
 * On le masque pour éviter tout flash.
 *
 * Dès que le JS démarre, il est physiquement déplacé dans
 * le premier slide.
 */

.section:has(.swiper.is--gallery) > .video--embed {
  display: none !important;
}

/* ==========================================================================
   GALLERY SWIPER — FADE
========================================================================== */

.swiper.is--gallery {
  position: relative;
  width: 100%;
  overflow: hidden;
  cursor: grab;
}

.swiper.is--gallery:active {
  cursor: grabbing;
}

.swiper.is--gallery .swiper-wrapper {
  position: relative;
}

/* ==========================================================================
   GALLERY BEFORE INITIALIZATION
========================================================================== */

.swiper.is--gallery:not(.swiper-initialized) {
  cursor: default;
}

.swiper.is--gallery:not(.swiper-initialized) .swiper-wrapper {
  transform: none !important;
}

.swiper.is--gallery:not(.swiper-initialized) .swiper-slide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.swiper.is--gallery:not(.swiper-initialized) .swiper-slide:first-child {
  opacity: 1;
  visibility: visible;
  position: relative;
}

/* ==========================================================================
   GALLERY SLIDES — STACKED FADE
========================================================================== */

/*
 * Hauteur : .swiper-slide.is--gallery (Webflow).
 * Largeur : 100% du swiper (slides empilées pour le fade).
 */

.swiper.is--gallery .swiper-slide {
  width: 100% !important;
  max-width: 100% !important;

  pointer-events: none;
}

.swiper.is--gallery .swiper-slide-active {
  pointer-events: auto;
}

/* ==========================================================================
   GALLERY IMAGE WRAPPER
========================================================================== */

.swiper.is--gallery .swiper-slide > .gallery--image-wrapper {
  position: relative;

  width: 100%;
  height: 100%;

  overflow: hidden;
}

.swiper.is--gallery .swiper-slide > .gallery--image-wrapper.is--fixed {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   GALLERY IMAGES
========================================================================== */

.swiper.is--gallery
  .swiper-slide
  > .gallery--image-wrapper
  > img {
  display: block;

  width: 100% !important;
  height: 100% !important;
}

/* ==========================================================================
   VIDEO — PERSISTENT LAYER (always playing)
========================================================================== */

/*
 * Un seul player, hors slides, TOUJOURS au-dessus du track.
 * Visible uniquement sur la slide vidéo — sinon opacity 0
 * (pas derrière les images, sinon il “reste toujours au fond”).
 */

.swiper.is--gallery > .gallery-video-layer {
  position: absolute;

  inset: 0;

  z-index: 5;

  width: 100%;
  height: 100%;

  overflow: hidden;

  opacity: 0;

  pointer-events: none;

  transition: opacity 0.7s ease;
}

/*
 * Avant init Swiper, la slide vidéo est la première :
 * on affiche déjà la couche (poster) pour éviter un vide.
 */

.swiper.is--gallery:not(.swiper-initialized) > .gallery-video-layer,
.swiper.is--gallery.is-showing-gallery-video > .gallery-video-layer {
  opacity: 1;
}

.swiper.is--gallery .gallery-video-poster {
  position: absolute;

  inset: 0;

  z-index: 3;

  display: block;

  width: 100%;
  height: 100%;

  object-fit: contain;

  pointer-events: none;

  transition: opacity 0.45s ease, visibility 0s linear 0s;
}

.swiper.is--gallery .gallery-video-poster.is-hidden {
  opacity: 0;
  visibility: hidden;

  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
}

.swiper.is--gallery .swiper-wrapper {
  position: relative;
  z-index: 2;
}

.swiper.is--gallery .swiper-slide.is-gallery-video-slide {
  background: transparent;
  pointer-events: auto;
}

.swiper.is--gallery
  .swiper-slide.is-gallery-video-slide
  > .gallery--image-wrapper {
  background: transparent;
}

.swiper.is--gallery .video--embed {
  position: absolute !important;

  inset: 0 !important;

  z-index: 1;

  display: block !important;

  width: 100% !important;
  height: 100% !important;

  overflow: hidden;

  pointer-events: none;
}

/* ==========================================================================
   VIDEO INTERNAL WRAPPER
========================================================================== */

.swiper.is--gallery .video--embed > .gallery--image-wrapper {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;

  overflow: hidden;
}

/* ==========================================================================
   GALLERY VIDEO
========================================================================== */

.swiper.is--gallery .gallery-video {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;

  overflow: hidden;

  pointer-events: none;
}

/* ==========================================================================
   VIMEO IFRAME
========================================================================== */

.swiper.is--gallery .gallery-video iframe {
  position: absolute;

  top: 50%;
  left: 50%;

  display: block;

  width: auto;
  height: auto;

  max-width: 100%;
  max-height: 100%;

  border: 0;

  pointer-events: none;

  transform: translate(-50%, -50%);
}

/* ==========================================================================
   VIDEO MUTE (base .hero--video-mute du Webflow, comme le hero)
========================================================================== */

.swiper.is--gallery .gallery-video-mute {
  right: max(
    1rem,
    calc(50% - var(--gallery-video-width, 100%) / 2 + 1rem)
  );
  bottom: max(
    1rem,
    calc(50% - var(--gallery-video-height, 100%) / 2 + 1rem)
  );
  z-index: 6;

  border: 0;
  color: #fff;

  cursor: pointer;
  user-select: none;
  pointer-events: auto;
}

.swiper.is--gallery.swiper-initialized:not(.is-showing-gallery-video)
  .gallery-video-mute {
  visibility: hidden;
  pointer-events: none;
}

.swiper.is--gallery .gallery-video-mute svg:nth-child(2),
.swiper.is--gallery .gallery-video-mute[data-vimeo-muted="true"] svg:nth-child(1) {
  display: none;
}

.swiper.is--gallery .gallery-video-mute svg:nth-child(1),
.swiper.is--gallery .gallery-video-mute[data-vimeo-muted="true"] svg:nth-child(2) {
  display: block;
}

.swiper.is--gallery .gallery-video-mute:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 0.25rem;
}

/* ==========================================================================
   GALLERY PAGINATION
========================================================================== */

.swiper--pagination.is--gallery {
  width: 24rem;

  max-width: calc(100% - 3rem);

  margin: 3rem auto 0;
}

.swiper--pagination.is--gallery .swiper--progress {
  position: relative;

  width: 100%;
  height: 1px;

  overflow: hidden;

  background-color: rgba(0, 0, 0, 0.18);
}

.swiper--pagination.is--gallery .pagination--indicator {
  width: 100%;
  height: 100%;

  background-color: currentColor;

  transform: scaleX(0);
  transform-origin: left center;

  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);

  will-change: transform;
}

/* ==========================================================================
   GALLERY TABLET
========================================================================== */

@media screen and (max-width: 991px) {
  .swiper--pagination.is--gallery {
    width: 20rem;
    margin-top: 2.5rem;
  }
}

/* ==========================================================================
   GALLERY MOBILE
========================================================================== */

@media screen and (max-width: 767px) {
  .swiper--pagination.is--gallery {
    width: calc(100% - 3rem);
    margin-top: 2rem;
  }
}

/* ==========================================================================
   REDUCED MOTION
========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .swiper.is--gallery .video--embed,
  .swiper--pagination.is--gallery .pagination--indicator {
    transition-duration: 0.01ms !important;
  }
}
