/* BUF PDP Gallery: main stage + 2x2 thumbnail grid. Scoped to .buf-gallery; nothing else on the page is touched.
   Uses the theme's tokens with literal fallbacks (--radius-md, --buf-line, --buf-ink; brand red #E30613 as on the rest of the site). */
.buf-gallery { width: 100%; }

/* Stage: fixed 4:5 frame (same proportion the site already uses for the product photo), so images and videos never resize the column. */
.buf-gallery__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: var(--radius-md, 14px);
  border: 1px solid var(--buf-line, #e6e6e1);
  background: #fff;
}
.buf-gallery__slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.buf-gallery__slide.is-active { opacity: 1; pointer-events: auto; z-index: 2; }
.buf-gallery__slide.is-under  { opacity: 1; z-index: 1; }     /* outgoing item stays visible under the incoming one, so the fade never washes out to white */
.buf-gallery__slide picture { display: block; width: 100%; height: 100%; }
.single-product .buf-gallery__slide img,
.single-product .buf-gallery__slide video {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  object-fit: cover;
  object-position: center;
  border-radius: 0;
  aspect-ratio: auto;
}
.buf-gallery__slide--video { background: var(--buf-ink, #14140F); }

/* Thumbnails: two columns, landscape cells, clear active ring. */
.buf-gallery__thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.single-product .buf-gallery__thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md, 14px);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  line-height: 0;
  min-height: 0;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  transition: transform .25s ease;
}
.single-product .buf-gallery__thumb img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  object-fit: cover;
  border-radius: 0;
  transition: transform .5s cubic-bezier(.22,.61,.36,1);
}
.buf-gallery__thumb::after {                /* ring drawn above the image so it stays visible */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--buf-line, #e6e6e1);
  transition: box-shadow .2s ease;
  pointer-events: none;
}
.buf-gallery__thumb:hover img { transform: scale(1.04); }
.buf-gallery__thumb.is-active::after { box-shadow: inset 0 0 0 2px #E30613; }
.buf-gallery__thumb:focus-visible { outline: 2px solid #E30613; outline-offset: 2px; }
.buf-gallery__thumb:focus:not(:focus-visible) { outline: none; }

/* Small play mark on video thumbnails. */
.buf-gallery__play {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(20, 20, 15, .72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.buf-gallery__play svg { width: 11px; height: 11px; margin-left: 2px; fill: currentColor; }

@media (max-width: 768px) {
  .buf-gallery__thumbs { gap: 10px; margin-top: 10px; }
  .single-product .buf-gallery__thumb { aspect-ratio: 4 / 3; }
}
@media (prefers-reduced-motion: reduce) {
  .buf-gallery__slide, .single-product .buf-gallery__thumb img, .buf-gallery__thumb::after { transition: none; }
  .buf-gallery__thumb:hover img { transform: none; }
}
