@reqvire-org/ads 0.3.45 → 0.3.47

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.
Files changed (160) hide show
  1. package/README.md +23 -11
  2. package/dist/a11y.mjs +102 -0
  3. package/dist/assets.mjs +37 -8
  4. package/dist/atomic-composition.mjs +3 -2
  5. package/dist/brand-assets.mjs +48 -11
  6. package/dist/brands.mjs +82 -0
  7. package/dist/browser-audit/worker.mjs +45 -0
  8. package/dist/browser-audit.mjs +117 -0
  9. package/dist/capture/worker.mjs +2 -1
  10. package/dist/capture-store.mjs +4 -1
  11. package/dist/capture.mjs +10 -4
  12. package/dist/check.mjs +40 -9
  13. package/dist/cli.mjs +55 -8
  14. package/dist/color-values.mjs +325 -0
  15. package/dist/config.mjs +19 -2
  16. package/dist/contracts/tokens.json +1 -1
  17. package/dist/control-padding.mjs +93 -0
  18. package/dist/design-values.mjs +11 -4
  19. package/dist/finding-rules.mjs +61 -0
  20. package/dist/foundation.mjs +17 -1
  21. package/dist/icons.mjs +107 -0
  22. package/dist/init.mjs +3 -0
  23. package/dist/mcp/apps.mjs +9 -6
  24. package/dist/mcp/drafts.mjs +3 -0
  25. package/dist/mcp/mutations.mjs +17 -1
  26. package/dist/mcp/preview-widget.bundle.js +45 -39
  27. package/dist/mcp/project-widget.bundle.js +26 -26
  28. package/dist/mcp/server.mjs +23 -9
  29. package/dist/mcp/widget.bundle.js +17 -17
  30. package/dist/palette-generated.mjs +180 -0
  31. package/dist/preview-resources.mjs +12 -3
  32. package/dist/render-color-probe.mjs +148 -0
  33. package/dist/runtime-contracts.mjs +14 -4
  34. package/dist/scenarios.mjs +1 -1
  35. package/dist/showcase/client.bundle.js +28 -28
  36. package/dist/showcase/icons.js +146 -0
  37. package/dist/showcase/index.html +2 -1
  38. package/dist/showcase/style.css +19 -2
  39. package/dist/skills/README.md +2 -1
  40. package/dist/skills/ads-break-ui/SKILL.md +6 -5
  41. package/dist/skills/ads-break-ui/references/atomic-styles.md +12 -12
  42. package/dist/skills/ads-break-ui/references/captures.md +3 -2
  43. package/dist/skills/ads-break-ui/references/contracts.md +13 -10
  44. package/dist/skills/ads-break-ui/references/design-data.md +199 -2
  45. package/dist/skills/ads-break-ui/references/validation.md +8 -4
  46. package/dist/skills/ads-designer/SKILL.md +32 -15
  47. package/dist/skills/ads-designer/references/accessibility.md +77 -0
  48. package/dist/skills/ads-designer/references/atomic-styles.md +12 -12
  49. package/dist/skills/ads-designer/references/branding.md +61 -6
  50. package/dist/skills/ads-designer/references/captures.md +3 -2
  51. package/dist/skills/ads-designer/references/cli.md +8 -2
  52. package/dist/skills/ads-designer/references/contracts.md +13 -10
  53. package/dist/skills/ads-designer/references/design-data.md +199 -2
  54. package/dist/skills/ads-designer/references/validation.md +8 -4
  55. package/dist/skills/ads-import/SKILL.md +9 -8
  56. package/dist/skills/ads-import/references/atomic-styles.md +12 -12
  57. package/dist/skills/ads-import/references/captures.md +3 -2
  58. package/dist/skills/ads-import/references/cli.md +8 -2
  59. package/dist/skills/ads-import/references/contracts.md +13 -10
  60. package/dist/skills/ads-import/references/design-data.md +199 -2
  61. package/dist/skills/ads-import/references/tokens.md +7 -3
  62. package/dist/skills/ads-import/references/validation.md +8 -4
  63. package/dist/skills/ads-motion/SKILL.md +6 -5
  64. package/dist/skills/ads-motion/references/atomic-styles.md +12 -12
  65. package/dist/skills/ads-motion/references/build.md +33 -0
  66. package/dist/skills/ads-motion/references/captures.md +3 -2
  67. package/dist/skills/ads-motion/references/contracts.md +13 -10
  68. package/dist/skills/ads-motion/references/design-data.md +199 -2
  69. package/dist/skills/ads-motion/references/motion-review.md +2 -2
  70. package/dist/skills/ads-motion/references/validation.md +8 -4
  71. package/dist/skills/ads-port/SKILL.md +6 -5
  72. package/dist/skills/ads-port/references/atomic-styles.md +12 -12
  73. package/dist/skills/ads-port/references/captures.md +3 -2
  74. package/dist/skills/ads-port/references/cli.md +8 -2
  75. package/dist/skills/ads-port/references/contracts.md +13 -10
  76. package/dist/skills/ads-port/references/design-data.md +199 -2
  77. package/dist/skills/ads-port/references/validation.md +8 -4
  78. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +76 -0
  79. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +19 -1
  80. package/dist/starters/preact/ds.config.json +13 -1
  81. package/dist/starters/react/ADS.md +43 -10
  82. package/dist/starters/react/README.md +61 -9
  83. package/dist/starters/react/design-system/assets/brand/README.md +8 -3
  84. package/dist/starters/react/design-system/assets/glyphs/README.md +15 -0
  85. package/dist/starters/react/design-system/assets/glyphs/aliases.json +1 -0
  86. package/dist/starters/react/design-system/assets/glyphs/check.svg +1 -0
  87. package/dist/starters/react/design-system/assets/glyphs/chevron-down.svg +1 -0
  88. package/dist/starters/react/design-system/assets/glyphs/chevron-right.svg +1 -0
  89. package/dist/starters/react/design-system/assets/glyphs/close.svg +1 -0
  90. package/dist/starters/react/design-system/assets/glyphs/external-link.svg +1 -0
  91. package/dist/starters/react/design-system/assets/glyphs/info.svg +1 -0
  92. package/dist/starters/react/design-system/assets/glyphs/menu.svg +1 -0
  93. package/dist/starters/react/design-system/assets/glyphs/plus.svg +1 -0
  94. package/dist/starters/react/design-system/assets/glyphs/search.svg +1 -0
  95. package/dist/starters/react/design-system/assets/glyphs/warning.svg +1 -0
  96. package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +11 -4
  97. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.fixture.ts +9 -0
  98. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.scenario.tsx +16 -0
  99. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +44 -0
  100. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +14 -0
  101. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +6 -0
  102. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +16 -0
  103. package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +42 -0
  104. package/dist/starters/react/design-system/components/Content/Icon/README.md +17 -0
  105. package/dist/starters/react/design-system/components/Content/Icon/glyphs.ts +17 -0
  106. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +3 -9
  107. package/dist/starters/react/design-system/components/Content/Logo/README.md +4 -2
  108. package/dist/starters/react/design-system/components/Forms/TextField/TextField.tsx +9 -5
  109. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +12 -0
  110. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +17 -0
  111. package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +75 -0
  112. package/dist/starters/react/design-system/components/Layout/Grid/README.md +21 -0
  113. package/dist/starters/react/design-system/controllers/Palette/Palette.ts +164 -0
  114. package/dist/starters/react/design-system/index.ts +6 -0
  115. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +2 -5
  116. package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +18 -0
  117. package/dist/starters/react/design-system/review/index.ts +1 -0
  118. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +19 -1
  119. package/dist/starters/react/design-system/styles.css +1 -0
  120. package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +114 -8
  121. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +23 -0
  122. package/dist/starters/react/design-system/tokens/{SpaceTypeMotion.ads.scenario.tsx → Layout.ads.scenario.tsx} +1 -1
  123. package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +18 -0
  124. package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +4 -0
  125. package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +30 -0
  126. package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +4 -0
  127. package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +37 -0
  128. package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +4 -0
  129. package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +29 -0
  130. package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +4 -0
  131. package/dist/starters/react/design-system/tokens/base.css +9 -3
  132. package/dist/starters/react/design-system/tokens/colors.css +210 -24
  133. package/dist/starters/react/design-system/tokens/elevation.css +44 -6
  134. package/dist/starters/react/design-system/tokens/spacing.css +67 -3
  135. package/dist/starters/react/design-system/tokens/themes.generated.css +142 -0
  136. package/dist/starters/react/design-system/tokens/themes.generated.ts +402 -0
  137. package/dist/starters/react/design-system/tokens/typography.css +25 -7
  138. package/dist/starters/react/ds.config.json +13 -1
  139. package/dist/style-boundaries.mjs +2 -1
  140. package/dist/themes-generated.mjs +150 -0
  141. package/dist/themes-watch.mjs +42 -0
  142. package/dist/themes.mjs +257 -0
  143. package/dist/token-export.mjs +69 -0
  144. package/dist/token-policy.mjs +2 -1
  145. package/dist/token-quality.mjs +112 -0
  146. package/dist/tokens.mjs +32 -30
  147. package/dist/validation.mjs +18 -1
  148. package/dist/verification/browser.mjs +14 -3
  149. package/docs/ADS.md +56 -13
  150. package/docs/ARCHITECTURE.md +82 -10
  151. package/docs/CACHING.md +2 -3
  152. package/docs/CHANGELOG.md +149 -13
  153. package/docs/CONTRACTS.md +13 -10
  154. package/docs/GUIDE.md +104 -8
  155. package/docs/MCP.md +46 -27
  156. package/docs/benchmarks/bun-previews.md +5 -5
  157. package/docs/benchmarks/{gidi-preview-memory.md → preview-memory.md} +14 -12
  158. package/docs/benchmarks/turbo-poc.md +24 -6
  159. package/package.json +2 -1
  160. package/dist/starters/react/design-system/tokens/SpaceTypeMotion.ads.fixture.ts +0 -36
@@ -145,11 +145,11 @@ helpers do not grant custom scenario CSS.
145
145
 
146
146
  For atomic base/variant styling, helper/wrapper class composition, extracted
147
147
  custom-property arithmetic, typed `@property` registrations, or an
148
- `atomic-composition-review` / `atomic-composition-limit` advisory, read
148
+ `atomic-composition-review` / `atomic-composition-limit` finding, read
149
149
  [atomic style composition](references/atomic-styles.md). The same guide is served
150
150
  as `ads://guides/atomic-styles`. It explains shorthand/logical conflicts and
151
151
  matching-property fixes, plus the build resolver for preserving opaque custom
152
- properties through extraction. Review warnings in the real `cx` composition and verify
152
+ properties through extraction. Check review items in the real `cx` composition and verify
153
153
  computed styles across affected sizes/states; retain intentional product behavior.
154
154
 
155
155
  For positioning, menu/listbox keyboard handling, focus trapping and virtual lists,
@@ -208,11 +208,15 @@ or empty. Use the latest published version unless the user names one; read
208
208
  Never copy starter files by hand or port React files to Preact.
209
209
 
210
210
  The created project's `README.md` and `ADS.md` explain it. It has semantic token
211
- defaults in two groups (Color; Space, type & motion), React or Preact
211
+ foundation in six groups (Color ramps and AA-checked roles, Type, Space & sizing, Shape &
212
+ elevation, Motion, Layout) with light and dark themes declared in `ds.config.json`
213
+ (`[data-theme]` themes the page or one section; optional `brands` add a brand axis beside
214
+ the themes; see `ads://guides/tokens`), React or Preact
212
215
  TypeScript/Linaria configuration, general lint, a public barrel, project-owned
213
216
  review renderers (token tiles, brand preview, demo and screen frames), placeholder
214
- brand artwork with an app icon, and one example of each layer: `Button`,
215
- `TextField` and `Logo` in three component groups, the `SearchBar` pattern and the
217
+ brand artwork with an app icon, a `Grid` (`GridItem`) on the grid tokens, an icon set with
218
+ `Icon` and `IconButton`, and one example of each layer: `Button`, `IconButton`, `Icon`,
219
+ `Logo`, `TextField` and `Grid` in four component groups, the `SearchBar` pattern and the
216
220
  `SearchPage` composition. Treat them as the project's own: adapt or replace them
217
221
  for the requested product. The browser shell is supplied by ADS tooling.
218
222
 
@@ -266,11 +270,11 @@ architectural reuse does not require moving application services into the ADS.
266
270
  ADS-owned frame patterns use `--ux-*`. Do not introduce configurable or
267
271
  product-prefixed token vocabularies.
268
272
  - Shared token names, meanings, types, and alias relationships form the contract;
269
- project values and theme overrides can differ. Item imports retain existing
273
+ project values and per-theme halves can differ. Item imports retain existing
270
274
  values and add missing definitions. Explicit token-values imports adopt source
271
- values and theme variants.
272
- - Scaffold defaults are dense 13px UI text, a 4px grid, warm surfaces, slate
273
- text, rose accents, restrained elevation, and system fonts. Treat these as
275
+ values and their per-theme halves.
276
+ - Scaffold defaults are 16 px body text, the 2 px spacing rhythm, slate surfaces
277
+ and text, a rose accent, restrained elevation, and system fonts. Treat these as
274
278
  initial project values; honor requested branding and preserve existing themes.
275
279
  - Reuse existing public components, patterns, and shared icons when compatible.
276
280
  Add missing primitives in their owning layer; inspect exports rather than
@@ -294,7 +298,8 @@ in the existing token files using fixed ADS names, and original artwork plus its
294
298
  usage, backgrounds, credits, and licenses in `assets/brand/`. Keep fonts in
295
299
  `assets/fonts/`, with optional `tokens/fonts.css` imported first. Follow the
296
300
  canonical foundation import order: fonts (if present), colors, typography,
297
- spacing, elevation, base. Artwork can have fixed SVG colors; UI styles must
301
+ spacing, elevation, base, then the generated `themes.generated.css`. Artwork can
302
+ have fixed SVG colors; UI styles must
298
303
  still use tokens and must not override primitive state.
299
304
 
300
305
  For standard web icons, set `assets.iconSource` to an SVG under `assets/brand/`,
@@ -313,10 +318,21 @@ and license each artwork in `assets/brand/README.md`, pair dark-theme variants a
313
318
  `<name>.dark.svg`, show them through a component, and preview them in the Brand
314
319
  section (`brand/<Group>/<Name>` scenarios). Finished PNG/JPEG/WebP images and
315
320
  delivered `.ico`/`.icns` files are artwork too; ADS never enlarges a finished
316
- image. Read
317
- [branding.md](references/branding.md) (`ads://guides/branding`) before changing
321
+ image. Other products' logos are not brand artwork or glyphs: keep them, in their own
322
+ colors and under their owners' trademark and usage terms, in `assets/logos/` and
323
+ show them as images (a CSS mask over `currentColor` for a muted use); ADS generates
324
+ and checks nothing there.
325
+ Read [branding.md](references/branding.md) (`ads://guides/branding`) before changing
318
326
  brand artwork, icon outputs or glyphs.
319
327
 
328
+ ## Accessibility
329
+
330
+ Target WCAG 2.2 AA. `ads check` fails on contrast in every theme and brand, target size,
331
+ focus, text resize, reduced motion, text spacing, image alternatives and icon-only controls
332
+ (`a11y-*` and `token-contrast`), and lists keyboard reach for review (`a11y-keyboard`);
333
+ `ads audit` adds axe-core in the browser. Read [accessibility.md](references/accessibility.md)
334
+ (`ads://guides/accessibility`) for the rules and the practice no tool can check.
335
+
320
336
  ## Design craft and mobile behavior
321
337
 
322
338
  For design direction, content/layout decisions, interface wording, component
@@ -463,9 +479,10 @@ foundation CSS rather than assigning shared token values in JavaScript. Keep
463
479
  full-app integration harnesses and workflow coverage in application test support.
464
480
 
465
481
  Foundation CSS is checked, not an escape hatch. Value sheets define shared tokens
466
- on the document root/themes; `fonts.css` holds font-face metadata. `base.css` has
467
- three closed roles: root/body typography, canvas and theme defaults; limited native
468
- normalization; and global focus indicators/reduced-motion rules. Every selector
482
+ on the document root (per-theme halves) or a brand's `[data-brand]`; `fonts.css`
483
+ holds font-face metadata. `base.css` has three closed roles: root/body typography,
484
+ canvas and theme defaults; limited native normalization; and global focus
485
+ indicators/reduced-motion rules. Every selector
469
486
  branch, property and value must fit its role. Token-backed control skins, layout,
470
487
  interactive state rules and owner hooks are rejected even through `:where()`.
471
488
  Do not copy an unchecked upstream preflight or turn a component repair into a reset.
@@ -0,0 +1,77 @@
1
+ # Accessibility
2
+
3
+ Target WCAG 2.2 AA. ADS checks what it can from
4
+ tokens and source; the rest is design and testing practice.
5
+
6
+ ## What `ads check` checks
7
+
8
+ `a11y-keyboard` is a review item (it cannot see every key handler); the others are errors.
9
+ Each message names its WCAG criterion.
10
+
11
+ | Rule | What it reviews | WCAG |
12
+ |---|---|---|
13
+ | `token-contrast` | Text, link, accent and status text on their backgrounds (4.5:1); focus and control borders on canvas and surface (3:1); in every theme and brand | 1.4.3, 1.4.11 |
14
+ | `a11y-target-size` | `--control-height-*` of at least 24 px (44 px where touch is common) | 2.5.8 |
15
+ | `a11y-focus` | `--focus-w` of at least 2 px, and a `:focus-visible` indicator in `base.css` | 2.4.7, 2.4.13 |
16
+ | `a11y-text-resize` | Font-size tokens in `rem`, so text follows the reader's browser font size | 1.4.4 |
17
+ | `a11y-reduced-motion` | Every non-zero `--dur-*` set to 0 under `prefers-reduced-motion`; infinite animations in components stopped there | 2.3.3, 2.2.2 |
18
+ | `a11y-text-spacing` | `--leading-normal` of at least 1.5; `--content-max` under 80 characters | 1.4.8, 1.4.12 |
19
+ | `a11y-image-alt` | `<img>` in components with `alt` (`alt=""` when decorative) | 1.1.1 |
20
+ | `a11y-icon-label` | A `<button>` or `<a>` in components whose only content is an icon has an accessible name (`aria-label`, or `IconButton` with its `label`) | 4.1.2 |
21
+ | `a11y-keyboard` | No `onClick` on `div`, `span` and other non-interactive elements without `role`, `tabIndex` and a key handler; prefer `<button>` | 2.1.1 |
22
+
23
+ Fix a finding in its owner: choose a different ramp step or size token, add the missing
24
+ attribute, or move the interaction to a native control. Do not silence it with a one-off
25
+ value.
26
+
27
+ ## Browser audit (axe-core)
28
+
29
+ Run `ads audit` after changing a component, pattern or composition scenario. It renders
30
+ each one in every declared brand and theme and runs axe-core's WCAG A/AA rules on the
31
+ scenario content.
32
+
33
+ ```sh
34
+ ads audit # every UI scenario, brand and theme
35
+ ads audit --scenario components/Button --theme dark --brand acme --json
36
+ ```
37
+
38
+ Each finding is an `a11y-axe` error on the scenario file, naming the axe rule, the WCAG
39
+ criterion, the themes and brands it fails in, the failing elements and the rule's help link:
40
+
41
+ ```text
42
+ design-system/components/Broken.scenario.tsx:1:1 [error:a11y-axe] axe button-name (critical), WCAG 4.1.2 in components/Broken [light, dark]: Buttons must have discernible text. 1 element: button. https://dequeuniversity.com/rules/axe/4.14/button-name?application=axeAPI
43
+ ```
44
+
45
+ - Fix the finding in the component that renders the failing element, not in the scenario.
46
+ - A `color-contrast` finding that `token-contrast` also reports is a token pair: change the
47
+ ramp step. One only the audit reports comes from a component pairing tokens itself: use
48
+ a role pair that `token-contrast` checks.
49
+ - Token and brand scenarios are skipped; name one with `--scenario` to audit it.
50
+ - To run the audit in `ads validate`/`ads_validate`, set `browserAudit: true` in that
51
+ policy (`validation` or `acceptance`); its findings then fail that policy, as they fail
52
+ `ads audit`. Draft and patch acceptance never run it.
53
+ - It needs the project's Playwright and browser, as captures do (`mcp.capture`).
54
+
55
+ A clean audit is not a pass: automated rules find only part of the WCAG failures. Keep the
56
+ manual checks below.
57
+
58
+ ## What only design and testing establish
59
+
60
+ - **Color is never the only signal.** Pair status color with text or an icon; underline links
61
+ in running text.
62
+ - **Keyboard.** Every action is reachable and usable with the keyboard, in a logical reading
63
+ order; focus never gets trapped and is always visible.
64
+ - **Screen readers.** Visual meaning has a text equivalent: labels on inputs and icon-only
65
+ buttons (`aria-label`), live regions for status messages, headings in order.
66
+ - **Zoom and reflow.** Layouts still make sense at 200% zoom and on a 320 px wide viewport;
67
+ related content stays together when magnified.
68
+ - **Motion.** Nothing autoplays or flashes more than three times a second; long motion can be
69
+ paused.
70
+ - **Media.** Video and animation with meaningful audio have captions and transcripts.
71
+ - **Cognitive load.** Plain language, one task per view where possible, information kept
72
+ visible while the task needs it.
73
+
74
+ Test by using each new view with the keyboard only, with a screen reader (VoiceOver, NVDA or
75
+ Orca), at 200% zoom, and in both themes. Browser checks run against real previews (`ads
76
+ verify`) can assert focus order and accessible names for important flows; `ads audit`
77
+ covers the rule-checkable rest of every scenario.
@@ -1,7 +1,7 @@
1
1
  # Atomic style composition
2
2
 
3
3
  Use this guide when creating or migrating component/pattern styles, changing
4
- base/size/state combinations, or reviewing `atomic-composition-review` warnings.
4
+ base/size/state combinations, or reviewing `atomic-composition-review` items.
5
5
  It is also available as `ads://guides/atomic-styles` through ADS MCP.
6
6
 
7
7
  ## Why valid tokens can still render incorrectly
@@ -203,7 +203,7 @@ entire className; `<button {...props} className={cx(base, className)} />` compos
203
203
  it explicitly. Keep the product's intended forwarding behavior when fixing an
204
204
  overlap. Do not change the public API simply to make tracing easier.
205
205
 
206
- Warnings include a bounded `composition` path through traced helpers and
206
+ Review items include a bounded `composition` path through traced helpers and
207
207
  components. A `target` identifies a statically reached DOM element. This
208
208
  establishes source composition, not that a scenario mounted it or that its
209
209
  computed result is wrong. `writingModeDependent: true` identifies overlaps that
@@ -213,9 +213,9 @@ expand them safely. Token formulas, inheritance and runtime values still need
213
213
  review. A margin shorthand and `margin-inline: auto` may agree horizontally but
214
214
  disagree in vertical text, so horizontal equality alone is insufficient.
215
215
 
216
- ## Respond to a warning
216
+ ## Respond to a review item
217
217
 
218
- 1. Follow the warning's related file/line locations and inspect the actual `cx`
218
+ 1. Follow the review item's related file/line locations and inspect the actual `cx`
219
219
  composition. Variant lookups may contribute several possible combinations.
220
220
  2. In a current built preview, inspect computed properties and the winning CSS
221
221
  rules. Establish whether extraction order, specificity, writing mode or an
@@ -231,7 +231,7 @@ Increasing specificity, adding `!important`, copying styles into scenarios or
231
231
  moving component styling into `base.css` can hide the symptom while retaining
232
232
  the conflict. Prefer resolving the composition itself. If an overlap is
233
233
  intentional, document why its precedence is stable and verify the resulting
234
- behavior rather than changing product capabilities to silence a warning.
234
+ behavior rather than changing product capabilities to silence a review item.
235
235
 
236
236
  Use existing behavior contracts and `ads_verify` for important geometry. Register
237
237
  a check beside its owner, link its real scenario and use the project's browser
@@ -249,16 +249,16 @@ states, themes and supported writing modes. Wait for observable readiness; an
249
249
  event-stream connection can prevent `networkidle` from settling. A generic
250
250
  overlap scan cannot decide which dimensions the product intended. A failed
251
251
  registered geometry assertion is blocking through the existing verification
252
- contract; an overlap warning remains a review signal.
252
+ contract; an overlap review item remains a review signal.
253
253
 
254
254
  ## What ADS checks
255
255
 
256
- `atomic-composition-review` is a nonblocking warning, returned under `advisories`
257
- with `severity: "warning"`. CLI checks still exit successfully when there are no
258
- errors; MCP checks and mutations preserve the warning and its guidance URI.
256
+ `atomic-composition-review` is a nonblocking review item, returned under `advisories`
257
+ with `severity: "review"`. CLI checks still exit successfully when there are no
258
+ errors; MCP checks and mutations preserve the review item and its guidance URI.
259
259
 
260
260
  An unchanged advisory baseline is not evidence that the affected styles are
261
- correct. Triage warnings that reach an edited owner or its shared helpers against
261
+ correct. Triage review items that reach an edited owner or its shared helpers against
262
262
  the actual DOM classes and computed styles in a compiled scenario. Interaction
263
263
  checks may pass without measuring padding, alignment or sizing. When an intended
264
264
  layout is known, add a focused rendered assertion for that contract; when keeping
@@ -285,7 +285,7 @@ unresolved DOM targets and traversal limits produce bounded
285
285
  `atomic-composition-limit` informational advisories where known atomic styles
286
286
  reach an unresolved composition. Ordinary externally supplied className values
287
287
  remain open inputs, not guaranteed safe styles. Depth, work and alternative
288
- limits keep source inspection bounded; an unreported path or an empty warning
288
+ limits keep source inspection bounded; an unreported path or an empty review
289
289
  list does not establish visual correctness. Actual failed registered
290
290
  browser/behavior checks remain blocking; potentially intentional source overlaps
291
- remain warnings.
291
+ remain review items.
@@ -7,8 +7,9 @@ that it stays complete; the project chooses the look.
7
7
 
8
8
  Change values in the existing token files, never names: `--accent`,
9
9
  `--font-sans`, `--radius-md` and the other shared roles keep their meaning across
10
- projects. `--brand-*` and other foreign prefixes fail checks. Theme variants
11
- redefine the same names under `:root[data-theme="dark"]`. Components read shared
10
+ projects. `--brand-*` and other foreign prefixes fail checks. A value that differs per
11
+ theme is written as halves (`--color-accent-9-light`, `--color-accent-9-dark`), and a
12
+ second brand re-sets halves on `[data-brand]` (`ads://guides/tokens`). Components read shared
12
13
  roles, so a brand change is a token change.
13
14
 
14
15
  ## Artwork
@@ -17,13 +18,16 @@ Keep every original SVG in `assets/brand/`. Fixed colors are allowed inside the
17
18
  artwork; component styles still use tokens.
18
19
 
19
20
  - **Document it.** `assets/brand/README.md` names each file, what it is for, the
20
- backgrounds it suits, its credits and its license. `ads check` warns about an
21
+ backgrounds it suits, its credits and its license. `ads check` fails on an
21
22
  undescribed file (`brand-readme`) and a README without a license
22
23
  (`brand-license`).
23
24
  - **Pair light and dark variants by name.** `logo.svg` is the default (light
24
25
  theme); `logo.dark.svg` is the same artwork for dark backgrounds. The component
25
- that shows it renders both and hides one with a `:root[data-theme="dark"] &`
26
- selector, so the theme switch needs no script.
26
+ that shows it renders both and shows each in its own theme with the generated display
27
+ switches: `display: var(--display-light, block)` on the light one and
28
+ `display: var(--display-dark, block)` on the dark one. They follow the nearest
29
+ `data-theme`, so a dark section shows the dark logo; a brand's own logo uses
30
+ `--display-brand-<brand>` the same way.
27
31
  - **Show it in a component.** A logo appears in the UI through a project
28
32
  component (the starter's `components/Content/Logo`) that imports the SVG with
29
33
  `?url`. Artwork that nothing uses is reported (`brand-unused`).
@@ -43,6 +47,24 @@ app icon of 1024 px); ADS never enlarges it. A finished icon file is only copied
43
47
  Prefer SVG masters when they exist; take finished images as delivered when that
44
48
  is what the brand provides.
45
49
 
50
+ ## Pictograms and illustrations
51
+
52
+ Pictograms are illustrations for empty states, onboarding and marketing surfaces, not UI
53
+ icons: never use one as an icon, a logo or a header lockup, and never use a UI glyph as an
54
+ illustration. Keep them as brand artwork in `assets/brand/pictograms/`, so the brand
55
+ checks (README, license, preview, use) cover them, and preview them in a `brand/Pictograms`
56
+ group.
57
+
58
+ - Show them at 48 px or larger, at their original proportions; never crop or stretch them.
59
+ - Keep clear space of at least a quarter of their size on every side, with or without a
60
+ container. Containers are a circle or a square only, with the pictogram optically
61
+ centered.
62
+ - Pair light and dark versions as `<name>.svg` and `<name>.dark.svg`, and show the one that
63
+ matches the background: light artwork on light surfaces, dark on dark. Avoid mid-tone
64
+ backgrounds and gradients behind them.
65
+ - A pictogram that carries meaning needs a text alternative; one that repeats nearby text is
66
+ decorative (`alt=""`).
67
+
46
68
  ## Web icons
47
69
 
48
70
  Set one square master as `assets.iconSource`: an SVG, or a square PNG, JPEG or WebP
@@ -101,4 +123,37 @@ Each file becomes `glyphs[name]` with `attributes` added where its `<svg>` does
101
123
  set them. `aliases.json` in the folder maps extra names to existing glyphs
102
124
  (`glyphAliases`); a file named like an alias is skipped. `ads assets` writes the
103
125
  module; `ads check` fails (`brand-output-stale`) when it is out of date. The icon
104
- component and its catalogue scenario read `glyphs` and `glyphAliases`.
126
+ component reads `glyphs` and `glyphAliases`. Review the set in the showcase's **Icons**
127
+ tab: every glyph at the size used beside text, so an outlier in weight or size stands out,
128
+ and each glyph on its grid at every icon size with its aliases and errors. Check a new or
129
+ redrawn glyph there before committing it.
130
+
131
+ Keep every glyph on one `viewBox` (the starter uses 24 × 24) and draw in `currentColor`:
132
+ `ads check` fails on a different or missing viewBox (`glyph-viewbox`) and fixed fill or
133
+ stroke colors (`glyph-color`). Other products' logos keep their own colors: keep them in
134
+ `assets/logos/` (see [Other products' logos](#other-products-logos)), not in the glyph set. The starter's `Icon` sizes glyphs with `--icon-sm/md/lg/xl`
135
+ (16/20/24/32 px; 16 beside body text), centers them beside text and hides decorative ones
136
+ from assistive technology; `label` names a meaningful one. Icons have no states of their
137
+ own: interactive icons go in `IconButton`, whose required `label` is its accessible name
138
+ and tooltip and whose background carries hover, pressed and disabled. `a11y-icon-label`
139
+ fails on icon-only buttons and links without a name.
140
+
141
+ ## Other products' logos
142
+
143
+ Logos of other products (a chat service, a model provider, a sign-in provider) are
144
+ not the project's brand and not UI icons. Keep them in `assets/logos/`, each in the
145
+ colors its owner publishes, with a `README.md` that names each file, its source and
146
+ the usage terms it is used under. Their owners' trademark and usage guidelines
147
+ apply: use the official artwork, keep its colors and proportions, and do not change
148
+ it to match the project's look.
149
+
150
+ Show them as images: import the file with `?url` and render an `<img>` with an
151
+ `alt` that names the product, or `alt=""` beside text that already names it. Where
152
+ the logo must follow the text color (a muted or monochrome use), use the file as a
153
+ CSS mask over `currentColor`, so its shape stays and the color follows the theme.
154
+
155
+ ADS generates nothing from `assets/logos/` and does not treat its files as brand
156
+ artwork or glyphs: the brand checks (`brand-readme`, `brand-preview`,
157
+ `brand-unused`), `assets.iconSource` and `assets.targets` cover only
158
+ `assets/brand/`, and the glyph checks cover only `assets.glyphs.source`. Keep the
159
+ project's own colored artwork, including its pictograms, in `assets/brand/`.
@@ -23,8 +23,9 @@ ads_capture({
23
23
  })
24
24
  ```
25
25
 
26
- The ID above is illustrative; use one returned by discovery. The default is light
27
- theme at 1280 × 800 CSS pixels. Capture uses the real sandboxed MCP App with the
26
+ The ID above is illustrative; use one returned by discovery. `theme` names one of the
27
+ project's declared themes (`ads_status.themes`); the default is the first declared theme at
28
+ 1280 × 800 CSS pixels. Capture uses the real sandboxed MCP App with the
28
29
  requested viewport and excludes showcase navigation. The default image records
29
30
  the complete widget viewport, including its current scroll/state; it does not
30
31
  automatically stitch every scroll position into one image.
@@ -90,14 +90,20 @@ For an initialized project, from its root:
90
90
  npx @reqvire-org/ads check
91
91
  npx @reqvire-org/ads tokens --json
92
92
  npx @reqvire-org/ads assets
93
+ npx @reqvire-org/ads audit
93
94
  ```
94
95
 
95
96
  Use the selected real distribution; for a local tarball, invoke
96
97
  `npx --yes --package "$ads_tool_package" ads check` instead. Other inspection
97
98
  commands accept a directory; init deliberately does not.
98
99
 
99
- Normal builds run native `ads check`, then generate configured standard brand
100
- icons in `.ds/assets/`. Set `assets.iconSource` to an SVG inside the ADS's
100
+ Normal builds run native `ads check`, then `ads assets`: configured standard brand
101
+ icons in `.ds/assets/`, committed `assets.targets`, the `assets.glyphs` module and the
102
+ generated `tokens/themes.generated.css` and `tokens/themes.generated.ts`. Run `ads
103
+ assets` after editing tokens or `ds.config.json` themes and brands without a running
104
+ showcase or MCP server (`themes-generated` fails while they are stale). `ads audit`
105
+ runs axe-core in every rendered UI scenario (`a11y-axe` errors; see
106
+ ads://guides/accessibility). Set `assets.iconSource` to an SVG inside the ADS's
101
107
  `assets/brand/`, relative to the ADS folder; no source means generation is a no-op.
102
108
  Integrate that directory through the app's existing asset mount. Fixed token
103
109
  names and prefixes are required; project values and artwork remain project-owned.
@@ -154,11 +154,14 @@ valueFrom: ["paint", "scheme.day", "scheme.night"],
154
154
  ```
155
155
 
156
156
  Register each matching `config.*.<path>` in `paintInputs`. The producer may write
157
- one declared field, or an exact `light-dark(${entry.scheme.day}, ${entry.scheme.night})`
158
- template over two declared fields. The normal key/map/root proof still applies.
159
- Raw constants, undeclared fields, extra writes and unknown transforms are rejected.
160
- The browser audit checks actual accessible color references in both branches;
161
- a local SVG URL or `none` is not a CSS color inside `light-dark()`.
157
+ one declared field, or a per-theme value built with the generated helpers from
158
+ `tokens/themes.generated.ts`: `themed({ light: entry.scheme.day, dark: entry.scheme.night })`
159
+ (keys exactly the declared themes) or `themedByScheme({ light: …, dark: … })` (each theme
160
+ takes the value for its color scheme). Every value is a declared field and the argument is
161
+ an object literal without spreads. The normal key/map/root proof still applies. Raw
162
+ constants, undeclared fields, `light-dark()`, extra writes and unknown transforms are
163
+ rejected. The browser audit checks an accessible color reference in every theme's branch;
164
+ a local SVG URL or `none` is not a color there.
162
165
 
163
166
  Families cannot overlap shared tokens, private runtime
164
167
  prefixes or other bindings. A broad family such as `--color-${key}` grants no
@@ -167,12 +170,12 @@ cannot be established. Registered paint consumers list their allowed binding IDs
167
170
  borrowing a peer's binding family or private runtime variable remains invalid. Bindings are scoped
168
171
  to their actual root; portals outside it need deliberate project integration.
169
172
 
170
- A registered binding producer may combine two accessible color references as
171
- `light-dark(var(--light-token), var(--dark-token))`. The App paint audit checks
172
- both branches and their observed effect in the active color scheme. Raw colors,
173
- undefined tokens and SVG URLs inside this color function remain invalid.
173
+ A registered binding producer gives a per-theme value with `themed()` or
174
+ `themedByScheme()`; its output is `var(--ads-if-<theme>, <reference>)` once per declared
175
+ theme, in declared order. The App paint audit checks every branch and its observed effect
176
+ in the active theme. Raw colors, undefined tokens and SVG URLs in a branch remain invalid.
174
177
  This derived binding form does not widen public paint-input types; use constrained
175
- references for each theme input and verify both color schemes in browser checks.
178
+ references for each theme input and verify every theme in browser checks.
176
179
 
177
180
  The App audit checks current mounted instances, accessible values, local SVG
178
181
  resources and computed paint-property responses. Visibility and complete rendered
@@ -74,7 +74,7 @@ Review that intent and do not disguise a new design decision as arithmetic.
74
74
 
75
75
  ## Review overlap without deleting legitimate roles
76
76
 
77
- `token-overlap-review` is a nonblocking warning for shared tokens with identical
77
+ `token-overlap-review` is a nonblocking review item for shared tokens with identical
78
78
  normalized definitions across their declared theme/condition scopes. It identifies
79
79
  the tokens and source. Inspect their consumers and roles. If one decision is being
80
80
  copied, reuse one shared token or make its relationship explicit with an alias.
@@ -82,10 +82,207 @@ Equal values alone do not prove equal purpose: body text and strong text, spacin
82
82
  and control sizes, or two motion roles may intentionally differ later. A light-only
83
83
  match does not justify merging tokens whose dark/reduced-motion values differ.
84
84
 
85
- For our existing workspaces, convert independent component constants explicitly:
85
+ For existing workspaces, convert independent component constants explicitly:
86
86
  select an existing shared role when it means the same thing; centralize genuinely
87
87
  missing decisions; remove private sheets/imports and contract fields; update token
88
88
  sample coverage in the shared directory. Preserve themes, units, public APIs and
89
89
  behavior unless changing the visual policy was explicitly intended. Review a Git
90
90
  diff and run core, project and browser checks. There is no compatibility mode that
91
91
  keeps independent component token definitions valid.
92
+
93
+ ## Accessibility and rhythm checks
94
+
95
+ `ads check` checks token values in every theme and brand. Each finding below is an error:
96
+
97
+ - `token-contrast`: the roles that meet on screen fall below WCAG 2.2 AA: `--text-strong`,
98
+ `--text-body`, `--text-muted`, `--text-link` and `--accent-text` on `--bg-canvas`,
99
+ `--bg-surface` and `--bg-hover`; `--accent-fg` on `--accent` and `--accent-hover`; each
100
+ status's `-fg` on its solid and `-text` on its `-bg` (4.5:1); `--border-focus` and
101
+ `--border-strong` on the canvas and surface (3:1). Fix it by choosing a different ramp
102
+ step for the role, in the theme the message names, never with a one-off color.
103
+ - `token-rhythm`: a numbered spacing step leaves the scale `--space-N` = N × 2 px.
104
+ - `control-padding`: pad a control with the token for its size. A block sized with
105
+ `--control-height-<size>` pads its sides with `--control-padding-<size>`; the small gap
106
+ inside a track (segmented control, switch) uses `--control-inset` (add it to the spacing
107
+ tokens if the project has none). Anything that is not a control does not use
108
+ `--control-height-*`.
109
+
110
+ `token-overlap-review` (review) compares values only within a token family (`--radius-*`
111
+ with `--radius-*`): a radius equal to a spacing step is two scales meeting, not a duplicate.
112
+
113
+ ## Exchange format
114
+
115
+ `ads tokens --format dtcg` prints the tokens as W3C Design Tokens (Community Group draft)
116
+ JSON: groups by family, typed `$value`s, `{group.token}` references for `var()` aliases.
117
+ Values the format cannot express (fluid `clamp()` sizes, layered shadows) keep their CSS in
118
+ `$extensions["org.reqvire.ads"].css`; other themes' values are in
119
+ `$extensions["org.reqvire.ads"].scopes`.
120
+
121
+ ## Grid
122
+
123
+ The `--grid-*` tokens describe a column grid: `--grid-columns-sm/md/lg` (the starter's 4, 8
124
+ and 16), `--grid-gutter`, `--grid-gutter-narrow`, `--grid-gutter-condensed` and
125
+ `--grid-margin-sm/md/lg`, aliasing spacing steps. The starter's `Grid` switches columns by
126
+ container width (768 and 1024 px) with container queries, since CSS variables cannot be
127
+ breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
128
+ widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
129
+
130
+ ## Color roles and states
131
+
132
+ Name roles by element and purpose, the same in every theme; only their values change. Point roles at ramp steps rather than raw colors, so a theme is a ramp swap:
133
+
134
+ - Layers: `--bg-canvas` → `--bg-surface` → `--bg-raised` (menus, popovers), with `--bg-field`
135
+ for inputs. In dark themes each layer up is one step lighter; in light themes surfaces stay
136
+ near white.
137
+ - States move along the ramp: hover one step, pressed or active two, selected a subtle accent
138
+ step (`--bg-selected`). Solid fills hover one step darker (`--accent-hover`).
139
+ - Disabled is always neutral (`--bg-disabled`, `--text-disabled`, `--border-disabled`) with no
140
+ hover or focus response; WCAG exempts it from contrast, so `token-contrast` skips it.
141
+ - `--bg-overlay` is the translucent scrim behind modals; `--bg-skeleton` fills loading
142
+ placeholders.
143
+ - Never signal state or status by color alone: pair it with text, an icon or a shape.
144
+
145
+ ## Themes
146
+
147
+ Declare themes in `ds.config.json` (`themes: [{ name, scheme }]`, the first is the default;
148
+ `scheme` sets `color-scheme` for native controls and scrollbars).
149
+
150
+ Write a token that differs per theme as one half per theme, named with the theme as suffix,
151
+ on `:root`:
152
+
153
+ ```css
154
+ :root {
155
+ --color-accent-9-light: oklch(55% .2 280);
156
+ --color-accent-9-dark: oklch(70% .16 280);
157
+ --bg-canvas-light: var(--slate-1-light);
158
+ --bg-canvas-dark: var(--slate-2-dark);
159
+ --accent: var(--color-accent-9);
160
+ }
161
+ ```
162
+
163
+ - A half is a plain value or refers to halves: `--text-muted-dark: var(--slate-11-dark)`,
164
+ never `var(--slate-11)` (`theme-half-reference`).
165
+ - Give every themed token a half for every declared theme (`theme-coverage`). Tokens that do
166
+ not change per theme stay single values; a role that aliases a ramp step
167
+ (`--accent: var(--color-accent-9)`) needs no halves.
168
+ - Never set token values under `[data-theme]` or `prefers-color-scheme` (`theme-old-form`),
169
+ and never set a token both as one value and as halves (`theme-half-conflict`).
170
+ - ADS writes `tokens/themes.generated.css` from the halves and the declared themes and
171
+ brands: `ads assets` writes it, and the showcase and MCP server rewrite it whenever tokens
172
+ or `ds.config.json` change. Commit it, never edit it; it is the last foundation import.
173
+ After editing tokens without a running showcase, run `ads assets` (`themes-generated`
174
+ fails when it is stale).
175
+ - `data-theme="<name>"` on `<html>` themes the page; on any element it themes that section
176
+ and everything inside it, down to the next `data-theme`. A themed section paints its own
177
+ canvas and text (`base.css`).
178
+ - Add a theme for a real need: high contrast, a dimmed reading mode. Add a half for it to
179
+ every themed token. Check a theme in the showcase (the theme button steps through declared
180
+ themes) and capture it by name.
181
+ - Show content that belongs to one theme (a dark logo variant) with the generated display
182
+ switch: `display: var(--display-dark, block)`. It is `none` outside the nearest dark
183
+ theme. Never style by theme or brand with a selector (`[data-theme="dark"] &`,
184
+ `:root[data-brand] &`): it ignores the nearest section (`theme-selector`). Give per-theme
185
+ values as token halves instead.
186
+ - A per-theme value that comes from data at runtime (a chart series color, a highlighter
187
+ color) uses the generated helpers, never `light-dark()` (`theme-light-dark`):
188
+ `style={{ "--series": themed({ light: a, dark: b }) }}` with every declared theme as a key,
189
+ or `themedByScheme({ light: a, dark: b })` when the data has only light and dark (each
190
+ theme takes the value for its scheme). Values are complete colors.
191
+ - To follow the OS setting, set `"followSystemTheme": true` in `ds.config.json`: a page
192
+ without `data-theme` takes the first declared theme whose scheme matches
193
+ `prefers-color-scheme`. An explicit `data-theme` always wins. Letting the user choose and
194
+ remembering it is application code: it sets `data-theme`.
195
+
196
+ ## Brands
197
+
198
+ A brand is a second axis beside the theme: the theme sets the color mode, the brand sets
199
+ identity (an accent ramp, a font). Use brands for white label (one product, each customer's
200
+ accent, font and logo, each in light and dark), a product family, or a co-branded partner
201
+ section; without them every combination becomes a theme (`acme-light`, `acme-dark`, …).
202
+
203
+ Declare brands in `ds.config.json` (`brands: [{ name }]`, the first is the default; leave
204
+ `brands` out for one brand). The default brand's values are the ones on `:root`. Another
205
+ brand re-sets existing tokens on its own selector only, with every half of a themed token it
206
+ changes:
207
+
208
+ ```css
209
+ [data-brand="acme"] {
210
+ --color-accent-9-light: oklch(55% .2 25);
211
+ --color-accent-9-dark: oklch(70% .16 25);
212
+ --font-sans: Georgia, serif;
213
+ }
214
+ ```
215
+
216
+ - `data-brand="<name>"` on `<html>` brands the page; on any element that section. Brand and
217
+ theme are independent: each element takes its nearest brand and its nearest theme, at any
218
+ nesting depth, including the default brand inside another brand's section.
219
+ - Errors: a brand that gives a themed token one value (`brand-theme-value`) or only some of
220
+ its halves or ramp steps (`brand-coverage`), a token only a brand defines
221
+ (`brand-new-token`), a declared brand without values (`brand-empty`), a `data-brand` name
222
+ the config does not declare (`brand-undeclared`). `token-contrast` runs for every brand
223
+ in every theme.
224
+ - A brand's logo is brand artwork (`ads://guides/branding`). Render every brand's logo and
225
+ show each with `display: var(--display-brand-<brand>, block)`, so a section shows its
226
+ nearest brand's logo.
227
+ - The showcase shows a brand selector next to the theme button; captures take `brand`;
228
+ `ads tokens --format dtcg --brand <name>` exports a brand (with `--theme`, one brand in
229
+ one theme).
230
+
231
+ ## Colors in Canvas, WebGL and SVG renderers
232
+
233
+ A renderer that needs colors as values (a graph, a chart, a canvas) reads them from the
234
+ generated palette, never from the page per item. `tokens/themes.generated.ts` holds every
235
+ color token resolved for every context (`<theme>`, and `<brand>/<theme>` for other brands)
236
+ as `{ css, rgba }`: `css` is `#rrggbb`, or `rgba(…)` when translucent; `rgba` is sRGB
237
+ 0–255 with alpha 0–1. Aliases, halves and `color-mix()` are resolved; out-of-gamut colors
238
+ are clipped per channel, as a canvas does. ADS writes it with `themes.generated.css`.
239
+
240
+ ```ts
241
+ import { paletteFor, observePalette } from "@ds";
242
+
243
+ let colors = paletteFor(container); // once per render pass
244
+ const fill = colors["--accent"].rgba; // inside the per-node loop
245
+ const stop = observePalette(container, next => { colors = next; redraw(); });
246
+ ```
247
+
248
+ - `paletteFor(element)` returns the palette of the element's nearest theme and brand (and
249
+ the OS setting under `followSystemTheme`). Call it once per render or context change; look
250
+ colors up inside loops.
251
+ - `observePalette(element, callback)` calls back once when the element's theme or brand
252
+ changes; redraw from it instead of rebuilding the renderer. It returns the unsubscribe.
253
+ - `paletteContext(element)` returns the context key (`<theme>` or `<brand>/<theme>`) for
254
+ `palette[key]` or for caching per context.
255
+ - `resolveColor(element, value)` resolves a color that is not a palette token (currentColor,
256
+ a value from data) once, without inserting elements, and caches it.
257
+ - A token whose value cannot be resolved ahead of time (currentColor, relative color syntax,
258
+ system colors) is not in the palette in any context; `unresolved` lists it. Use
259
+ `resolveColor` for those.
260
+ - The palette reflects token sheets, not inline token overrides at runtime or `@media`
261
+ variants.
262
+
263
+ `render-color-probe` (review) flags a computed-style color read or `getImageData` inside a
264
+ per-item path (an array callback, a loop body, `nodeReducer`/`edgeReducer`, d3 `.attr`/
265
+ `.style` callbacks). Move the read out with `paletteFor`.
266
+
267
+ ## Spacing
268
+
269
+ `--space-N` is N × 2 px, from 2 to 160 px; the same values hold at every screen size, and a
270
+ layout steps down one or two sizes at narrow widths instead of scaling. Use the scale for
271
+ padding inside components and for gaps between them; a value off the scale needs a reason.
272
+
273
+ - Distance says how related things are: closer means more related. Group with space before
274
+ reaching for dividers, borders or cards.
275
+ - More space around an element gives it more importance. Sections can be dense, but leave the
276
+ page as a whole room to breathe.
277
+ - Parents own the space between their children (`gap`, stack tokens); a component carries no
278
+ outer margin, so it fits wherever it is placed.
279
+ - Horizontal layout follows the column grid; percentages are fine for splitting a region and
280
+ for minimum and maximum widths.
281
+
282
+ ## Motion tokens
283
+
284
+ Six durations (`--dur-instant` 70 ms, `--dur-fast` 110, `--dur-moderate` 150, `--dur-normal`
285
+ 240, `--dur-slow` 400, `--dur-slower` 700) and three curve pairs (standard, enter and exit, each everyday and
286
+ `-strong`). Every duration is 0 under `prefers-reduced-motion`. Pick by purpose, not by
287
+ number: the ads-motion skill's build guide maps each token to its use and gives the easing
288
+ rules.