/* Product viewer: fixed desktop gallery with independently scrolling details. */
dialog#productDialog {
  width: min(1480px, calc(100vw - 32px));
  height: min(920px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  overflow: hidden;
}

#dialogContent,
.detail {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.detail {
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr);
  overflow: hidden;
}

.detail-copy {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 5rem clamp(1.5rem, 3vw, 3.5rem) 7rem;
}

.persistent-actions {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 9;
  width: 46%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .65rem;
  padding: .75rem clamp(1rem, 2vw, 2rem);
  border-top: 1px solid var(--line);
  background: rgba(245, 243, 237, .97);
  box-shadow: 0 -10px 28px #0002;
  backdrop-filter: blur(12px);
}

.persistent-actions .cta,
.persistent-actions .secondary {
  min-width: 0;
  min-height: 52px;
  margin: 0;
  padding: .75rem .65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  line-height: 1.1;
}

.action-icon {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 104px;
  background: #e7e4dc;
  border-right: 1px solid var(--line);
}

.gallery-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  touch-action: pan-y;
  user-select: none;
}

.gallery-main {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  object-fit: contain;
  background: #fff;
}

.gallery-controls {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem;
  background: rgba(5, 6, 7, .94);
  color: #fff;
  box-shadow: 0 8px 28px #0004;
  z-index: 2;
}

.gallery-controls button {
  width: 44px;
  height: 44px;
  border: 1px solid #fff;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.gallery-controls button:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.gallery-count {
  min-width: 62px;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
}

.gallery-thumbs {
  min-width: 0;
  height: 104px;
  display: flex;
  gap: .55rem;
  padding: .7rem;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  background: #dcd8cf;
  scrollbar-width: thin;
}

.gallery-thumbs button {
  flex: 0 0 66px;
  width: 66px;
  height: 80px;
  padding: 0;
  border: 3px solid transparent;
  background: #fff;
  cursor: pointer;
}

.gallery-thumbs button[aria-current="true"] {
  border-color: var(--gold);
}

.gallery-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 800px) {
  dialog#productDialog {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: hidden;
  }

  #dialogContent,
  .detail { height: 100%; }

  .detail {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 76px;
  }

  .gallery {
    height: min(78dvh, 700px);
    min-height: 500px;
    grid-template-rows: minmax(0, 1fr) 94px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .gallery-thumbs {
    height: 94px;
  }

  .gallery-thumbs button {
    height: 70px;
    flex-basis: 58px;
    width: 58px;
  }

  .detail-copy {
    height: auto;
    overflow: visible;
    padding: 4.5rem 1.5rem 3rem;
  }

  .persistent-actions {
    width: 100%;
    padding: .65rem max(.75rem, env(safe-area-inset-right)) calc(.65rem + env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left));
  }
}

@media (max-width: 520px) {
  .gallery {
    height: min(72dvh, 620px);
    min-height: 430px;
  }

  .gallery-controls {
    bottom: .75rem;
  }

  .detail-copy {
    padding-inline: 1rem;
  }

  .persistent-actions {
    gap: .45rem;
  }

  .persistent-actions .cta,
  .persistent-actions .secondary {
    min-height: 48px;
    padding: .65rem .4rem;
    font-size: .68rem;
    letter-spacing: .035em;
  }

  .action-icon {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
  }
}
