/* P31 Design Portal — cascade-layer order declaration.
   The sheets themselves are imported from src/main.tsx (JS-side, in this exact
   order: design-core → tokens → workspace → globals → content), so Vite's
   module graph resolves every package subpath reliably. index.css only
   declares the layer order + the base layer. */

@layer base, legacy, vendors, suite, content;

/* Base resets (lowest layer). */
@layer base {
  html {
    background: var(--p31-bg, oklch(10% 0.01 240));
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
    /* The topbar must be full-width. A vendor rule sets display:flex on body,
       which shrink-wraps the topbar to its content (~960px) and breaks the
       shell. This base-layer override guarantees block layout. */
    display: block;
    width: 100%;
  }

  #root {
    min-height: 100vh;
  }

  a {
    color: var(--p31-accent);
    text-decoration: none;
  }
  a:hover {
    text-decoration: underline;
  }

  :focus-visible {
    outline: 2px solid var(--p31-accent);
    outline-offset: 2px;
  }
}

@layer base {
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  /* Portal shell geometry guarantees (Track D quarantine counter, 2026-10-14).
     The legacy design-core recipes.css carries
     `@media (min-width: 768px) { .sidebar { display: block !important } }`.
     Quarantined in @layer legacy, that important declaration now outranks the
     portal's unlayered !important breakpoint rules in workspace.css
     (cascade-5: an important declaration in a layer beats an unlayered
     important declaration). base is declared BEFORE legacy, and for important
     declarations the EARLIER layer wins — so the portal's one-nav breakpoint
     states live here and hold at every width. */
  @media (width > 768px) {
    .sidebar { display: flex !important; }
    .sidebar-drawer { display: flex !important; }
    .mobile-bottom-nav { display: none !important; }
  }
  @media (max-width: 768px) {
    /* Sidebar v2 drawer: the FIXED drawer is the visibility gate. Closed
       (not rendered) → display:none so the check-shell `oneNav` probe sees
       `.sidebar` hidden at ≤768px; the mobile overlay opens with the canon
       presence attr data-mobile-open (P3 migration Step 3.1). */
    .sidebar-drawer:not([data-mobile-open]) { display: none !important; }
    .sidebar-spacer { display: none !important; }
    .mobile-bottom-nav { display: flex !important; }
  }

  /* Mobile topbar triage: badges hide, brand never wraps */
  @media (max-width: 767px) {
    .topbar-center {
      display: none;
    }
  }
}