/* SuperAwesome — mobile hardening (loaded on every page).
   - Locks the page against horizontal "float"/rubber-band on a gentle left/right swipe.
   - Pins the bottom nav; keeps it out of the way of the keyboard & messenger.
   - Makes the messenger a real full-screen chat instead of a page-breaking dock. */

/* ---- global: gentle guards only (no scroll-container changes on <html>) ---- */
html, body {
  overscroll-behavior-y: none;   /* stop pull-to-refresh bounce, keep normal scrolling */
  -webkit-tap-highlight-color: transparent;
}
img, video, iframe, canvas { max-width: 100%; }

@media (max-width: 760px) {
  /* Prevent sideways drift on touch WITHOUT putting overflow on <html>
     (overflow-x:hidden on <html> moves the desktop scrollbar to the left and
     breaks trackpad scrolling). overflow-x:clip doesn't create a scroll container. */
  body { overflow-x: clip; }
  .app, .feed, .feedwrap, .maincol, .wrap, main, .content, .right { max-width: 100%; }
  .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. Covers everything incl. the nav; bottom rides the keyboard. */
  .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 */
  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; }
}
