/* ============================================================================
   layers.css - the ONE stacking order for every CabDesign and StackDesign page
   ----------------------------------------------------------------------------
   PIECE W7-01 (card P2449, re-architecture programme, stage 7), rule R-29: one
   file declares the stack, and a stacking value written anywhere else is an
   error. tests/math-audit/one-stacking-order.audit.cjs is the lint that holds
   the repository to that.

   HOW TO USE IT
     A page, a shared stylesheet or a shared script never writes a number after
     z-index. It writes a layer:
         z-index: var(--layer-dialog);
     and in script:  el.style.zIndex = 'var(--layer-dialog)';  or, inside a
     cssText or injected stylesheet string:  "z-index:var(--layer-dialog);".
     The keywords auto, inherit, initial, unset and revert are not stacking
     values and stay allowed. To put a new surface on the page, pick the layer
     that says what the surface IS, never a number that happens to beat what is
     there today.

   HOW A PAGE GETS THIS FILE
     Every shared stylesheet that uses a layer imports it as its first rule
     (shared/site-header.css, shared/bws-panel.css, shared/material-picker.css,
     shared/slide-datums-view.css, guides/guide.css), so a page that already links
     any of them has the layers with no head edit. That is the choice over a
     <link> in every head: nearly every deployed page links site-header.css and this
     piece touches only some of them, so an import reaches all of them at once and a
     new page cannot forget it. The two shared scripts that also run on pages
     with none of those stylesheets (shared/analytics.js and shared/theme.js, both
     on signin.html) add one <link> themselves when the variable is not defined, and
     a page with no shared stylesheet at all links it directly. The lint proves
     every consumer is covered, because an unloaded variable makes z-index fall back
     to auto and buries a dialog under the page.

   THE ORDER, bottom to top: base, canvas, canvas overlay, docked, panel, menu,
   popover, dialog, gate, teaching, toast, dev. The register's list is base, canvas,
   canvas overlay, docked, panel, menu, popover, dialog, toast, teaching, dev. Two
   things differ from it, both on purpose and both written down here:
     - THE GATE IS ADDED, between dialog and teaching. The lane brief requires the
       sign-in and module gate to stay above every panel, menu, popover and dialog.
       The cookie consent card and its preferences panel live in the gate band, above
       the gate itself (P1634: the sign-in gate never hides the consent question).
     - TOAST IS ABOVE TEACHING, which swaps the register's two. The standing rule is
       that an error is never covered, and the code already says so in four places:
       the Designer's own tour is documented as sitting "below the max-int error
       toasts so a toast still shows above it", the tour and coach-mark journeys are
       written around an error toast landing on top of a tour card, the Designer pins
       that its confirm out-ranks every ordinary surface except the toasts
       (p457-step6 section 7j), and the consent card is documented as sitting below
       the first-run choice and the tour. Teaching therefore sits between the gate
       band and the toast band. If the register's order is wanted instead it is a
       swap of the numbers of these two bands and of BANDS in the lint.
   Each band has its own number range, so a band never reaches into the next, and the
   lint asserts it. Inside a band the members are listed bottom to top, and a member's
   name says what sits there.

   WHERE THE OLD CODE AND THE REGISTER'S BAND ORDER DISAGREED, and what this file does:
     - MENUS AND POPOVERS ARE BELOW DIALOGS. The account menu, the tools switcher and
       the theme popover used to sit above every dialog (3000 and up), and a dialog
       now covers them, which is what a modal does. A popover that opens FROM INSIDE
       a dialog (the material picker, the Cut List role note) has its own member,
       dialog-popover.
     - THE BUG-REPORT BUTTON AND THE SETUP-GUIDE CHIP ARE DOCKED, so they sit under
       the panels. The button used to sit above the Designer's panels (1100 against
       860 to 900); a panel now covers it. The button stays above the chip.
     - THE DESIGNER'S OWN COACH MARKS ARE A POPOVER and its own guided tour is
       dialog-tour, in the dialog band, because both used to sit below the confirm.
       The shared first-run choice, tour and tooltip are in the teaching band, above
       every dialog as they were.
   The numbers below are new on purpose: only the ORDER is the contract, and no
   page may rely on a value.

   RELATIONS THE CODE RELIES ON, each pinned by name in the lint:
     panel-flyout     above panel          (P1665: a rail flyout is not buried by the catalog panel)
     menu             above panel-assistant-open (P809: the account menu clears the Assistant dock)
     menu             above docked-yield (P4474: the consent card yields to an open menu)
     panel-assistant-open above panel-drawer (P3353, the live check of 11/10/2026: the Materials page's Edit material drawer
                      opened over the dock and hid its next confirm card, so nobody could answer the chat until the drawer was
                      closed. A page's detail drawer leaves the page usable, so it is a panel, under the open dock and its cards;
                      a page's modal dialog, which takes over until it is answered, stays in the dialog band, over the dock)
     panel-drawer     above panel-assistant (P3353: the dock's closed launch button sits in the corner where a drawer keeps its
                      Done button, so the open drawer covers the launcher, as it always did, and never the other way round)
     dialog-confirm   above dialog, dialog-drawer and dialog-tour (a confirm opened from a dialog sits over it)
     dialog-shell     above dialog, and dialog-shell-menu above dialog-shell, both below dialog-tour (P4227: the Cut List page's
                      bar, rail and menus stay over that page's own dialogs, as the old calc(--layer-dialog + 1 and + 2) kept them)
     dialog-yield     below dialog-drawer-scrim, so below every other modal member and its dim, and above popover-prompt, so above
                      every panel, menu and popover (P4473: the Designer's offline materials notice, a toast about the page's state
                      and raised by no dialog, stood on --layer-toast over the open Setup Studio's Continue and the method editor's
                      Undo at 1280 by 720, and nothing could press them. Where its column meets an open modal's box it waits here,
                      under the modal's dim, and is back on --layer-toast the moment the modal closes. An error a dialog's own
                      action raised keeps --layer-toast: nothing covers an error)
     gate             above every panel, menu, popover and dialog member
     gate-consent     above gate           (P1634: the sign-in gate never hides the consent question)
     teaching         above gate-consent   (the consent question is never the most urgent thing on a page)
     toast            above every dialog member, the gate, the consent card and every teaching member
     teaching-tip     above dialog-system  (a tooltip on a dialog button is readable)
     docked-sub-top   above docked-sub     (a bar's menus drop over the bar docked right beneath it: a tie hands
                      the later bar the top of the menu, because a sticky bar is a stacking context and its
                      menus rank at the bar's own level)
   ============================================================================ */

:root {

  /* ---- BASE: behind the page, and the page's own content --------------------
     step-N is a local lift: a sticky header over its table body, a child above
     its sibling scrim, a hovered tile above its neighbours. It only ever orders
     things inside ONE component, so it stays below every band that follows. */
  --layer-behind: -1;          /* a decorative layer painted behind the page's content */
  --layer-base: 0;             /* the page's own content; a scrim inside its own panel */
  --layer-step-1: 1;
  --layer-step-2: 2;
  --layer-step-3: 3;
  --layer-step-4: 4;
  --layer-step-5: 5;
  --layer-step-6: 6;

  /* ---- CANVAS: the drawing surface (the plan, the elevation, the 3D view) ----
     The canvas itself is declared for the fixed-viewport piece (W7-02) and has no
     user yet. canvas-overlay is a control floating over it. */
  --layer-canvas: 100;
  --layer-canvas-overlay: 110; /* the on-canvas Add cabinet button; the 3D view's own controls */

  /* ---- DOCKED: chrome that stays put while the page scrolls ------------------ */
  --layer-docked-sub: 200;     /* sticky bars under the main bar: the Designer's bands, tab strips, summary bars */
  --layer-docked-sub-top: 205; /* a docked bar whose menus drop over the bar beneath it: the Cut List toolbar over its tab strip */
  --layer-docked: 210;         /* the main bars: the app top bar, the marketing bar, a guide's nav, the rail */
  --layer-docked-yield: 215;   /* the consent card while a rail flyout or a menu is open: above the rail, under every panel and menu */
  --layer-docked-chip: 220;    /* the setup-guide chip */
  --layer-docked-fab: 225;     /* the floating bug-report button, above the chip that can share its corner */
  --layer-docked-skip: 230;    /* the skip link, which has to clear every bar when it is focused */

  /* ---- PANEL: surfaces beside or over the working area ----------------------- */
  --layer-panel-scrim: 300;        /* the dim behind a drawer that covers the page (the detail drawers) */
  --layer-panel-sheet: 310;        /* a panel docked to an edge in the narrow layout: the catalog sheet, the place list */
  --layer-panel-sheet-flyout: 320; /* a rail flyout in the narrow layout */
  --layer-panel-tab: 330;          /* the edge tab that brings a tucked panel back */
  --layer-panel: 340;              /* the working panel: the catalog, the parts panel, the shortcuts reference */
  --layer-panel-side: 350;         /* the inspector and the side panels that sit over it */
  --layer-panel-flyout: 360;       /* a rail flyout over the catalog (Problems, Menu, Build, Display, Libraries) */
  --layer-panel-handle: 370;       /* a handle that must be grabbable on top of its own panel's edge */
  --layer-panel-assistant: 380;    /* the AI assistant dock's launch button and its first-visit offer */
  --layer-panel-drawer: 382;       /* a page's detail drawer (the Materials and Hardware editors): over the page, its scrim and the dock's closed launch button, under the open dock (P3353) */
  --layer-panel-assistant-open: 385; /* the open assistant dock, over its own launch button */

  /* ---- MENU: a list that drops from a control -------------------------------- */
  --layer-menu: 400;           /* project and wall menus, the account menu, the tools switcher, context menus, listboxes */

  /* ---- POPOVER: a small surface anchored to a control or the pointer --------- */
  --layer-popover: 500;        /* help popovers, choosers, inline editors, the drag ghost, the theme popover */
  --layer-popover-prompt: 510; /* a one-line prompt over the canvas (the wall length ask) */

  /* ---- DIALOG: a surface that takes over until it is answered ---------------- */
  --layer-dialog-boot: 600;          /* the loading screen that covers the app until the workspace opens */
  --layer-dialog-yield: 602;         /* a page notice of the toast stack waiting under an open modal whose box meets its column (P4473) */
  --layer-dialog-drawer-scrim: 605;  /* the dim behind a setup drawer */
  --layer-dialog-drawer: 610;        /* the Project setup drawer, a detail drawer, the wizard shell default */
  --layer-dialog-wizard: 620;        /* the guided setup wizard, over the drawer that opened it */
  --layer-dialog-wizard-return: 625; /* the "back to the guide" pill, reachable above the wizard */
  --layer-dialog: 630;               /* a page's own modal: its catalog and library dialogs, a lightbox */
  --layer-dialog-shell: 631;         /* the Cut List page's shell (top bar, rail and its edge), kept over that page's own dialogs so the menu stays clickable (P4292, P4227) */
  --layer-dialog-shell-menu: 632;    /* the shell's menus and tips on the Cut List page, over its own top bar and rail (P4292, P4227) */
  --layer-dialog-tour: 635;          /* the Designer's own guided tour: over the page's dialogs, under the confirm */
  --layer-dialog-confirm: 640;       /* a confirm opened from a dialog, over it, and over the Designer's tour */
  --layer-dialog-feedback: 650;      /* the bug-report dialog, over a page's own dialogs */
  --layer-dialog-system: 660;        /* the shared dialog and the command palette */
  --layer-dialog-popover: 670;       /* a popover opened from inside a dialog */

  /* ---- GATE: what stands over the whole page at the door --------------------- */
  --layer-gate: 700;                 /* the sign-in and module-access overlay: above every panel, menu, popover and dialog */
  --layer-gate-consent: 710;         /* the cookie consent card, above the gate (P1634) so the question stays answerable */
  --layer-gate-consent-panel: 720;   /* its Manage preferences panel */

  /* ---- TEACHING: the surfaces that explain the page -------------------------- */
  --layer-teaching: 800;             /* the first-run choice and the tour offer */
  --layer-teaching-tour: 810;        /* a running page tour */
  --layer-teaching-offer: 820;       /* the card offer, a surface that asks for full attention */
  --layer-teaching-tip: 830;         /* a tooltip, which has to be readable over everything but a toast */

  /* ---- TOAST: a message that must be seen ------------------------------------ */
  --layer-toast-progress: 900;       /* a progress card that sits under the toast lane */
  --layer-toast-minor: 910;          /* the update notice and the bug-report thank-you */
  --layer-toast: 920;                /* the toast lane and the status bars: nothing covers an error */

  /* ---- DEV: tooling that is never part of a customer's page ------------------ */
  --layer-dev: 1000;                 /* reserved for the dev dashboard, which is on a named exemption until its follow-up */
}
