/* Carrousel : les photos sont empilées ; la photo courante entre, la précédente sort. */
@layer components {
  .carousel__slide {
    position: absolute;
    inset: 0;
    display: none;
    will-change: transform;
  }

  .carousel__slide picture {
    width: 100%;
    height: 100%;
  }

  .carousel__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .carousel__slide[data-state] {
    display: block;
  }

  .carousel__slide[data-state="current"] {
    z-index: 2;
  }

  .carousel__slide[data-state="previous"] {
    z-index: 1;
  }

  /* Le sens du dernier déplacement est porté par le conteneur ; aucune animation avant le premier. */
  .carousel[data-direction="next"] [data-state="current"] {
    animation: slide-in-from-end var(--carousel-duration) var(--ease-carousel) both;
  }

  .carousel[data-direction="next"] [data-state="previous"] {
    animation: slide-out-to-start var(--carousel-duration) var(--ease-carousel) both;
  }

  .carousel[data-direction="prev"] [data-state="current"] {
    animation: slide-in-from-start var(--carousel-duration) var(--ease-carousel) both;
  }

  .carousel[data-direction="prev"] [data-state="previous"] {
    animation: slide-out-to-end var(--carousel-duration) var(--ease-carousel) both;
  }

  @keyframes slide-in-from-end {
    from {
      transform: translateX(100%);
    }

    to {
      transform: translateX(0);
    }
  }

  @keyframes slide-in-from-start {
    from {
      transform: translateX(-100%);
    }

    to {
      transform: translateX(0);
    }
  }

  @keyframes slide-out-to-start {
    from {
      transform: translateX(0);
    }

    to {
      transform: translateX(-100%);
    }
  }

  @keyframes slide-out-to-end {
    from {
      transform: translateX(0);
    }

    to {
      transform: translateX(100%);
    }
  }
}
