/* https://modern-css.com/articles/build-a-css-only-carousel/ */

.carousel-wrapper {
  position: relative;
}

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  gap: 16px;
  scrollbar-width: none;

  /* focus visible csstricks: only focus for keyboard navigation */
  &:focus:not(:focus-visible) {
    outline: none;
  }

  /* scroll-marker-group: after; // coming in the future */

  li {
    flex: 0 0 100%;
    scroll-snap-align: center;
    scroll-margin: 0;
    scroll-margin-top: 100vh; /* this weird trick helps stop scrolling to top */
    overflow-y: hidden;
    scrollbar-width: none;
  }
}

.carousel-dots {
  position: absolute;
  bottom: .5rem;
  left: 50%;
  transform: translateX(-50%);
  width: fit-content;
  height: 1rem;
  display: flex;
  gap: .5rem;
  a {
    width: .5rem;
    height: .5rem;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #ccc;
    transition: all .3s ease-in;
  }
}

/* Select active dots based on which slide has been targeted */
.carousel-wrapper:has(#carousel-slide-1:target) .carousel-dots a[href="#carousel-slide-1"],
.carousel-wrapper:has(#carousel-slide-2:target) .carousel-dots a[href="#carousel-slide-2"],
.carousel-wrapper:has(#carousel-slide-3:target) .carousel-dots a[href="#carousel-slide-3"], 
.carousel-wrapper:has(#carousel-slide-4:target) .carousel-dots a[href="#carousel-slide-4"], 
.carousel-wrapper:has(#carousel-slide-5:target) .carousel-dots a[href="#carousel-slide-5"],
.carousel-wrapper:has(#carousel-slide-6:target) .carousel-dots a[href="#carousel-slide-6"],
.carousel-wrapper .carousel-dots a.is-active {
  transform: scale(1.4);
  background: #fff;
}

/* These will work in the future: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/::scroll-button#browser_compatibility */

/* .carousel::scroll-button(left) {
  content: "←" / "Previous";
  outline: 5px yellow solid;
}
.carousel::scroll-button(right) {
  content: "→" / "Next";
}

.carousel li::scroll-marker {
  content: '';
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #ccc;
}

.carousel li::scroll-marker:target-current {
  background: #7c3aed;
} */