/* STORE APP Patch 444: recover clickability when an orphan modal/backdrop layer remains. */
html body.site-masterpalm:not(.modal-open):not(.mp-express-shipping-modal-open):not(.mp-product-option-modal-open) > .modal-backdrop,
html body.site-masterpalm:not(.modal-open):not(.mp-express-shipping-modal-open):not(.mp-product-option-modal-open) > .offcanvas-backdrop,
html body.site-masterpalm > .modal-backdrop:not(.show),
html body.site-masterpalm > .offcanvas-backdrop:not(.show){
  display:none!important;
  visibility:hidden!important;
  opacity:0!important;
  pointer-events:none!important;
}

/* A backdrop should never sit above an active Store App modal. */
html body.site-masterpalm > .modal-backdrop,
html body.site-masterpalm > .offcanvas-backdrop{
  max-width:100vw!important;
  max-height:100vh!important;
}

/* Express shipping modal gets pointer events only while it is truly shown. */
html body.site-masterpalm:not(.mp-express-shipping-modal-open) #mpb2bExpressShippingModal:not(.show){
  display:none!important;
  visibility:hidden!important;
  opacity:0!important;
  pointer-events:none!important;
}

html body.site-masterpalm.mp-express-shipping-modal-open #mpb2bExpressShippingModal.show,
html body.site-masterpalm.mp-express-shipping-modal-open #mpb2bExpressShippingModal.show .modal-dialog,
html body.site-masterpalm.mp-express-shipping-modal-open #mpb2bExpressShippingModal.show .modal-content{
  pointer-events:auto!important;
}

/* Product option overlay follows the same rule. */
html body.site-masterpalm:not(.mp-product-option-modal-open) #mpProductOptionModal:not(.is-open):not(.show){
  display:none!important;
  visibility:hidden!important;
  opacity:0!important;
  pointer-events:none!important;
}

/* Keep normal page controls clickable when no Store App modal is actually open. */
html body.site-masterpalm:not(.modal-open):not(.mp-express-shipping-modal-open):not(.mp-product-option-modal-open) #site-main,
html body.site-masterpalm:not(.modal-open):not(.mp-express-shipping-modal-open):not(.mp-product-option-modal-open) .mpb2b-header,
html body.site-masterpalm:not(.modal-open):not(.mp-express-shipping-modal-open):not(.mp-product-option-modal-open) .mpb2b-footer{
  pointer-events:auto!important;
}

/* CSS-only fallback for modern browsers when JavaScript is delayed by cache. */
@supports selector(body:has(.modal.show)){
  html body.site-masterpalm.modal-open:not(:has(.modal.show)):not(:has(.offcanvas.show)) > .modal-backdrop,
  html body.site-masterpalm.modal-open:not(:has(.modal.show)):not(:has(.offcanvas.show)) > .offcanvas-backdrop,
  html body.site-masterpalm.mp-express-shipping-modal-open:not(:has(#mpb2bExpressShippingModal.show)) > .modal-backdrop,
  html body.site-masterpalm.mp-product-option-modal-open:not(:has(#mpProductOptionModal.show)):not(:has(#mpProductOptionModal.is-open)) > .modal-backdrop{
    display:none!important;
    visibility:hidden!important;
    opacity:0!important;
    pointer-events:none!important;
  }
  html body.site-masterpalm.mp-express-shipping-modal-open:not(:has(#mpb2bExpressShippingModal.show)),
  html body.site-masterpalm.mp-product-option-modal-open:not(:has(#mpProductOptionModal.show)):not(:has(#mpProductOptionModal.is-open)){
    overflow:auto!important;
    padding-right:0!important;
  }
}
