/*
 * Do not wrap carousel layout in @layer.
 * Some App WebViews drop unknown @layer blocks entirely.
 */
theme-carousel {
  position: relative;
  display: block;
}

theme-carousel .carousel__track {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  /* auto: iOS Safari stutters when smooth is on the overflow container.
     Programmatic smooth scrolling uses scrollTo({ behavior }) in goTo(). */
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none;
  /* Keep horizontal overscroll from chaining to the page (iOS rubber-band shake). */
  overscroll-behavior-x: contain;
}

theme-carousel.has-drag:not(.is-dragging) .carousel__track {
  cursor: grab;
}

/*
 * Allow native horizontal pan on touch. Custom drag is mouse-only; pan-y-only
 * previously forced JS scrollLeft and caused iOS Safari swipe jitter.
 */
theme-carousel.has-drag:not([data-direction="vertical"]):not([data-mobile-direction="vertical"]) .carousel__track {
  touch-action: pan-x pan-y pinch-zoom;
}

theme-carousel.has-drag.is-dragging .carousel__track {
  cursor: grabbing;
  user-select: none;
  touch-action: none;
}

theme-carousel.has-drag.is-dragging .carousel__track > * {
  transition: none !important;
}

theme-carousel.has-drag .carousel__track img,
theme-carousel.has-drag .carousel__track a {
  -webkit-user-drag: none;
  user-select: none;
}

theme-carousel .carousel__track::-webkit-scrollbar {
  display: none;
}

theme-carousel .carousel__track > * {
  flex-shrink: 0;
  list-style: none;
  scroll-snap-align: start;
}

theme-carousel .carousel__track-scroll-behavior--auto {
  scroll-behavior: auto;
}

theme-carousel .carousel__track-scroll-snap-type--none {
  scroll-snap-type: none;
}

theme-carousel[data-scroll-snap-align="center"] .carousel__track > * {
  scroll-snap-align: center;
}

theme-carousel[data-scroll-snap-align="end"] .carousel__track > * {
  scroll-snap-align: end;
}

theme-carousel[data-direction="vertical"] .carousel__track {
  flex-direction: column;
  overflow-x: unset;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
}

@media (min-width: 960px) {
  theme-carousel[data-desktop-direction="vertical"] .carousel__track {
    flex-direction: column;
    overflow-x: unset;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
  }
}

@media (max-width: 959px) {
  theme-carousel[data-mobile-direction="vertical"] .carousel__track {
    flex-direction: column;
    overflow-x: unset;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
  }
}
