/**
 * carousel.css
 *
 * Styles for a responsive and touch-friendly carousel.
 * ------------------------------------------------------------------------------
 * @feature {CSS Custom Properties} - For easy customization of animation.
 * @feature {backdrop-filter} - For modern "glassmorphism" button effects.
 * @feature {Scroll Snap} (Progressive Enhancement) - Provides a JS-free fallback.
 */

:is(carousel, [data-carousel], .carousel) {
  --slide-duration: attr(duration type(*), 500ms);
  --slide-timing: attr(timing-function type(*), cubic-bezier(0.4, 0, 0.2, 1));

  position: relative;
  display: block;
  overflow: hidden;
  border-radius: attr(radius type(*), 0.75rem);
  width: attr(width type(*), 100%);
  max-inline-size: 100%;
}

/*
 * The slides container can use scroll-snapping as a JS-free enhancement.
 * The JS will override this with transform-based animation if it loads.
 */
:is(.carousel-slides, [data-carousel-slides]) {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Hide scrollbar in Firefox */
  -ms-overflow-style: none; /* Hide scrollbar in IE/Edge */
  transition: transform var(--slide-duration) var(--slide-timing);
@media (prefers-reduced-motion: reduce) {
  transition: none;
}

  &::-webkit-scrollbar { display: none; } /* Hide scrollbar in WebKit */
}

:is(carousel-item, [data-carousel-item], .carousel-item) {
  flex-shrink: 0;
  scroll-snap-align: start;
}

:is(carousel-trigger, [data-carousel-trigger], .carousel-trigger) {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background-color: oklch(from var(--theme-bg) l c h / 0.5);
  backdrop-filter: blur(5px);
  color: var(--theme-text);
  border: 1px solid transparent;
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, opacity 0.2s;

  &:hover {
    background-color: oklch(from var(--theme-bg) l c h / 0.8);
    border-color: var(--theme-primary);
  }

  &[direction="prev"] { inset-inline-start: 1rem; }
  &[direction="next"] { inset-inline-end: 1rem; }

  &[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
  }
}
