/* SuperAwesome — mobile hardening (loaded on every page).
   Fixes the iOS Safari "bouncing bottom nav": rubber-band overscroll + the
   address bar toggling viewport height under a position:fixed bar.
   Also makes the home-screen (PWA) install feel app-like. */
@media (max-width: 760px) {
  html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
  .app { min-height: 100svh; }
  .rail {
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    width: 100% !important; height: auto !important;
    z-index: 200 !important;
    padding-bottom: calc(6px + env(safe-area-inset-bottom)) !important;
    transform: translateZ(0); will-change: transform;
  }
  .feed, .wrap, main, .maincol, .content {
    padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important;
  }

  /* ===== MESSENGER ON MOBILE ===== */
  /* Collapsed = a compact launcher pill bottom-right, above the nav. */
  .samsg-dock.collapsed {
    left: auto !important; right: 12px !important;
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    width: auto !important; max-width: 76vw !important;
  }
  /* Open = full-screen chat (like Instagram DMs). Covers everything incl. the nav;
     bottom rides on the keyboard so the compose bar is always visible. */
  .samsg-dock:not(.collapsed) {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    bottom: var(--kb, 0px) !important;
    width: 100% !important; max-width: 100% !important; height: auto !important;
    max-height: none !important;
    border: none !important; box-shadow: none !important;
    z-index: 9999 !important;
    display: flex !important; flex-direction: column !important;
    transition: bottom .12s ease;
  }
  .samsg-dock:not(.collapsed) .samsg-head {
    padding-top: calc(11px + env(safe-area-inset-top)) !important;
    flex: 0 0 auto !important;
  }
  .samsg-dock:not(.collapsed) .samsg-body { flex: 1 1 auto !important; display: flex !important; flex-direction: column !important; }
  .samsg-dock:not(.collapsed) .samsg-thread { flex: 1 1 auto !important; }

  /* while the messenger is open, get the bottom nav out of the way entirely */
  body.samsg-open .rail { display: none !important; }

  /* keyboard open on any OTHER page (compose/search): slide the nav away so it
     never floats mid-screen while you type */
  body.kb-open .rail { transform: translateY(130%) !important; }
}
@media (display-mode: standalone) {
  .rail { padding-bottom: calc(6px + env(safe-area-inset-bottom)) !important; }
  body { overscroll-behavior: none; }
}
