/**
 * APD 409 — Modal shell structure with Safari chrome-safe scroll viewport.
 *
 * Sole responsibility: create the fixed iPhone/Safari search viewport.
 * No card/calendar/location/guest/service visuals live here.
 */
@media (max-width: 767px) {
  html.apd186-search-lock,
  html.apd186-search-lock body,
  html body.apd186-search-modal-open {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  html body.apd186-search-modal-open {
    overflow-y: hidden !important;
    overscroll-behavior: none !important;
  }

  html body.apd186-search-modal-open #apd5-header {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  html body.apd186-search-modal-open #apd5-search-backdrop,
  html body.apd186-search-modal-open .apd176-search-close,
  html body.apd186-search-modal-open .apd10-mobile-nav {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .apd186-search-topbar[hidden],
  .apd186-search-portal[hidden] {
    display: none !important;
  }

  html body .apd186-search-topbar {
    box-sizing: border-box !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 2147483000 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html body .apd186-search-close {
    box-sizing: border-box !important;
    position: absolute !important;
    z-index: 2 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  html body .apd186-search-portal {
    box-sizing: border-box !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    z-index: 2147482000 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: var(--apd186-shell-height, 100dvh) !important;
    min-height: var(--apd186-shell-height, 100dvh) !important;
    overflow: hidden !important;
    background: #f7f7f7 !important;
    transform: translate3d(0,0,0) !important;
    contain: layout paint !important;
  }

  html body.apd186-search-modal-open .apd186-search-portal #apd5-search,
  html body.apd186-search-modal-open .apd186-search-portal #apd5-search.apd176-ready {
    box-sizing: border-box !important;
    position: relative !important;
    inset: auto !important;
    z-index: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: calc(var(--apd186-shell-height, 100dvh) - 80px) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 12px 12px calc(112px + env(safe-area-inset-bottom, 0px)) !important;
    background: #f7f7f7 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: auto !important;
    overscroll-behavior: contain !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translate3d(0,0,0) !important;
  }

  /* APD409: when Safari expands/collapses its bottom toolbar, 100dvh follows
     the actually visible viewport while --apd186-shell-height intentionally
     remains stable. Keep the scrollable form above the fixed action footer.
     During keyboard entry we retain the proven locked height to avoid a sheet
     jump while iOS animates the keyboard. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open:not(.apd186-keyboard-open)
  .apd186-search-portal #apd5-search,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open:not(.apd186-keyboard-open)
  .apd186-search-portal #apd5-search.apd176-ready {
    height: calc(100dvh - 80px) !important;
    max-height: calc(100dvh - 80px) !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search > [data-search-field="guests"],
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search > [data-search-field="service"] {
    scroll-margin-bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
