/* ============================================================================
   ink.css: Ink's stylesheet — the ink layer, Ink's own controls and the Ink
   Window.
   ============================================================================

   WHY THIS SHEET IS ITS OWN FILE AND NOT A SECOND COPY. Ink now rides more than
   one canvas: the Build Machine Workshop (public/workshop/canvas.html) and the
   Simple Workshop (public/simple-workshop/canvas.html), which are the two parents
   sessions run on (LINKED_CANVAS_PARENT_KEYS, src/index.js). These rules began
   inside public/workshop.css, where they were one page's own. Pasting
   them into the second page's sheet would have been the same declaration twice,
   and the first day the two disagreed an attendee would be watching an ink layer
   laid out one way and a set of controls sized for another.

   MACHINERY ARRIVES BY DECLARATION, NEVER BY A COPY (Build Machine in the log:
   /mymanual build machine). A page declares ink.js in its extras; the shell's
   MODULE_STYLESHEETS entry for ink.js supplies this sheet. Pattern sheets arrive
   through PATTERN_ASSETS. Pages do not declare stylesheet names.

   It is NOT in the shell's own stylesheet list, because Ink is not on every
   canvas: a page carrying no ink.js has no use for these rules and should not be
   asked to fetch them.
   ============================================================================ */

/* ---------- Ink: the writing layer ---------- */
/* The board sits over the playfield (#kit-playfield is z-index 0, frame.css) and
	under the chrome (the chips and the author bar are 60, tweaks.css). An
	attendee never touches it; only the pen page takes a pointer. */
.ws-ink-layer {
	position: fixed;
	inset: 0;
	z-index: 6;
	pointer-events: none;
}

/* The canvas frame: a fixed 1280 by 720 design rectangle, scaled whole and centred, so one stroke
	lands in the same place on every attendee's laptop. The box is measured in
	JavaScript on every resize; only what does not move lives here. */
.ws-ink {
	position: absolute;
	overflow: visible;
}

.ws-ink.pen-active {
	pointer-events: auto;
	cursor: crosshair;
	touch-action: none;
}

/* The visible edges are SVG paint, not CSS outlines on the root SVG. WebKit
	does not reliably paint that outline on inline SVG roots, while a rect is
	painted by both WebKit and Chromium. The line on the edge of the canvas frame
	is never a path and never takes pointer events. */
.ws-ink-canvas-frame,
.ws-ink-window-shortcuts {
	display: none;
	pointer-events: none;
}

.ws-ink.pen-active .ws-ink-canvas-frame {
	display: block;
	fill: none;
	stroke: var(--border);
	stroke-width: 2;
	vector-effect: non-scaling-stroke;
}

/* ---------- Select: what is picked up, on the pen page alone ---------- */
/* Mike, 3 October 2026 (ink.js, "SELECT"). A halo under each picked stroke, one
	dashed box round them all, and the loop while the pencil draws it. These are
	the pen page's own marks, never strokes and never sent, so the Ink Window that
	Ecamm films never carries them. They are chrome, so they wear the design
	system's accent rather than an ink colour. */
.ws-ink-picked-halo {
	stroke: var(--accent);
	stroke-opacity: 0.5;
}

.ws-ink-picked-box,
.ws-ink-select-loop {
	fill: none;
	stroke: var(--accent);
	stroke-width: 2;
	stroke-dasharray: 8 6;
}

.ws-ink-select-loop {
	fill: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ---------- Ink's controls, where the chip has put them ---------- */
/* Ink declares its controls and the chip machinery draws them (ink.js, "Ink's
	controls"; Mike, 19 September 2026: "The ink controls probably want to be a
	set of controls I add to the chips just like any other"). So every rule the
	old pen bar needed for its own box, its own buttons and its own rows is gone:
	the chip owns all of that now, in the one stylesheet it already carries
	(public/selector-chip.js, ensureMenuChipStyles).

	What is left is only what is Ink's own, and it is scoped to the element the
	slot mounts Ink into, so nothing here can reach another set of controls.

	THE REACH IS THE ONE RULE WORTH KEEPING. The chip's buttons are sized for a
	mouse; Mike writes with an Apple Pencil on an iPad held at arm's length, and
	the bar's own note said it plainly — every control clears a 44px reach. */

/* The shared swatch ring the chip draws round the CHOSEN colour asks for
	--c-marker, which the two spatial canvases that have carried swatches until
	now define for themselves. A page without it drops the ring as invalid and
	Mike cannot see which ink he is on. So Ink names it in its own scope, as the
	design system's own marker rather than a colour of its own. */
.ws-ink-controls {
	--c-marker: var(--marker);
	/* Keep the drawn finger target at 44px even when Size scales the chip
	   down, without spreading empty button faces across the row. */
	--ink-button-size: max(var(--s-12), calc(44px / var(--controls-chip-scale, 1)));
	--ink-width-size: max(calc(var(--s-16) + var(--b-hair)), var(--ink-button-size));
}

.ws-ink-controls .cd-sb,
.ws-ink-controls .cd-sb-listitem.can-open,
.ws-ink-controls .cd-sb-listadd {
	min-height: 44px;
}

.ws-ink-controls .cd-sb-sw {
	width: 44px;
	height: 44px;
	border-radius: var(--r-pill);
}

/* Ink's drawn controls use the tall approved arrangement. The shared chip keeps
	owning the flex row; these declarations only give Ink's own controls their
	declared shape. */
.ws-ink-controls .ws-ink-width,
.ws-ink-controls .ws-ink-shape,
.ws-ink-controls .ws-ink-tool,
.ws-ink-controls .ws-ink-kind-button {
	box-sizing: border-box;
	min-height: var(--s-12);
	border: var(--b-hair) solid var(--border);
	background: color-mix(in srgb,var(--fg) 7%,transparent);
	color: var(--fg-soft);
}

.ws-ink-controls .ws-ink-width {
	flex: none;
	width: var(--ink-width-size) !important;
	height: var(--ink-button-size);
	min-height: var(--ink-button-size);
	min-width: 0;
}

.ws-ink-controls .cd-sb:is(.ws-ink-shape, .ws-ink-tool, .ws-ink-kind-button, .ws-ink-export, .ws-ink-load, .ws-ink-takeover) {
	flex: none;
	width: var(--ink-button-size) !important;
	height: var(--ink-button-size);
	min-height: var(--ink-button-size);
	min-width: 0;
}

/* Tall's pairs wrap as whole buttons if another anchored chip narrows it. */
.ws-ink-controls .cd-sb-rowpair {
	width: max-content;
	max-width: 100%;
	flex-wrap: wrap;
}

.ws-ink-controls .ws-ink-width.on,
.ws-ink-controls .ws-ink-shape.on,
.ws-ink-controls .ws-ink-tool.on,
.ws-ink-controls .ws-ink-kind-button.on {
	border-color: var(--accent);
	background: color-mix(in srgb,var(--accent) 16%,transparent);
	color: var(--accent);
}

/* The chip's direct-button layout rule clears a whole border after this sheet.
	A selected width must restore the complete accent edge, not only its colour:
	the extra button class makes this Ink-only rule win in both chip shapes. */
.ws-ink-controls .cd-sb.ws-ink-width.on.ws-ink-width {
	border: var(--b-hair) solid var(--accent);
	background: color-mix(in srgb,var(--accent) 16%,transparent);
}

.ws-ink-controls .ws-ink-width svg {
	width: var(--s-12);
	height: var(--s-4);
}

.ws-ink-controls .ws-ink-shape svg,
.ws-ink-controls .ws-ink-eraser svg,
.ws-ink-controls .ws-ink-tool-icon {
	width: var(--s-6);
	height: var(--s-6);
}

.ws-ink-controls .ws-ink-kind-button {
	min-width: 0;
	justify-content: center !important;
	align-items: center !important;
}

.ws-ink-controls .ws-ink-kind-button svg {
	width: var(--s-6);
	height: var(--s-6);
}

.ws-ink-controls .ws-ink-kind-button.is-off {
	opacity: 0.35;
	pointer-events: none;
}

.ws-ink-controls .ws-ink-paste-to-inkboard.on {
	color: var(--amber);
	background: color-mix(in srgb,var(--amber) 16%,transparent);
}

.ws-ink-controls .ws-ink-screens {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--s-2);
}

.ws-ink-controls .ws-ink-screens .cd-sb-listitem {
	position: relative;
	min-width: 0;
	padding: 0;
	border: 0;
}

.ws-ink-controls .ws-ink-screens .cd-sb-listitem.is-open {
	background: color-mix(in srgb, var(--amber) 16%, transparent);
}

.ws-ink-controls .ws-ink-screens .cd-sb-listpicture {
	aspect-ratio: 16 / 9;
	border: var(--b-hair) solid var(--border);
	border-radius: var(--r-md);
	overflow: hidden;
}

.ws-ink-controls .ws-ink-screens .cd-sb-listitem.is-open .cd-sb-listpicture {
	border: var(--b-stroke) solid var(--amber);
}

.ws-ink-controls .ws-ink-screens .cd-sb-listpicture svg {
	width: 100%;
	height: 100%;
}

.ws-ink-controls .ws-ink-screens .cd-sb-listhead {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.ws-ink-controls .ws-ink-screens .cd-sb-listlabel {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.ws-ink-controls .ws-ink-screens .cd-sb-listmark {
	position: absolute;
	right: var(--s-1);
	bottom: var(--s-1);
	width: var(--s-4);
	height: var(--s-4);
	min-width: 0;
	border-radius: var(--r-md);
	background: var(--panel);
	color: var(--fg-soft);
}

.ws-ink-controls .ws-ink-screens .cd-sb-listmark svg {
	width: var(--s-3);
	height: var(--s-3);
}

/* Delete this page lives on the lit thumbnail only. Its 44px box is the finger
	   reach; the visible cross stays inside that box and inside the picture. */
.ws-ink-controls .ws-ink-screens .ws-ink-delete-screen {
	position: absolute;
	top: 0;
	right: 0;
	z-index: 2;
	box-sizing: border-box;
	width: 62px;
	height: 62px;
	min-width: 62px;
	min-height: 62px;
	padding: 0;
	pointer-events: auto;
	border: var(--b-hair) solid var(--border);
	border-radius: var(--r-md);
	background: var(--panel);
	color: var(--fg-soft);
	font-size: 28px;
	line-height: 1;
	font-family: var(--font-sans);
}

.ws-ink-controls .ws-ink-screens .ws-ink-delete-screen.is-armed {
	border-color: var(--alert);
	background: color-mix(in srgb, var(--alert) 16%, var(--panel));
	color: var(--alert);
}

.ws-ink-controls .ws-ink-screens .cd-sb-listadd {
	/* New stays beside the controls and newest boards, even while older boards
	   scroll past it. TALL's first grid cell and WIDE's first column. */
	order: -1;
	position: sticky;
	top: 0;
	left: 0;
	z-index: 3;
	align-self: start;
	margin-top: 0;
	background: var(--panel);
	width: auto;
	min-height: 0;
	aspect-ratio: 16 / 9;
	border: var(--b-hair) dashed var(--border);
	border-radius: var(--r-md);
	color: var(--fg-soft);
}

.ws-ink-controls .ws-ink-screens .cd-sb-listadd svg {
	width: var(--s-6);
	height: var(--s-6);
}

.ws-ink-controls .ws-ink-takeover {
	min-height: var(--s-14);
	border: var(--b-hair) solid var(--border);
	background: color-mix(in srgb,var(--fg) 7%,transparent);
	color: var(--fg-soft);
	justify-content: center !important;
	align-items: center !important;
}

.ws-ink-controls .ws-ink-takeover.on {
	background: var(--amber);
	border-color: var(--amber);
	color: var(--marker-ink);
}

.ws-ink-controls .ws-ink-takeover svg {
	width: var(--s-10);
	height: var(--s-8);
}

/* A SHAPE IS SIZED BY A DRAG ON THE PAGE (Mike, 19 September 2026: "Yes I'd
	love to be able to resize ist placement"), not by a drag off the control, so
	a shape control is an ordinary chip button and needs nothing of its own here.
	The rule that keeps the browser from taking that drag for a scroll is the one
	the writing surface already carries, because the drag is on the writing
	surface (.ws-ink.pen-active). Ink's one rule of its own is the 44px reach
	above, because Mike writes with an Apple Pencil at arm's length. */

/* A control that can do nothing says so, and looks it: the pin control on a
	page that reports no step to pin to. */
.ws-ink-controls .cd-sb.is-off {
	opacity: 0.5;
	cursor: default;
}

/* The relay's connection readout keeps the dot beside the room word. The
	readout remains the chip's own text style; only its layout and dot are Ink's. */
.ws-ink-controls .ws-ink-status {
	display: inline-flex;
	align-items: center;
	gap: var(--s-1);
	flex: 0 0 auto;
	width: auto;
	height: auto;
	min-height: 0;
	padding: 0;
	background: transparent;
}

.ws-ink-controls .ws-ink-status::before {
	content: '';
	flex: 0 0 auto;
	width: var(--s-2);
	height: var(--s-2);
	border-radius: var(--r-pill);
	background: var(--status-alert);
}

.ws-ink-controls .ws-ink-status.ok::before {
	background: var(--status-ok);
}

/* INK in WIDE. Ink declares the groups; the frame owns the strip. The
	buttons keep their content sizes and their 44px drawn minimum in both
	shapes, without growing to divide the strip's spare width. */
.chip-v2.wide .ws-ink-controls .cd-sb-sw {
	width: 38px;
	height: 38px;
}
.chip-v2.wide .authbar-wide-scroll > .chip-frame-body .ws-ink-controls > .cd-sb-wide-group[data-wide-columns]:is([data-selector-group="ink-widths"], [data-selector-group="ink-shapes"]) {
	flex: none;
	grid-template-columns: repeat(var(--wide-columns), max-content);
	grid-auto-rows: max-content;
	align-self: stretch;
	align-items: stretch;
	align-content: start;
}
.chip-v2.wide .ws-ink-controls .ws-ink-screens {
	display: flex;
	gap: 6px;
}
/* Boards alone scroll. Short lists keep file actions next to the boards; long lists
	shrink to the space left by the tools, file actions and frame controls. */
.chip-v2.wide .authbar-wide-scroll > .chip-frame-body:has(.ws-ink-controls > .cd-sb-wide-group[data-selector-group="ink-screens"][data-wide-grow]) {
	/* Give the middle the actual remaining width, rather than an intrinsic
	   width measured through several nested shrinking flex boxes. */
	flex: 1 1 0;
	min-width: 0;
}
.chip-v2.wide .authbar-wide-scroll > .chip-frame-body .ws-ink-controls > .cd-sb-wide-group[data-selector-group="ink-screens"][data-wide-grow] {
	flex: 1 0 calc(44px + var(--ink-board-width, 104px) + var(--chip-button-gap));
	min-width: calc(44px + var(--ink-board-width, 104px) + var(--chip-button-gap));
	max-width: calc(44px + var(--chip-button-gap) + var(--ink-boards-width, 100vw));
	contain: none;
	/* Cap the group at Add and every card, so short lists leave no blank strip
	   before file actions. The inner viewport owns the swipe. */
	overscroll-behavior: auto;
	/* The shared group handler targets the declared inner scroller and
	   separates a swipe from a board tap. */
	touch-action: pan-x;
}
.chip-v2.wide .ws-ink-controls .ws-ink-screens .cd-sb-listitem {
	flex: none;
	width: 104px;
	height: 64px;
	min-height: 0;
}
.chip-v2.wide .ws-ink-controls .ws-ink-screens .cd-sb-listpicture {
	/* New leads the row, so the final picture must include its border inside
	   the card's width rather than extend the board scroller by two pixels. */
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	aspect-ratio: auto;
}
/* Keep the existing finger target without painting a box over the drawing.
   The narrower thumbnails must still show the current board's ink. */
.chip-v2.wide .ws-ink-controls .ws-ink-screens .ws-ink-delete-screen {
	background: transparent;
	border-color: transparent;
	align-items: flex-start;
	justify-content: flex-end;
	padding: var(--s-1);
	font-size: var(--t-md);
	text-shadow: 0 0 var(--b-stroke) var(--panel);
}
.chip-v2.wide .ws-ink-controls .ws-ink-screens .cd-sb-listadd {
	top: auto;
	align-self: center;
	flex: none;
	width: 44px;
	height: 64px;
	aspect-ratio: auto;
}
/* At a narrower workshop window, thumbnails still clear a 44px pointer
   target at the smallest SIZE (72%), with three boards and new in view. */
@media (max-width: 1240px) {
	.chip-v2.wide .ws-ink-controls { --ink-board-width: 64px; }
	.chip-v2.wide .ws-ink-controls .ws-ink-screens .cd-sb-listitem {
		width: 64px;
	}
}

/* New stays outside the board scroller. The viewport contains whole cards;
   additional boards remain in this group and can be swiped horizontally. */
.chip-v2.wide .ws-ink-controls .ws-ink-screens {
	flex: 1;
	min-width: 0;
	align-items: center;
	gap: var(--chip-button-gap);
}
.chip-v2.wide .ws-ink-controls .ws-ink-screens .cd-sb-listadd {
	position: relative;
	left: auto;
}
.chip-v2.wide .ws-ink-board-pages {
	display: flex;
	flex: 1;
	min-width: 0;
	max-width: var(--ink-pages-width, 100%);
	gap: var(--chip-button-gap);
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior: contain;
	touch-action: pan-x;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}
.chip-v2.wide .ws-ink-board-pages > .cd-sb-listitem {
	scroll-snap-align: start;
}

/* ---------- The Ink Window ---------- */
/* A browser window on Mike's Mac showing ONLY the ink of the writing screen his
	pen page is on, on the FlightDeck's green, so Ecamm keys the green out and his
	handwriting floats in front of or behind him. Mike named it on 19 September
	2026. It is the same page with ?ink-window; ink.js puts the class on the root
	element and writes the chosen green into --deck-chroma.

	THE GREEN IS THE FLIGHTDECK'S OWN and its value is DATA, not a token: Ecamm is
	keyed to that exact pixel (public/patterns/slides.js, `_setChroma`, soft
	#5A9F7A or broadcast #00b140). So the property arrives from JavaScript and
	this file states no green of its own — there is no third green to state.

	EVERYTHING ELSE GOES, and goes by a rule rather than by a sweep, so whatever
	the engine appends next is covered too: the field, the running pattern, the
	chips, the author bar, the send control, the build stamp. VISIBILITY, not
	display: the engine is a live animated experience that measures its own boxes,
	and taking the boxes away would be fighting it for no gain. Nothing painted is
	nothing filmed. */
.ws-ink-window,
.ws-ink-window body {
	background: var(--deck-chroma) !important;
}

.ws-ink-window :is(body, :where(#kit-page-room)) > *:not(.ws-ink-layer):not(#kit-page-room) {
	visibility: hidden !important;
}

/* No cursor on camera, wherever it is resting when Mike lets go of the mouse. */
.ws-ink-window,
.ws-ink-window * {
	cursor: none !important;
}

/* The Ink Window's line on the edge of the canvas frame and its written
	shortcuts are a switch for Ecamm alignment, not ink. The colour is written as
	measured data by ink.js, beside the chroma values. Both are SVG paint so they
	share the 1280 by 720 canvas frame and
	remain visible on WebKit. */
.ws-ink-window-canvas-frame .ws-ink .ws-ink-canvas-frame {
	display: block;
	fill: none;
	stroke: var(--ink-window-canvas-frame-line);
	stroke-width: 2;
	vector-effect: non-scaling-stroke;
}

.ws-ink-window-canvas-frame .ws-ink .ws-ink-window-shortcuts {
	display: block;
	fill: var(--ink-window-canvas-frame-line);
	font-family: var(--font-mono);
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* ---------- The whiteboard, and whiteboard takeover ---------- */
/* Mike, 19 September 2026: "So I can have the whiteboard open myself which draws
	over whatever screen they're on of the experience. BUT I can also go into
	whiteboard takeover mode which pulls them out of the experience onto a full
	whiteboard - when I close it they land back where they were".

	THIS IS THE INK WINDOW'S BLOCK WITH TWO DIFFERENCES, and it is deliberately the
	same rule rather than a second idea: the surface is the page's own (var(--bg))
	instead of a green Ecamm is keyed to, and the chips are left standing, because
	Mike has to be able to reach the control that ends what he started. Everything
	else goes by the same rule the window uses, so whatever the engine appends next
	is covered as readily as what is already there.

	"WHEN I CLOSE IT THEY LAND BACK WHERE THEY WERE" IS WHY IT IS VISIBILITY. The
	exercise underneath is not unmounted, navigated or restored — it goes on
	running, measuring its own boxes, holding the step and the answers it already
	had, with a clean surface laid over it. Take the class off and every attendee is
	exactly where they were, because there is nowhere they went. A hidden element is
	not hit-testable either, so nobody presses a button they cannot see while the
	surface is up.

	ink.js puts this class on the root element and takes it off again, and the one
	answer that decides it is WorkshopInk.whiteboardShowing. The Ink Window never
	wears it: a white sheet arriving on the surface Ecamm films would take the
	chroma key with it. */
.ws-ink-whiteboard,
.ws-ink-whiteboard body {
	background: var(--bg) !important;
}

.ws-ink-whiteboard :is(body, :where(#kit-page-room)) > *:not(.ws-ink-layer):not(.chip-v2):not(#kit-page-room):not(#kit-chip-layer) {
	visibility: hidden !important;
}

/* File actions stay at the far end of the boards, outside their scroll. */
.ws-ink-controls :is(.ws-ink-export, .ws-ink-load) {
	justify-content: center;
	min-width: calc(var(--s-10) + var(--s-1));
}
.ws-ink-controls :is(.ws-ink-export, .ws-ink-load).is-off {
	color: var(--fg-soft);
	cursor: default;
}
.ws-ink-controls .ws-ink-files-notice {
	color: var(--status-alert);
	font-family: var(--font-sans);
}

.chip-v2.wide .authbar-wide-scroll > .chip-frame-body .cd-sb-bar .cd-sb-list.ws-ink-screens {
	flex: 1;
	width: 0;
	gap: var(--chip-button-gap);
}

/* Portrait keeps the board selector whole beside the tools. The same groups
   still occupy one row; the widest icon block uses three columns. */
@media (max-width: 900px) {
	.chip-v2.wide .authbar-wide-scroll > .chip-frame-body .ws-ink-controls > .cd-sb-wide-group[data-selector-group="ink-shapes"][data-wide-columns] {
		grid-template-columns: repeat(3, max-content);
	}
}

.chip-v2.wide .authbar-wide-scroll > .chip-frame-body .ws-ink-controls > .cd-sb-wide-group[data-wide-columns] {
	grid-auto-rows: max-content;
	align-content: start;
}

.chip-v2.wide .ws-ink-controls {
	--ink-width-size: var(--ink-button-size);
}

/* Seven colours share three compact rows (3, 2, 2), without a lone colour
   or taking the width needed by Mike's third board picture. */
.chip-v2.wide .authbar-wide-scroll > .chip-frame-body .ws-ink-controls > .cd-sb-wide-group[data-selector-group="ink-colours"][data-wide-columns] {
	grid-template-columns: repeat(3, max-content);
}
.chip-v2.wide .authbar-wide-scroll > .chip-frame-body .ws-ink-controls > .cd-sb-wide-group[data-selector-group="ink-colours"] .ws-ink-swatch:nth-child(6) {
	grid-column: 1;
}
