/* web/ui-contract/shell.css — RawProd Factory layer over the reference console design.
 *
 * Load order (web/index.html): fonts → rac-console.css (the reference Admin/Agent design layer,
 * vendored verbatim) → alembic-tokens.css (the ALEMBIC contract; wins on every shared custom
 * property) → this file. The shell itself — rail, top bar, glass cards, 12-column card grid,
 * floating dock, expanded-card sheet, page transition, toast — is the reference's, 1:1. This
 * file only carries:
 *   1. the legacy custom-property shim the pre-port render code still reads;
 *   2. RawProd-only components (workspace switcher, offline banner, inline row detail, row
 *      actions, in-card tabs, sign-in card, dashboard text roles);
 *   3. corrections where the reference falls short of a hard rule — WCAG AA contrast on the
 *      rail's small text, the 44px touch floor, prefers-reduced-motion, and a phone path to
 *      the full navigation (the reference hides the rail entirely below 1024px, which is fine
 *      for its 13 destinations but not for a factory role with 25).
 */

/* ---------------- legacy custom-property shim ----------------
 * Pre-port render code (shell.js + ws-*.js) still references the old design system's names;
 * each maps to its ALEMBIC token so those call sites render in the one palette. New markup uses
 * the real token names directly. */
:root{
  --surface: var(--panel);
  --well: var(--panel-2);
  --t1: var(--ink);
  --t2: var(--ink-2);
  --t3: var(--ink-3);
  --border: var(--line);
  --cbord: var(--line);
  --wbord: var(--line-2);
  --track: var(--line-2);
  --barmute: var(--line-2);
  --cblur: none;
  --rai: none;
  --rai-sm: none;
  --ins: none;
  --ins-sm: none;
  --page: var(--bg);
  --hov: var(--panel-2);
}

/* ---------------- reference corrections: contrast ----------------
 * The reference sets several rail labels at 2.9–4.4:1 on the #26262B rail; AA needs 4.5:1 for
 * text this small, so they take the rail's own secondary ink instead. */
.rs,.ri .ct,.rme .who small,.brandmark.on-ink .bt small{color:#BDBDB6}
.bar-brand i{color:var(--ink-3);opacity:1}

/* The reference positions .rail-min absolutely without a positioned rail, so on an open desktop
 * rail it lands at the top-right of the whole stage (under the top bar). Anchor it to the rail. */
.rail{position:relative}

/* ---------------- reference corrections: phone navigation ----------------
 * Below 1024px the reference turns the dock into a tab bar of EVERY destination and hides the
 * rail outright. With up to 25 destinations per role that is 15px per tab, so: the tab bar keeps
 * the role's first destinations (.hot) plus a "Sections" tab, and Sections opens the rail as a
 * drawer — the same arrangement ALEMBIC's own console.css settled on. */
@media (max-width:1023px){
  .qdock .qb:not(.hot){display:none !important}
  .qdock .dk-navtoggle{display:flex !important}
  body.rail-open .rail{display:flex !important;position:fixed;z-index:560;top:0;bottom:0;left:0;
    width:min(86vw,var(--ch-rail-width));margin:0;border-radius:0 26px 26px 0;visibility:visible;pointer-events:auto;
    box-shadow:26px 0 64px -16px rgba(10,10,10,.36)}
  body.rail-open .rail-scrim{display:block}
}
.rail-scrim{display:none;position:fixed;inset:0;z-index:555;background:rgba(20,20,19,.34)}

/* ---------------- reference corrections: touch floor + motion ----------------
 * `.btn.p` 44px floor from VIEWPORT WIDTH as well as pointer type (ops/ui-parity/console-
 * acceptance.spec.ts measures under a fine pointer at 768/375). */
@media (pointer:coarse){ .btn,.ri,.pg button,.tab,.xp,.gbtn,.qdock .qb{min-height:var(--ch-touch-floor-coarse-pointer)} .xp{min-width:var(--ch-touch-floor-coarse-pointer)} }
@media (max-width:900px){ .btn.p{min-height:var(--ch-touch-floor-coarse-pointer)} }
/* One blanket motion collapse — ALEMBIC apps/web/app/reduced-motion.css, verbatim in effect:
 * animations land on their end frame, transitions are removed (not shortened — Gecko keeps
 * sub-µs transitions "running" and pins the refresh driver). */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{animation-duration:.01ms !important;animation-iteration-count:1 !important;animation-delay:0s !important;transition:none !important;scroll-behavior:auto !important}
}
/* iOS zooms any input under 16px on focus (APPLE_PASS_SYSTEM.md §5, coarse pointer). */
@media (pointer:coarse){ input,select,textarea{font-size:16px !important} }

/* dock: the brand tile is a real button (home); shortcut hints hide where the dock is a tab bar */
.qdock .qd-brand{background:none;border:0;padding:0 10px 0 4px;cursor:pointer}
@media (max-width:1023px){ body.rail-off .qdock .qb .kb .kc,body .qdock .qb .kb .kc{display:none !important} }
/* top-bar alert count on the reference .gbtn */
#ra-bell-badge{font:var(--w-med) var(--t-micro)/1 var(--ui);color:#F4F4F1;background:var(--red);border-radius:var(--r-pill);padding:3px 6px;margin-left:2px}

/* ---------------- RawProd-only components ---------------- */
/* workspace switcher (permission-driven, one PWA, no second login) — a .gbtn-shaped select */
.wsw{display:inline-flex;align-items:center;height:32px;padding:0 4px;border-radius:var(--r-pill);background:rgba(255,255,255,.72);box-shadow:0 0 0 .5px var(--gl-hair)}
.wsw select{border:none;background:transparent;font:var(--w-med) var(--t-cap)/1 var(--ui);color:var(--ink);padding:0 8px;height:30px;outline:none;cursor:pointer}
.wsw select:focus-visible{outline:2px solid var(--blue);outline-offset:1px}

/* offline / degraded banner — truthful, never implies queued writes */
.net-banner{display:none;align-items:center;gap:var(--s-tight);padding:8px var(--s-base);font:var(--w-med) var(--t-cap)/1.3 var(--ui);background:rgba(138,90,76,.12);color:var(--red);border-bottom:1px solid rgba(138,90,76,.28)}
.net-banner.show{display:flex}
.net-banner .dot{width:7px;height:7px;border-radius:50%;background:var(--red);flex:0 0 auto}

/* list-card body + bits the reference leaves to each page */
.card-bd{padding:0 var(--pad-card) var(--pad-card-btm)}
.card > .card-bd > table,.card-bd > div > table{min-width:0}
.sect{text-transform:uppercase}
.pageview > .stats{margin-bottom:var(--gr-gap)}
/* Phone: the reference stacks KPI tiles one per 150px row, which puts four tiles (600px) ahead of
 * every list's table. Two per row at a shorter height keeps the figures and the data on screen. */
@media (max-width:767px){
  .pageview > .stats{grid-template-columns:repeat(2,minmax(0,1fr)) !important;grid-auto-rows:108px;gap:12px}
  .pageview > .stats > .stat{padding:18px 18px 16px}
}
.stat .l .ic,.stat .l svg{width:12px;height:12px}
thead th[data-sort]{cursor:pointer;user-select:none}
#ra-results tbody td{white-space:nowrap}
thead th.on{color:var(--ink)}
.fld::placeholder{color:var(--ink-3)}
.chip .dot{width:6px;height:6px;border-radius:50%;background:currentColor;flex:0 0 auto}
.per{display:flex;align-items:center;gap:6px;font:var(--w-med) var(--t-cap)/1 var(--ui);color:var(--ink-2)}
.sw.on{background:var(--green)}
.cb.on svg{width:10px;height:10px}

/* in-card subnav tabs (flat) */
.tabs{display:flex;gap:2px;padding:6px var(--s-tight);border-bottom:1px solid var(--line);flex:0 0 auto;background:var(--panel-2);flex-wrap:wrap}
.tab{padding:5px 9px;border-radius:var(--r-sm);font:var(--w-med) var(--t-cap)/1 var(--ui);color:var(--ink-2);white-space:nowrap;display:inline-flex;align-items:center;cursor:pointer}
.tab:hover{background:var(--panel)}
.tab.on{background:var(--ink);color:#fff}
.tab .n{font-family:var(--mono);font-size:var(--t-micro);margin-left:5px;opacity:.7}

/* dialogs built on the reference .xp-scrim/.xp-sheet: form bodies stack with one gap, and the
 * header's close control carries the reference's own × glyph. Phone = full-height sheet. */
.xp-sheet .xp-sheet-hd h2{flex:1;min-width:0}
.xp-sheet-bd.form{display:flex;flex-direction:column;gap:var(--s-snug)}
@media (max-width:767px){
  .xp-sheet{width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;border-radius:0;padding:var(--s-base)}
}

/* inline row-detail panel (ALEMBIC's live edit/detail pattern) */
.row-detail{background:rgba(20,20,19,.035);padding:var(--s-base) var(--pad-card)}
.row-detail .fgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:var(--s-snug)}
tr.ra-drow[aria-expanded="true"]{background:rgba(90,90,102,.08)}
tr.row-detail-row:hover{background:transparent}

/* disabled row action + its plain-language reason (tooltip on hover, inline on touch) */
.ra-act[disabled]{cursor:not-allowed}
.ra-act .act-hint{display:none}
@media (pointer:coarse){
  .ra-act[disabled] .act-hint{display:block;font:var(--w-reg) var(--t-micro)/var(--lh-cap) var(--ui);color:var(--ink-3);white-space:normal;margin-top:2px;max-width:140px}
}

/* toast tones on the reference's dark pill */
.toast.bad .d{background:#9A6A5C}
.toast.good .d{background:var(--accent)}

/* empty / not-built states */
.notbuilt{padding:var(--pad-card-top) var(--pad-card) var(--pad-card-btm);max-width:640px}
.notbuilt h2{font:var(--w-med) var(--t-h2)/var(--lh-h2) var(--ui);margin:0 0 var(--s-tight)}
.notbuilt p{font:var(--w-reg) var(--t-body)/var(--lh-body) var(--ui);color:var(--ink-2);margin:0}

/* zone tiles are a dynamic-length collection — an auto-fit track on the .gwrap gap language */
.gwrap-auto{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:var(--gr-gap)}
@media (max-width:767px){ .gwrap-auto{grid-template-columns:1fr} }
.tscroll > table{min-width:620px}

/* "My work" tiles and alert rows */
[data-alert-nav]:hover{background:var(--panel-2)}
.work-tile{background:rgba(255,255,255,.66);box-shadow:0 0 0 .5px var(--gl-hair);border:0;font-family:inherit;color:inherit;transition:box-shadow .22s,transform .22s}
.work-tile[data-work-nav]{cursor:pointer}
.work-tile[data-work-nav]:hover{box-shadow:0 0 0 1px var(--accent-line),0 6px 16px -8px rgba(20,20,19,.2);transform:translateY(-1px)}

/* command palette (dock ⌘K) — reference glass, RawProd destinations */
.cmdk{position:fixed;z-index:620;left:50%;top:14vh;transform:translateX(-50%);width:min(560px,calc(100vw - 32px));display:flex;flex-direction:column;padding:var(--s-snug)}
.cmdk input{height:44px;border:0;outline:none;border-radius:var(--r-md);padding:0 var(--s-snug);background:rgba(255,255,255,.8);box-shadow:0 0 0 .5px var(--gl-hair);font:var(--w-reg) var(--t-h3)/1 var(--ui);color:var(--ink)}
.cmdk ul{list-style:none;margin:var(--s-tight) 0 0;padding:0;max-height:50vh;overflow-y:auto}
.cmdk li button{width:100%;display:flex;align-items:center;gap:var(--s-snug);padding:10px 12px;border-radius:10px;font:var(--w-reg) var(--t-body)/1.2 var(--ui);color:var(--ink);text-align:left}
.cmdk li button svg{width:15px;height:15px;color:var(--ink-3)}
.cmdk li button.on,.cmdk li button:hover{background:var(--accent-soft)}
.cmdk li button .sc{margin-left:auto;font:var(--w-reg) var(--t-micro)/1 var(--mono);color:var(--ink-3)}

/* ---------------- sign-in (UX-C) ----------------
 * One sign-in look for all three RawProd consoles — the Platform Operations pattern: one card on
 * the rail colour, the console name, one short line, "Sign in via ALEMBIC →". The same rules are
 * repeated verbatim in web-platform/platform.css and web-vault/vault.css. */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;background:var(--rail);padding:var(--s-base)}
.login-card{width:min(380px,100%);background:var(--panel);border-radius:var(--r-xl);padding:var(--pad-region) var(--pad-card)}
.login-card .mark{font:var(--w-med) var(--t-fig-sm)/var(--lh-fig-sm) var(--font-ui);letter-spacing:var(--ls-tight);color:var(--ink);margin:0 0 var(--s-tight)}
.login-card .sub{font:var(--w-reg) var(--t-body)/var(--lh-body) var(--font-ui);color:var(--ink-3);margin:0 0 var(--s-base)}
.login-card .btn{width:100%;justify-content:center;min-height:var(--ch-touch-floor-coarse-pointer);font-size:var(--t-body);text-decoration:none}
.login-card .btn[aria-disabled="true"]{opacity:.5;pointer-events:none}
.login-card .err{margin-top:var(--s-snug);font:var(--w-reg) var(--t-cap)/var(--lh-cap) var(--font-ui);color:var(--red)}
.login-card .err:empty{display:none}

/* ---------------- dashboard text roles (UX-C) ----------------
 * Replaces the per-call inline font sizes/weights the dashboard renderers carried (40px/800,
 * 13px/700, 9.5px mono/700 …) — Outfit ships 300/400/500 only, so 600–800 were synthesised bold. */
.kv{display:flex;align-items:center;gap:var(--s-snug);padding:var(--s-tight) 0;border-bottom:1px solid var(--line)}
.kv:last-child{border-bottom:0}
.kv .k{flex:1;min-width:0;font:var(--w-reg) var(--t-body)/1.3 var(--font-ui);color:var(--ink-2)}
.kv .v{font:var(--w-med) var(--t-h3)/1 var(--font-ui);font-variant-numeric:tabular-nums}
.kv .sw-dot{width:8px;height:8px;border-radius:var(--r-pill);flex:0 0 auto}
.meter{height:8px;border-radius:var(--r-pill);background:var(--panel-3);overflow:hidden}
.meter > i{display:block;height:100%;border-radius:inherit}
.ring-c{font:var(--w-light) var(--t-fig)/1 var(--font-ui);letter-spacing:var(--ls-tight);font-variant-numeric:tabular-nums}
.ring-s{margin-top:var(--s-hair);font:var(--w-med) var(--t-micro)/1 var(--font-ui);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-3)}
.loading{padding:var(--s-open);text-align:center;font:var(--w-reg) var(--t-cap)/1 var(--font-ui);color:var(--ink-3)}

/* ---------------- quick-access dock (web/dock.js) ----------------
 * Owner 2026-09-29: "dock is abnormally huge, it won't be responsive". The dock now carries at most
 * eight primary destinations + "All sections" + Ask Aria. Same block, verbatim, in
 * web/ui-contract/shell.css, web-platform/platform.css and web-vault/vault.css.
 * - Labels: the reference shows a destination's label on hover only; keyboard focus shows it too.
 * - Desktop: the pill can never be wider than the window.
 * - Below 1024px: the tab bar (first four destinations, Ask Aria, More). "More" replaces the
 *   desktop "All sections" label and sits last, as a tab bar's overflow tab does.
 * - --dock-runway: the region's bottom padding, so the last row never sits under the dock (the
 *   same token ALEMBIC's console.css defines, safe-area aware on phones). */
:root{--dock-runway:108px}
body .content,body .main > .content{padding-bottom:var(--dock-runway) !important;scroll-padding-bottom:var(--dock-runway)}
.qdock{max-width:calc(100vw - 32px)}
.qdock .qb:focus-visible .kb{opacity:1;transform:translateX(-50%) translateY(0)}
.qdock .qb .kb-m{display:none}
@media (max-width:1023px){
  :root{--dock-runway:calc(92px + env(safe-area-inset-bottom,0px))}
  .qdock{max-width:100%;overflow:hidden}
  .qdock .qb .kb-d{display:none}
  .qdock .qb .kb-m{display:inline}
  .qdock .dk-navtoggle{order:10}
  .qdock .qb .kb .kb-d,.qdock .qb .kb .kb-m{position:static}
}
/* sections sheet: the pin beside each section (Factory) */
.ri-row{position:relative}
.ri-row > .ri{padding-right:38px}
.ri-pin{position:absolute;right:4px;top:50%;transform:translateY(-50%);width:30px;height:30px;border:0;border-radius:8px;background:transparent;color:#9D9D95;display:grid;place-items:center;cursor:pointer;opacity:0;transition:opacity .15s,background .15s,color .15s}
.ri-pin svg{width:14px;height:14px;display:block}
.ri-row:hover .ri-pin,.ri-row:focus-within .ri-pin,.ri-pin.on{opacity:1}
.ri-pin:hover{background:var(--rail-2);color:#fff}
.ri-pin.on{color:var(--accent)}
.ri-row > .ri.on + .ri-pin{color:#26262B}
.ri-row > .ri.on + .ri-pin:hover{background:rgba(38,38,43,.12)}
.ri-pin:focus-visible{outline:2px solid var(--accent-line);outline-offset:1px;opacity:1}
.ri-reset{margin-top:8px}
@media (pointer:coarse){ .ri-pin{opacity:1;width:40px;height:40px} .ri-row > .ri{padding-right:48px} }
