/* Product gallery (1.8.0): thumbnails rail + main photo on desktop, full-bleed swipe photo + thumbnail row on
   phones, crossfade between photos, desktop hover lens, and the full-screen viewer (pinch / double-tap zoom). */
.duera-gallery {
  --gallery-ink: var(--dark, #311b14);
  --gallery-brand: var(--duera-burgundy, #4f0a09);
  --gallery-soft: #f6f3ef;
  --gallery-thumb: 76px;
  display: grid;
  grid-template-columns: var(--gallery-thumb) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  color: var(--gallery-ink);
}

.duera-gallery.is-single {
  grid-template-columns: minmax(0, 1fr);
}

/* Main photo */
.duera-gallery-stage {
  position: relative;
  grid-row: 1;
  grid-column: 2;
  width: min(100%, max(420px, calc((100svh - 150px) * 0.8)));
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 14px;
  background: var(--gallery-soft);
  isolation: isolate;
}

.duera-gallery.is-single .duera-gallery-stage {
  grid-column: 1;
}

.duera-gallery-track {
  position: relative;
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  outline: none;
}

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

.duera-gallery-track:focus-visible {
  box-shadow: inset 0 0 0 2px var(--gallery-brand);
}

.duera-gallery-slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  cursor: zoom-in;
}

.duera-gallery-image,
.duera-gallery-placeholder img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* Crossfade layer: the next photo fades in over the current one, then the track moves underneath. */
.duera-gallery-fade {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--gallery-soft);
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.duera-gallery-fade.is-in {
  opacity: 1;
}

/* Desktop hover lens: the full-size photo follows the cursor in place. */
.duera-gallery-lens {
  position: absolute;
  z-index: 3;
  opacity: 0;
  background-color: #fff;
  background-repeat: no-repeat;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.duera-gallery-lens.is-on {
  opacity: 1;
}

.duera-gallery-arrow,
.duera-gallery-expand {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--gallery-ink);
  background: #ffffffeb;
  box-shadow: 0 2px 10px #311b141f;
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.duera-gallery-arrow:hover,
.duera-gallery-expand:hover {
  background: #fff;
}

.duera-gallery-arrow:focus-visible,
.duera-gallery-expand:focus-visible,
.duera-gallery-thumb:focus-visible {
  outline: 2px solid var(--gallery-brand);
  outline-offset: 2px;
}

.duera-gallery-arrow {
  top: 50%;
  width: 42px;
  height: 42px;
  opacity: 0;
  transform: translateY(-50%);
}

.duera-gallery-arrow svg {
  width: 20px;
  height: 20px;
}

.duera-gallery-arrow.is-prev {
  left: 14px;
}

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

.duera-gallery-stage:hover .duera-gallery-arrow,
.duera-gallery-arrow:focus-visible {
  opacity: 1;
}

.duera-gallery-stage .duera-gallery-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

.duera-gallery-expand {
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
}

.duera-gallery-expand svg {
  width: 20px;
  height: 20px;
}

.duera-gallery-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: none;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: #311b14b3;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  pointer-events: none;
}

/* Thumbnails: a rail as tall as the main photo. */
.duera-gallery-thumbs {
  position: relative; /* offset parent for keeping the active thumbnail in view */
  grid-row: 1;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 0;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.duera-gallery-thumbs::-webkit-scrollbar {
  display: none;
}

.duera-gallery-thumb {
  position: relative;
  flex: none;
  display: block;
  width: var(--gallery-thumb);
  aspect-ratio: 4 / 5;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: var(--gallery-soft);
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.duera-gallery-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px #311b1414;
  transition: box-shadow 0.2s ease;
}

.duera-gallery-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duera-gallery-thumb:hover {
  opacity: 0.85;
}

.duera-gallery-thumb.is-active {
  opacity: 1;
}

.duera-gallery-thumb.is-active::after {
  box-shadow: inset 0 0 0 2px var(--gallery-brand);
}

/* Desktop layout around the gallery (1.8.1): the photo's height follows the screen, so the gallery column takes
   exactly the gallery's width and the summary takes the rest; no empty band between them. Page content is at
   most 1440px wide so the summary does not stretch on very wide screens. */
@media (min-width: 992px) {
  .duera-pdp > .container {
    max-width: 1440px;
  }

  .duera-pdp-grid {
    grid-template-columns: max-content minmax(0, 1fr);
    gap: clamp(40px, 4vw, 64px);
  }

  .duera-gallery-stage {
    /* Fits the screen height, but never under ~42% of the page width (short laptop screens). */
    width: clamp(380px, min(max(calc((100svh - 150px) * 0.8), calc(min(100vw, 1440px) * 0.42)), calc(100vw - 640px)), 760px);
  }
}

/* Tablet and phones: photo on top, thumbnail row below, swipe instead of arrows. */
@media (max-width: 991px) {
  .duera-gallery {
    --gallery-thumb: 60px;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .duera-gallery-stage {
    grid-column: 1;
    width: 100%;
  }

  .duera-gallery-thumbs {
    grid-row: 2;
    flex-direction: row;
    height: auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .duera-gallery-arrow {
    display: none;
  }

  .duera-gallery-count {
    display: block;
  }

  .duera-gallery-slide {
    cursor: pointer;
  }
}

@media (max-width: 767px) {
  .duera-pdp {
    overflow-x: clip;
  }

  .duera-gallery {
    --gallery-thumb: 52px;
    gap: 8px;
  }

  /* Edge to edge like a shopping app. */
  .duera-gallery-stage {
    width: 100vw;
    margin-inline: calc(50% - 50vw);
    border-radius: 0;
  }

  /* The thumbnail row is edge to edge like the photo, from the first view (1.8.1). */
  .duera-gallery-thumbs {
    gap: 6px;
    margin-inline: calc(50% - 50vw);
    padding-inline: 6px;
    scroll-padding-inline: 6px;
  }

  .duera-gallery-thumb {
    border-radius: 8px;
  }

  .duera-gallery-expand {
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
  }
}

/* Full-screen viewer */
html.duera-viewer-locked {
  overflow: hidden;
}

.duera-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: #fff;
  background: transparent;
  overscroll-behavior: contain;
}

.duera-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: duera-viewer-in 0.22s ease-out;
}

.duera-viewer::backdrop {
  background: transparent;
}

.duera-viewer::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #140b09;
  opacity: var(--viewer-fade, 1);
}

.duera-viewer.is-closing {
  opacity: 0;
  transition: opacity 0.2s ease;
}

@keyframes duera-viewer-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.duera-viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 12px 8px 18px;
}

.duera-viewer-count {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.duera-viewer-tools {
  display: flex;
  gap: 8px;
}

.duera-viewer-button,
.duera-viewer-arrow {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #ffffff1f;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.duera-viewer-button {
  width: 44px;
  height: 44px;
}

.duera-viewer-button:hover,
.duera-viewer-arrow:hover {
  background: #ffffff38;
}

.duera-viewer-button:focus-visible,
.duera-viewer-arrow:focus-visible,
.duera-viewer-thumb:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.duera-viewer-button svg {
  width: 22px;
  height: 22px;
}

.duera-viewer-button .is-out,
.duera-viewer.is-zoomed .duera-viewer-button .is-in {
  display: none;
}

.duera-viewer.is-zoomed .duera-viewer-button .is-out {
  display: block;
}

.duera-viewer-stage {
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
}

.duera-viewer.is-zoomed .duera-viewer-stage {
  cursor: grab;
}

.duera-viewer.is-zoomed .duera-viewer-stage:active {
  cursor: grabbing;
}

.duera-viewer-track {
  display: flex;
  height: 100%;
  will-change: transform;
}

.duera-viewer-track.is-animating,
.duera-viewer-image.is-animating {
  transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.24, 1);
}

.duera-viewer-slide {
  flex: 0 0 100%;
  height: 100%;
  overflow: hidden;
}

.duera-viewer-slide.is-animating {
  transition: transform 0.25s ease;
}

.duera-viewer-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.duera-viewer-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 48px;
  height: 48px;
  transform: translateY(-50%);
}

.duera-viewer-arrow svg {
  width: 24px;
  height: 24px;
}

.duera-viewer-arrow.is-prev {
  left: 20px;
}

.duera-viewer-arrow.is-next {
  right: 20px;
}

/* Beats the theme's `.duera-pdp button:disabled` (opacity .45). */
.duera-viewer .duera-viewer-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

.duera-viewer.is-zoomed .duera-viewer-arrow {
  opacity: 0;
  pointer-events: none;
}

.duera-viewer-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff;
  background: #000000a6;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
  animation: duera-viewer-in 0.3s ease-out;
}

.duera-viewer-hint svg {
  width: 18px;
  height: 18px;
}

.duera-viewer-thumbs {
  display: flex;
  justify-content: safe center;
  gap: 8px;
  padding: 10px 16px max(14px, env(safe-area-inset-bottom));
  overflow-x: auto;
  scrollbar-width: none;
  transition: opacity 0.2s ease;
}

.duera-viewer-thumbs::-webkit-scrollbar {
  display: none;
}

.duera-viewer.is-zoomed .duera-viewer-thumbs {
  opacity: 0.35;
}

.duera-viewer-thumb {
  position: relative;
  flex: none;
  width: 52px;
  aspect-ratio: 4 / 5;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #ffffff14;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.duera-viewer-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duera-viewer-thumb.is-active {
  opacity: 1;
  box-shadow: 0 0 0 2px #fff;
}

@media (hover: none), (max-width: 991px) {
  .duera-viewer-arrow {
    display: none;
  }
}

@media (max-width: 767px) {
  .duera-viewer-thumb {
    width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .duera-gallery-fade,
  .duera-viewer[open],
  .duera-viewer-hint {
    transition: none;
    animation: none;
  }
}
