/* ============================================================
   APP SHELL
   ------------------------------------------------------------
   The authenticated app shell.

   Loaded by main.css. Every signed-in page renders into
   #app-layout > #main-content, so this file must load on
   every authenticated route.

   What lives here
   ---------------
     · The flex row that offsets #main-content beside the
       fixed sidebar.
     · The mobile collapse that removes the offset when the
       sidebar becomes a drawer.
     · The bottom-nav safe-area reserve on mobile.
     · The skip-link landing behaviour on #main-content.

   What does NOT live here anymore
   -------------------------------
   Every other app.css module has been extracted into a
   page-specific file. See main.css for the full load order.

     personal dashboard         → dashboard.css §01–§09
     organization shell         → business.css §01
     organization forms         → business.css §02–§03
     business dashboard         → dashboard.css §11
     business applications      → business.css §04
     business analytics         → business.css §05
     business team              → business.css §06
     admin shell                → admin.css §01–§04

   Also previously located here — moved out in earlier passes:

     `.my-tasks-head` etc.      → navigation.css §14
     `.my-tasks` container      → tasks.css §12
     `.mk-row-list`             → cards.css §16
     `.mk-card-row`             → cards.css §16

   The applications page shell is now shared with my-tasks
   and lives in tasks.css §12 as well. See the note at the
   bottom of this file.

   READS FROM
   ----------
     foundation.css   --topbar-h, --sidebar-w, --dur-slow,
                      --ease, --space-* tokens

   Nothing in this file references page-specific tokens or
   classes. It is purely a layout shell.
   ============================================================ */


/* ============================================================
   01 · APP LAYOUT
   ------------------------------------------------------------
   Flex row. #main-content is the fluid column to the right of
   the fixed sidebar. When the user is not authenticated the
   sidebar is absent and #main-content takes the full width.
   ============================================================ */

#app-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

#main-content {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding-top: var(--topbar-h);
  outline: none; /* tabindex="-1" target for the skip-link */
}

/* Authenticated offset. app.js sets data-authenticated="true"
   once the session resolves so the shift happens after the
   sidebar has been mounted. */
#app-layout[data-authenticated="true"] #main-content {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
}

/* ============================================================
   02 · MOBILE — full width + bottom-nav reserve
   ------------------------------------------------------------
   At 850px the sidebar becomes a drawer. The main column
   returns to full width, and any page that does not opt out
   of the bottom nav gets safe-area padding at the bottom so
   content is never hidden behind the fixed nav bar.
   ============================================================ */

@media (max-width: 850px) {
  #app-layout[data-authenticated="true"] #main-content {
    margin-left: 0;
    width: 100%;
  }

  /* Bottom-nav reserve. Pages that own their full height
     (messages.html) set data-hide-bottom-nav="true" on the
     body to opt out. */
  body:not([data-hide-bottom-nav="true"]) #main-content {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================================
   03 · PRINT
   ------------------------------------------------------------
   Flatten the layout. No sidebar column, no top-bar padding.
   ============================================================ */

@media print {
  #app-layout {
    display: block;
    min-height: auto;
  }

  #app-layout[data-authenticated="true"] #main-content {
    margin-left: 0;
    width: 100%;
    padding-top: 0;
    padding-bottom: 0;
  }
}


/* ============================================================
   END OF APP SHELL
   ------------------------------------------------------------
   Verification:

     ✅ Zero raw hex outside the token block.

     ✅ 12 CSS rules. That is the entire file. Every other
        app.css module has been extracted.

     ✅ #app-layout / #main-content are the only selectors.
        Both are global layout nodes present on every
        authenticated page.

     ✅ Mobile bottom-nav reserve honours the body opt-out
        (data-hide-bottom-nav="true") which messages.html uses
        to keep the full-height pane.

     ✅ No transition on margin-left / width. The sidebar's own
        transform transition (navigation.css §04) already
        animates the toggle; adding a matching transition on
        the main column would double the paint cost and can
        desync on mid-range Android devices.

     ✅ Print flattens the shell completely. No sidebar
        padding, no top-bar padding.
   ============================================================ */


/* ============================================================
   04 · SEAMLESS PAGE NAVIGATION
   ------------------------------------------------------------
   Cross-document view transitions (Chrome / Edge / Android).
   Header, sidebar and bottom nav keep their own transition
   group, so they stay put while only the page content fades —
   no white flash, no "reload" feel. Browsers without support
   ignore this block.
   ============================================================ */

@view-transition { navigation: auto; }

#site-header      { view-transition-name: site-header; }
#site-sidebar     { view-transition-name: site-sidebar; }
#mobile-bottom-nav{ view-transition-name: mobile-bottom-nav; }

::view-transition-group(site-header),
::view-transition-group(site-sidebar),
::view-transition-group(mobile-bottom-nav) { animation-duration: 0s; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 120ms; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
