/* iOS/Safari modal containment hotfix. The product overlay is rendered inside
   .site-shell; overflow clipping + an isolated stacking context can make a
   fixed overlay behave like in-flow content on WebKit. Relax those properties
   only while the overlay exists, then pin the overlay to the visual viewport. */
.site-shell:has(> .overlay) {
  overflow: visible !important;
  isolation: auto !important;
  transform: none !important;
  filter: none !important;
  contain: none !important;
  perspective: none !important;
}

body:has(.site-shell > .overlay) {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.site-shell > .overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  width: 100vw !important;
  width: 100dvw !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100svh !important;
  overflow: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  align-items: center !important;
  justify-content: center !important;
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left)) !important;
}

@media (max-width: 760px) {
  .site-shell > .overlay > .detail-modal {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - 16px) !important;
    margin: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  .site-shell > .overlay .detail-modal > .close-button {
    position: sticky !important;
    top: 8px !important;
    margin-inline-start: auto;
  }
}

@media (max-width: 380px) {
  .site-shell > .overlay {
    padding-inline: 0 !important;
  }

  .site-shell > .overlay > .detail-modal {
    max-height: 100dvh !important;
    border-inline: 0 !important;
  }
}
