/* =========================================================
   Rescue-Net Mobile Navigation Drawer
   Off-canvas sidebar for internal pages, <1024px.
   Loaded after style.css and rn-navigation-v2.css so these
   rules win the cascade without needing to unpick the legacy
   mobile overrides in style.css.
   ========================================================= */

.rn-drawer-topbar,
.rn-drawer-backdrop {
  display: none;
}

@media (max-width: 1023px) {
  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) {
    min-width: 0 !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .app-shell {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100vh !important;
  }

  /* Sticky top bar: hamburger left, title center, logo right */
  .rn-drawer-topbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 220;
    height: 56px;
    padding: 0 10px;
    background: var(--panel2, #fff8f3);
    border-bottom: 1px solid var(--line, rgba(104, 64, 45, .14));
  }

  .rn-drawer-topbar .rn-drawer-title {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-weight: 800;
    font-size: 16px;
    color: var(--text, #2d211b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rn-drawer-topbar .rn-drawer-logo {
    flex: 0 0 auto;
    height: 30px;
    width: auto;
  }

  .rn-drawer-hamburger {
    display: inline-flex;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 4px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
  }

  .rn-drawer-hamburger:focus-visible {
    outline: 2px solid var(--peach2, #e8835d);
    outline-offset: 2px;
  }

  .rn-drawer-hamburger span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--text, #2d211b);
  }

  /* The sticky top bar replaces the old fixed floating mobile title */
  body:not(.home-page) .topbar .rn-page-mobile-title {
    display: none !important;
  }

  /* Off-canvas drawer: reuse the existing .sidebar element as the panel */
  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 16px 14px !important;
    border-right: 1px solid var(--line, rgba(104, 64, 45, .14)) !important;
    border-bottom: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    z-index: 210 !important;
    transform: translateX(-100%) !important;
    transition: transform 220ms ease !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3) !important;
  }

  body.rn-drawer-open:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .sidebar {
    transform: translateX(0) !important;
  }

  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .sidebar nav {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .sidebar nav a,
  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .rn-nav-v2-link,
  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .rn-nav-v2-summary {
    flex: 0 0 auto !important;
    min-height: 44px !important;
    white-space: normal !important;
    border-radius: 8px !important;
    font-size: 14px !important;
  }

  body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .main {
    width: 100% !important;
    min-width: 0 !important;
    padding: 14px 12px 24px !important;
  }

  /* Backdrop */
  .rn-drawer-backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }

  body.rn-drawer-open .rn-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Lock page scroll while the drawer is open; main content itself never shifts */
  body.rn-drawer-open {
    overflow: hidden !important;
  }

  @media (prefers-reduced-motion: reduce) {
    body:not(.home-page):not(.viewer-page):not(.mockup-viewer):not(.public-report-page) .sidebar,
    .rn-drawer-backdrop {
      transition: none !important;
    }
  }
}

@media (min-width: 1024px) {
  .rn-drawer-topbar,
  .rn-drawer-hamburger,
  .rn-drawer-backdrop {
    display: none !important;
  }
}
