soul.demarkus.io:6309/demarkus-library/journal/2026-12-02.md/v2 draft reader meta

demarkus-library journal: 2026-12-02

Reader light/dark switch on branch feat/reader-scheme, uncommitted. Nav has a 3-way form (auto · light · dark) that POSTs /scheme. That sets cookie demarkus_library_scheme (auto clears it) and redirects 303 to the Referer path. The server renders <html data-scheme> from the cookie, so the first paint is right. library.css has color-scheme: var(--reader-scheme, light dark), with [data-scheme] setting the var.

The user chose "theme wins". A theme that sets color-scheme itself (e.g. the #126 hub sheet, only dark with fixed paper/ink) replaces the declaration, and islands.js syncSchemeSwitch hides the switch. It does this by flipping data-scheme in place and probing with isDarkAt, on load and on each body swap. On that deployment the switch stays hidden until the sheet uses light-dark() tokens.

JS posts the form in place (fetch, redirect: manual), sets the attribute, and re-themes mermaid. rethemeDiagrams also runs on a matchMedia change, which pays the debt entry. SchemeRoutes is registered in main, outside the turnstile; CSRF still applies.

Tests: TestSchemeSwitchStoresChoice, TestPagesRenderReaderScheme, and TestBrowserSchemeSwitch (OS change, click, persistence across a full load, hidden under a forced world). Each piece was verified by mutation. Gates green.

Seen: the nav overflows at 600px. This is pre-existing and now recorded in debt.md.

Nav overflow on narrow screens fixed on feat/reader-scheme (same branch as the scheme switch, still uncommitted). nav now has flex-wrap: wrap; justify-content: flex-end. Doors that do not fit wrap to a second row, flush right; .world still grows on row one, so the first row looks unchanged. The pane-scroll room is fine with it, since the nav is flex: 0 0 auto in a column and the canvas takes the rest. TestBrowserNavFitsNarrowScreen fails before the fix at 480px (librarian door, switch).

Gotcha: a headless Chrome --window-size=380,… screenshot is not a 380px layout. Chrome enforces a wider minimum window, so the page lays out wider and the PNG is clipped. Items look missing or overflowing when they are not. For narrow widths use CDP Emulation.setDeviceMetricsOverride, as the browser test does, and measure rects instead of trusting the screenshot.

trail
  1. soul.demarkus.io:6309 v2