.product-media-gallery {
  position: relative;
  width: min(100%, 620px);
  min-width: 0;
  justify-self: center;
}

.product-media-gallery__viewport.gallery__main {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: clamp(14px, 1.8vw, 22px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 30px;
  background:
    radial-gradient(circle at 22% 12%, rgba(40, 214, 255, 0.14), transparent 38%),
    radial-gradient(circle at 86% 84%, rgba(255, 79, 183, 0.14), transparent 42%),
    var(--surface);
  box-shadow: var(--shadow);
  outline: none;
  touch-action: pan-y pinch-zoom;
}

.product-media-gallery__viewport:focus-visible {
  box-shadow: 0 0 0 3px rgba(40, 214, 255, 0.34), var(--shadow);
}

.product-media-gallery__slides {
  position: relative;
  width: 100%;
  height: 100%;
}

.product-media-gallery__slide {
  width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transform: translateX(0) scale(1);
  transition: opacity 240ms ease, transform 320ms ease;
}

.product-media-gallery__slide[hidden] {
  display: none !important;
}

.product-media-gallery__media,
.gallery__main .product-media-gallery__media {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 22px;
  filter: drop-shadow(0 24px 45px rgba(0, 0, 0, 0.3));
}

/*
 * home-v2.css possui uma regra generica para imagens de galerias com
 * object-fit: cover. Ela tem especificidade maior e acabava ampliando/cortando
 * as fotos do produto. Este componente precisa sempre preservar a midia toda.
 */
.store-v2 .product-media-gallery__viewport.gallery__main .product-media-gallery__media {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center;
}

video.product-media-gallery__media {
  background: rgba(3, 8, 25, 0.72);
  filter: none;
}

.product-media-gallery__arrow {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 48px;
  height: 48px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(7, 17, 45, 0.75);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transform: translateY(-50%);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.product-media-gallery__arrow:hover {
  border-color: rgba(40, 214, 255, 0.66);
  background: rgba(13, 29, 66, 0.94);
}

.product-media-gallery__arrow:active {
  transform: translateY(-50%) scale(0.94);
}

.product-media-gallery__arrow:focus-visible,
.product-media-gallery__autoplay:focus-visible,
.product-media-gallery__thumb:focus-visible {
  outline: 3px solid rgba(40, 214, 255, 0.65);
  outline-offset: 3px;
}

.product-media-gallery__arrow--prev {
  left: 14px;
}

.product-media-gallery__arrow--next {
  right: 14px;
}

.product-media-gallery__toolbar {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.product-media-gallery__status {
  margin: 0;
  color: rgba(239, 246, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.product-media-gallery__autoplay {
  min-height: 34px;
  padding: 6px 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(239, 246, 255, 0.88);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.product-media-gallery__autoplay:hover {
  border-color: rgba(255, 79, 183, 0.42);
  background: rgba(255, 255, 255, 0.08);
}

.product-media-gallery__thumbs.gallery__thumbs {
  width: 100%;
  padding: 4px 3px 8px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(82px, 108px);
  grid-template-columns: none;
  justify-content: start;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scrollbar-color: rgba(40, 214, 255, 0.45) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

.product-media-gallery__thumbs::-webkit-scrollbar {
  height: 7px;
}

.product-media-gallery__thumbs::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.product-media-gallery__thumbs::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(40, 214, 255, 0.42);
}

.product-media-gallery__thumb.gallery__thumb {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  padding: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
  scroll-snap-align: start;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.product-media-gallery__thumb:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.28);
}

.product-media-gallery__thumb.is-active {
  border-color: #28d6ff;
  box-shadow: 0 0 0 2px rgba(40, 214, 255, 0.2), 0 10px 24px rgba(40, 214, 255, 0.14);
}

.product-media-gallery__thumb img,
.product-media-gallery__thumb video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 11px;
  object-fit: contain;
  object-position: center;
  background: rgba(255, 255, 255, 0.94);
}

.product-media-gallery__thumb-video {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.product-media-gallery__play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  padding-left: 2px;
  color: #fff;
  font-size: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 50%;
  background: rgba(7, 17, 45, 0.78);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.product-media-gallery__slide img.product-media-gallery__media {
  cursor: zoom-in;
}

.product-media-gallery__zoom {
  position: absolute;
  z-index: 5;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(7, 17, 45, 0.75);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.product-media-gallery__zoom:hover {
  border-color: rgba(40, 214, 255, 0.66);
  background: rgba(13, 29, 66, 0.94);
  transform: scale(1.06);
}

.product-media-gallery__zoom:focus-visible {
  outline: 3px solid rgba(40, 214, 255, 0.65);
  outline-offset: 3px;
}

/* Lightbox — visualizacao ampliada */
body.ff-lightbox-open {
  overflow: hidden;
}

.ff-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 200ms ease;
}

.ff-lightbox.is-visible {
  opacity: 1;
}

.ff-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 20, 0.92);
  backdrop-filter: blur(10px);
  cursor: zoom-out;
}

.ff-lightbox__stage {
  position: relative;
  z-index: 1;
  max-width: min(1200px, 92vw);
  max-height: 86vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ff-lightbox__media {
  display: block;
  max-width: min(1200px, 92vw);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

.ff-lightbox__button {
  position: absolute;
  z-index: 2;
  width: 50px;
  height: 50px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(7, 17, 45, 0.78);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.ff-lightbox__button:hover {
  border-color: rgba(40, 214, 255, 0.66);
  background: rgba(13, 29, 66, 0.96);
}

.ff-lightbox__button:focus-visible {
  outline: 3px solid rgba(40, 214, 255, 0.65);
  outline-offset: 3px;
}

.ff-lightbox__button--close {
  top: 20px;
  right: 20px;
}

.ff-lightbox__button--prev {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.ff-lightbox__button--next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.ff-lightbox__button--prev:active,
.ff-lightbox__button--next:active {
  transform: translateY(-50%) scale(0.94);
}

.ff-lightbox__counter {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 18px;
  margin: 0;
  padding: 7px 16px;
  color: rgba(239, 246, 255, 0.9);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(7, 17, 45, 0.78);
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
}

@media (max-width: 680px) {
  .product-media-gallery__viewport.gallery__main {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    padding: 10px;
    border-radius: 21px;
  }

  .product-media-gallery__media,
  .gallery__main .product-media-gallery__media {
    border-radius: 15px;
  }

  .product-media-gallery__arrow {
    width: 40px;
    height: 40px;
  }

  .product-media-gallery__arrow--prev {
    left: 9px;
  }

  .product-media-gallery__arrow--next {
    right: 9px;
  }

  .product-media-gallery__zoom {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
  }

  .ff-lightbox__button {
    width: 44px;
    height: 44px;
  }

  .ff-lightbox__button--close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
  }

  .ff-lightbox__button--prev {
    left: 10px;
  }

  .ff-lightbox__button--next {
    right: 10px;
  }

  .ff-lightbox__media {
    max-width: 96vw;
    max-height: 80vh;
    max-height: 80svh;
    border-radius: 12px;
  }

  .product-media-gallery__thumbs.gallery__thumbs {
    grid-auto-columns: 76px;
    gap: 9px;
  }

  .product-media-gallery__autoplay [data-gallery-autoplay-label] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

@media (max-width: 420px) {
  .product-media-gallery { width: 100%; }
  .product-media-gallery__viewport.gallery__main { padding: 8px; border-radius: 18px; }
  .product-media-gallery__arrow { width: 38px; height: 38px; }
  .product-media-gallery__arrow--prev { left: 7px; }
  .product-media-gallery__arrow--next { right: 7px; }
  .product-media-gallery__zoom { width: 38px; height: 38px; }
  .product-media-gallery__toolbar { padding-inline: 2px; }
  .product-media-gallery__thumbs.gallery__thumbs { grid-auto-columns: 70px; gap: 8px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .product-media-gallery__viewport.gallery__main {
    width: min(100%, 78svh);
    height: min(78vh, 78svh);
    aspect-ratio: 1 / 1;
    margin-inline: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-media-gallery *,
  .product-media-gallery *::before,
  .product-media-gallery *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
