/* ============================================================
   PASSAGE by Khoshà — mobile SHELL compaction layer (ms- prefix)
   Loads LAST (after mobile.css / mobile.js output), so equal-
   specificity rules here win without needing !important.

   Scope: app chrome (topbar, gov-links strip, full-screen menu,
   page gutters) + Dashboard + Intake. Everything that changes
   layout is inside @media (max-width:760px) — desktop is
   untouched. The one exception is the ".ms-menu-*" block right
   below, which styles content that only ever exists inside the
   full-screen menu overlay (built by mobile.js) — that overlay
   is itself inert above 760px (its trigger is display:none), so
   leaving these rules unscoped is consistent with how mobile.css
   treats .mb-menu-tile etc.
   ============================================================ */

/* ---------- full-screen menu: compact actions row (footer) ----------
   Appended by mobile-shell.js as the last child of #mbMenuOverlay,
   a sibling of .mb-menu-head / .mb-menu-scroll — NOT inside
   .mb-menu-scroll, so mobile.js's own buildMenu() (which clears
   and rebuilds only #mbMenuScroll on every open) never wipes it. */
.ms-menu-actions{
  position:relative; z-index:2; flex:0 0 auto;
  display:flex; align-items:center; gap:10px;
  padding:12px 18px calc(14px + env(safe-area-inset-bottom,0px));
  border-top:1px solid var(--stroke-soft);
  background:rgba(255,255,255,.5);
}
.ms-menu-new{
  flex:1 1 auto; min-height:44px;
  display:flex; align-items:center; justify-content:center;
}
.ms-menu-lang{ flex:0 0 auto; min-height:44px; }
.ms-menu-lang span{ padding:8px 13px; }

/* ---------- full-screen menu: 3-up tile grid (client ask — was 2-up
   in mobile.css). Grid auto-placement already leaves a short section's
   trailing column(s) empty instead of stretching the tiles present,
   so a 1- or 2-item section reads left-aligned with no extra rules. ---------- */
.mb-menu-grid{
  grid-template-columns:repeat(3,1fr);
  gap:8px;
}
.mb-menu-tile{
  min-height:40px;
  padding:8px 6px;
  gap:5px;
  border-radius:14px;
  align-items:center;
  text-align:center;
}
.mb-menu-tile .orb{ width:26px; height:26px; flex:0 0 26px; }
.mb-menu-tile .orb svg{ width:12px; height:12px; }
.mb-menu-lbl{
  font-size:10.5px;
  line-height:1.18;
  text-align:center;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  word-break:break-word;
}

/* ---------- search sheet close button ----------
   mobile-shell.js appends this into .searchbox on every viewport
   (guarded lookups don't re-run per width), so its base "hidden"
   state must not be scoped to the mobile media query — otherwise
   it renders as a stray ✕ inside the desktop search field. The
   mobile open-state rule below (.searchbox.ms-open .ms-search-close)
   is more specific and still wins there. */
.ms-search-close{ display:none; }

/* ============================================================
   MOBILE — everything below is scoped to <=760px so desktop
   layout/behaviour is completely untouched.
   ============================================================ */
@media (max-width:760px){

  /* ---------- agreed compact scale (shared with the dossier and
     list/table compaction passes — values must match exactly) ---------- */
  body{ font-size:13.5px; }
  .view{ padding-left:12px; padding-right:12px; padding-top:6px; }
  .panel{ padding:13px 14px; border-radius:16px; }
  .panel-title{ font-size:13px; margin-bottom:8px; }
  .panel-title .hint{ font-size:10.5px; }
  .dash-grid{ gap:10px; }
  .dash-col{ gap:10px; }
  .btn{ min-height:40px; padding:9px 16px; box-sizing:border-box; }

  /* ============================================================
     1. topbar → one row, ~52px tall
     [menu] [crumb .....flex.....] [search icon] [alert bell] [avatar]
     ============================================================ */
  .topbar{
    flex-wrap:nowrap;
    align-items:center;
    gap:8px;
    padding:calc(6px + env(safe-area-inset-top,0px)) 12px 6px;
    min-height:40px;
  }
  .mb-menu-btn{ width:40px; height:40px; flex:0 0 40px; order:-2; }
  .crumb{
    font-size:15.5px;
    line-height:1.15;
    order:-1;
  }
  .top-tools{
    flex-wrap:nowrap;
    gap:8px;
    flex:0 0 auto;
  }

  /* quick-add + language switch move into the full-screen menu
     (mobile-shell.js appends proxies there); the originals stay
     in the topbar DOM — just hidden — so their listeners survive */
  /* target by id, not .lang-sw — the menu's EN/FR proxy button below
     reuses the .lang-sw class for its styling and must stay visible */
  #quickAdd,#langSw{ display:none; }

  .avatar{
    display:grid;
    width:30px; height:30px; flex:0 0 30px;
    font-size:10.5px;
  }

  /* ---------- search: icon-only button that opens a full-width
     sheet under the bar. #globalSearch / #searchPop are moved
     nowhere — only revealed — so app.js's bindings stay valid ---------- */
  .searchbox{
    width:40px; height:40px; flex:0 0 40px;
    padding:0; gap:0; margin-top:0; order:0;
    border-radius:50%;
    justify-content:center;
    transition:background .2s,border-color .2s;
  }
  .searchbox svg{ width:16px; height:16px; }
  .searchbox input{
    position:absolute;
    width:0; height:0; padding:0; border:0; opacity:0;
    pointer-events:none;
  }
  .searchbox.ms-open{
    position:fixed;
    top:var(--ms-topbar-h,52px);
    left:0; right:0;
    width:auto; height:auto; max-height:min(420px,70dvh);
    z-index:65;
    border-radius:0 0 18px 18px;
    padding:10px 14px;
    gap:8px;
    background:var(--paper);
    box-shadow:var(--shadow);
    border:0; border-bottom:1px solid var(--stroke-soft);
    justify-content:flex-start;
  }
  .searchbox.ms-open svg{ width:15px; height:15px; flex:0 0 15px; }
  .searchbox.ms-open input{
    position:static;
    width:auto; height:auto; padding:0; opacity:1; flex:1 1 auto; min-width:0;
    pointer-events:auto;
  }
  .searchbox.ms-open .ms-search-close{
    display:grid; place-items:center;
    width:32px; height:32px; flex:0 0 32px;
    border-radius:50%;
    border:1px solid var(--stroke-soft);
    background:var(--bone);
    color:var(--ink-soft);
  }
  .searchbox.ms-open .ms-search-close svg{ width:14px; height:14px; flex:0 0 14px; }

  /* alert bell: ~28px visual dot, 40px hit box via padding (content-box) */
  .gv-bell{
    box-sizing:content-box;
    width:28px; height:28px;
    padding:6px;
    border:0;
    background-clip:content-box;
  }
  .gv-bell svg{ width:14px; height:14px; }
  .gv-badge{ top:2px; right:2px; }

  /* ============================================================
     2. gov-links strip → thin utility rail
     ============================================================ */
  .gv-bar{ padding:0 12px 6px; margin-top:-2px; }
  .gv-track{ gap:6px; }
  .gv-link{ padding:4px 10px; font-size:10.5px; gap:4px; }
  .gv-link svg{ width:9px; height:9px; }

  /* ============================================================
     3. Dashboard
     ============================================================ */
  .hero{ padding:4px 2px 8px; gap:2px; }
  .hero h1{ line-height:1.08; }
  .hero .sub{
    display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical;
    overflow:hidden;
    font-size:11.5px;
    margin-top:3px;
    max-width:100%;
  }

  .kpis{ gap:8px; margin-bottom:10px; }
  .kpi{
    display:grid;
    grid-template-columns:26px 1fr;
    grid-template-rows:auto auto auto;
    align-items:center;
    column-gap:8px; row-gap:0;
    padding:10px 12px;
    min-height:64px;
    border-radius:14px;
  }
  .kpi .k-orb{
    grid-row:1 / 4; grid-column:1;
    width:26px; height:26px;
    margin-bottom:0;
  }
  .kpi .k-orb svg{ width:12px; height:12px; }
  .kpi .k-num{ grid-row:1; grid-column:2; font-size:16.5px; line-height:1.15; }
  .kpi .k-lbl{ grid-row:2; grid-column:2; font-size:9.5px; margin-top:0; line-height:1.2; }
  /* This used to end in `white-space:nowrap; text-overflow:ellipsis`, which
     truncated the sub-line of EVERY tile on EVERY screen on a phone —
     "1 bill is past the due date" arrived as "1 bill is past the due d…".
     That is the firm's own complaint, twice: "the information is getting cut
     off, especially on the cards… please be smart about how you display the
     information." A tile is a few pixels taller when the sentence wraps; a
     consultant reading a truncated number on a client call is the actual
     cost. Wrap, and cap at two lines so a long one cannot run away. */
  .kpi .k-sub{
    grid-row:3; grid-column:2;
    font-size:8.5px; margin-top:1px; line-height:1.25;
    white-space:normal; overflow-wrap:anywhere;
    display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden;
  }

  .funnel{ gap:5px; }
  .fun-row{ grid-template-columns:70px 1fr 22px; gap:6px; }
  .fun-lbl{ font-size:9.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .fun-track{ height:14px; }
  .fun-n{ font-size:11px; }

  .rev-wrap{ height:80px; gap:6px; padding-top:4px; }
  .rev-stack{ max-width:26px; }
  .rev-mo{ font-size:8.5px; }
  .legend{ font-size:10.5px; gap:12px; margin-top:6px; }

  .dl-it,.act-it{ padding:6px 2px; gap:8px; }
  .dl-date{ flex:0 0 38px; padding:3px 0; border-radius:9px; }
  .dl-date .d{ font-size:13px; }
  .dl-date .m{ font-size:8px; }
  .dl-txt .t{ font-size:12.5px; }
  .dl-txt .s{ font-size:10.5px; }
  .act-txt{ font-size:11.5px; }
  .act-when{ font-size:10px; }

  /* ============================================================
     4. Intake
     ============================================================ */
  .intake-wrap{ padding:4px 0 10px; }
  .intake-head{ padding:4px 4px 12px; }
  .intake-head h1{ font-size:19px; line-height:1.15; }
  .intake-head .sub{
    font-size:11.5px; margin-top:5px;
    display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
    overflow:hidden;
  }

  .intake-cards{ gap:8px; margin-bottom:14px; }
  .intake-card{ padding:13px 14px; border-radius:16px; }
  .intake-card-orb{ width:36px; height:36px; margin-bottom:8px; }
  .intake-card-orb svg{ width:17px; height:17px; }
  .intake-card-label{ font-size:15px; }
  .intake-card-sub{ font-size:11.5px; margin-top:3px; }
  .intake-card-list{ margin:10px 0 4px; gap:5px; }
  .intake-card-list li{ font-size:11px; padding-left:16px; }
  /* trim the feature list to its top two lines on phones */
  .intake-card-list li:nth-child(n+3){ display:none; }
  .intake-card-cta{ margin-top:10px; padding-top:8px; font-size:12px; }

  .intake-recent{ gap:8px; }
  .intake-recent-col{ padding:12px 14px; border-radius:16px; }
  .intake-recent-title{ font-size:12.5px; margin-bottom:6px; }
  .intake-recent-row{ padding:6px 2px; }
  .intake-recent-name{ font-size:12px; }
}
