/* TAAM WebKit/iOS Safari refinements — loaded after mobile-fixes.css.
   Only applied to touch WebKit browsers; desktop layout is unchanged. */
@supports (-webkit-touch-callout: none) {
  @media screen and (hover: none) and (pointer: coarse) and (max-width: 1024px) {
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    body { overflow-x: hidden; }

    /* Avoid large blurred compositing layers flickering while Safari scrolls. */
    #facilities .journey-panel {
      -webkit-backdrop-filter: none !important;
      backdrop-filter: none !important;
      background: rgba(19, 30, 40, .90) !important;
    }
    #facilities .journey-bg {
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
    }
    #facilities .journey-gallery-controls,
    #facilities .journey-step-controls,
    #hse .training-controls,
    #hse .training-gallery,
    .location-photo, .location-photo-grid {
      min-width: 0;
      max-width: 100%;
    }
    #hse .training-stage img { width: 100%; height: 100%; object-fit: cover; }
    #hse .training-thumbnails {
      -webkit-overflow-scrolling: touch;
      touch-action: auto;
    }
    .photo-dialog, .facility-photo-dialog {
      max-height: calc(100svh - 16px);
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
    .photo-dialog img, .facility-photo-dialog img { max-height: 62svh; }

    /* On Safari, prefer a stable small viewport height to 100dvh;
       the toolbar moving should not push the interactive map offscreen. */
    #facilities .journey-map-card.is-expanded {
      -webkit-backdrop-filter: none !important;
      backdrop-filter: none !important;
      background: #152530 !important;
      min-width: 0 !important;
      min-height: 0 !important;
      top: calc(env(safe-area-inset-top, 0px) + 8px) !important;
      right: calc(env(safe-area-inset-right, 0px) + 8px) !important;
      bottom: auto !important;
      left: calc(env(safe-area-inset-left, 0px) + 8px) !important;
      height: calc(100svh - env(safe-area-inset-top, 0px) - 16px) !important;
      max-height: calc(100svh - env(safe-area-inset-top, 0px) - 16px) !important;
    }
    #facilities .journey-map-card.is-expanded .journey-map {
      flex: 1 1 0% !important;
      min-height: 0 !important;
      overflow: hidden;
    }
    #facilities .journey-map-card.is-expanded .facility-map-search input {
      font-size: 16px !important; /* Safari: prevent automatic focus zoom. */
    }
    #facilities .journey-map-card.is-expanded .journey-map-heading,
    #facilities .journey-map-card.is-expanded .journey-map-bottom {
      flex-shrink: 0;
    }
  }
}
