.sp-carousel {
  --sp-carousel-control-size: 40px;
  --sp-carousel-touch-size: 44px;
  --sp-carousel-dot-size: 8px;
  --sp-carousel-gap: var(--space-6, 1.5rem);
}

[data-sp-carousel] {
  position: relative;
}

.sp-carousel__viewport {
  position: relative;
}

.sp-carousel__track {
  display: flex;
  gap: var(--sp-carousel-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.sp-carousel__track::-webkit-scrollbar {
  display: none;
}

.sp-carousel__track.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  user-select: none;
}

.sp-carousel.is-ready .sp-carousel__track {
  cursor: grab;
}

.sp-carousel__slide {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.sp-carousel__arrow,
[data-sp-carousel] [data-carousel-prev],
[data-sp-carousel] [data-carousel-next] {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--sp-carousel-control-size);
  height: var(--sp-carousel-control-size);
  min-width: var(--sp-carousel-touch-size);
  min-height: var(--sp-carousel-touch-size);
  padding: 0;
  border: 1px solid var(--color-border, rgba(0, 0, 0, .16));
  border-radius: 50%;
  background: var(--color-surface, #fff);
  color: var(--color-heading, currentColor);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease;
}

.sp-carousel__arrow {
  position: absolute;
  z-index: 3;
}

.sp-carousel__arrow svg,
[data-sp-carousel] [data-carousel-prev] svg,
[data-sp-carousel] [data-carousel-next] svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sp-carousel__arrow:hover,
[data-sp-carousel] [data-carousel-prev]:hover,
[data-sp-carousel] [data-carousel-next]:hover {
  border-color: var(--sp-action, currentColor);
  background: var(--sp-action, currentColor);
  color: var(--sp-action-contrast, #fff);
}

.sp-carousel__arrow[aria-disabled="true"],
.sp-carousel__arrow.is-disabled,
[data-sp-carousel] [data-carousel-prev][aria-disabled="true"],
[data-sp-carousel] [data-carousel-next][aria-disabled="true"],
[data-sp-carousel] [data-carousel-prev].is-disabled,
[data-sp-carousel] [data-carousel-next].is-disabled {
  opacity: .35;
  pointer-events: none;
}

/* Grid rails render text labels inside the bare-attr buttons; keep them for AT, hide visually */
[data-sp-carousel] [data-carousel-prev] span[data-lang],
[data-sp-carousel] [data-carousel-next] span[data-lang] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sp-carousel__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: var(--space-4, 1.5rem);
}

.sp-carousel__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.sp-carousel__dot {
  position: relative;
  width: var(--sp-carousel-dot-size);
  height: var(--sp-carousel-dot-size);
  padding: 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.sp-carousel__dot::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 999px;
  background: var(--color-border, rgba(0, 0, 0, .18));
  transition: width .25s ease, background-color .2s ease, border-radius .25s ease;
}

.sp-carousel__dot[aria-disabled="true"]::before {
  width: 24px;
  border-radius: 4px;
  background: var(--sp-action, currentColor);
}

.sp-carousel__dot[aria-disabled="true"] {
  width: 24px;
}

.sp-carousel__dot span,
.sp-carousel__sr-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sp-carousel__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--color-border, rgba(0, 0, 0, .16));
  border-radius: 50%;
  background: var(--color-surface, #fff);
  color: var(--color-heading, currentColor);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.sp-carousel__toggle:hover {
  border-color: var(--sp-action, currentColor);
  background: var(--sp-action, currentColor);
  color: var(--sp-action-contrast, #fff);
}

.sp-carousel__toggle::before {
  content: "";
  display: block;
  width: 10px;
  height: 12px;
  border-style: solid;
  border-width: 0 3px;
  border-color: currentColor;
}

.sp-carousel__toggle.is-paused::before {
  width: 0;
  height: 0;
  margin-left: 2px;
  border-style: solid;
  border-width: 7px 0 7px 11px;
  border-color: transparent transparent transparent currentColor;
}

[data-sp-carousel]:not(.is-ready) [data-carousel-prev],
[data-sp-carousel]:not(.is-ready) [data-carousel-next],
[data-sp-carousel]:not(.is-ready) [data-carousel-dots],
[data-sp-carousel]:not(.is-ready) [data-carousel-toggle] {
  display: none;
}

[data-sp-carousel][data-nav="none"] .sp-carousel__arrow,
[data-sp-carousel][data-nav="none"] .sp-carousel__dots,
[data-sp-carousel][data-nav="arrows"] .sp-carousel__dots,
[data-sp-carousel][data-nav="dots"] .sp-carousel__arrow {
  display: none;
}

.sp-carousel__track:focus-visible,
.sp-carousel__arrow:focus-visible,
.sp-carousel__dot:focus-visible,
.sp-carousel__toggle:focus-visible {
  outline: 2px solid var(--sp-action, currentColor);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .sp-carousel__track {
    scroll-behavior: auto;
  }
}
