/* ================= FINAL MOBILE CLEANUP ================= */
body {
  background: #121212;
}
/* ================= MOBILE: STOP PULL-TO-REFRESH & OVERSCROLL ================= */
html,
body {
  max-width: 100%;
  overflow-x: hidden;

  /* 🔒 Stops pull-to-refresh + overscroll chaining */
  overscroll-behavior: none;
}

/* iOS Safari fix */
body {
  position: relative;
  background: #121212;
  -webkit-overflow-scrolling: auto; /* disables rubber-band */
}

/* Ensure scrolling happens only inside page */
@media (max-width: 480px) {
  body {
    touch-action: pan-y;
  }
}

@media (max-width: 480px) {

  /* ---------------- GLOBAL REMOVALS ---------------- */

  .bottom-row,
  .bottom-row *,
  .footer,
  .footer-links,
  .footer-links *,
  body > div[style*="text-align:center"],
  .user-posts,
  .user-posts *,
  .banner-links,
  .banner-links *,
  .nav-links,
  .nav-links * {
    display: none !important;
  }

  /* ❌ REMOVE ACCOUNT BOX */
  .login-logo,
  .login-logo * {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ---------------- LAYOUT ---------------- */

  .main-content {
    display: flex !important;
    flex-direction: column !important;
  }

  /* ---------------- FRIEND REQUESTS ---------------- */

  /* ✅ KEEP FRIENDS / REQUESTS */
  .right-box {
    display: block !important;
    width: 100% !important;
    margin: 0 0 12px 0 !important;
    order: 1; /* 👈 FIRST */
  }

  .right-box-content {
    height: auto !important;
    overflow: visible !important;
  }


  /* ---------------- REMOVE MESSAGES ONLY ---------------- */


  /* ---------------- CONTAINER ---------------- */

@media (max-width: 480px) {
  .container {
    height: 100%;
    max-height: 100%;
    padding: 0 !important;   /* 🚨 remove padding */
    overflow: hidden !important;
  }
}

}
.mobile-bottom-nav {
  display: none !important;
}
/* ================= MOBILE BOTTOM NAV ================= */
@media (max-width: 480px) {

  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 52px;

    background: #121212;

    display: flex;
    justify-content: space-around;
    align-items: center;

    z-index: 5000;
  }

  .mobile-bottom-nav a {
    font-size: 12px;
    color: #6ab0ff;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
  }

  .mobile-bottom-nav a:hover {
    text-decoration: underline;
  }

  /* Prevent content from hiding behind nav */
  .container {
    padding-bottom: 80px !important;
  }
}

.banner-text,
.banner-search-wrapper,
.banner-search-wrapper *,
#banner-search-form {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
/* ================= MOBILE: RECENT POSTS FIX ================= */
@media (max-width: 480px) {

  /* Remove desktop height constraints */
  .main-content {
    height: auto !important;
    overflow: visible !important;
  }

  .content-box.left-box {
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    margin-bottom: 30px;
  }

  .left-box-content,
  #recent-posts {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Ensure post cards expand and wrap */
  .post-item {
    width: 100% !important;
    height: auto !important;
    overflow: hidden !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .post-item img {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
  }

}

@media (max-width: 480px) {

  .banner {
    width: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right));
    margin-left: calc(-50vw + 50% + env(safe-area-inset-left));
    margin-right: calc(-50vw + 50% + env(safe-area-inset-right));

    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;


  }

  #ribbitLogo {
    max-height: 56px;
  }
}

@media (max-width: 480px) {
  body {
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }
}

@media (max-width: 480px) {

  /* Stop desktop centering behavior */
  body {
    display: block !important;
  }

  /* Normalize container for mobile flow */
  .container {
    position: static !important;
    transform: none !important;
    padding-top: 0 !important;
  }

  /* Clean, normal mobile banner */
  .banner {
    position: static !important;
    height: auto !important;
    min-height: 56px;

    display: flex !important;
    justify-content: center !important;
    align-items: center !important;


  }

  #ribbitLogo {
    display: block !important;
    margin: 0 auto !important;
    max-height: 56px;
  }

}
@media (max-width: 480px) {
  #invite-bottom {
    display: none !important;
  }
}
@media (max-width: 480px) {

  /* FULL-WIDTH MOBILE BANNER */
  .banner {
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;

    position: relative !important;
    left: 0 !important;
    right: 0 !important;

    display: flex !important;
    justify-content: center !important;
    align-items: center !important;


  }

  #ribbitLogo {
    max-height: 56px;
  }

}

/* ================= MOBILE: FRIENDS & REQUESTS EXPAND ================= */
@media (max-width: 480px) {

  /* Friends / Requests outer boxes */
  .right-box,
  .content-box.right-box {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  /* Inner scroll containers */
  .right-box-content {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  /* Individual cards (defensive) */
  .right-box-content > *,
  .right-box-content * {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}
/* ================= MOBILE: FIX FRIENDS / REQUESTS FLOW ================= */
@media (max-width: 480px) {

  /* Turn right column into normal flow */
  .right-column {
    display: block !important;
    width: 100% !important;
  }

  /* Ensure the box participates in height calculation */
  .content-box.right-box {
    position: relative !important;
    display: block !important;

    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Inner content must NOT scroll */
  .right-box-content {
    display: block !important;

    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}


@media (max-width: 480px) {
  html,
  body {
    height: auto !important;
    min-height: 100svh !important;
  }
}
/* ================= MOBILE: FIX DM INPUT CUT-OFF ================= */
@media (max-width: 480px) {

  /* Kill desktop fixed height */
  .container {
    height: auto !important;
    border: none !important;
    min-height: 100vh !important;
  }

  /* Remove flex height trap */
  .chat-wrapper {
    height: auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Messages area flexes correctly */
  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  /* Input row must NEVER shrink or clip */
  .dm-input-area {
    flex-shrink: 0 !important;
    position: relative !important;
  }
}
/* ================= MOBILE: REDUCE DM CONTAINER SIZE ================= */
@media (max-width: 480px) {

  /* Direct Messages outer box */
  .content-box.left-box {
    max-height: calc(100vh - 180px) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Ensure inner layout still works */
  .chat-wrapper {
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }
}
.mobile-bottom-nav a {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
@media (max-width: 480px) {

  /* When chat is open, hide sidebars */
  body.mobile-chat-open .instant-box,
  body.mobile-chat-open .group-box {
    display: none !important;
  }

  /* Make chat take full screen */
  body.mobile-chat-open .chat-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.mobile-chat-open .chat-messages {
    height: calc(100vh - 120px) !important;
    max-height: none !important;
    overflow-y: auto !important;
  }


}
@media (max-width: 480px) {
  body {
    overflow: hidden;
    height: 100vh;
    touch-action: none; /* stops body scroll */
  }
}
@media (max-width: 480px) {

  .chat-messages {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* smooth iOS scrolling */
    touch-action: pan-y; /* allow vertical scroll */
    height: 100%;
  }

}
@media (max-width: 480px) {

  /* Reduce the overall chat box height */
  .chat-box {
    height: calc(100svh - 140px); /* 👈 adjust this number */
    max-height: calc(100svh - 140px);
    display: flex;
    flex-direction: column;
  }

  /* Messages scroll inside the reduced box */
  .chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Input stays visible */
  .dm-input-area {
    flex-shrink: 0;
  }

}
  body:not(.mobile-chat-open) .content-box.left-box {
    display: none !important;
  }

  /* Show chat box once a friend is selected */
  body.mobile-chat-open .content-box.left-box {
    display: block !important;
  }

}
@media (max-width: 480px) {

  /* Entire chat box must fit ABOVE bottom nav */
  body.mobile-chat-open .content-box.left-box {
    height: calc(100svh - 52px - 56px); 
    /* 52px = bottom nav
       56px = top banner / spacing */
    max-height: calc(100svh - 52px - 56px);
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  /* Chat wrapper fills the box */
  body.mobile-chat-open .chat-wrapper {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Messages scroll INSIDE only */
  body.mobile-chat-open .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Input row stays visible */
  body.mobile-chat-open .dm-input-area {
    flex-shrink: 0 !important;
  }

}
@media (max-width: 480px) {

  /* Chat box fits ABOVE bottom nav */
  body.mobile-chat-open .content-box.left-box {
    height: calc(100svh - 52px); /* only subtract nav */
    max-height: calc(100svh - 52px);
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  /* Chat wrapper fills box */
  body.mobile-chat-open .chat-wrapper {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Messages take remaining space */
  body.mobile-chat-open .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Input stays INSIDE the box */
  body.mobile-chat-open .dm-input-area {
    flex-shrink: 0 !important;
    position: relative !important;
  }

}


@media (max-width: 480px) {
  html,
  body {
    height: 100vh;
    overflow: hidden !important;
    overscroll-behavior: none;
  }
}
@media (max-width: 480px) {

  /* Reduce image size inside chat bubbles */
  .chat-bubble img,
  .bubble-image {
    max-width: 160px !important;
    max-height: 180px !important;

  }

}
/* ================= MOBILE: CHAT FITS SCREEN WITH BOTTOM SPACE ================= */
@media (max-width: 480px) {

  /* Viewport lock (no bounce) */
  html,
  body {
    height: 100svh !important;
    overflow: hidden !important;
  }

  /* Container behaves like feed pages */
  .container {
    height: 100svh !important;
    display: flex !important;
    flex-direction: column !important;
    padding-bottom: calc(
      52px + env(safe-area-inset-bottom) + 24px
    ) !important; /* 👈 THIS is the “space like other pages” */
    overflow: hidden !important;
  }

  /* Chat box just flows */
  body.mobile-chat-open .content-box.left-box {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  /* Messages scroll internally */
  body.mobile-chat-open .chat-wrapper {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.mobile-chat-open .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Input always visible */
  body.mobile-chat-open .dm-input-area {
    flex-shrink: 0 !important;
    position: relative !important;
  }

}
/* ================= MOBILE: ALLOW BODY SCROLL ================= */
@media (max-width: 480px) {

  html,
  body {
    height: auto !important;
    min-height: 100svh !important;
    overflow-y: auto !important;     /* ✅ allow scrolling */
    overflow-x: hidden !important;
    touch-action: pan-y !important;  /* ✅ vertical scroll only */
  }

}
/* ================= MOBILE: CONTAINER SCROLL FIX ================= */
@media (max-width: 480px) {

  .container {
    height: auto !important;
    min-height: 100svh !important;
    overflow: visible !important;   /* ✅ allow page flow */
    display: flex !important;
    flex-direction: column !important;

    /* Space for bottom nav like feed pages */
    padding-bottom: calc(
      52px + env(safe-area-inset-bottom) + 24px
    ) !important;
  }

}

/* ================= MOBILE: REMOVE BANNER GAP (FINAL) ================= */
@media (max-width: 480px) {

  /* Stop viewport height fights */
  html,
  body {
    height: auto !important;
    min-height: unset !important;
    overflow-y: auto !important;
  }

  /* Container must not reserve space above banner */
  .container {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  /* Banner sits at top naturally */
  .banner {
    position: static !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    top: 0 !important;
  }
}
html,
body {
  margin: 0 !important;
  padding: 0 !important;
}
@media (max-width: 480px) {
  .banner {
    margin: 0 !important;
    padding: 0 !important;
  }
}
@media (max-width: 480px) {
  .page-flex {
    margin-top: 0 !important;
  }
}
@media (max-width: 480px) {
  body.has-site-background .container {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
  }
}

html, body {
  height: auto !important;
  min-height: unset !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
.container {
  min-height: calc(100svh - 52px - env(safe-area-inset-bottom));
  padding-bottom: calc(52px + env(safe-area-inset-bottom));
}

.mobile-bottom-nav {
  position: fixed !important;
  bottom: env(safe-area-inset-bottom);
  left: 0;
  width: 100%;
  height: 52px;
  z-index: 99999;
}
@media (max-width: 480px) {
  html,
  body {
    height: 100svh !important;
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
  }
}
@media (max-width: 480px) {
  .container {
    height: 100svh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;

    /* space for bottom nav */
    padding-bottom: calc(
      52px + env(safe-area-inset-bottom)
    ) !important;
  }
}
@media (max-width: 480px) {
  html,
  body {
    height: auto !important;
    min-height: 100svh;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: none;
    touch-action: pan-y;
    background: #121212;
  }
}
@media (max-width: 480px) {
  .container {
    height: auto !important;
    min-height: 100svh;
    overflow: visible !important;

    /* space for bottom nav */
    padding-bottom: calc(
      52px + env(safe-area-inset-bottom)
    ) !important;
  }
}
/* ================= MOBILE NAV STABLE FIX ================= */
@media (max-width: 480px) {

  html,
  body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  .container {
    padding-bottom: calc(
      52px + env(safe-area-inset-bottom)
    ) !important;
  }

  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;

    height: 52px;
    padding-bottom: env(safe-area-inset-bottom);

    transform: translate3d(0,0,0);
    will-change: transform;
    backface-visibility: hidden;

    z-index: 99999;
  }

}
@media (max-width: 480px) {

  .mobile-bottom-nav a,
  .mobile-bottom-nav a:link,
  .mobile-bottom-nav a:visited,
  .mobile-bottom-nav a:hover,
  .mobile-bottom-nav a:active,
  .mobile-bottom-nav a:focus {
    text-decoration: none !important;
    outline: none !important;
  }

  /* Remove iOS tap highlight */
  .mobile-bottom-nav a {
    -webkit-tap-highlight-color: transparent;
  }

}

/* ================= FINAL WKWEBVIEW SAFE FIX ================= */
@media (max-width: 480px) {

  html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  .container {
    padding-bottom: calc(52px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;

    height: 52px;
    padding-bottom: env(safe-area-inset-bottom);

    z-index: 99999;

    transform: translateZ(0);
    backface-visibility: hidden;
  }

}
@media (max-width: 480px) {

  .banner {
    position: relative;
    padding-top: env(safe-area-inset-top);
  }

  .banner::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 32px; /* LOWER fade */

    pointer-events: none;
    z-index: 1;

    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;

    background: linear-gradient(
      to bottom,
      rgba(0,0,0,0.6) 0%,
      rgba(0,0,0,0.35) 40%,
      rgba(0,0,0,0.12) 70%,
      rgba(0,0,0,0) 100%
    );
  }

}
@media (max-width: 480px) {

  .mobile-bottom-nav {
    position: relative;
  }

  .mobile-bottom-nav::after {
    content: "";
    position: absolute;
    bottom: -32px; /* sits below nav */
    left: 0;
    width: 100%;
    height: 32px;

    pointer-events: none;
    z-index: 1;

    border-top-left-radius: 14px;
    border-top-right-radius: 14px;

    background: linear-gradient(
      to bottom,
      rgba(0,0,0,0.6) 0%,
      rgba(0,0,0,0.35) 40%,
      rgba(0,0,0,0.12) 70%,
      rgba(0,0,0,0) 100%
    );
  }

}

