/* ============================================================
carino-ui.js — the behaviour half of carino-ui.css.
Canonical copy: Branding/carino-ui.js; Carino-Systems/propagate.sh
copies it into each site. Load it deferred, after carino-navbar.js:
Four pieces, all opt-in by markup or call, so loading the file on a
page that uses none of them does nothing:
1. Workspace drawer. Below 900px .ws-rail is an off-canvas drawer.
Any [data-ws-toggle] button opens and closes it; the scrim, Esc and
growing past 900px close it. The scrim is created here.
2. Slice router. A Suite's (or Learning's) modules are addressable as
#, with extra parameters after "&": #edit&sample=ct, and a
place inside a module after "/": #sha2/stage-3 (as params.path).
CarinoUI.slices({
menu: document.querySelector('.slice-menu'), // .slice[data-id] inside
onRoute(id, params) { … }, // id null = overview
collapsed: true, // optional: start collapsed (modules share one input)
});
Clicking a slice only sets location.hash; hashchange drives
everything, so Back, bookmarks and shared links all land right.
It keeps body.state-overview / body.state-module and .active in step.
3. Export menu. Every .cs-menu: its [aria-haspopup] button opens the
.cs-menu-panel; choosing an item, clicking away or Esc closes it.
Items keep their own handlers; the menu only governs visibility.
4. Modal. Works on both markups: a .modal-scrim[hidden] holding a
.modal, or a native