/**
 * HubSpot chat stacking.
 *
 * - Launcher / greeting: under fixed header (z 99990).
 * - Expanded desktop: float above header (z 1000100) — HubSpot’s natural size.
 * - Expanded mobile: FULLSCREEN takeover (covers site chrome). Close widget
 *   to return to the page. Geometry uses --wdi-hs-chat-top/height from JS
 *   (visualViewport when the keyboard is open).
 * - Hamburger open: HubSpot hidden; menu wins.
 *
 * Keep this file out of WP Rocket CSS minify (see PHP enqueue).
 */

html body div#hubspot-messages-iframe-container,
html body div#hubspot-messages-iframe-container.widget-align-right,
html body div#hubspot-messages-iframe-container.widget-align-left,
html body #hubspot-messages-iframe-container {
  z-index: 99990 !important;
  pointer-events: none !important;
}

html body #hubspot-messages-iframe-container iframe,
html body #hubspot-messages-iframe-container iframe#hubspot-conversations-iframe,
html body #hubspot-messages-iframe-container iframe#hs-messages-iframe {
  pointer-events: auto !important;
}

@media screen and (min-width: 981px) {
  html body.wdi-hs-chat-expanded div#hubspot-messages-iframe-container,
  html body.wdi-hs-chat-expanded #hubspot-messages-iframe-container {
    z-index: 1000100 !important;
  }
}

@media screen and (max-width: 980px) {
  html body.wdi-hs-chat-expanded {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
  }

  /*
   * Fullscreen takeover — covers site header/nav. Not inset under header.
   * JS sets --wdi-hs-chat-top / --wdi-hs-chat-height (0 / 100% normally;
   * visualViewport when keyboard is open).
   */
  html body.wdi-hs-chat-expanded #hubspot-messages-iframe-container {
    z-index: 1000100 !important;
    position: fixed !important;
    top: var(--wdi-hs-chat-top, 0px) !important;
    right: 0 !important;
    left: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: var(--wdi-hs-chat-height, 100dvh) !important;
    max-height: var(--wdi-hs-chat-height, 100dvh) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    transform: none !important;
    border-radius: 0 !important;
  }

  html body.wdi-hs-chat-expanded #hubspot-messages-iframe-container iframe,
  html
    body.wdi-hs-chat-expanded
    #hubspot-messages-iframe-container
    iframe#hubspot-conversations-iframe,
  html
    body.wdi-hs-chat-expanded
    #hubspot-messages-iframe-container
    iframe#hs-messages-iframe {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  html body.wdi-hs-chat-open:not(.wdi-hs-chat-expanded)
    #hubspot-messages-iframe-container {
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 99990 !important;
  }

  html.wdi-mobile-nav-open #hubspot-messages-iframe-container,
  html.wdi-mobile-nav-open #hubspot-messages-iframe-container iframe,
  html.wdi-mobile-nav-open #hubspot-messages-iframe-container *,
  html body:has(.mobile_nav.opened) #hubspot-messages-iframe-container,
  html body:has(.mobile_nav.opened) #hubspot-messages-iframe-container iframe,
  html body:has(.mobile_nav.opened) #hubspot-messages-iframe-container * {
    pointer-events: none !important;
    visibility: hidden !important;
  }

  html.wdi-mobile-nav-open #mobile_menu.et_mobile_menu,
  html.wdi-mobile-nav-open #mobile_menu.et_mobile_menu a,
  html.wdi-mobile-nav-open #mobile_menu.et_mobile_menu button,
  html body:has(.mobile_nav.opened) #mobile_menu.et_mobile_menu,
  html body:has(.mobile_nav.opened) #mobile_menu.et_mobile_menu a,
  html body:has(.mobile_nav.opened) #mobile_menu.et_mobile_menu button {
    pointer-events: auto !important;
    visibility: visible !important;
  }

  html.wdi-mobile-nav-open #mobile_menu.et_mobile_menu,
  html body:has(.mobile_nav.opened) #mobile_menu.et_mobile_menu {
    z-index: 1000500 !important;
  }

  html.wdi-mobile-nav-open #main-header,
  html.wdi-mobile-nav-open #top-header,
  html body:has(.mobile_nav.opened) #main-header,
  html body:has(.mobile_nav.opened) #top-header {
    z-index: 1000400 !important;
  }
}
