/* Swipeable product image gallery (templates/quiz/_image_gallery.html).
   Sits inside an existing image figure (.top-pick-image, .compare-product-image),
   which supplies the size, background and border. */

.image-gallery {
  position: relative;
}

/* The track is absolutely positioned inside the image frame (inset by the
   frame's --image-frame-pad), and each image fills its slide. No percentage
   heights are involved: WebKit resolves those unreliably inside flex items
   and aspect-ratio boxes, which cropped images instead of fitting them. */
.image-gallery .image-gallery-track {
  position: absolute;
  inset: var(--image-frame-pad, 0.5rem);
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.image-gallery .image-gallery-track::-webkit-scrollbar {
  display: none;
}

.image-gallery .image-gallery-track:focus-visible {
  outline: 2px solid var(--pico-primary);
  outline-offset: 2px;
}

.image-gallery .image-gallery-slide {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.image-gallery .image-gallery-slide img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  user-select: none;
}

.image-gallery .image-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  color: #1f2937;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.15s ease;
}

.image-gallery .image-gallery-nav[hidden] {
  display: none;
}

.image-gallery .image-gallery-nav:hover,
.image-gallery .image-gallery-nav:focus-visible {
  opacity: 1;
}

.image-gallery .image-gallery-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.image-gallery .image-gallery-prev {
  left: 0.25rem;
}

.image-gallery .image-gallery-next {
  right: 0.25rem;
}

.image-gallery .image-gallery-counter {
  position: absolute;
  bottom: 0.3rem;
  right: 0.3rem;
  padding: 0.05rem 0.45rem;
  font-size: 0.7rem;
  line-height: 1.4;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .image-gallery .image-gallery-track {
    scroll-behavior: auto;
  }
}
