/** APD 504 — compact iPhone destination focus + proven APD503 calendar contract. */
@media (max-width: 767px) {
  html,
  body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  /* Safari auto-focus zoom is triggered below 16px. Use 17px on every live APD
     search field so computed styles, font substitution and fractional scaling
     cannot fall under the threshold. */
  html body #apd5-search :is(input:not([type="hidden"]), textarea, select),
  html body #apd5-auth-modal :is(input:not([type="hidden"]), textarea, select),
  html body .apd54-auth-dialog :is(input:not([type="hidden"]), textarea, select),
  html body .apd5-auth-dialog :is(input:not([type="hidden"]), textarea, select) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 17px !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open .apd186-search-portal,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open .apd186-search-topbar,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open #apd5-search {
    box-sizing: border-box !important;
    left: 0 !important;
    right: 0 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* APD504 keeps the existing expansion state only for the explicit chevron. The compatibility body class and the form
     state are intentionally equivalent; retired apd328/apd392 expansion classes
     no longer control layout. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd370-location-expanded
  #apd5-search[data-apd-location-mode="expanded"][data-active-panel="location"] {
    transform: none !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-apd-location-mode="expanded"][data-active-panel="location"]
  #apd5-destination-filter {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 17px !important;
  }

  /* Deterministic one-finger calendar owner. A touch beginning on a day cell is
     allowed to drag the month stack; taps still reach the date button normally. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="dates"] #apd5-calendar-months,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="dates"] #apd5-calendar-months > .apd5-calendar-month,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="dates"] #apd5-calendar-months .apd5-calendar-days,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="dates"] #apd5-calendar-months .apd5-calendar-days > :is(button,span) {
    touch-action: none !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="dates"] #apd5-calendar-months {
    display: block !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    scroll-behavior: auto !important;
    scroll-snap-type: none !important;
    pointer-events: auto !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="dates"] #apd5-calendar-months.apd503-is-dragging,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="dates"] #apd5-calendar-months.apd503-is-dragging * {
    -webkit-user-select: none !important;
    user-select: none !important;
  }

  /* Native card anchors are the only APD504 navigation owner. Favorite stays above
     the link and retains its independent action. */
  .apd5-stay-card {
    position: relative !important;
    pointer-events: auto !important;
  }
  .apd5-stay-card .apd5-card-media,
  .apd5-stay-card .apd5-card-media > a,
  .apd5-stay-card .apd5-card-body-link {
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
  }
  .apd5-stay-card .apd5-card-media > a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }
  .apd5-stay-card .apd5-favorite,
  .apd5-stay-card [data-apd-favorite] {
    position: absolute !important;
    z-index: 20 !important;
    pointer-events: auto !important;
  }
}


/* APD504 — focus/typing cannot promote Dónde to a viewport-sized editor. */
@media (max-width: 767px) {
  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd504-destination-focused .apd186-search-topbar {
    display: flex !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd504-destination-focused .apd186-search-portal {
    padding-top: 80px !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd504-destination-focused
  #apd5-search[data-active-panel="location"] {
    width: 100% !important;
    max-width: 100% !important;
    transform: translate3d(0,0,0) !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd504-destination-focused
  #apd5-search[data-active-panel="location"] > .apd5-location-panel {
    position: relative !important;
    inset: auto !important;
    z-index: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 30px !important;
    box-shadow: 0 8px 30px rgba(0,0,0,.06) !important;
    background: #fff !important;
  }

  /* Live matches scroll inside the same compact card instead of enlarging the sheet. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd504-destination-focused:is(.apd392-location-typing,.apd386-location-typing)
  #apd5-search[data-active-panel="location"][data-apd-location-mode="compact"] > .apd5-location-panel {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd504-destination-focused:is(.apd392-location-typing,.apd386-location-typing)
  #apd5-search[data-active-panel="location"][data-apd-location-mode="compact"] > .apd5-location-panel::-webkit-scrollbar {
    display: none !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open.apd504-destination-focused
  #apd5-search #apd5-destination-filter {
    font-size: 17px !important;
    transform: none !important;
    zoom: 1 !important;
  }
}
