/* ============================================
   Jade — Mobile Responsive Styles
   Consolidated single source of truth for all
   mobile/tablet responsive behavior.
   ============================================ */

/* ──────────────────────────────────────────────
   Base: hide mobile-only elements on desktop
   ────────────────────────────────────────────── */
.mobile-header {
  display: none;
}

.bottom-bar {
  display: none;
}

.compose-fab {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* ──────────────────────────────────────────────
   Breakpoint: ≤1024px — Tablet (hide aside)
   ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas: "sidebar main";
  }

  .aside {
    display: none;
  }

  .main-content {
    max-width: 100%;
    padding: var(--space-6) var(--space-6);
  }

  /* Profile page aside */
  .profile-page-aside {
    display: none;
  }
}

@media (min-width: 1025px) {
  .profile-page-aside {
    display: block;
  }
}

/* ──────────────────────────────────────────────
   Breakpoint: ≤768px — Mobile (tablets/phones)
   Single column, bottom bar, mobile header
   ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* ── Body ── */
  body {
    padding-bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
  }

  /* ── App Shell: single column ── */
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "main";
    padding-bottom: 0;
  }

  /* ── Sidebar: hide desktop, enable mobile overlay ── */
  .sidebar {
    display: none;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out);
  }

  .sidebar--mobile-open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: var(--sidebar-expanded);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.5);
    transform: translateX(0);
  }

  /* ── Sidebar backdrop ── */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 39;
  }

  .sidebar-backdrop--visible {
    display: block;
  }

  /* ── Main content ── */
  .main-content {
    max-width: 100%;
    padding: var(--space-3) var(--space-3);
  }

  /* ── Full-width cards ── */
  .post-card {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .composer-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  /* ── Mobile Header ── */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 25;
    height: 52px;
  }

  .mobile-header__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green-bright);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
    text-decoration: none;
  }

  .mobile-header__logo svg {
    width: 24px;
    height: 24px;
  }

  .mobile-header__auth {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
  }

  .mobile-header__auth svg {
    width: 20px;
    height: 20px;
  }

  .mobile-header__auth:hover {
    background: rgba(0,255,135,0.1);
    color: var(--green-bright);
  }

  .mobile-header__auth--connected {
    background: rgba(0,255,135,0.1);
    color: var(--green-bright);
    border: 1px solid rgba(0,255,135,0.2);
  }

  /* Hamburger menu button */
  .mobile-header__hamburger {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
  }

  .mobile-header__hamburger:hover {
    background: rgba(0,255,135,0.1);
    color: var(--green-bright);
  }

  .mobile-header__hamburger svg {
    width: 20px;
    height: 20px;
  }

  /* Desktop nav hide on mobile */
  .desktop-nav-hide {
    display: none;
  }

  .hide-mobile {
    display: none !important;
  }

  /* ── Bottom Bar ── */
  .bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-bar-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* ── Touch-friendly tap targets (min 44px) ── */
  .btn-primary,
  .btn-secondary,
  .btn-ghost,
  .btn-fab {
    min-height: 44px;
  }

  .btn-icon,
  .composer-tool {
    min-width: 44px;
    min-height: 44px;
  }

  .post-card__action {
    min-height: 44px;
    padding: 10px 12px;
  }

  .tabs-pill__item {
    padding: 10px 16px;
    min-height: 44px;
  }

  .card-creator__subscribe {
    padding: 10px 16px;
    min-height: 44px;
  }

  .explore-card__subscribe {
    min-height: 44px;
    padding: 10px 18px;
  }

  /* Scrollable modals on mobile */
  .jade-profile-modal {
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal {
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-dropdown {
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Chat page: conversation list narrower ── */
  #chatConvList {
    width: 200px !important;
    min-width: 160px !important;
  }

  /* ── Activity stats grid: 2 columns ── */
  #activity-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Subscriptions list padding ── */
  .card-subscription {
    flex-direction: column;
  }

  .card-subscription__thumbnail {
    width: 100%;
    height: auto;
    aspect-ratio: 3/2;
  }
}

/* ──────────────────────────────────────────────
   Breakpoint: ≤640px — Small phones
   ────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* ── Tighter padding ── */
  .main-content {
    padding: var(--space-3) var(--space-2);
  }

  /* ── Hide inline composer, show FAB ── */
  .composer-card {
    display: none;
  }

  .compose-fab {
    display: flex;
    position: fixed;
    bottom: calc(var(--bottom-bar-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-circle);
    background: var(--green-bright);
    color: var(--text-on-green);
    border: none;
    box-shadow: var(--shadow-glow-green), 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    z-index: 25;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-out);
  }

  .compose-fab:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-glow-green-strong), 0 6px 16px rgba(0, 0, 0, 0.5);
  }

  .compose-fab svg {
    width: 24px;
    height: 24px;
  }

  /* ── Auth dropdown full-width ── */
  .auth-dropdown {
    width: calc(100% - 32px);
    left: 16px;
    right: 16px;
  }

  .auth-dropdown::before {
    display: none;
  }

  /* ── Guide page heading sizes ── */
  .guide-hero h1 {
    font-size: var(--text-h1);
  }

  .guide-section h2 {
    font-size: var(--text-h3);
  }

  /* ── Chat page: single column (conv list fills width) ── */
  #chatConvList {
    width: 100% !important;
    min-width: 100% !important;
    border-right: none !important;
  }

  /* When a conversation is active, hide the list */
  #chatConvList.conv-hidden {
    display: none;
  }

  /* ── Activity stats: single column on tiny screens ── */
  #activity-stats {
    grid-template-columns: 1fr !important;
  }

  /* ── Profile page compact ── */
  .card-profile {
    padding: var(--space-4);
  }

  .profile-page-aside {
    display: none !important;
  }
}

/* ──────────────────────────────────────────────
   Desktop (≥769px): hide mobile-only elements
   ────────────────────────────────────────────── */
@media (min-width: 769px) {
  .bottom-bar {
    display: none;
  }

  .mobile-header {
    display: none;
  }

  .compose-fab {
    display: none;
  }

  .sidebar-backdrop,
  .sidebar-backdrop--visible {
    display: none;
  }

  .sidebar--mobile-open {
    /* Reset to normal sidebar behavior on desktop */
    position: relative;
    width: var(--sidebar-width);
    box-shadow: none;
    transform: translateX(0);
  }
}

/* ──────────────────────────────────────────────
   Bottom Bar Navigation (base styles)
   ────────────────────────────────────────────── */
.bottom-bar__nav {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-4);
}

.bottom-bar__nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-circle);
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease-out);
  text-decoration: none;
}

.bottom-bar__nav-item:hover,
.bottom-bar__nav-item--active {
  color: var(--green-bright);
}

.bottom-bar__nav-item svg {
  width: 22px;
  height: 22px;
}

.bottom-bar__create {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-circle);
  background: var(--green-bright);
  color: var(--text-on-green);
  box-shadow: var(--shadow-glow-green);
  margin-top: -12px;
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  border: none;
}

.bottom-bar__create:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow-green-strong);
}

.bottom-bar__create svg {
  width: 22px;
  height: 22px;
}

/* ──────────────────────────────────────────────
   Roadmap page mobile
   ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .roadmap-container {
    padding: var(--space-4) var(--space-3);
  }

  .roadmap-grid {
    grid-template-columns: 1fr;
  }
}

/* ──────────────────────────────────────────────
   Landing page mobile
   ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .landing-nav__inner {
    padding: 12px 16px;
  }

  .landing-nav__links {
    display: none;
  }

  .landing-hero {
    padding: 60px 16px;
    min-height: auto;
  }

  .landing-hero__title {
    font-size: clamp(1.75rem, 6vw, 3rem);
  }

  .landing-hero__stats {
    gap: 24px;
    margin-top: 32px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .steps-row {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .step-connector {
    display: none;
  }

  .protocol-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .landing-section {
    padding: 48px 16px;
  }
}

@media (max-width: 640px) {
  .btn-hero-primary {
    min-width: auto;
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
  }

  .landing-hero__actions {
    flex-direction: column;
    width: 100%;
  }

  .btn-hero-secondary {
    width: 100%;
    justify-content: center;
  }
}
