
/* ==================================================
   GPCHILD SLIDER LIGHT
   GeneratePress + GenerateBlocks
   ================================================== */

/* 1. VARIABLES GLOBALES */

.gpchild-slider {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 420px;
  background: #18212c;
  color: #fff;

  /* Padding du contenu */
  --slider-content-pt: 0;
  --slider-content-pb: 0;
  --slider-content-pl: 4rem;
  --slider-content-pr: 0;

  /* Position du contenu */
  --slider-content-x: flex-start;
  --slider-content-y: center;
  --slider-text-align: left;

  /* Vitesse et animation */
  --slider-autoplay-ms: 6500;
  --slider-transition: 650ms;
}

.gpchild-slider,
.gpchild-slider * {
  box-sizing: border-box;
}

/* 2. GALERIE ET IMAGES */

.gpchild-slider .wp-block-gallery.gpchild-slider__gallery {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  gap: 0;
  background: #18212c;
}

.gpchild-slider
.wp-block-gallery.gpchild-slider__gallery
> figure.wp-block-image {
  position: absolute;
  inset: 0;
  display: block;
  flex: none;
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--slider-transition) ease,
    visibility var(--slider-transition) ease;
}

/* Première image visible sans JavaScript */

.gpchild-slider
.wp-block-gallery.gpchild-slider__gallery:not(.is-enhanced)
> figure.wp-block-image:first-child,
.gpchild-slider
.wp-block-gallery.gpchild-slider__gallery
> figure.wp-block-image.is-active {
  opacity: 1;
  visibility: visible;
}

.gpchild-slider
.wp-block-gallery.gpchild-slider__gallery
> figure.wp-block-image img {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Les légendes sont affichées par le JS */

.gpchild-slider
.wp-block-gallery.gpchild-slider__gallery
figcaption {
  display: none;
}

/* 3. VOILE DE CONTRASTE */

.gpchild-slider::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.45) 48%,
    rgba(0, 0, 0, 0.12) 100%
  );
}

/* 4. CONTENU FIXE GENERATEBLOCKS */

.gpchild-slider .gpchild-slider__content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;

  align-items: var(--slider-content-x);
  justify-content: var(--slider-content-y);
  text-align: var(--slider-text-align);

  width: 100%;
  min-height: clamp(440px, 43.75vw, 760px);
  margin-inline: auto;

  padding-top: var(--slider-content-pt);
  padding-bottom: var(--slider-content-pb);

  padding-left: max(
    var(--slider-content-pl),
    env(safe-area-inset-left)
  );

  padding-right: max(
    var(--slider-content-pr),
    env(safe-area-inset-right)
  );
}

.gpchild-slider .gpchild-slider__content > * {
  max-width: 100%;
  min-width: 0;
}

.gpchild-slider .gpchild-slider__content :is(h1, h2, h3) {
  max-width: 900px;
  color: inherit;
  line-height: 1.08;
  text-align: var(--slider-text-align);
  text-wrap: balance;
}

.gpchild-slider .gpchild-slider__content p {
  max-width: 700px;
  color: inherit;
  text-align: var(--slider-text-align);
  text-wrap: pretty;
}

/* Groupes de boutons */

.gpchild-slider .gpchild-slider__content :is(
  .gb-buttons,
  .gb-button-wrapper,
  .wp-block-buttons
) {
  justify-content: var(--slider-content-x);
}

/* Protection des CTA */

.gpchild-slider .gpchild-slider__content :is(
  .gb-button,
  .wp-block-button__link
) {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* 5. NAVIGATION */

.gpchild-slider__controls {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 16px;
  transform: translateX(-50%);
}

.gpchild-slider__arrow {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.gpchild-slider__arrow:hover {
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
}

.gpchild-slider__dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gpchild-slider__dot {
  display: block;
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
}

.gpchild-slider__dot.is-active {
  background: #fff;
  transform: scale(1.2);
}

.gpchild-slider__arrow:focus-visible,
.gpchild-slider__dot:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

/* 6. LEGENDE OPTIONNELLE */

.gpchild-slider__caption {
  position: absolute;
  right: 24px;
  bottom: 30px;
  z-index: 3;
  max-width: 340px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  text-align: right;
  pointer-events: none;
}

.gpchild-slider__caption:empty {
  display: none;
}

/* 7. TABLETTE / MOBILE */

@media (max-width: 768px) {
  .gpchild-slider {
    --slider-content-pt: 4rem;
    --slider-content-pb: 7rem;
    --slider-content-pl: 1.25rem;
    --slider-content-pr: 1.25rem;
    --slider-content-y: flex-end;
  }

  .gpchild-slider::before {
    background: linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.30) 0%,
      rgba(0, 0, 0, 0.55) 48%,
      rgba(0, 0, 0, 0.82) 100%
    );
  }

  .gpchild-slider .gpchild-slider__content {
    min-height: clamp(540px, 85svh, 760px);
  }

  .gpchild-slider__caption {
    display: none;
  }

  .gpchild-slider__controls {
    bottom: 24px;
  }
}

/* 8. PETITS MOBILES */

@media (max-width: 480px) {
  .gpchild-slider {
    --slider-content-pt: 3rem;
    --slider-content-pb: 7rem;
  }

  .gpchild-slider .gpchild-slider__content {
    min-height: clamp(540px, 88svh, 720px);
  }

  .gpchild-slider__arrow {
    width: 40px;
    height: 40px;
  }
}

/* 9. POSITION HORIZONTALE */

.gpchild-slider.gpchild-slider--left {
  --slider-content-x: flex-start;
  --slider-text-align: left;
}

.gpchild-slider.gpchild-slider--center-x {
  --slider-content-x: center;
  --slider-text-align: center;
}

.gpchild-slider.gpchild-slider--right {
  --slider-content-x: flex-end;
  --slider-text-align: right;
}

/* 10. POSITION VERTICALE */

.gpchild-slider.gpchild-slider--top {
  --slider-content-y: flex-start;
}

.gpchild-slider.gpchild-slider--center-y {
  --slider-content-y: center;
}

.gpchild-slider.gpchild-slider--bottom {
  --slider-content-y: flex-end;
}

/* 11. VITESSES PREREGLEES */

.gpchild-slider.gpchild-slider--fast {
  --slider-autoplay-ms: 4000;
  --slider-transition: 400ms;
}

.gpchild-slider.gpchild-slider--slow {
  --slider-autoplay-ms: 9000;
  --slider-transition: 1000ms;
}

/* 12. ACCESSIBILITE */

@media (prefers-reduced-motion: reduce) {
  .gpchild-slider
  .wp-block-gallery.gpchild-slider__gallery
  > figure.wp-block-image {
    transition: none;
  }
}
