/* =========================================================
   RSBuild Mobile App Shell
   Production mobile stylesheet
   ========================================================= */

/* ---------- Base safety ---------- */

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
}

button,
a {
  touch-action: manipulation;
}

.rs-mobile-bottom-nav,
.rs-mobile-menu,
.rs-mobile-header-avatar {
  display: none;
}

/* =========================================================
   Mobile app frame
   ========================================================= */

@media (max-width: 768px) {
  :root {
    --mobile-topbar-h: 54px;
    --mobile-bottom-nav-h: 76px;
    --mobile-page-gutter: 12px;
  }

  body {
    padding-top: var(--mobile-topbar-h) !important;
    padding-bottom: calc(var(--mobile-bottom-nav-h) + env(safe-area-inset-bottom)) !important;
  }

  .rs-top {
    min-height: var(--mobile-topbar-h) !important;
  }

  .rs-top-inner {
    position: relative !important;
    min-height: var(--mobile-topbar-h) !important;
    padding: 8px 12px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  .rs-brand {
    width: auto !important;
    height: 38px !important;
    margin: 0 auto !important;
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .rs-brand-logo {
    height: 30px !important;
    width: auto !important;
    margin: 0 !important;
    display: block !important;
  }

  .rs-top .rs-nav {
    display: none !important;
  }

  .rs-main,
  .container.rs-main {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 8px var(--mobile-page-gutter) 0 !important;
  }

  .rs-page {
    width: 100% !important;
    max-width: none !important;
    padding: 8px 0 18px !important;
  }
}

/* =========================================================
   Mobile header account avatar + dropdown
   ========================================================= */

@media (max-width: 768px) {
  .rs-mobile-header-avatar {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);

    width: 34px;
    height: 34px;
    border-radius: 999px;
    overflow: hidden;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    border: 1px solid rgba(15,23,42,.16);
    background: #e5e7eb;
    color: #111827;

    font-size: 13px;
    font-weight: 900;
    z-index: 50;
  }

  .rs-mobile-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .rs-mobile-header-avatar span {
    font-size: 13px;
    font-weight: 900;
    color: #111827;
  }

  .rs-top .rs-actions {
    display: block !important;
    position: absolute !important;
    right: 0;
    top: 0;
    width: 0;
    height: 0;
    overflow: visible !important;
  }

  .rs-top .rs-actions > .rs-ico,
  .rs-top .rs-actions > .rs-user-menu > .rs-user-btn {
    display: none !important;
  }

  .rs-user-menu {
    display: block !important;
    position: static !important;
  }

  .rs-user-dd {
    position: fixed !important;
    top: 58px !important;
    right: 12px !important;
    left: auto !important;
    z-index: 3000 !important;
    width: 230px !important;
  }
}

/* =========================================================
   Home page mobile feed layout
   ========================================================= */

@media (max-width: 768px) {
  body.route-home .rs-main,
  body.route-home .container.rs-main {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  body.route-home .dash {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.route-home .dash-center {
    order: 1;
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
  }

  body.route-home .dash-left {
    order: 2;
    width: 100% !important;
    max-width: none !important;
    padding: 0 12px !important;
  }

  body.route-home .dash-right {
    order: 3;
    width: 100% !important;
    max-width: none !important;
    padding: 0 12px !important;
  }

  body.route-home .home-feed-shell,
  body.route-home .home-feed-list {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.route-home .feedcard {
    width: 100% !important;
    max-width: none !important;
    margin: 0 0 10px !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    overflow: hidden;
  }

  body.route-home .dash-left .box,
  body.route-home .dash-right .box {
    border-radius: 14px !important;
  }
}

/* =========================================================
   Feed header compact mobile styling
   ========================================================= */

@media (max-width: 768px) {
  body.route-home .feed-h {
    position: relative !important;
    z-index: 30 !important;
    overflow: visible !important;
    padding: 8px 10px !important;
    min-height: 42px !important;
    gap: 8px !important;
  }

  body.route-home .feed-h,
  body.route-home .feed-stats,
  body.route-home .comment-preview {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .feed-h .avatar,
  .feed-h .rs-avatar {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    flex: 0 0 30px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    font-size: 12px !important;
  }

  .feed-h .avatar img,
  .feed-h .rs-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block;
  }

  .feed-h .user,
  .feed-h .username,
  .feed-h .uname {
    font-size: 13px !important;
    line-height: 1.2 !important;
  }

  .feed-h .meta,
  .feed-h .ago,
  .feed-h .fhs {
    font-size: 11px !important;
  }

  .feed-h .ago {
    margin-left: -5px !important;
  }

  .feed-h .post-menu-trigger {
    width: 34px !important;
    height: 34px !important;
  }
}

/* =========================================================
   Feed photos and mobile image behaviour
   ========================================================= */

@media (max-width: 768px) {
  img,
  a,
  button,
  .photos,
  .photos a,
  .photos img,
  .feedcard,
  .feedcard * {
    -webkit-tap-highlight-color: transparent;
  }

  .photos img,
  .feedcard img {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  body.route-home .photos {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.route-home .photos img {
    width: 100% !important;
    display: block;
  }

  body.route-home .photos .psmall {
    display: none !important;
  }

  body.route-home .photos .pbig {
    position: relative !important;
    display: block !important;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  body.route-home .photos .pbig img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .feedcard img,
  .photos img,
  .photos .pbig,
  .photos a {
    border-radius: 0 !important;
  }

  body.route-home .photos a,
  body.route-home .pbig {
    position: relative;
    overflow: hidden;
  }

  body.route-home .photos a:active::after,
  body.route-home .pbig:active::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,0.08);
  }

  .photos .pbig[data-post-href] {
    cursor: pointer;
  }
}

/* Mobile multi-image count pill */
@media (max-width: 768px) {
  body.route-home .pcount--mobile {
    position: absolute !important;
    top: auto !important;
    left: auto !important;
    right: 10px !important;
    bottom: 10px !important;
    transform: none !important;

    min-width: 40px !important;
    height: 30px !important;
    padding: 0 10px !important;

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

    border-radius: 10px !important;
    background: rgba(15, 23, 42, .85) !important;
    color: #fff !important;

    font-size: 13px !important;
    font-weight: 900 !important;
    line-height: 1 !important;

    border: 1px solid rgba(255,255,255,.25) !important;
    box-shadow: 0 6px 16px rgba(0,0,0,.25) !important;

    pointer-events: none !important;
    z-index: 5 !important;
  }
}

@media (min-width: 769px) {
  .pcount--mobile {
    display: none !important;
  }
}

/* =========================================================
   Mobile double-tap like heart animation
   ========================================================= */

@media (max-width: 768px) {
  .mobile-long-like-heart {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 20;

    transform: translate(-50%, -50%) scale(.7);
    animation: mobileLongLikePop .7s ease forwards;

    color: #ff2d55;
    font-size: 92px;
    line-height: 1;
    text-shadow: 0 8px 26px rgba(0,0,0,.35);

    pointer-events: none;
  }
}

@keyframes mobileLongLikePop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.6);
  }

  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(1);
  }
}

/* =========================================================
   Mobile comment preview
   ========================================================= */

@media (max-width: 768px) {
  body.route-home .comment-preview {
    opacity: 0.85;
    padding: 6px 12px 10px !important;
  }

  body.route-home .comment-preview .cmt:nth-child(n+2) {
    display: none !important;
  }

  body.route-home .comment-preview .cmt {
    pointer-events: none;
  }
}

/* =========================================================
   Mobile post menu safety
   ========================================================= */

.post-menu-wrap {
  position: relative;
  z-index: 50;
}

.post-menu-dropdown {
  position: absolute;
  z-index: 9999 !important;
}

@media (max-width: 768px) {
  body.route-home .post-menu-wrap {
    position: relative !important;
    z-index: 1000 !important;
  }

  body.route-home .post-menu-trigger {
    position: relative !important;
    z-index: 1001 !important;
    width: 42px !important;
    height: 42px !important;
  }

  body.route-home .post-menu-dropdown {
    position: absolute !important;
    z-index: 1002 !important;
    top: 42px !important;
    right: 0 !important;
    min-width: 170px !important;
    background: #fff !important;
    box-shadow: 0 18px 45px rgba(15,23,42,.22) !important;
  }

  body.route-home .photos,
  body.route-home .photos a,
  body.route-home .photos img {
    position: relative !important;
    z-index: 1 !important;
  }

  body.route-home .post-menu-item {
    min-height: 46px !important;
    padding: 13px 15px !important;
    font-size: 14px !important;
  }
}

/* =========================================================
   Mobile post composer
   Opens from bottom-nav create button
   ========================================================= */

@media (max-width: 768px) {
  body.route-home .mobile-composer {
    display: none !important;
  }

  body.route-home .mobile-composer.is-mobile-open {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 12px 10px !important;
    padding: 0 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    scroll-margin-top: 70px;
  }

  body.route-home .mobile-composer.is-mobile-open .box-b {
    padding: 12px !important;
  }

  body.route-home .mobile-composer.is-mobile-open .composer-row,
  body.route-home .mobile-composer.is-mobile-open .composer-form {
    width: 100% !important;
    max-width: none !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  body.route-home .mobile-composer.is-mobile-open .composer-select,
  body.route-home .mobile-composer.is-mobile-open .btn,
  body.route-home .mobile-composer.is-mobile-open button {
    width: 100% !important;
    max-width: none !important;
  }
}

/* =========================================================
   Bottom navigation
   ========================================================= */

@media (max-width: 768px) {
  .rs-mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;

    height: calc(var(--mobile-bottom-nav-h) + env(safe-area-inset-bottom));
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));

    display: grid;
    grid-template-columns: 1fr 1fr auto 1fr 1fr !important;
    align-items: center;
    gap: 4px;

    background: #fff;
    border-top: 1px solid rgba(15,23,42,.12);
    box-shadow: 0 -10px 30px rgba(15,23,42,.12);

    margin-bottom: 0 !important;
  }

  .rs-mobile-nav-item {
    position: relative;
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 16px;

    background: transparent;
    color: #64748b;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .rs-mobile-nav-item svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.15;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .rs-mobile-nav-item.active {
    color: #111827;
    background: rgba(15,23,42,.06);
  }

  .rs-mobile-nav-item.active::after {
    content: "";
    position: absolute;
    bottom: 5px;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: currentColor;
  }

  .rs-mobile-badge {
    position: absolute;
    top: 5px;
    right: 13px;

    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: #e11d48;
    color: #fff;

    font-size: 10px;
    font-weight: 900;
    border: 2px solid #fff;
  }

  .rs-mobile-create-btn {
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 999px;

    background: #111827;
    color: #fff;

    font-size: 32px;
    line-height: 1;
    font-weight: 400;

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

    transform: translateY(-8px);
    box-shadow: 0 5px 14px rgba(15,23,42,.22);

    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .rs-mobile-create-btn:active {
    transform: translateY(-14px) scale(.94);
  }
}

/* =========================================================
   Mobile footer
   ========================================================= */

@media (max-width: 768px) {
  .footer {
    display: block !important;
    margin: 14px 0 calc(var(--mobile-bottom-nav-h, 76px) + env(safe-area-inset-bottom) + 14px) !important;
    padding: 18px 12px 20px !important;

    background: #fff;
    border-top: 1px solid rgba(15,23,42,.08);
  }

  .footer-inner {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;

    text-align: center !important;
  }

  .footer-left {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
  }

  .footer-brand {
    text-decoration: none !important;
  }

  .footer-brand-text {
    font-size: 11px !important;
    font-weight: 900 !important;
    color: #64748b !important;
  }

  .footer-links {
    width: 100% !important;

    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px 12px !important;
  }

  .footer-links a,
  .footer-cookie-link {
    width: auto !important;
    min-height: auto !important;
    padding: 0 !important;

    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;

    color: #334155 !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;

    appearance: none !important;
    cursor: pointer;
  }

  .footer-links a:hover,
  .footer-cookie-link:hover {
    text-decoration: underline !important;
  }
}

/* =========================================================
   Mobile page safety
   ========================================================= */

@media (max-width: 768px) {
  #pvFsEnter,
  .pv-fs-enter {
    display: none !important;
  }

  .dm-page,
  .dm-card,
  .dm-list,
  .dm-item {
    max-width: 100%;
    overflow-x: hidden;
  }
}

/* =========================================================
   iOS / iPadOS PWA safe-area status bar
   ========================================================= */

@supports (-webkit-touch-callout: none) {
  html,
  body {
    background: #111827;
  }

  body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;

    height: env(safe-area-inset-top);
    background: #111827;

    z-index: 9999;
    pointer-events: none;
  }

  body {
    padding-top: calc(env(safe-area-inset-top) + 54px) !important;
  }

  .rs-top {
    padding-top: env(safe-area-inset-top);
  }

  .rs-main {
    background: #f5f6f8;
  }
}


/* =========================================================
   iOS / iPadOS PWA install banner
   ========================================================= */
.ios-install-prompt {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 18px;
    z-index: 99999;
}

.ios-install-card {
    position: relative;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 42px 14px 14px;
    background: #111827;
    color: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0,0,0,.28);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ios-install-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #fff;
    color: #111827;
    font-weight: 800;
    font-size: 15px;
}

.ios-install-text {
    display: grid;
    gap: 2px;
    font-size: 13px;
    line-height: 1.35;
}

.ios-install-text strong {
    font-size: 15px;
}

.ios-install-text span {
    color: #e5e7eb;
}

.ios-install-text small {
    color: #cbd5e1;
}

.ios-install-close {
    position: absolute;
    top: 8px;
    right: 12px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

/* =========================================================
   Remember me checkbox & label
   ========================================================= */

.remember-wrap {
    margin: 14px 0 18px;
}

.remember-control {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.remember-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.remember-box {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #fff;
    transition:
        background 0.18s ease,
        border-color 0.18s ease;
    position: relative;
    flex-shrink: 0;
}

.remember-control input:checked + .remember-box {
    background: #000;
    border-color: #000;
}

.remember-control input:checked + .remember-box::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.remember-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.01em;
    position: relative;
    top: 1px;
}

.remember-control:focus,
.remember-control:active,
.remember-control:focus-visible {
    outline: none;
    box-shadow: none;
}

/* =========================================================
   Hide emoji picker button on phones/tablets
   ========================================================= */

@media (max-width: 768px), (hover: none) and (pointer: coarse) {

    /* DM emoji button */
    button#dmEmojiBtn,
    .dm-emoji-trigger,

    /* Comment emoji button */
    .emoji-inside-btn,
    .comment-emoji-btn {
        display: none !important;
        visibility: hidden !important;
    }

    .pv-scope .pv-hero-img.is-loading {
    opacity: 1 !important;
    filter: none !important;
  }
}

@media (max-width:720px){

  .online-drawer{
      right:8px;
      bottom:82px;

      width:auto;

      left:auto;
  }

  /* small chip */
  .online-drawer-toggle{
      width:auto;
      min-width:unset;

      height:38px;

      padding:0 12px;

      border-radius:999px;

      font-size:12px;
  }

  .online-drawer-label{
      display:none;
  }

  /* keep just: "1 online" */
  .online-drawer-count{
      margin-left:0;
  }

  /* OPEN STATE = full bottom sheet */
  .online-drawer.is-open .online-drawer-panel{

      position:fixed;

      left:12px;
      right:12px;

      width:auto;

      bottom:80px;

      max-height:65vh;

      border-radius:
         20px 20px 16px 16px;
  }

  .online-drawer-list{
      max-height:
      calc(65vh - 82px);
  }
}

@media (max-width:720px) and (orientation: landscape) {
  .online-drawer {
    bottom: 2px;
  }

  .online-drawer.is-open .online-drawer-panel {
    bottom: 18px;
    max-height: calc(100vh - 36px);
  }

  .online-drawer-list {
    max-height: calc(100vh - 118px);
  }
}

/* =========================================================
   Mobile bottom nav hard reset
   ========================================================= */

@media (max-width: 768px) {
  html,
  body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  body {
    padding-bottom: calc(
      var(--mobile-bottom-nav-h, 76px) + env(safe-area-inset-bottom)
    ) !important;
  }

  .rs-main,
  .container.rs-main,
  .rs-page,
  .dash,
  .dash-center,
  .dash-center--full {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

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

    width: 100vw !important;
    max-width: 100vw !important;

    z-index: 5000 !important;

    transform: none !important;
    margin: 0 !important;
  }

  .footer {
    margin-bottom: calc(
      var(--mobile-bottom-nav-h, 76px) + env(safe-area-inset-bottom) + 14px
    ) !important;
  }
}

@media (max-width: 768px){

  .pv-mobile-zoom{
    position: fixed;
    inset: 0;
    z-index: 99999;

    background: #000;

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

    overflow: hidden;

    touch-action: none;

    overscroll-behavior: none;
  }

  .pv-mobile-zoom[hidden]{
    display: none;
  }

  .pv-mobile-zoom img{
    display: block;

    max-width: 100vw;
    max-height: 100vh;

    width: auto;
    height: auto;

    object-fit: contain;

    transform-origin: center center;

    will-change: transform;

    touch-action: none;
    user-select: none;

    transition: transform .04s linear;
  }

  .pv-mobile-zoom__close{
    position: fixed;
    top: 14px;
    right: 14px;

    z-index: 100000;

    width: 42px;
    height: 42px;

    border: 0;
    border-radius: 999px;

    background: rgba(0,0,0,.55);

    color: #fff;

    font-size: 32px;
    line-height: 1;
  }

  .dm-compose-tools {
    margin-bottom: 50px;
}

}