/* Opening a modal must not change the page's available layout width. */
html { scrollbar-gutter: stable; }
#contact-dialog { scrollbar-gutter: stable; }
#product-dialog[open], #privacy-dialog[open] { animation: stable-dialog-in 180ms ease; }
@keyframes stable-dialog-in { from { opacity: 0; } to { opacity: 1; } }

/* The source-rendered header already occupies its final space. Enable the
   deliberate compacting transition only after its initial state is applied. */
.header-shell[data-header-ready="false"] *,
.header-shell[data-header-ready="false"] > .site-header { transition: none; }
.site-header[data-header-motion="static"]:not([data-header-built])::before,
.site-header[data-header-motion="static"]:not([data-header-built])::after { display: none; }

/* Every platform opens in the same viewport-capped frame. Images and longer
   specifications fit inside it without moving or resizing the window. */
#product-dialog.product-dialog {
  width: min(960px, calc(100vw - 40px));
  height: min(720px, calc(100svh - 40px));
  height: min(720px, calc(100dvh - 40px));
  max-height: none;
  overflow: hidden;
}
#product-detail { height: 100%; min-height: 0; }
#product-dialog .product-detail-layout {
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
#product-dialog .product-detail-visual {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--ink);
}
#product-dialog .product-detail-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
#product-dialog .product-detail-copy {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

@media (max-width: 1100px) {
  #product-dialog.product-dialog { width: min(730px, calc(100vw - 40px)); }
}
@media (max-width: 800px) {
  #product-dialog.product-dialog {
    width: calc(100vw - 24px);
    max-width: none;
    height: calc(100svh - 24px);
    height: calc(100dvh - 24px);
  }
  #product-dialog .product-detail-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: clamp(150px, 30dvh, 230px) minmax(0, 1fr);
  }
}
@media (prefers-reduced-motion: reduce) {
  #product-dialog[open], #privacy-dialog[open] { animation: none; }
}
