/**
 * Guide modals — full-screen on every device.
 * Overlay covers the viewport; panels fill it (safe-area aware).
 */

body.mg-guide-active.mg-guide--atlas,
body.mim-homepage-map-embed {
  --mg-ocean-modal-h: 100dvh;
  --mg-ocean-modal-w: 100%;
}

/* ── Open overlays: full viewport shell ── */
body.mg-guide-active .mg-atlas-sheet.is-open,
body.mg-guide-active #mgOffersModal.is-open,
body.mg-guide-active .mg-dmodal.is-open,
body.mg-guide-active .mg-booking-modal.is-open,
body.mg-guide-active .mg-guide-modal--booking.is-open,
body.mg-guide-active .mg-tool-modal.is-open,
body.mg-guide-active .mg-atlas-discover:not([hidden]),
body.mg-guide-active .mg-local-services-widget.is-open,
body.mg-guide-active .mg-quick-tools-widget.is-open,
body.mim-homepage-map-embed .mg-atlas-sheet.is-open,
body.mim-homepage-map-embed #mgOffersModal.is-open,
body.mim-homepage-map-embed .mg-dmodal.is-open,
body.mim-homepage-map-embed .mg-booking-modal.is-open,
body.mim-homepage-map-embed .mg-guide-modal--booking.is-open {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  z-index: var(--mg-z-modal, 100010) !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
  place-items: stretch !important;
  align-items: stretch !important;
  justify-items: stretch !important;
  align-content: stretch !important;
  justify-content: stretch !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  pointer-events: auto !important;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: hidden !important;
  background: rgba(1, 6, 12, 0.72) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
}

/* Offers sits above the district modal (100010) but below booking (100020),
   so closing offers returns to the district cluster grid, not home. */
body.mg-guide-active #mgOffersModal.is-open,
body.mim-homepage-map-embed #mgOffersModal.is-open {
  z-index: 100015 !important;
}

body.mg-guide-active .mg-booking-modal.is-open,
body.mg-guide-active .mg-guide-modal--booking.is-open,
body.mim-homepage-map-embed .mg-booking-modal.is-open,
body.mim-homepage-map-embed .mg-guide-modal--booking.is-open {
  z-index: var(--mg-z-modal-top, 100020) !important;
}

body.mg-guide-active .mg-local-services-widget.is-open > .mg-local-services-widget__toggle,
body.mg-guide-active .mg-quick-tools-widget.is-open > .mg-local-services-widget__toggle {
  display: none !important;
}

/* Backdrops fill grid cell under the panel */
body.mg-guide-active .mg-atlas-sheet.is-open > .mg-atlas-sheet__backdrop,
body.mg-guide-active #mgOffersModal.is-open > .mg-atlas-sheet__backdrop,
body.mg-guide-active .mg-dmodal.is-open > .mg-dmodal__backdrop,
body.mg-guide-active .mg-booking-modal.is-open > .mg-booking-modal__backdrop,
body.mg-guide-active .mg-guide-modal--booking.is-open > .mg-guide-modal__backdrop,
body.mg-guide-active .mg-tool-modal.is-open > .mg-tool-modal__backdrop,
body.mg-guide-active .mg-atlas-discover:not([hidden]) > .mg-atlas-discover__backdrop,
body.mim-homepage-map-embed .mg-atlas-sheet.is-open > .mg-atlas-sheet__backdrop,
body.mim-homepage-map-embed #mgOffersModal.is-open > .mg-atlas-sheet__backdrop,
body.mim-homepage-map-embed .mg-dmodal.is-open > .mg-dmodal__backdrop,
body.mim-homepage-map-embed .mg-booking-modal.is-open > .mg-booking-modal__backdrop,
body.mim-homepage-map-embed .mg-guide-modal--booking.is-open > .mg-guide-modal__backdrop {
  grid-area: 1 / 1 !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  z-index: 0 !important;
  opacity: 1 !important;
  background: transparent !important;
}

/* Full-screen dialog panels */
body.mg-guide-active .mg-atlas-sheet.is-open > .mg-atlas-sheet__panel,
body.mg-guide-active #mgOffersModal.is-open > .mg-atlas-sheet__panel,
body.mg-guide-active #mgOffersModal.is-open > .mg-offers-modal__panel,
body.mg-guide-active .mg-dmodal.is-open > .mg-dmodal__sheet,
body.mg-guide-active .mg-booking-modal.is-open > .mg-booking-modal__panel,
body.mg-guide-active .mg-guide-modal--booking.is-open > .mg-guide-modal__panel,
body.mg-guide-active .mg-tool-modal.is-open > .mg-tool-modal__panel,
body.mg-guide-active .mg-atlas-discover:not([hidden]) > .mg-atlas-discover__panel,
body.mg-guide-active .mg-local-services-widget.is-open > .mg-local-services-widget__drawer,
body.mg-guide-active .mg-quick-tools-widget.is-open > .mg-local-services-widget__drawer,
body.mim-homepage-map-embed .mg-atlas-sheet.is-open > .mg-atlas-sheet__panel,
body.mim-homepage-map-embed #mgOffersModal.is-open > .mg-atlas-sheet__panel,
body.mim-homepage-map-embed #mgOffersModal.is-open > .mg-offers-modal__panel,
body.mim-homepage-map-embed .mg-dmodal.is-open > .mg-dmodal__sheet,
body.mim-homepage-map-embed .mg-booking-modal.is-open > .mg-booking-modal__panel,
body.mim-homepage-map-embed .mg-guide-modal--booking.is-open > .mg-guide-modal__panel {
  grid-area: 1 / 1 !important;
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  z-index: 1 !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border: 0 !important;
  box-sizing: border-box !important;
  padding-top: max(0px, env(safe-area-inset-top, 0px)) !important;
  padding-right: max(0px, env(safe-area-inset-right, 0px)) !important;
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px)) !important;
  padding-left: max(0px, env(safe-area-inset-left, 0px)) !important;
  transform: none !important;
  translate: 0 0 !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  animation: none !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

body.mg-guide-active .mg-dmodal.is-open .mg-dmodal__body,
body.mim-homepage-map-embed .mg-dmodal.is-open .mg-dmodal__body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.mg-guide-active #mgOffersModal.is-open .mg-atlas-sheet__body,
body.mim-homepage-map-embed #mgOffersModal.is-open .mg-atlas-sheet__body,
body.mg-guide-active .mg-atlas-sheet.is-open .mg-atlas-sheet__body,
body.mim-homepage-map-embed .mg-atlas-sheet.is-open .mg-atlas-sheet__body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

body.mg-guide-active .mg-dmodal.is-open .mg-dmodal__pane.is-active,
body.mim-homepage-map-embed .mg-dmodal.is-open .mg-dmodal__pane.is-active {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

body.mg-guide-active .mg-local-services-widget.is-open > .mg-local-services-widget__drawer,
body.mg-guide-active .mg-quick-tools-widget.is-open > .mg-local-services-widget__drawer {
  grid-template-rows: 1fr !important;
}

body.mg-guide-active .mg-local-services-widget.is-open .mg-ocean-services,
body.mg-guide-active .mg-quick-tools-widget.is-open .mg-ocean-services {
  max-height: none !important;
  height: 100% !important;
  width: 100% !important;
}

/* Kill bottom-sheet / centered-card leftovers */
body.mg-guide-active .mg-atlas-sheet__panel,
body.mim-homepage-map-embed .mg-atlas-sheet__panel,
body.mg-guide-active .mg-dmodal__sheet,
body.mim-homepage-map-embed .mg-dmodal__sheet {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  body.mg-guide-active .mg-atlas-sheet.is-open > .mg-atlas-sheet__panel,
  body.mg-guide-active .mg-dmodal.is-open > .mg-dmodal__sheet,
  body.mg-guide-active .mg-local-services-widget.is-open > .mg-local-services-widget__drawer {
    transition: none !important;
  }
}
