/* ─────────────────────────────────────────────────────────────────────────────
   Bobby Product Gallery (funnel port)
   - 5px gap tra slide, 10% peek della slide successiva (flex: 0 0 90%)
   - Scroll-snap nativo del browser (x mandatory); snap off durante il drag desktop
   - Mobile: scroll nativo OS con inerzia fisica del SO
   Differenze rispetto a Norvato: media con --media-radius e slide quadrate (1:1).
   ───────────────────────────────────────────────────────────────────────────── */

.bobby-product-gallery {
  --media-radius: var(--r);
  width: 100%;
  position: relative;
  margin: 0;
  overflow: hidden;
}

/* ─── Container: flex + scroll-snap nativo ─────────────────────────────────── */
.bobby-product-gallery .bobby-gallery-container {
  display: flex;
  overflow-x: scroll;
  overflow-y: hidden;
  width: 100%;
  gap: 5px;

  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;

  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;

  cursor: grab;
}

.bobby-product-gallery .bobby-gallery-container:active {
  cursor: grabbing;
}

.bobby-product-gallery .bobby-gallery-container::-webkit-scrollbar {
  display: none;
}

/* Durante il drag desktop: disabilita snap per movimento 1:1 libero */
.bobby-product-gallery .bobby-gallery-container.bobby-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
}

/* ─── Slide: quadrate (1:1), 90% width = 10% peek della successiva ──────────── */
.bobby-product-gallery .bobby-gallery-slide {
  flex: 0 0 calc(90% - 2.5px); /* compensa meta del gap da un lato */
  aspect-ratio: 1;
  height: auto;
  position: relative;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--media-radius);

  scroll-snap-align: start;
  scroll-snap-stop: normal;
}

.bobby-product-gallery .bobby-gallery-slide img,
.bobby-product-gallery .bobby-gallery-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: var(--media-radius);
  box-shadow: none;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

/* ─── Lazy loading fade-in ──────────────────────────────────────────────────── */
.bobby-product-gallery .bobby-gallery-slide img[loading='lazy'] {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bobby-product-gallery .bobby-gallery-slide img[loading='lazy'].bobby-loaded {
  opacity: 1;
}

/* ─── Dots ───────────────────────────────────────────────────────────────────── */
.bobby-product-gallery .bobby-gallery-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  margin-top: 1.25rem;
}

.bobby-product-gallery .bobby-gallery-dots .bobby-dot {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.bobby-product-gallery .bobby-gallery-dots .bobby-dot:hover {
  transform: scale(1.1);
}

.bobby-product-gallery .bobby-gallery-dots .bobby-dot span {
  display: block;
  width: 10px;
  height: 10px;
  margin: 5px 7px;
  border-radius: 30px;
  background: #d6d6d6;
  transition: background-color 0.2s ease;
}

.bobby-product-gallery .bobby-gallery-dots .bobby-dot:hover span,
.bobby-product-gallery .bobby-gallery-dots .bobby-dot.bobby-active span {
  background: var(--blue);
}

.bobby-product-gallery .bobby-gallery-dots .bobby-dot:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 50%;
}

/* ─── Thumbnails ────────────────────────────────────────────────────────────── */
.bobby-product-gallery .bobby-gallery-thumbs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.bobby-product-gallery .bobby-gallery-thumbs .bobby-thumb {
  flex: 0 0 calc(20% - 0.4rem);
  aspect-ratio: 1;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 1px; /* 1px di spazio tra bordo e immagine */
  background: transparent;
  cursor: pointer;
  margin: 0;
  overflow: hidden;
  opacity: 0.55;
  transition:
    opacity 0.2s ease,
    border-color 0.2s ease;
}

.bobby-product-gallery .bobby-gallery-thumbs .bobby-thumb:hover {
  opacity: 0.85;
}

.bobby-product-gallery .bobby-gallery-thumbs .bobby-thumb.bobby-active {
  opacity: 1;
  border-color: #9aa1ac; /* antracite chiaro */
}

.bobby-product-gallery .bobby-gallery-thumbs .bobby-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 10px; /* outer 12 - 1px bordo - 1px gap */
}

.bobby-product-gallery .bobby-gallery-thumbs .bobby-thumb:focus-visible {
  outline: 2px solid #353a42;
  outline-offset: 2px;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (min-width: 750px) {
  .bobby-product-gallery .bobby-gallery-thumbs {
    margin-top: 1.25rem;
    gap: 0.75rem;
  }

  .bobby-product-gallery .bobby-gallery-thumbs .bobby-thumb {
    flex-basis: calc(20% - 0.6rem);
  }

  .bobby-product-gallery .bobby-gallery-dots {
    margin-top: 1rem;
  }
}

@media (max-width: 749px) {
  .bobby-product-gallery .bobby-gallery-thumbs.bobby-mobile-hide {
    display: none;
  }

  .bobby-product-gallery .bobby-gallery-thumbs.bobby-mobile-columns {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .bobby-product-gallery .bobby-gallery-thumbs.bobby-mobile-columns .bobby-thumb {
    flex-basis: calc(50% - 0.25rem);
    margin-bottom: 0.5rem;
  }
}

/* ─── Accessibilita ─────────────────────────────────────────────────────────── */
.bobby-sr-only {
  position: absolute !important;
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  word-wrap: normal !important;
}

@media (prefers-reduced-motion: reduce) {
  .bobby-product-gallery .bobby-gallery-slide img,
  .bobby-product-gallery .bobby-gallery-dots .bobby-dot {
    transition: none;
  }
}
