/* ============================================================================
   mobile-boot.css — the drawer's FIRST PAINT, before any deferred script runs.
                                                                   v9.266 (2026-10-26)

   ADEEL: "when we open this CRM there is a cached/preloaded page that has the
   side-navigation opened and when page fully loads it closes in mobile view".

   MEASURED on a cold 390px load, before this file existed:
     150ms .. 1000ms   .sidebar  x=0    w=220   <- WIDE OPEN, over the content
     1600ms            .sidebar  x=-242 w=242   <- then it slides shut
   Same on a plain reload, so nothing to do with caching.

   THE CAUSE was load order, not caching:
     - mobile.css is APPENDED on window.load (deliberately: it used to carry top-level
       rules that would break desktop if parsed early). Measured: load at ~1.1s, after
       ~95 deferred modules. So for the whole boot there was NO mobile CSS at all.
     - Without it, the rail keeps its DESKTOP state: in the grid flow, open, width
       driven by --nv-w. The drawer rules only arrived with the sheet, which is why
       the rail "closes itself" once the page finishes loading.

   WHY THIS FILE CAN BE PARSED EARLY: every rule below is (a) inside @media
   (max-width:820px) and (b) limited to `html.m-boot-phone` — a class the tiny
   parse-time script in index.html puts on <html> only when the initial viewport is a
   phone. So on desktop (and on tablets above 820px) this file matches nothing at all
   and cannot affect the layout. mobile.css remains the single owner of the mobile
   styles; this file only holds the drawer SHUT until it arrives.

   `transition: none` matters: without it the drawer would visibly animate across the
   screen at load instead of simply being closed. mobile-nav.js removes the
   m-boot-phone class once it owns the drawer, so the normal slide animation resumes.
   ============================================================================ */
@media (max-width: 820px) {
  html.m-boot-phone .app .sidebar,
  html.m-boot-phone .sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: auto;
    height: 100dvh;
    max-height: 100dvh;
    width: 264px;              /* --m-drawer-w; the token file has not loaded yet */
    max-width: 86vw;
    transform: translateX(-100%) !important;
    transition: none !important;
    box-shadow: none !important;
    z-index: 1000;
  }
  /* a closed drawer must never paint a scrim, and the page must not be scroll-locked */
  html.m-boot-phone #m-scrim { display: none !important; opacity: 0 !important; }
  html.m-boot-phone body { overflow: auto !important; }
}
