/* Preserve native dialog focus without the theme's outer halo or square corners. */
#product-dialog .product-sheet > .sheet-close:focus {
  outline: none;
  box-shadow: none;
  border-radius: 50%;
  text-decoration: none !important;
}

#product-dialog .product-sheet > .sheet-close:focus-visible {
  filter: brightness(1.18);
}

#product-dialog .product-sheet > .sheet-close {
  place-items: center;
  font-size: 0;
  line-height: 1;
  text-decoration: none !important;
}

#product-dialog .product-sheet > .sheet-close > span {
  display: block;
  font-family: Arial, sans-serif;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
  transform: translateY(-1px);
}

/* The existing image is the only trigger; no visible zoom control or extra border. */
[data-image-viewer-trigger] {
  cursor: pointer;
}

#product-image-viewer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  overflow: hidden;
  overscroll-behavior: contain;
}

#product-image-viewer::backdrop {
  background: rgba(0, 0, 0, .88);
}

.product-image-viewer-stage {
  --viewer-top: max(16px, env(safe-area-inset-top));
  --viewer-bottom: max(16px, env(safe-area-inset-bottom));
  --viewer-left: max(16px, env(safe-area-inset-left));
  --viewer-right: max(16px, env(safe-area-inset-right));
  box-sizing: border-box;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.product-image-viewer-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-snap-type: inline mandatory;
  scrollbar-width: none;
  touch-action: pan-x pinch-zoom;
}

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

.product-image-viewer-track:focus-visible {
  outline: none;
}

.product-image-viewer-track > figure {
  box-sizing: border-box;
  display: grid;
  flex: 0 0 100%;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: var(--viewer-top) var(--viewer-right) var(--viewer-bottom) var(--viewer-left);
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.product-image-viewer-frame {
  position: relative;
  display: grid;
  place-items: start end;
  width: max-content;
  height: max-content;
  max-width: 100%;
  max-height: 100%;
}

#product-image-viewer .product-image-viewer-frame > img {
  grid-area: 1 / 1;
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - var(--viewer-left) - var(--viewer-right));
  max-height: calc(100vh - var(--viewer-top) - var(--viewer-bottom));
  max-height: calc(100dvh - var(--viewer-top) - var(--viewer-bottom));
  object-fit: contain;
  border: 0;
  border-radius: 0;
  user-select: none;
  -webkit-user-drag: none;
}

#product-image-viewer [data-close-image-viewer] {
  grid-area: 1 / 1;
  z-index: 6;
  align-self: start;
  justify-self: end;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 8px;
  padding: 0 0 1px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  text-decoration: none !important;
}

#product-image-viewer [data-close-image-viewer]:focus-visible {
  filter: brightness(1.22);
}

#product-image-viewer [data-close-image-viewer] > span {
  display: block;
  font-family: Arial, sans-serif;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  transform: translateY(-1px);
}

.product-image-viewer-arrow.previous {
  left: max(18px, env(safe-area-inset-left));
}

.product-image-viewer-arrow.next {
  right: max(18px, env(safe-area-inset-right));
}

.product-image-viewer-dots {
  bottom: max(18px, env(safe-area-inset-bottom));
}

.product-image-viewer-count {
  left: max(18px, env(safe-area-inset-left));
  top: max(18px, env(safe-area-inset-top));
}

.product-image-viewer-arrow[hidden],
.product-image-viewer-dots[hidden],
.product-image-viewer-count[hidden] {
  display: none;
}

.product-detail-gallery {
  position: relative;
  width: calc(100% - 24px);
  aspect-ratio: 1 / 1;
  margin: 12px 12px 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink) 10%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
  isolation: isolate;
}

.product-detail-gallery-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-snap-type: inline mandatory;
  scrollbar-width: none;
  touch-action: pan-x pinch-zoom;
}

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

.product-detail-gallery-track:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: -3px;
}

.product-detail-gallery figure {
  display: block;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  margin: 0;
  min-width: 0;
  min-height: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.product-detail-gallery img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  object-position: center center;
  border-radius: inherit;
  user-select: none;
  -webkit-user-drag: none;
}

.product-detail-media {
  display: block;
  width: calc(100% - 24px);
  aspect-ratio: 1 / 1;
  margin: 12px 12px 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink) 10%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}

.product-detail-media img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  object-position: center center;
  border-radius: inherit;
}

.product-gallery-arrow {
  position: absolute;
  z-index: 4;
  top: 50%;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0 0 3px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 50%;
  color: #fff;
  background: rgba(16, 23, 19, .35);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .15);
  backdrop-filter: blur(10px);
  font-size: 28px;
  line-height: 1;
  transform: translateY(-50%);
  transition: background .18s ease, opacity .18s ease, transform .18s ease;
}

.product-gallery-arrow:hover:not(:disabled) {
  background: rgba(16, 23, 19, .58);
  transform: translateY(-50%) scale(1.04);
}

.product-gallery-arrow:disabled {
  opacity: .24;
}

.product-gallery-arrow.previous {
  left: 14px;
}

.product-gallery-arrow.next {
  right: 14px;
}

.product-detail-gallery-dots {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: rgba(16, 23, 19, .32);
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
}

.product-detail-gallery-dots button {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  transition: width .18s ease, background .18s ease;
}

.product-detail-gallery-dots button.active {
  width: 20px;
  background: #fff;
}

.product-gallery-count {
  position: absolute;
  z-index: 4;
  left: 14px;
  top: 14px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  color: #fff;
  background: rgba(16, 23, 19, .34);
  backdrop-filter: blur(10px);
  font-size: 10px;
  font-weight: 750;
}

@media (max-width: 700px) {
  .product-gallery-arrow {
    width: 38px;
    height: 38px;
    font-size: 25px;
  }

  .product-gallery-arrow.previous {
    left: 10px;
  }

  .product-gallery-arrow.next {
    right: 10px;
  }

  .product-image-viewer-arrow.previous {
    left: max(12px, env(safe-area-inset-left));
  }

  .product-image-viewer-arrow.next {
    right: max(12px, env(safe-area-inset-right));
  }
}

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

  .product-gallery-arrow,
  .product-detail-gallery-dots button {
    transition: none;
  }
}
