/* ============================================================
   LEGION — mobile / responsive layer
   ============================================================ */

/* sidebar header wrapper (desktop + mobile) */
.sb-top { display: flex; align-items: center; justify-content: space-between; margin: 4px 8px 22px; }
.sb-logo { margin: 0; }
.sb-close { display: none; width: 34px; height: 34px; border-radius: 9px; align-items: center; justify-content: center; color: var(--text-2); }
.sb-close:hover { background: var(--surface-2); color: var(--text); }

/* mobile chrome hidden on desktop */
.m-topbar, .m-nav, .nav-scrim { display: none; }

@media (max-width: 880px) {
  /* ---- sidebar becomes a drawer ---- */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: min(86vw, 300px);
    z-index: 60; padding: 18px 14px 18px;
    background: var(--bg-2); border-right: 1px solid var(--border);
    transform: translateX(-104%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 0 48px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: none; }
  .sb-close { display: flex; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(6,6,9,.62); backdrop-filter: blur(3px); animation: toastIn .2s ease both; }

  /* ---- swap topbars ---- */
  .topbar { display: none; }
  .m-topbar { display: flex; position: sticky; top: 0; z-index: 40; height: 56px; align-items: center; gap: 10px; padding: 0 12px;
    background: color-mix(in oklab, var(--bg-1) 88%, transparent); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); border-bottom: 1px solid var(--border); }
  .m-iconbtn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); }
  .m-iconbtn:active { background: var(--surface-2); }
  .m-logo { display: flex; align-items: center; }
  .m-logo img { height: 21px; opacity: .96; }
  .m-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }
  .m-xp { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 800; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); padding: 5px 9px; border-radius: 8px; font-feature-settings: "tnum"; }
  .m-xp svg { color: var(--yellow); }
  .m-prof { display: flex; }

  /* ---- bottom tab bar ---- */
  .m-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0); align-items: stretch;
    background: color-mix(in oklab, var(--bg-1) 93%, transparent); backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%); border-top: 1px solid var(--border); }
  .m-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 58px; color: var(--text-3); font-size: 10px; font-weight: 700; letter-spacing: .02em; }
  .m-nav-item svg { opacity: .9; transition: transform .15s; }
  .m-nav-item.on { color: var(--accent); }
  .m-nav-item.on svg { opacity: 1; transform: translateY(-2px); }
  .m-nav-item:active { background: var(--surface-2); }

  /* ---- layout spacing ---- */
  .content-wrap { padding: 16px 14px 92px; gap: 16px; }
  .content { gap: 16px; }
  .card-pad { padding: 16px; }

  /* rail below content, full width */
  .content-wrap { grid-template-columns: 1fr; }
  .rail { position: static; flex-direction: column; }
  .rail > * { flex: none; }

  /* ---- profile header ---- */
  .xp-cover { height: 150px; }
  .xp-body { padding: 0 16px 18px; }
  .xp-toprow { margin-top: -38px; align-items: flex-start; }
  .xp-avatar .av-ring { box-shadow: 0 0 0 3px var(--surface-solid); }
  .xp-avatar .av { width: 74px !important; height: 74px !important; }
  .xp-actions { gap: 7px; }
  .xp-actions .btn, .xp-actions .pill { font-size: 12.5px; padding: 7px 11px; }
  .xp-name-row h1 { font-size: 22px; }
  .xp-bio { font-size: 13.5px; }
  .xp-meta { gap: 12px 16px; font-size: 12.5px; }

  /* tighten section heads */
  .sec-head h2, .qboard-head h2, .page-head h1 { font-size: 20px; }
  .page-head h1 { font-size: 24px; }

  /* ---- quests ---- */
  .qboard-head { gap: 12px; }
  .qfilter { width: 100%; overflow-x: auto; }
  .qfilter .seg { flex: 1; white-space: nowrap; }

  /* ---- season ---- */
  .season-main { padding: 16px; gap: 14px; }
  .season-cd { width: 100%; justify-content: space-between; }
  .cd-unit { flex: 1; min-width: 0; }
  .season-phases { overflow-x: auto; }
  .season-phase { min-width: 130px; flex: none; }

  /* ---- feed ---- */
  .feed-wrap { max-width: 100%; }
  .post-actions { max-width: 100%; }
  .composer input { min-width: 0; }

  /* ---- toasts above bottom nav ---- */
  .xp-toasts { bottom: 78px; }
}

/* ---- smaller phones ---- */
@media (max-width: 560px) {
  .xp-toprow { flex-direction: column; gap: 14px; }
  .xp-actions { width: 100%; }
  .xp-actions .btn:last-child { margin-left: auto; }

  .quest { flex-wrap: wrap; }
  .q-action { width: 100%; justify-content: space-between; padding-left: 52px; }
  .q-action .btn { min-width: 0; flex: 1; max-width: 180px; }

  /* leaderboard podium scaled down */
  .podium-stage { gap: 6px; padding: 26px 8px 0; }
  .podium { width: auto; flex: 1 1 0; min-width: 0; }
  .podium-av .av { width: 50px !important; height: 50px !important; }
  .podium-1 .podium-av .av { width: 62px !important; height: 62px !important; }
  .podium-medal { font-size: 10px; min-width: 18px; height: 18px; }
  .podium-name { font-size: 12px; }
  .podium-xp { font-size: 11px; }
  .podium-base-num { font-size: 34px; }
  .podium-base-label { font-size: 8.5px; }
  .podium-1 .podium-base { height: 116px; } .podium-2 .podium-base { height: 92px; } .podium-3 .podium-base { height: 76px; }

  /* world pass */
  .wp-display { font-size: 30px; }
  .wp-perks { grid-template-columns: 1fr; }
  .wp-copy, .wp-media { padding: 22px; }

  /* referral */
  .ref-hero-actions { flex-direction: column; }
  .ref-hero-actions .btn { width: 100%; }
  .ms-info .chip-xp { display: none; }
  .ref-levels .ref-level { flex-wrap: wrap; }

  /* presale */
  .ps-hero { flex-direction: column; text-align: left; }
  .ps-notify-form { width: 100%; }
  .ps-notify-form input { width: 100%; max-width: none; }

  /* doc */
  .doc-head h1 { font-size: 30px; }
  .lore-read-inner h1 { font-size: 32px; }

  /* rank-up modal */
  .rankup-card { padding: 28px 22px 24px; }
  .rankup-actions { flex-direction: column; }
  .rankup-actions .btn { width: 100%; }
}
