/* mobile.css — extracted from index.html (Phase: CSS modularization).
   Load order theme -> layout -> components -> mobile is load-bearing (cascade). */
/* ================================================================
   MOBILE-FIRST REDESIGN — everything below 900px
   ================================================================ */

/* Desktop: hide mobile-only elements */
.bnav { display: none; }
.m-stat-strip { display: none; }
.topbar-title { display: none; }
.m-hub { display: none; }
.m-hub-util { display: none; }

/* ── Bottom navigation bar ── */
.bnav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 80;
  background: rgba(10,10,18,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  justify-content: space-around;
  align-items: stretch;
}
.bnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  background: none;
  border: none;
  color: var(--faint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: .5px;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 60px;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bnav-btn svg { width: 22px; height: 22px; transition: transform .18s; }
.bnav-btn.on { color: var(--violet); }
.bnav-btn.on svg { transform: translateY(-1px); }
.bnav-btn.on::after {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  border-radius: 0 0 3px 3px;
  background: var(--grad);
}
.bnav-badge {
  position: absolute;
  top: 8px; right: calc(50% - 18px);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 6px var(--rose);
}

@media (max-width: 900px) {
  /* ── Hamburger drawer is the mobile nav (matches Claude/ChatGPT); the bottom
        nav was eating ~20% of every view, so it's retired in favour of the slide-in
        rail drawer, which already holds the full nav + settings. ── */
  .bnav { display: none; }
  .menu-btn { display: grid; }

  /* ── Kill expensive GPU layers on mobile ── */
  .aurora b { display: none; }
  .grain { display: none; }
  .rail { backdrop-filter: none; }
  .topbar { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

  /* ── Shell: full height; no bottom nav now, just breathing room + safe area ── */
  .main {
    height: 100dvh;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Topbar: slimmer, only title + avatar ── */
  .topbar {
    padding: 11px 16px;
    gap: 0;
    border-bottom: 1px solid var(--line);
    min-height: 54px;
  }
  /* Hide streak/XP chips from topbar on mobile — they live in Today hero */
  .topbar .chip { display: none; }
  .topbar .right { gap: 0; }
  .topbar .mode { display: none; }
  /* Section title in topbar */
  .topbar-title {
    flex: 1;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.3px;
    padding-left: 4px;
  }

  /* ── Views: full bleed, comfortable padding ── */
  .view { padding: 16px 16px 24px; }

  /* ── Card spacing ── */
  .panel { border-radius: 16px; }

  /* ── Show mobile-only elements ── */
  .m-stat-strip { display: flex; }
  .topbar-title { display: block; }

  /* ── Profile hub: secondary nav grid (mobile only) ── */
  .m-hub {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
  }
  .m-hub-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    min-height: 72px;
  }
  .m-hub-btn:active { background: var(--panel2); border-color: var(--violet); }
  .m-hub-btn svg { width: 22px; height: 22px; color: var(--violet); }
  .m-hub-util {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
  }
  .m-hub-util-btn {
    flex: 1;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 8px;
    color: var(--muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background .15s;
    min-height: 40px;
  }
  .m-hub-util-btn:active { background: var(--panel2); }

  /* ── Today page: mobile layout ── */
  /* Compact hero strip replacing the big hero card + ring */
  .g-hero { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
  .hero { padding: 20px; border-radius: 16px; }
  .hero .hi { font-size: 24px; }
  .hero .line { font-size: 14px; margin-top: 7px; }
  .hero .acts { gap: 10px; margin-top: 16px; }
  .hero .acts .btn { padding: 12px 16px; font-size: 13.5px; }

  /* Mobile XP+Streak pill strip — sits above tasks */
  .m-stat-strip {
    display: flex;
    gap: 10px;
    margin-top: 14px;
  }
  .m-stat-pill {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel);
  }
  .m-stat-pill .icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 18px;
    flex: none;
  }
  .m-stat-pill .icon.streak-icon { background: rgba(245,181,68,.15); }
  .m-stat-pill .icon.xp-icon { background: rgba(34,211,238,.12); }
  .m-stat-pill .icon.lvl-icon { background: rgba(134,255,107,.12); }
  .m-stat-pill .val {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 800;
    font-size: 22px;
    line-height: 1;
  }
  .m-stat-pill .lbl {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    color: var(--faint);
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-top: 2px;
  }
  /* Hide ring card on mobile (replaced by stat pills) */
  .ring-card { display: none; }
  /* Consist grid: tasks full width first, XP second */
  .consist-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }

  /* ── Today page: bigger touch targets on tasks ── */
  .task-row {
    padding: 14px 14px;
    border-radius: 14px;
    margin-bottom: 10px;
    min-height: 52px;
  }
  .task-check {
    width: 28px; height: 28px;
    border-radius: 8px;
    flex: 0 0 28px;
  }
  .task-title { font-size: 14.5px; }

  /* ── Rhythm strip: horizontal scroll ── */
  .rhythm {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-top: 16px;
    padding-bottom: 4px;
  }
  .rhythm::-webkit-scrollbar { display: none; }
  .day {
    flex: 0 0 auto;
    width: 70px;
    padding: 12px 8px;
    border-radius: 14px;
  }
  .day .d { font-size: 10px; }
  .day .icn { font-size: 22px; margin: 6px 0 4px; }
  .day .lbl { font-size: 11px; }

  /* ── Stat row: 2 columns on mobile ── */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
  /* Third stat takes full width */
  .stat-row .panel:nth-child(3) { grid-column: span 2; }
  .stat { padding: 16px; }
  .stat .v { font-size: 22px; }

  /* ── Section headers: smaller on mobile ── */
  h2.title { font-size: 24px; letter-spacing: -.4px; margin-top: 4px; }
  .eyebrow { font-size: 10px; letter-spacing: 2px; }
  .sub { font-size: 14px; }

  /* ── Astra: full-screen chat (fills the shell like ChatGPT / Claude) ──
     The active view becomes a flex column sized to exactly the room left under
     the sticky topbar (~54px) and above the bottom nav (76px + safe area), so the
     message stream gets the maximum readable height and the composer pins to the
     bottom — no more reading a long answer through a tiny window. */
  .view.on[data-view="astra"] {
    display: flex; flex-direction: column; min-height: 0; padding: 0;
    height: calc(100dvh - 54px - 20px - env(safe-area-inset-bottom, 0px));
  }
  .view.on[data-view="astra"] > .title { display: none; } /* topbar already shows "Astra · Study" */
  .astra-wrap { display: flex; flex-direction: column; gap: 0; margin-top: 0; flex: 1; min-height: 0; }
  .chatcard { min-height: 0; height: auto; flex: 1; border: none; border-radius: 0; }
  .chathead { padding: 14px 16px; }
  .stream { padding: 14px 16px; gap: 12px; }
  .msg { font-size: 14px; max-width: 90%; }
  .composer {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    gap: 8px;
  }
  .composer input, .composer textarea { padding: 12px 14px; font-size: 15px; }
  .composer .send { padding: 0 14px; min-height: 46px; }
  /* Hide mic on mobile (parked feature) */
  .composer .mic { display: none; }
  /* Suggestions: horizontal scroll */
  .suggest {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 14px 12px;
    gap: 7px;
  }
  .suggest::-webkit-scrollbar { display: none; }
  .suggest button { flex: 0 0 auto; white-space: nowrap; padding: 9px 13px; }
  /* Hide the desktop side panel in Astra */
  .astra-wrap .side { display: none; }

  /* ── Paths: remove timeline line, card-based layout ── */
  .roadmap { padding-left: 0; }
  .roadmap::before { display: none; }
  .node { padding: 0 0 12px; }
  .node::before { display: none; }
  /* Replace with top status pill */
  .node { padding: 0 0 12px; position: relative; }
  .node .mtitle {
    font-size: 15px;
    padding: 14px 16px 0;
    gap: 6px;
  }
  .node .mdesc { padding: 4px 16px 0; font-size: 13px; }
  .node ul { margin: 8px 12px 4px; gap: 4px; }
  .node li { padding: 9px 11px 9px 28px; font-size: 13px; min-height: 40px; }
  .node .res { margin: 6px 16px 0; padding: 8px 0 0; font-size: 10.5px; }
  /* Status dot: top-left absolute inside card */
  .node.done { border-color: rgba(134,255,107,.25); }
  .node.now { border-color: rgba(34,211,238,.35); box-shadow: 0 0 0 1px rgba(34,211,238,.15); }

  /* Goal card */
  .goal-card { padding: 18px; margin-bottom: 14px; }
  .goal-card .gtitle { font-size: 17px; }
  .goal-actions { gap: 8px; }
  .goal-actions .btn { padding: 10px 14px; font-size: 13px; }
  .path-tabs { gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .path-tabs::-webkit-scrollbar { display: none; }
  .path-tabs button { flex: 0 0 auto; }

  /* ── Archetype grid: single column on small screens ── */
  .arch-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 16px; }
  .arch { padding: 18px; }
  .arch h3 { font-size: 17px; }
  .arch p { font-size: 13px; }

  /* ── Calendar: full width ── */
  .cal-wrap { grid-template-columns: 1fr; gap: 14px; }
  .cal-cell { padding: 4px; border-radius: 8px; }
  .cal-cell .dnum { font-size: 11px; }

  /* ── Profile banner ── */
  .pf-banner { height: 120px; }
  /* consistent profile action-button sizing + alignment on mobile */
  .pf-actions { flex-direction: column; align-items: stretch; }
  .pf-actions .btn { width: 100%; justify-content: center; margin-left: 0; }
  .pf-account .btn { margin-left: 0; }
  .pf-avatar { width: 82px; height: 82px; }
  .pf-avatar-wrap { margin-top: -40px; }
  .pf-form { padding: 14px 16px 20px; }
  .opt-row { gap: 10px; }

  /* ── Challenge/Spark card ── */
  #sparkCard { padding: 18px; }
  .sm2-opt { padding: 13px 14px; min-height: 48px; font-size: 14px; }
  /* MCQ options: larger tap targets */
  .sm2-opt:active { background: rgba(124,92,255,.18); transform: none; }

  /* ── Leaderboard rows ── */
  .lb-row { padding: 12px 14px; min-height: 56px; }
  .lb-ava { width: 36px; height: 36px; }

  /* ── Teams cards ── */
  .team-card { padding: 14px 16px; min-height: 56px; }

  /* ── Complete-profile banner ── */
  #completeBanner { margin: 12px 16px 0; padding: 14px 16px; border-radius: 14px; }
  #cbUsername { width: 100%; }
  #cbAge { width: 70px; }

  /* ── XP toasts: lower so they clear the bottom nav ── */
  .xp-toast {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    right: 16px;
  }

  /* ── Toast host: above bottom nav ── */
  .toast-host {
    top: auto;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    transform: none;
    left: 16px;
    right: 16px;
    align-items: flex-start;
  }

  /* ── Server status pill: above bottom nav ── */
  #serverStatus {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* ── Mission/Quests ── */
  .q-controls { flex-direction: column; gap: 10px; }
  .sel select { min-width: unset; width: 100%; }
  .mission { padding: 18px; }
  .mission .story { font-size: 14.5px; }
  .solverow { flex-direction: column; gap: 8px; }
  .solverow input { width: 100%; }

  /* ── Onboarding option rows ── */
  .opt-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .opt-row .sel select { min-width: unset; }

  /* ── News briefing cards ── */
  .news-card-actions { flex-wrap: nowrap; overflow-x: auto; gap: 8px; scrollbar-width: none; }
  .news-card-actions::-webkit-scrollbar { display: none; }

  /* ── Command palette: full screen on mobile ── */
  .cmdk { top: 0; left: 0; right: 0; width: 100%; border-radius: 0 0 16px 16px; transform: none; }

  /* ── Game modals: full screen ── */
  .gm-modal, .sm2-modal { width: 100%; min-height: 100dvh; border-radius: 0; margin: 0; }
  .gm-scrim, .sm2-scrim { padding: 0; align-items: flex-start; }

  /* ── Note panel ── */
  .note { font-size: 13px; padding: 14px 16px; }

  /* ── Prevent iOS Safari zoom-on-focus ── any text field <16px makes the
     viewport jump on tap. Force 16px on all of them (the big math-game input
     keeps its size). !important is needed to beat inline font-size styles. */
  input:not([type=range]):not(.sm-input), select, textarea { font-size: 16px !important; }

  /* ── Larger tap targets for small icon controls ── */
  .cal-nav { width: 40px; height: 40px; }
  .cal-x { padding: 4px 8px; }
  .fb-del { padding: 2px 6px; }

  /* ── Button sizes: minimum 44px touch target ── */
  .btn { min-height: 44px; }
  .btn-g { padding: 11px 16px; }
  .btn-p { padding: 13px 20px; }

  /* ── Chips in nav are already hidden; these are content chips ── */
  .chip { padding: 7px 11px; font-size: 11.5px; }
}

@media (max-width: 480px) {
  .view { padding: 14px 14px 20px; }
  .hero .hi { font-size: 22px; }
  .hero .acts { flex-direction: column; }
  .hero .acts .btn { width: 100%; justify-content: center; }
  .m-stat-strip { gap: 8px; }
  .m-stat-pill .val { font-size: 20px; }
  .stat-row { grid-template-columns: 1fr; }
  .stat-row .panel:nth-child(3) { grid-column: span 1; }
  /* Topbar section title */
  .topbar-title { font-size: 16px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SAFE-AREA TOP + MOBILE-GRADE POLISH (2026-07-02)
   Fix: edge-to-edge PWA/TWA (Android 15+ enforces it) draws the page UNDER the
   status bar — the topbar's first ~1cm (hamburger + title) was unreachable.
   viewport-fit=cover is set, so env(safe-area-inset-top) carries the real
   inset; harmless 0px fallback in a normal browser tab.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* absorb the status-bar inset in the sticky topbar + the fixed drawer */
  .topbar { padding-top: calc(11px + env(safe-area-inset-top, 0px)); }
  .rail   { padding-top: calc(22px + env(safe-area-inset-top, 0px)); }
  /* modals / overlays that stretch full-screen shouldn't hide under it either */
  .set-overlay { padding-top: env(safe-area-inset-top, 0px); }

  /* notification inbox → a comfortable sheet pinned under the topbar on phones */
  .notif-panel { position: fixed; top: calc(60px + env(safe-area-inset-top, 0px));
                 right: 8px; left: 8px; width: auto; max-width: none; max-height: 74vh; }
  .notif-bell { width: 36px; height: 36px; }
  .notif-wrap { margin-right: 9px; }   /* topbar .right has gap:0 on mobile — keep bell off the avatar */

  /* ── touch-grade inputs: 16px stops iOS auto-zoom on focus ── */
  #astraInput, #reflectInput, .pg-code, .pg-select,
  .rail-chats-search, input[type="text"], input[type="number"], textarea, select { font-size: 16px; }

  /* ── copy/listen affordances are hover-revealed on desktop → always visible on touch ── */
  .copy-btn { opacity: .55; }
  .code-copy { opacity: .55; }

  /* ── Code Lab, phone layout: stacked head, full-width controls ── */
  .pg-head { flex-direction: column; align-items: stretch; }
  .pg-tabs { width: 100%; box-sizing: border-box; }
  .pg-tab { flex: 1; text-align: center; padding: 9px 3px; font-size: 12px; }  /* 5 tabs fit */
  .pg-actions { width: 100%; }
  /* real flex-basis so the picker claims a row beside the trophy chip instead of
     being crushed to nothing by the zero-basis flex:1 it had before */
  .pg-select { flex: 1 1 200px; max-width: none; min-width: 0; }
  .pg-actions .pg-hint-btn { flex: 1 1 auto; white-space: nowrap; min-height: 40px; }
  .pg-run { flex: 1; padding: 11px 20px; }
  .pg-kbd { display: none; }              /* Ctrl+↵ means nothing on touch */
  .pg-code { min-height: 220px; }
  .pg-main .CodeMirror-scroll { min-height: 220px; max-height: 52vh; }
  .pg-challenge { padding-right: 14px; }        /* reset button flows below the text on phones */
  .pg-reset { position: static; align-self: flex-start; margin-top: 4px; }
  .pg-out { max-height: 240px; }
  .pg-hintbar { gap: 7px; }
  .pg-hintbar-label { width: 100%; }
  .pg-hint-btn { flex: 1; text-align: center; min-height: 40px; }
  .pg-zoom button { padding: 10px 13px; }   /* comfortable touch target */
  .pg-ask input { min-width: 0; width: 100%; flex-basis: 100%; }
  .pg-ask .pg-select, .pg-ask .btn { flex: 1; }

  /* ── daily loop bar: compact, stake pill drops inline ── */
  .day-objective-bar { padding: 10px 12px; gap: 8px; }
  .day-objective-bar .dob-xp { margin-left: 0; }
  .obj-chip { min-height: 34px; }

  /* ── three stat pills fit comfortably ── */
  .m-stat-pill { padding: 12px 10px; gap: 8px; }

  /* ── roadmap journey: label fits beside the bar on small screens ── */
  .journey-label { font-size: 9.5px; }
  .ms-head { min-height: 40px; align-content: center; }   /* comfortable tap target */
}

@media (max-width: 380px) {
  /* ultra-narrow: shrink the stat pills instead of wrapping */
  .m-stat-pill .icon { width: 30px; height: 30px; font-size: 15px; }
  .m-stat-pill .val { font-size: 18px; }
  .m-stat-pill .lbl { font-size: 8.5px; }
  /* 5 language tabs share one row on tiny phones — trim so no label clips */
  .pg-tab { font-size: 11px; padding: 9px 2px; letter-spacing: -.2px; }
}
