@cameronsjo/artificer 0.18.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,151 @@
1
+ // Artificer Hard rule #1 lint engine — the single source of the discipline,
2
+ // shared by the workshop gate (scripts/lint-css-tokens.mjs, a thin wrapper) and
3
+ // the consumer `artificer lint` subcommand (bin/artificer.mjs). It lives in
4
+ // bin/ because that dir rides BOTH the npm payload (package.json files) and the
5
+ // public export ({ dir: 'bin' }); scripts/ ships to the public repo but not to
6
+ // npm, so the engine cannot live there.
7
+ //
8
+ // Flags raw values in hand-authored CSS that have a token equivalent:
9
+ // - raw hex colors (any), and
10
+ // - on-scale spacing/radius px that maps to a token, and
11
+ // - near-scale font-size px (within ±2px of a --t-*-size token),
12
+ // OUTSIDE custom-property definitions and comments. A trailing `/* tuned */`
13
+ // exempts a line (component-internal optical values). Off-scale px is skipped.
14
+ //
15
+ // The token maps are the WORKSHOP's scale by default (the built-ins below), so
16
+ // the wrapper's behavior is unchanged. The consumer subcommand projects the
17
+ // maps from a vendored tokens.json instead (buildTokenMaps), version-locking the
18
+ // lint to whatever the consumer vendored.
19
+
20
+ // ── Built-in maps (the workshop scale; the last-resort consumer fallback) ────
21
+ export const BUILTIN_SPACING = { 4: '--s-xs', 8: '--s-sm', 16: '--s-md', 24: '--s-lg', 32: '--s-xl', 48: '--s-2xl', 96: '--s-3xl' };
22
+ export const BUILTIN_RADIUS = { 4: '--radius-sm', 8: '--radius-md', 12: '--radius-lg' };
23
+ // Repo type scale in px (artificer.css --t-*-size definitions).
24
+ export const BUILTIN_TYPE_PX = [
25
+ [28, '--t-headline-lg-size'], [22, '--t-headline-md-size'], [16, '--t-body-lg-size'],
26
+ [14, '--t-body-md-size'], [13, '--t-label-md-size'], [12, '--t-label-sm-size'],
27
+ [11, '--t-label-xs-size'],
28
+ ];
29
+
30
+ const HEX = /#[0-9a-fA-F]{3,8}\b/;
31
+ // property declaration → captures prop name and its value (single declaration, no braces)
32
+ const DECL = /\b(gap|padding|margin|border-radius)\b[^;{}]*?:\s*([^;{}]+)/g;
33
+ const FONT_DECL = /\bfont-size\b\s*:\s*([^;{}]+)/g;
34
+ // Sheets whose type contract is NOT the repo scale — the Lane 2 Obsidian sister.
35
+ export const FONT_SCALE_EXEMPT = /theme\.src\.css$/;
36
+
37
+ // camelCase scale key → CSS var stem: headlineLg → headline-lg, labelSm → label-sm.
38
+ const kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
39
+ const pxOf = (v) => {
40
+ const m = /^(\d+(?:\.\d+)?)px$/.exec(String(v).trim());
41
+ return m ? Number(m[1]) : null;
42
+ };
43
+ // rem/px size → px (1rem = 16px at the default root, which is never overridden).
44
+ const sizePx = (v) => {
45
+ const s = String(v).trim();
46
+ let m = /^(\d+(?:\.\d+)?)rem$/.exec(s);
47
+ if (m) return Math.round(Number(m[1]) * 16);
48
+ m = /^(\d+(?:\.\d+)?)px$/.exec(s);
49
+ return m ? Math.round(Number(m[1])) : null;
50
+ };
51
+
52
+ // Project a parsed tokens.json into lint maps. The merge is PER-KEY, not
53
+ // per-section: the built-in map is the FLOOR (never lint weaker than the
54
+ // workshop scale — even against a tokens.json whose section OMITS a key the
55
+ // built-ins have, e.g. src/tokens.json's spacing has no `3xl` while
56
+ // artificer.css defines --s-3xl), and the projection overlays on top (it wins
57
+ // on shared px — that is the version-lock; the floor fills the gaps).
58
+ export function buildTokenMaps(tokens) {
59
+ const spacing = { ...BUILTIN_SPACING };
60
+ for (const [k, v] of Object.entries(tokens?.spacing ?? {})) {
61
+ if (k.startsWith('$')) continue;
62
+ const px = pxOf(v);
63
+ if (px != null) spacing[px] = `--s-${k}`;
64
+ }
65
+ const radius = { ...BUILTIN_RADIUS };
66
+ for (const [k, v] of Object.entries(tokens?.radius ?? {})) {
67
+ if (k.startsWith('$')) continue;
68
+ const px = pxOf(v?.value ?? v);
69
+ if (px != null) radius[px] = `--radius-${k}`;
70
+ }
71
+ // px → token, seeded with the built-in floor, projection overlaid.
72
+ const typeByPx = new Map(BUILTIN_TYPE_PX);
73
+ for (const [k, v] of Object.entries(tokens?.typography?.scale ?? {})) {
74
+ if (k.startsWith('$')) continue;
75
+ const px = sizePx(v?.size ?? v);
76
+ if (px != null) typeByPx.set(px, `--t-${kebab(k)}-size`);
77
+ }
78
+ return { spacing, radius, typePx: [...typeByPx.entries()] };
79
+ }
80
+
81
+ function nearestTypeToken(px, typePx) {
82
+ let best = null;
83
+ for (const [tpx, tok] of typePx) {
84
+ const d = Math.abs(px - tpx);
85
+ if (d <= 2 && (!best || d < best.d)) best = { d, tok, tpx };
86
+ }
87
+ return best;
88
+ }
89
+
90
+ export function lintText(text, { fontScale = true, tokens } = {}) {
91
+ const spacingMap = tokens?.spacing ?? BUILTIN_SPACING;
92
+ const radiusMap = tokens?.radius ?? BUILTIN_RADIUS;
93
+ const typePx = tokens?.typePx ?? BUILTIN_TYPE_PX;
94
+ const out = [];
95
+ let inComment = false;
96
+
97
+ text.split('\n').forEach((line, i) => {
98
+ // Rule #1 escape valve: explicit /* tuned */ marker exempts a line from
99
+ // scale-token enforcement (component-internal padding, tuned optical values).
100
+ if (line.includes('/* tuned */')) return;
101
+ let scan = line;
102
+ if (inComment) {
103
+ const end = scan.indexOf('*/');
104
+ if (end === -1) return;
105
+ scan = scan.slice(end + 2);
106
+ inComment = false;
107
+ }
108
+ scan = scan.replace(/\/\*.*?\*\//g, '');
109
+ const open = scan.indexOf('/*');
110
+ if (open !== -1) { inComment = true; scan = scan.slice(0, open); }
111
+
112
+ // custom-property DEFINITIONS are where raw values belong — skip
113
+ if (/^\s*--[\w-]+\s*:/.test(scan)) return;
114
+
115
+ // raw hex in a value (declarations only)
116
+ if (scan.includes(':')) {
117
+ const hex = scan.slice(scan.indexOf(':') + 1).match(HEX);
118
+ if (hex) out.push({ n: i + 1, msg: `raw hex ${hex[0]} → define/use a color token`, src: line.trim() });
119
+ }
120
+
121
+ // on-scale spacing/radius px → suggest the token
122
+ for (const m of scan.matchAll(DECL)) {
123
+ const prop = m[1];
124
+ const map = prop === 'border-radius' ? radiusMap : spacingMap;
125
+ for (const px of m[2].matchAll(/(\d+)px/g)) {
126
+ const tok = map[Number(px[1])];
127
+ if (tok) out.push({ n: i + 1, msg: `${px[1]}px in ${prop} → var(${tok})`, src: line.trim() });
128
+ }
129
+ }
130
+
131
+ // near-scale font-size px → suggest the nearest type token (#187)
132
+ if (fontScale) {
133
+ for (const m of scan.matchAll(FONT_DECL)) {
134
+ for (const px of m[1].matchAll(/(\d+(?:\.\d+)?)px/g)) {
135
+ const hit = nearestTypeToken(Number(px[1]), typePx);
136
+ if (hit) {
137
+ const off = hit.d ? ` (${hit.tpx}px scale, ${hit.d}px off)` : '';
138
+ out.push({ n: i + 1, msg: `${px[1]}px in font-size → var(${hit.tok})${off}`, src: line.trim() });
139
+ }
140
+ }
141
+ }
142
+ }
143
+ });
144
+ return out;
145
+ }
146
+
147
+ export function report(label, v, err = console.error) {
148
+ err(`⚠ Artificer Hard rule #1 — raw values in ${label} (use tokens; see CLAUDE.md "Token cheatsheet"):`);
149
+ for (const x of v.slice(0, 10)) err(` L${x.n} ${x.msg}\t${x.src}`);
150
+ if (v.length > 10) err(` …and ${v.length - 10} more`);
151
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cameronsjo/artificer",
3
- "version": "0.18.1",
3
+ "version": "0.21.0",
4
4
  "description": "Cameron's personal design system — AuDHD-friendly, dark-first, for tools and dashboards. Apache-2.0 but Cameron-first: published for my own reuse, unsupported, no stability guarantees implied.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Cameron Sjo",
@@ -10,8 +10,12 @@
10
10
  },
11
11
  "type": "module",
12
12
  "sideEffects": [
13
- "*.css"
13
+ "*.css",
14
+ "src/artificer-*.js"
14
15
  ],
16
+ "bin": {
17
+ "artificer": "./bin/artificer.mjs"
18
+ },
15
19
  "style": "./src/artificer.css",
16
20
  "exports": {
17
21
  "./artificer.css": "./src/artificer.css",
@@ -30,7 +34,9 @@
30
34
  "./package.json": "./package.json"
31
35
  },
32
36
  "files": [
33
- "src"
37
+ "src",
38
+ "bin",
39
+ "reference/SKILL.md"
34
40
  ],
35
41
  "publishConfig": {
36
42
  "access": "public"
@@ -43,6 +49,8 @@
43
49
  "lint:palette": "node scripts/lint-css-palette.mjs",
44
50
  "check:version": "node scripts/sync-version.mjs --check",
45
51
  "sync:version": "node scripts/sync-version.mjs",
52
+ "check:tokens": "node scripts/sync-tokens.mjs --check",
53
+ "sync:tokens": "node scripts/sync-tokens.mjs",
46
54
  "sri": "node scripts/gen-sri.mjs",
47
55
  "test": "node --test scripts/*.test.mjs"
48
56
  }
@@ -0,0 +1,407 @@
1
+ ---
2
+ name: Artificer
3
+ description: Cameron's personal design system. AuDHD-optimized, Ghostty-rooted, dark-first with a paper-stock light mode and a Jazz Age Deco palette (burnished gold + royal purple). Use for tools, dashboards, agent UIs, terminals, settings panels — anything that must stay calm until something demands action. Do NOT use for marketing sites, kid-facing UI, or anywhere the goal is delight-via-stimulation.
4
+ ---
5
+
6
+ # Artificer · v0.21.0
7
+
8
+ A neurodivergent-first design system for Cameron. Every token and rule here exists to reduce cognitive load for an AuDHD brain that **scans instead of reads** and holds **3–4 items** in working memory.
9
+
10
+ ---
11
+
12
+ ## When to use this
13
+
14
+ Use Artificer for:
15
+ - Internal tools, dashboards, admin panels
16
+ - Agent UIs, terminal-adjacent surfaces, dev tools
17
+ - Personal sites where "calm focus" is the brand
18
+ - Settings, configuration, log/history surfaces
19
+
20
+ Don't use Artificer for:
21
+ - Marketing/landing pages (it's intentionally not playful)
22
+ - Anything kid-facing or entertainment-focused
23
+ - E-commerce purchase flows (gold-as-interactive collides with sale-color conventions)
24
+ - Surfaces where bright energy is the point
25
+
26
+ ---
27
+
28
+ ## File map
29
+
30
+ | File | Purpose |
31
+ |---|---|
32
+ | `artificer.css` | All tokens + utility classes. The only stylesheet you need. |
33
+ | `artificer-theme.js` | Persistent theme control — dark / light / auto (auto follows the OS live); hydrates the empty canonical `.theme-toggle` button. |
34
+ | `assets/cameron-logo.jpg` | Personal mark — only used on Cameron-branded surfaces. |
35
+ | `README.html` | System overview, principles, do/don't. |
36
+ | `colors.html` · `typography.html` · `spacing.html` | Foundations specs. |
37
+ | `components.html` · `patterns.html` · `notifications.html` | Live component specs. |
38
+ | `layout.html` | Layout primitives: `.stack`, `.cluster`, `.grid-auto`, `.container`, `.page-shell`. |
39
+ | `motion.html` | Duration/easing tokens, the five motion patterns, reduced-motion rules. |
40
+ | `overlay.html` | Modal, popover, tooltip, scrim. Six-rung z-index scale. Pairs with `artificer-focus.js`. |
41
+ | `forms-extended.html` | Field anatomy, validation, fieldsets, helper/error text. The twelve non-negotiable rules. |
42
+ | `data-display.html` | Tables, key-value lists, stat cards, progress. Tabular-nums everywhere. |
43
+ | `states.html` | Empty, loading, error — by duration. Skeleton sizing rules. |
44
+ | `a11y.html` | WCAG 2.2 audit, contrast ratios, focus rings, the 12-point shipping checklist. |
45
+ | `artificer-icons.js` | Lucide-rooted icon set, Lucide-canonical names (legacy names alias; unknown names render a dashed placeholder). Auto-hydrates `<i data-icon="…">` placeholders. |
46
+ | `artificer-focus.js` | `ArtificerFocus.trap(el, {onEscape})` — focus-trap helper for modals/dialogs. |
47
+ | `icons.html` | Icon catalog + usage rules (16px viewBox, 1.5 stroke, inherit color). |
48
+ | `voice-and-tone.html` | Microcopy spec — empty states, errors, success, loading. 7-point checklist. |
49
+ | `tokens.json` | Machine-readable token export (for Tailwind, Figma, non-CSS consumers). |
50
+ | `print.css` | Print stylesheet. Forces ivory/navy paper mode, strips chrome. Load `media="print"`. |
51
+ | `assets/favicon.svg` · `assets/og-image.svg` | Favicon (32px) and Open Graph card (1200×630). SVG, themeable. |
52
+
53
+ ---
54
+
55
+ ## The boilerplate (copy this)
56
+
57
+ ```html
58
+ <!doctype html>
59
+ <html lang="en">
60
+ <head>
61
+ <meta charset="utf-8" />
62
+ <title>...</title>
63
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
64
+ <!-- Theme bootstrap — FIRST, before any CSS, so a dark page never flashes
65
+ light. Key 'artificer.theme' (dot); dark-first. See QUICKSTART.md. -->
66
+ <script>(function(){try{var s=localStorage.getItem('artificer.theme');var p=s==='light'||s==='dark';var l=window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches;document.documentElement.setAttribute('data-theme',p?s:(l?'light':'dark'));}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
67
+ <link rel="icon" type="image/svg+xml" href="assets/favicon.svg" />
68
+ <meta property="og:image" content="assets/og-image.svg" />
69
+ <link rel="stylesheet" href="artificer.css" />
70
+ <link rel="stylesheet" href="print.css" media="print" />
71
+ <script src="artificer-theme.js" defer></script>
72
+ <script src="artificer-icons.js" defer></script>
73
+ </head>
74
+ <body>
75
+ <button class="theme-toggle" data-theme-toggle aria-label="Toggle theme"></button>
76
+ <main style="max-width:820px;margin:0 auto;padding:48px 24px">
77
+ <!-- your content -->
78
+ </main>
79
+ </body>
80
+ </html>
81
+ ```
82
+
83
+ If you have **no file system** (chat-only artifact), inline the contents of `artificer.css` into a `<style>` block instead of linking it.
84
+
85
+ ---
86
+
87
+ ## Decision recipes
88
+
89
+ | User asks for… | Reach for… |
90
+ |---|---|
91
+ | App shell / full-viewport layout | `app-shell.html` — `.app-shell` + `.app-shell__content`; appbar + sidenav + content skeleton for tool surfaces, collapses to the drawer under `--bp-tablet` |
92
+ | Top app bar | `app-shell.html` — `.appbar` + `__brand`/`__search`/`__actions`/`__menu-btn`/`__spacer`; sticky tool chrome, clears the notch via `safe-area-inset` |
93
+ | Side navigation | `app-shell.html` — `.sidenav` + `.sidenav__group` (+ `.label`/`.count` slots); the section spine, one level deep, `.tree` for deeper |
94
+ | Mobile nav drawer | `app-shell.html` — `.nav-drawer` + `.nav-scrim`; takes over below `--bp-tablet` |
95
+ | Breadcrumb | `navigation.html` — `.crumb` + `.crumb__sep`; where-am-I, nav's first rung |
96
+ | Button | `.btn` + `--primary`/`--secondary`/`--ghost`/`--icon` — one primary per view — `components.html` |
97
+ | Dashboard with file/agent list | `patterns.html` sidebar + tabs + content pane |
98
+ | Add a settings page | `forms-extended.html` `.field` blocks + fieldsets, grouped 3–5 per section |
99
+ | Form field / form (any kind) | `forms-extended.html` — label → input → hint/error, never placeholder-as-label |
100
+ | Confirmation dialog / modal | `overlay.html` — `.scrim` + `.modal`, wire `ArtificerFocus.trap()` for focus-trap |
101
+ | Tooltip / popover | `overlay.html` — `.tooltip` (label) or `.popover` (body content) |
102
+ | Page layout (sidebar/main) | `layout.html` — `.page-shell`, `.container` + `.container--{sm\|md\|lg}` (the base class is required — it carries width, centering, and inline padding; the size modifier only sets max-width) |
103
+ | Blog / editorial / document top nav / masthead | `.masthead` (`artificer-editorial.css`) — non-sticky, no border; document counterpart to `.appbar`. Brand via `.wordmark`, toggle via `.theme-toggle--inline` — `navigation.html` |
104
+ | Stacking children | `layout.html` — `.stack` (vertical), `.cluster` (horizontal wrap) |
105
+ | Card grid | `layout.html` — `.grid-auto` with `--min: 240px`, never hand-rolled flexbox |
106
+ | Command palette / ⌘K / "search anything" | `.palette` (= `.palette__search` combobox input + `.listbox` body) on a `.scrim` — `ArtificerOptions.combobox(input, list)` + `ArtificerFocus.trap()`, Esc closes; 5–7 results visible — `components-extended.html` |
107
+ | Combobox / dropdown / palette | One option-popover: `.menu` (actions) / `.listbox` (selection) + `__option`/`__label`/`__sep`/`__hint`/`--danger`; `.is-active` is the cursor. Behavior: `data-options` / `ArtificerOptions.enhance()` — `components-extended.html` |
108
+ | Tabs / view switcher | `.tabs` + `role=tablist`/`tab`/`tabpanel`; keyboard model via `ArtificerTabs.enhance()` (or `data-tabs` + `observe()`) — `patterns.html` |
109
+ | Segmented control / view-param switch | `.timerange` (time window, density) — NOT `.tabs` (tabs switch the whole view) — `navigation.html` |
110
+ | Accordion / disclosure | `.accordion` wrapping native `<details><summary>` + `.accordion__body` — keyboard + a11y for free, no JS — `components.html` |
111
+ | Chip / facet tag | `.chip` (+ `.chip__count`); faceted filters in a `.filter-bar` or `.cluster` — `composition.html` |
112
+ | Filter bar | `.filter-bar` + `.grow`; ALL filters in one top bar, never sprinkled into panels — `composition.html` |
113
+ | Search input | `.search`; the icon-slotted search box, `.appbar__search` in the bar — `forms-extended.html` |
114
+ | Toast / alert | `notifications.html` — pick tier by *action required*, not severity; silent by default — audible escalation only as a named, opt-in carve-out |
115
+ | Transient toast placement | Mount the `.notif` in a `.toast-region` (fixed corner stack on `--z-toast`, `+N more` via `.toast-region__more`); roles set at INSERT: urgent → `alert`, attention/info → `status`, background → none — `notifications.html` |
116
+ | Tree / file explorer / nested nav | `.tree` > `.tree__group` > `.tree__row` (+ `.tree__twisty`, `.tree__leaf`); `role=tree/treeitem/group`; keyboard ships via `data-tree` / `ArtificerTree.enhance()` — `components-extended.html` |
117
+ | Pagination | `.pagination` + `.pagination__gap`; `[aria-current=page]` marks the page; prev/next disable at ends; counted ranges only — `components-extended.html` |
118
+ | Persistent page banner | `.banner` + `--info/attention/urgent/success` + `.banner__body`/`.banner__actions` — a standing layout band, NOT the transient `.notif` — `components-extended.html` |
119
+ | Footer / colophon / fine print / attribution | `.colophon` + `.colophon__label` (column headers) + `.colophon__fine` (legal tier); columns via `.grid-auto`; prose auto-sans even inside `.surface-tool` — `.surface-document` flips any other prose island back — `layout.html` |
120
+ | Selected card / selected row / active choice | `.card--active` (`background: var(--bg)` + accent left border) for a card, `.is-active` (`background: var(--bg-raised)`) for a list row — never `--accent-fill` as a large surface bg, its only rated text color is `--on-accent` — `components.html` |
121
+ | Split pane / master-detail | `.split-pane` + `.pane--active`/`.pane--inactive`; recession marks the unfocused pane — `composition.html` |
122
+ | Status pill | `.badge--{tier}` with a `.dot--{tier}` inside — dot AND text, never color alone |
123
+ | Status indicator (bare, no count) | `.dot--{accent\|attention\|urgent\|success}` |
124
+ | Count indicator | `.badge--{accent\|attention\|urgent\|success}` with number |
125
+ | Avatar | `.avatar` (image or initials) + `--sm`/`--lg`/`--xl`/`--square`; not `.dot` (8px status) or `.badge` (pill) — `components.html` |
126
+ | File upload / dropzone | `.file-field` (click-to-browse) → add `.file-field--drop` for a drag well; toggle `.is-dragover` on drag events — `components.html` |
127
+ | Dense table status / ✓✗~– cells | `.glyph--{success\|muted\|attention\|na}` tints ✓✗~– with a theme token; graphical (SC 1.4.11) so each pairs with `aria-label` — sparse/labeled status stays `.badge`+`.dot` — `data-display.html` |
128
+ | Icon inside button/link | `<i data-icon="search"></i>` — see `icons.html` for full set |
129
+ | Table of data | `data-display.html` — `.table`, right-align numerics, `font-variant-numeric: tabular-nums` |
130
+ | Key-value list | `.kv`; mono `<dl>` grid for metadata pairs, `.table` for real data — `data-display.html` |
131
+ | Live data indicator | `.live-tick` (pulsing dot) + `.last-updated` (timestamp); auto-updating regions still need an in-UI pause — `composition.html` |
132
+ | Stat card / KPI strip / headline numbers (KPIs) | `.stat` — `.stat__label` + `.stat__value` (mono, tabular) + `.stat__row` + `.stat__delta`(`.down`); the cell of a `.kpi-strip`, max 4 per row — `data-display.html` |
133
+ | Dashboard shell | `.dash` + `.dash__topbar` (`.dash__title` + `.dash__actions`) — one frame, five recipes — `composition.html` |
134
+ | Chart / sparkline / gauge | `.sparkline`/`.sparkbars` (in tables, no axes), `.gauge`; series via `--series-1..5` — `charts.html` |
135
+ | Architecture / flow diagram | `.dia-node`/`.dia-edge` on inline SVG — `diagrams.html` |
136
+ | Syntax-highlighted code block | `.code-block` + the `.tok-*` roles — `components-extended.html` |
137
+ | Brand wordmark | `.wordmark` (renders `artificer.`) — `README.html` |
138
+ | Theme toggle | empty `<button class="theme-toggle" data-theme-toggle aria-label="Toggle theme">` — the module injects the glyph |
139
+ | Tabular number | `.num` utility — sets `font-variant-numeric: tabular-nums`; drop on the cell, or the parent for a whole table — `data-display.html` |
140
+ | Short hint paragraph under a figure or field | `.note` — sister of `.meta`, smaller (label-sm); inherits the body face, mono on tool surfaces / sans on document surfaces |
141
+ | Doc-page section header | `<h2 class="section-title">` — mono, uppercase, `--fg-secondary`, border-bottom rule; doc/spec chrome — `data-display.html` |
142
+ | Live-spec / doc-page example container | `<figure class="figure">` + `<figcaption class="meta">…</figcaption>` — `.figure--frame`/`--flush` modifiers — `data-display.html` |
143
+ | Make it fun / playful / celebratory / rainbow | The sanctioned `.whimsy` layer, opt-in, one per view; never on chrome/status/data/errors — `whimsy.html` |
144
+ | Make it feel like paper / give it grain / material / texture / depth | `.tex-grain` / `.tex-dots` / `.tex-line` / `.tex-paper` / `.tex-raised`; hueless + motionless, never on data/status/errors — `texture.html` |
145
+ | Empty state / error / loading copy | `voice-and-tone.html` — never improvise microcopy |
146
+ | Loading state / UI | `states.html` — pick by *duration*: nothing → disabled label → skeleton → progress → background |
147
+ | Long wait, nothing to count | `.progress--indeterminate` + `role="progressbar"` + `aria-label` with concrete copy, NO `aria-valuenow/min/max` — `states.html` |
148
+ | Refreshing a value in place | `.live-value[data-refreshing]` recedes the stale value + `.live-value__dot` pulses — NOT `.skeleton` (would blank it) — `composition.html` |
149
+ | Animation / transition | `motion.html` — `--dur-fast` + `--ease`. Don't invent durations. |
150
+ | z-index | `motion.html` / `overlay.html` — six rungs only: `--z-{base\|raised\|overlay\|popover\|modal\|toast}` |
151
+ | Pre-ship a11y check | `a11y.html` — 12-point checklist before merging |
152
+ | Token in non-CSS context | Read `tokens.json` |
153
+ | PDF / print output | Add `<link rel="stylesheet" href="print.css" media="print">` |
154
+ | Hero/landing page | **Don't** — wrong system. Suggest a brand-marketing system instead. |
155
+
156
+ ### SPA lifecycle (icons / whimsy / theme + modal re-trap)
157
+
158
+ Icons and theme arm their own `MutationObserver` on DOM ready — SPA-mounted
159
+ `[data-icon]` / `[data-theme-toggle]` nodes hydrate and bind automatically.
160
+ Whimsy hydrates once on `DOMContentLoaded`; tabs, options, and tree enhance
161
+ on explicit calls. For nodes that mount after first paint in those modules,
162
+ use the lifecycle API:
163
+
164
+ - **`ArtificerIcons.observe(root?)` / `Whimsy.observe(root?)` /
165
+ `ArtificerTheme.observe(root?)`** — framework-agnostic. Hydrates `root` now,
166
+ then a `MutationObserver` re-hydrates inserted nodes (idempotent guards make
167
+ it cheap). Returns a disconnect fn. Use for vanilla / Vue / Svelte / streamed
168
+ content.
169
+ - **React:** `useIcons(ref?)` / `useWhimsy(ref?)` hydrate on mount; the `Icon`
170
+ component already self-hydrates. For content that streams in after mount,
171
+ prefer `observe()`.
172
+ - **Theme persistence key is `'artificer.theme'` (a DOT).** Vanilla and the
173
+ React `useTheme` must agree on it or theme won't survive the
174
+ SPA↔first-paint boundary.
175
+ - **Modal re-trap:** `ArtificerFocus.trap()` recomputes focusables on **every
176
+ Tab**, so controls added while the modal is open are reachable automatically
177
+ — you do **not** re-trap for that. The only thing fixed at open is **initial
178
+ focus**. If you swap modal content (e.g. a wizard step) and want focus moved
179
+ to the new first control, `release()` then `trap()` again (or `.focus()` the
180
+ new target yourself).
181
+
182
+ ---
183
+
184
+ ## The ten non-negotiables
185
+
186
+ 1. **Dark is default.** Light mode is a paper alternative, not the primary.
187
+ 2. **Max 2 semantic colors on screen at once.** Brand purple + gold = one "Cameron" signal, doesn't count.
188
+ 3. **Bold 3–5 anchor words per paragraph.** Use `class="anchor"` or `<b>`. Primary scanning mechanism. When prose arrives as data, mark anchors as `**…**` in the source and promote each marked span to `<b class="anchor">` at render — single-level only, never nested.
189
+ 4. **One primary CTA per screen.** Always. Everything else is `.btn--secondary` or `.btn--ghost`.
190
+ 5. **5–7 items max** in any list/palette/menu before progressive disclosure.
191
+ 6. **No pure black.** `#1D1F21` is the darkest value in the system.
192
+ 7. **Honor `prefers-reduced-motion`** — durations collapse to 0ms (already wired in CSS).
193
+ 8. **WCAG AAA** for body text (7:1). Text-safe accent variants already hit this.
194
+ 9. **Never mix rounded and sharp corners** in one view.
195
+ 10. **Voice is literal, direct, lightly deadpan.** No metaphor, sarcasm, or figurative copy. Autism demands clarity.
196
+
197
+ ### Status-density carve — budgets, not absolutes, on status-dense tool surfaces
198
+
199
+ Rules 2, 4, and 5 read as absolutes. On a status-dense, read-only surface
200
+ (monitoring, fleet dashboards) the colors and interaction load arrive with
201
+ the data — they're facts, not decoration a designer chose. These are
202
+ budgets-with-exemptions, not exceptions that swallow the rule:
203
+
204
+ - **Color budget (rule 2).** A status-dense tool surface is exempt when the
205
+ colors ARE the data — a fleet-state table can legitimately show 5 tier
206
+ colors at once. Discipline: low-saturation dot+text chips, never filled
207
+ pills; filled treatment stays reserved for the urgent tier and the
208
+ connection-loss banner. Decoration still budgets at 2 — the exemption
209
+ doesn't extend to anything that isn't the data itself.
210
+ - **List cap (rule 5).** A primary data table is not a "list" — it's
211
+ governed by the table recipes, not this cap. The cap still governs
212
+ panels, fact clusters, and menus: ≤5 items per labeled group in a detail
213
+ panel.
214
+ - **Primary CTA (rule 4).** "At most one" includes zero. A read-only
215
+ surface with no CTA at all — only selection, tabs, toggles, external
216
+ links — is valid, not a violation.
217
+
218
+ ---
219
+
220
+ ## Token cheatsheet
221
+
222
+ ```
223
+ SURFACES --bg / --bg-raised / --bg-overlay / --bg-inactive
224
+ TEXT --fg / --fg-secondary / --fg-muted / --fg-disabled / --border
225
+
226
+ INTERACTIVE --accent gold text (AAA) — links, focus, secondary buttons
227
+ --accent-bright hover state
228
+ --accent-fill gold background — SMALL controls only (buttons, badges);
229
+ never a selected-card/surface bg, pairs only with --on-accent
230
+
231
+ ATTENTION --attention rose text (AAA) — "look when you can"
232
+ --attention-fill rose background
233
+
234
+ URGENT --urgent vermillion text — errors, blocking
235
+ --urgent-fill vermillion background
236
+
237
+ SUCCESS --success olive — completed
238
+ META --steel / --steel-fill — chrome, secondary UI
239
+
240
+ BRAND --brand-purple / --brand-purple-fill — wordmarks, masthead, NOT semantic
241
+
242
+ TYPE --font-mono JetBrains Mono
243
+ · BODY FACE for tool surfaces (dashboards,
244
+ terminals, data tables, settings panels)
245
+ · ALWAYS for code, identifiers, file paths,
246
+ numerals — including inside documents
247
+ --font-sans iA Writer Quattro
248
+ · BODY FACE for document surfaces (writeups,
249
+ READMEs, reports, design docs)
250
+ · On tool surfaces: labels, hints, microcopy
251
+
252
+ Decision rule. >3 paragraphs of running prose → document → sans body.
253
+ Mostly chrome around data → tool → mono body. Same project can mix.
254
+ Anti-pattern: setting prose in mono and then overriding `.meta`,
255
+ headings, tables back to sans. If you're escaping the body face,
256
+ the body face is wrong — flip it.
257
+ Type utilities set size + line-height only — compose vertical
258
+ rhythm with `.stack` (gap-owned), not margins.
259
+
260
+ SPACING --s-xs(4) sm(8) md(16) lg(24) xl(32) 2xl(48)
261
+ RADII --radius-sm(4 · buttons) md(8 · cards) lg(12 · overlays only) pill(999 · toggle/chip)
262
+ MOTION --dur-instant(80) fast(160) max(300) · ease cubic-bezier(.2,.7,.3,1)
263
+ ```
264
+
265
+ ---
266
+
267
+ ## Utility classes
268
+
269
+ ```
270
+ TYPE .t-headline-lg .t-headline-md .t-body-lg .t-body-md
271
+ .t-label-md .t-label-sm .t-code
272
+ .anchor (bold anchor word) · .meta (secondary color)
273
+
274
+ BUTTONS .btn + .btn--primary | --secondary | --ghost | --destructive
275
+ [disabled] for inactive
276
+ .btn--icon (square 44px, needs aria-label) + .btn--icon-prominent
277
+ when it stands ALONE as a primary control (hamburger, modal close)
278
+
279
+ CARDS .card + .card--active | --attention | --urgent
280
+
281
+ FORMS .field > label + .input | .select | .textarea + .hint | .error
282
+
283
+ BADGES .badge + .badge--accent | --attention | --urgent | --success | --ghost
284
+ DOTS .dot + .dot--accent | --attention | --urgent | --success
285
+
286
+ PANES .pane--active (gold left border) · .pane--inactive (55% opacity, desaturated)
287
+
288
+ KBD <kbd>⌘ ↵</kbd>
289
+ THEME <button class="theme-toggle" data-theme-toggle aria-label="Toggle theme"></button>
290
+ (empty — the module injects the glyph; cycles dark → light → auto)
291
+ ```
292
+
293
+ Coming from Bootstrap/Tailwind `warning`? That tier is **`--attention`** here —
294
+ across badge, dot, card, notif, and banner. One name per tier; there is no
295
+ `warning` alias.
296
+
297
+ ---
298
+
299
+ ## Anti-patterns vs patterns
300
+
301
+ ```html
302
+ <!-- ANTI: three semantic colors competing -->
303
+ <div>
304
+ <button class="btn btn--primary">Save</button>
305
+ <button class="btn btn--destructive">Delete</button>
306
+ <span class="badge badge--attention">2 reviews</span>
307
+ </div>
308
+
309
+ <!-- PATTERN: one primary, others demoted -->
310
+ <div>
311
+ <button class="btn btn--primary">Save</button>
312
+ <button class="btn btn--ghost">Delete</button>
313
+ <span class="badge badge--ghost">2 reviews</span>
314
+ </div>
315
+ ```
316
+
317
+ ```html
318
+ <!-- ANTI: prose with no anchors. Nothing to scan. -->
319
+ <p>The agent finished writing the section and is now waiting for the editor to review the changes before continuing.</p>
320
+
321
+ <!-- PATTERN: 3 anchor words. Bolded path makes sense alone. -->
322
+ <p>The <b>writer agent</b> finished the section. <b>Waiting on editor</b> to review before <b>continuing</b>.</p>
323
+ ```
324
+
325
+ ```html
326
+ <!-- ANTI: placeholder-only label, vague error -->
327
+ <input class="input" placeholder="API key" aria-invalid="true" />
328
+ <span class="error">Invalid input</span>
329
+
330
+ <!-- PATTERN: persistent label, specific remediation -->
331
+ <div class="field">
332
+ <label for="k">API key</label>
333
+ <input id="k" class="input" aria-invalid="true" />
334
+ <span class="error">Missing <code>sk-</code> prefix. Paste the full key from console.</span>
335
+ </div>
336
+ ```
337
+
338
+ ```html
339
+ <!-- ANTI: 12 items in a flat list -->
340
+ <ul><li>...</li>... 12 items ...</ul>
341
+
342
+ <!-- PATTERN: 5 + "show more", or grouped with labeled dividers -->
343
+ <ul><li>...</li>... 5 items ...</ul>
344
+ <button class="btn btn--ghost">Show 7 more</button>
345
+ ```
346
+
347
+ ---
348
+
349
+ ## Composition cheatsheet
350
+
351
+ When you're past atoms and need to lay out a real product surface, the shell
352
+ is always **`.dash`** (frame + `.dash__topbar`) + a `density-*` + a body built
353
+ from shipped primitives. The five recipes (these are RECIPES, not classes —
354
+ there is no `.dash-*` class):
355
+
356
+ | Surface | Recipe (`.dash` + body) | Density default |
357
+ |---|---|---|
358
+ | Metrics overview | `.kpi-strip` over a chart | `.density-cozy` |
359
+ | Ops console / log view | `.split-pane` + log stream + `.table` | `.density-compact` |
360
+ | Observability | chart grid (`.grid-2` / `.grid-auto`) | `.density-cozy` |
361
+ | Records / queues | `.table` is the body | `.density-compact` |
362
+ | Master / detail | `.split-pane` | `.density-cozy` |
363
+
364
+ ### Charts — non-negotiable
365
+
366
+ - **5 series max.** Beyond that → split chart, group, or sequential ramp (`--ramp-1..5`).
367
+ - **No pies above n=3.** Bar chart. Always.
368
+ - **Sparklines have no axes.** Use `.sparkline` / `.sparkbars` inside tables.
369
+ - **2 gridlines max.** Baseline + one mid.
370
+ - **Bars start at zero.** Lines may fit Y-range.
371
+ - **Tabular numerals** wherever a number renders. Already wired via `--font-mono`.
372
+ - **No entry animation by default.** Honor `prefers-reduced-motion`.
373
+ - **Muted series is a stance.** Series slots alias semantic tokens on purpose — color alone fails CVD validators. A second channel (label, shape, line style, position) is mandatory on every multi-series categorical chart.
374
+ - **Light mode has fewer channels than dark** — attention collapses toward gold. Categorical series + an attention marker together need a glyph or label to carry the distinction, not color alone.
375
+ - **Diverge vs. ramp.** `--diverge-low|mid|high` for valenced scales with two charged ends; `--ramp-1..5` for magnitude where one end is neutral.
376
+
377
+ ### Diagrams — non-negotiable
378
+
379
+ - **`.dia-node` + `.dia-edge` + `.dia-edge-label`** — apply directly to inline SVG `<rect>`/`<path>`/`<text>`.
380
+ - **1 accent node per diagram** (`.dia-node--accent`) — the diagram's subject.
381
+ - **Ghost = planned** (`.dia-node--ghost`, dashed border).
382
+ - **Edge stroke encodes resolution:** default = step, `--strong` = closes the flow, `--dashed` = async/return.
383
+ - **9 nodes ceiling.** Group beyond that.
384
+ - **Mermaid:** initialize with `theme:'base'` + `themeVariables` reading CSS vars (snippet in `live-spec/diagrams.html`).
385
+ - **React Flow:** wrap in `.rf-artificer`.
386
+ - **Excalidraw palette:** strokes `#ffffff #c5c8c6 #e0b558 #e8836f` · fills `#292c33 #313540 #3c4150`. "Architect" roughness for system maps; "artist" for sketches.
387
+ - **`<defs>` ids are document-scoped.** Namespace per instance (`arrow-<id>`) when repeating a diagram component; never hard-code one inside it.
388
+ - **Interactive nodes:** `tabindex="0"` + `role="button"` + `aria-label` + Enter/Space. Focus ring free from the global catch-all.
389
+
390
+ ---
391
+
392
+ ## Voice rules
393
+
394
+ - **Literal.** Name the thing. Don't gesture.
395
+ - **Direct.** Front-load the action. "Save changes" > "Click here to save your changes."
396
+ - **Lightly deadpan.** Wit lives in restraint, not in jokes. A palette showing exactly 5 things is funnier than any pun.
397
+ - **No metaphor in errors.** "Build failed: missing close brace at line 214" beats "Looks like things went sideways."
398
+ - **No sarcasm anywhere.** Autism demands clarity; sarcasm is confusing.
399
+
400
+ ---
401
+
402
+ ## Versioning & attribution
403
+
404
+ - **v0.1** · 2026 · personal use, no license required for Cameron's projects.
405
+ - Palette inspired by 1920s–50s Jazz Age Deco screen-print posters.
406
+ - Surface scale rooted in [Ghostty](https://ghostty.org) terminal defaults.
407
+ - AAA contrast values pre-tuned; don't substitute hexes without re-running contrast checks.
@@ -27,6 +27,46 @@
27
27
  line-height: var(--t-body-lg-lh);
28
28
  }
29
29
 
30
+ /* ─── Masthead — the document-surface top nav ──────────────────────────────
31
+ The document counterpart to the tool-surface .appbar (artificer.css). Quiet,
32
+ NON-sticky, single-row site header for reading surfaces: brand + a few links
33
+ + optional meta (theme toggle). No border, no sticky chrome — it scrolls with
34
+ the page (the .appbar traits #131 called wrong over prose). Sans face; the
35
+ .wordmark brand keeps mono by its own rule. Compose the brand with
36
+ .wordmark--stop-none for a period-bearing mark, and the toggle with
37
+ .theme-toggle--inline. One <nav aria-label> landmark. Fixes #131. */
38
+ .masthead {
39
+ display: flex; align-items: center; flex-wrap: wrap;
40
+ gap: var(--s-md) var(--s-lg);
41
+ padding: var(--s-lg) 0;
42
+ font-family: var(--font-sans);
43
+ }
44
+ .masthead__brand { margin-right: auto; } /* pushes nav + meta to the right */
45
+ .masthead__nav {
46
+ display: flex; align-items: center; gap: var(--s-lg);
47
+ font-size: var(--t-label-md-size);
48
+ }
49
+ .masthead__nav a {
50
+ color: var(--fg-secondary); text-decoration: none;
51
+ transition: color var(--dur-fast) var(--ease);
52
+ }
53
+ .masthead__nav a:hover { color: var(--fg); }
54
+ .masthead__nav a[aria-current="page"] {
55
+ color: var(--accent);
56
+ box-shadow: inset 0 -2px 0 var(--accent); /* active band — mirrors .sidenav's rail, rotated for a horizontal nav */
57
+ }
58
+ .masthead__meta { display: flex; align-items: center; gap: var(--s-sm); }
59
+
60
+ /* Nav targets are 44px always (a11y rule #8) — same treatment as .crumb a /
61
+ .appbar__brand in artificer.css, applied to the masthead's own links. */
62
+ @media (pointer: coarse) {
63
+ .masthead__brand,
64
+ .masthead__nav a {
65
+ min-height: 44px; min-width: 44px;
66
+ display: inline-flex; align-items: center;
67
+ }
68
+ }
69
+
30
70
  /* ─── Prose — long-form vertical rhythm ────────────────────────────────────
31
71
  Block flow with a measured column and generous, even spacing. Drop .prose
32
72
  on the article body; children inherit the rhythm without per-element margins. */