/* SO-OEPNVPRO · zentraler Mobile-Scroll-Vertrag · 2026-08-30
   Wird absichtlich NACH allen seiten-/modulspezifischen Styles geladen.
   Ziel: Live, Abfahrt, Karte und weitere lange Seiten muessen auf Android/iOS
   im normalen Dokumentfluss vertikal erreichbar bleiben. */

@media (max-width: 900px) {
  html {
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  body:not(.modal-open):not(.map-fullscreen-active) {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    min-height: 100svh !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    overscroll-behavior-y: auto !important;
  }

  body:not(.modal-open):not(.map-fullscreen-active) .page-shell {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Programmatic jumps must stop below the sticky global header. */
  body[data-page="abfahrten"] .departures-board,
  body[data-page="live"] .live-bus-root [data-mobile-panel] {
    scroll-margin-top: calc(74px + env(safe-area-inset-top));
  }

  /* Die fixe Bottom-Navigation braucht echten Auslauf unter dem Seiteninhalt. */
  body:not(.map-fullscreen-active) .page-shell {
    padding-bottom: calc(112px + env(safe-area-inset-bottom) + var(--browser-bottom-gap, 0px)) !important;
  }

  body:not(.map-fullscreen-active) .site-footer {
    margin-bottom: calc(82px + env(safe-area-inset-bottom) + var(--browser-bottom-gap, 0px));
  }

  /* Abfahrtsmonitor: keine innere Viewport-/Panelhoehe darf den Dokument-Scroll ersetzen. */
  body[data-page="abfahrten"]:not(.modal-open):not(.map-fullscreen-active) .departures-shell,
  body[data-page="abfahrten"]:not(.modal-open):not(.map-fullscreen-active) .departure-dashboard,
  body[data-page="abfahrten"]:not(.modal-open):not(.map-fullscreen-active) .departures-board,
  body[data-page="abfahrten"]:not(.modal-open):not(.map-fullscreen-active) .departure-side-column,
  body[data-page="abfahrten"]:not(.modal-open):not(.map-fullscreen-active) .departure-live-list {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  body[data-page="abfahrten"]:not(.modal-open):not(.map-fullscreen-active) .departure-live-list {
    overflow: visible !important;
  }

  /* Live-Busse: alte BusLive-App war urspruenglich eine abgeschlossene 100dvh-App.
     In OEPNVPRO muss sie mobil Teil der scrollbaren Gesamtseite sein. */
  body[data-page="live"]:not(.modal-open):not(.map-fullscreen-active) .live-page,
  body[data-page="live"]:not(.modal-open):not(.map-fullscreen-active) .live-bus-root,
  body[data-page="live"]:not(.modal-open):not(.map-fullscreen-active) .live-bus-root .app-shell,
  body[data-page="live"]:not(.modal-open):not(.map-fullscreen-active) .live-bus-root .workspace {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  body[data-page="live"]:not(.modal-open):not(.map-fullscreen-active) .live-bus-root {
    overscroll-behavior-y: auto !important;
  }

  body[data-page="live"]:not(.modal-open):not(.map-fullscreen-active) .live-bus-root .app-shell {
    overflow: visible !important;
    grid-template-rows: auto auto auto auto !important;
  }

  body[data-page="live"]:not(.modal-open):not(.map-fullscreen-active) .live-bus-root .workspace {
    overflow: visible !important;
  }

  /* Leaflet selbst behaelt seine Karten-Gesten; ausserhalb der Karte scrollt die Seite. */
  body[data-page="live"] .live-bus-root #map {
    overscroll-behavior: contain;
  }
}
