@tjakoen/grain 0.1.12

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 (181) hide show
  1. package/LICENSE +202 -0
  2. package/PLAN.md +27 -0
  3. package/README.md +243 -0
  4. package/ai/accepts.test.ts +69 -0
  5. package/ai/accepts.ts +57 -0
  6. package/ai/ai.css +127 -0
  7. package/ai/client-door.test.ts +70 -0
  8. package/ai/client-door.ts +56 -0
  9. package/ai/contract.test.ts +158 -0
  10. package/ai/contract.ts +285 -0
  11. package/ai/interaction-layer.test.ts +270 -0
  12. package/ai/interaction-layer.ts +138 -0
  13. package/ai/manifest-dom.test.ts +176 -0
  14. package/ai/manifest-dom.ts +187 -0
  15. package/ai/manifest.test.ts +71 -0
  16. package/ai/manifest.ts +57 -0
  17. package/ai/markdown.test.ts +68 -0
  18. package/ai/markdown.ts +74 -0
  19. package/ai/model-chat.test.ts +131 -0
  20. package/ai/model-chat.ts +151 -0
  21. package/ai/model-reasoner.test.ts +152 -0
  22. package/ai/model-reasoner.ts +146 -0
  23. package/ai/model.test.ts +148 -0
  24. package/ai/model.ts +200 -0
  25. package/ai/reasoner-kit.test.ts +142 -0
  26. package/ai/reasoner-kit.ts +159 -0
  27. package/ai/reasoner.test.ts +227 -0
  28. package/ai/reasoner.ts +446 -0
  29. package/ai/timeline-log.test.ts +55 -0
  30. package/ai/timeline-log.ts +50 -0
  31. package/ai/vocab-reference.test.ts +43 -0
  32. package/ai/vocab-reference.ts +107 -0
  33. package/ai/webllm.test.ts +79 -0
  34. package/ai/webllm.ts +125 -0
  35. package/assets/figure-sample.svg +14 -0
  36. package/assets/sprite.svg +22 -0
  37. package/catalog/catalog.test.ts +37 -0
  38. package/catalog/catalog.ts +424 -0
  39. package/components/atoms/action-badge/action-badge.css +17 -0
  40. package/components/atoms/action-badge/action-badge.html +6 -0
  41. package/components/atoms/action-badge/action-badge.md +23 -0
  42. package/components/atoms/b-badge/b-badge.css +15 -0
  43. package/components/atoms/b-badge/b-badge.html +2 -0
  44. package/components/atoms/b-badge/b-badge.md +16 -0
  45. package/components/atoms/b-button/b-button.ai.md +22 -0
  46. package/components/atoms/b-button/b-button.css +87 -0
  47. package/components/atoms/b-button/b-button.html +5 -0
  48. package/components/atoms/b-button/b-button.md +77 -0
  49. package/components/atoms/b-icon/b-icon.css +10 -0
  50. package/components/atoms/b-icon/b-icon.html +5 -0
  51. package/components/atoms/b-icon/b-icon.md +36 -0
  52. package/components/atoms/b-icon-button/b-icon-button.ai.md +11 -0
  53. package/components/atoms/b-icon-button/b-icon-button.css +43 -0
  54. package/components/atoms/b-icon-button/b-icon-button.html +8 -0
  55. package/components/atoms/b-icon-button/b-icon-button.md +33 -0
  56. package/components/atoms/b-input/b-input.css +36 -0
  57. package/components/atoms/b-input/b-input.html +8 -0
  58. package/components/atoms/b-input/b-input.md +59 -0
  59. package/components/atoms/b-kbd/b-kbd.css +11 -0
  60. package/components/atoms/b-kbd/b-kbd.html +3 -0
  61. package/components/atoms/b-kbd/b-kbd.md +13 -0
  62. package/components/atoms/b-list/b-list.css +21 -0
  63. package/components/atoms/b-list/b-list.html +6 -0
  64. package/components/atoms/b-list/b-list.md +24 -0
  65. package/components/atoms/b-meter/b-meter.css +39 -0
  66. package/components/atoms/b-meter/b-meter.md +44 -0
  67. package/components/atoms/b-select/b-select.css +35 -0
  68. package/components/atoms/b-select/b-select.md +75 -0
  69. package/components/atoms/b-switch/b-switch.css +61 -0
  70. package/components/atoms/b-switch/b-switch.html +6 -0
  71. package/components/atoms/b-switch/b-switch.md +40 -0
  72. package/components/atoms/b-text/b-text.ai.md +29 -0
  73. package/components/atoms/b-text/b-text.css +2 -0
  74. package/components/atoms/b-text/b-text.html +3 -0
  75. package/components/atoms/b-text/b-text.md +23 -0
  76. package/components/atoms/code-block/code-block.css +42 -0
  77. package/components/atoms/code-block/code-block.md +23 -0
  78. package/components/examples.test.ts +23 -0
  79. package/components/molecules/callout/callout.css +19 -0
  80. package/components/molecules/callout/callout.md +15 -0
  81. package/components/molecules/card/card.css +28 -0
  82. package/components/molecules/card/card.md +30 -0
  83. package/components/molecules/chat-message/chat-message.css +83 -0
  84. package/components/molecules/chat-message/chat-message.md +52 -0
  85. package/components/molecules/chip-group/chip-group.css +35 -0
  86. package/components/molecules/chip-group/chip-group.md +42 -0
  87. package/components/molecules/content-index/content-index.css +87 -0
  88. package/components/molecules/content-index/content-index.md +27 -0
  89. package/components/molecules/content-source/content-source.css +6 -0
  90. package/components/molecules/content-source/content-source.md +13 -0
  91. package/components/molecules/figure/figure.css +19 -0
  92. package/components/molecules/figure/figure.md +20 -0
  93. package/components/molecules/lede/lede.css +17 -0
  94. package/components/molecules/lede/lede.md +17 -0
  95. package/components/molecules/made-with/made-with.css +25 -0
  96. package/components/molecules/made-with/made-with.md +35 -0
  97. package/components/molecules/nav-item/nav-item.css +19 -0
  98. package/components/molecules/nav-item/nav-item.md +21 -0
  99. package/components/molecules/stat-tile/stat-tile.css +34 -0
  100. package/components/molecules/stat-tile/stat-tile.md +50 -0
  101. package/components/molecules/status-list/status-list.css +47 -0
  102. package/components/molecules/status-list/status-list.md +62 -0
  103. package/components/molecules/tab/tab.css +32 -0
  104. package/components/molecules/tab/tab.md +27 -0
  105. package/components/molecules/table/table.css +23 -0
  106. package/components/molecules/table/table.md +18 -0
  107. package/components/organisms/activity-bar/activity-bar.css +36 -0
  108. package/components/organisms/activity-bar/activity-bar.md +43 -0
  109. package/components/organisms/app-shell/app-shell.css +193 -0
  110. package/components/organisms/app-shell/app-shell.md +58 -0
  111. package/components/organisms/app-shell/app-shell.test.ts +74 -0
  112. package/components/organisms/app-window/app-window.css +111 -0
  113. package/components/organisms/app-window/app-window.md +53 -0
  114. package/components/organisms/chat-log/chat-log.css +5 -0
  115. package/components/organisms/chat-log/chat-log.md +14 -0
  116. package/components/organisms/code-editor/code-editor.ai.md +31 -0
  117. package/components/organisms/code-editor/code-editor.css +111 -0
  118. package/components/organisms/code-editor/code-editor.md +122 -0
  119. package/components/organisms/console/console.css +112 -0
  120. package/components/organisms/console/console.md +66 -0
  121. package/components/organisms/file-tree/file-tree.css +85 -0
  122. package/components/organisms/file-tree/file-tree.md +49 -0
  123. package/components/organisms/note/note.css +19 -0
  124. package/components/organisms/note/note.md +20 -0
  125. package/components/organisms/notepad/notepad.css +60 -0
  126. package/components/organisms/notepad/notepad.md +40 -0
  127. package/components/organisms/side-rail/side-rail.css +55 -0
  128. package/components/organisms/side-rail/side-rail.md +24 -0
  129. package/components/organisms/sidebar-panel/sidebar-panel.css +69 -0
  130. package/components/organisms/sidebar-panel/sidebar-panel.md +47 -0
  131. package/components/organisms/status-bar/status-bar.css +33 -0
  132. package/components/organisms/status-bar/status-bar.md +28 -0
  133. package/components/organisms/tab-bar/tab-bar.css +48 -0
  134. package/components/organisms/tab-bar/tab-bar.md +26 -0
  135. package/components/organisms/timeline/timeline.css +51 -0
  136. package/components/organisms/timeline/timeline.md +42 -0
  137. package/components/organisms/topbar/topbar.css +8 -0
  138. package/components/organisms/topbar/topbar.md +26 -0
  139. package/components/responsive-polish.test.ts +43 -0
  140. package/components/tokens.test.ts +39 -0
  141. package/fonts/redaction-35-400.woff2 +0 -0
  142. package/fonts/redaction-400.woff2 +0 -0
  143. package/fonts/redaction-50-400.woff2 +0 -0
  144. package/fonts/redaction-70-400.woff2 +0 -0
  145. package/package.json +46 -0
  146. package/scripts/ai-dispatch.js +583 -0
  147. package/scripts/ai-dispatch.test.ts +85 -0
  148. package/scripts/ai-spotlight.d.ts +23 -0
  149. package/scripts/ai-spotlight.js +139 -0
  150. package/scripts/ai-spotlight.test.ts +31 -0
  151. package/scripts/catalog-peek.js +156 -0
  152. package/scripts/catalog-peek.test.ts +31 -0
  153. package/scripts/cmdk.js +159 -0
  154. package/scripts/demo-box.js +53 -0
  155. package/scripts/handoff.js +64 -0
  156. package/scripts/handoff.test.ts +36 -0
  157. package/scripts/lightbox.js +144 -0
  158. package/scripts/lightbox.test.ts +23 -0
  159. package/scripts/made-with.d.ts +2 -0
  160. package/scripts/made-with.js +22 -0
  161. package/scripts/made-with.test.ts +25 -0
  162. package/scripts/notepad.js +100 -0
  163. package/scripts/shell.js +204 -0
  164. package/scripts/shell.test.ts +50 -0
  165. package/scripts/tabs.js +127 -0
  166. package/scripts/tabs.test.ts +40 -0
  167. package/scripts/terminal.js +271 -0
  168. package/scripts/terminal.test.ts +36 -0
  169. package/scripts/theme-boot.js +15 -0
  170. package/scripts/theme.js +87 -0
  171. package/scripts/type-effect.js +25 -0
  172. package/scripts/xray.js +79 -0
  173. package/scripts/xray.test.ts +43 -0
  174. package/styles/cmdk.css +65 -0
  175. package/styles/global.css +80 -0
  176. package/styles/grain.css +47 -0
  177. package/styles/lightbox.css +78 -0
  178. package/styles/themes/_template.css +48 -0
  179. package/styles/themes/baguette.css +30 -0
  180. package/styles/themes/brioche.css +30 -0
  181. package/styles/variables.css +217 -0
@@ -0,0 +1,80 @@
1
+ /* grain/styles/global.css — GRAIN's base/skin: reset, paper, base layout, masthead.
2
+ The grade-as-signal MECHANISM is the sibling grain.css; the token VALUES live in
3
+ variables.css. The three are linked together as GRAIN's default theme. */
4
+
5
+ /* Cross-document (MPA) view transitions: a slow fade fits e-ink; bouncy easing
6
+ would break the spell (DESIGN-SYSTEM §6). */
7
+ @view-transition { navigation: auto; }
8
+ @media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
9
+ ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.3s; }
10
+
11
+ * { box-sizing: border-box; }
12
+
13
+ /* Smooth programmatic scrolling owned by CSS in ONE place — the AI spotlight just calls
14
+ scrollIntoview() with no behavior, and this decides (honoring reduced-motion). */
15
+ html { scroll-behavior: smooth; }
16
+ @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
17
+
18
+ body {
19
+ font: var(--font-base);
20
+ color: var(--color-fg);
21
+ background: var(--paper);
22
+ margin: 0;
23
+ -webkit-font-smoothing: antialiased;
24
+ text-rendering: optimizeLegibility;
25
+ }
26
+
27
+ /* ---- Paper grain (DESIGN-SYSTEM §6): one fixed full-screen SVG turbulence layer,
28
+ multiply-blended so it darkens the surface like fibre. Covers everything. */
29
+ body::before {
30
+ content: "";
31
+ position: fixed; inset: 0; z-index: 9999;
32
+ pointer-events: none;
33
+ mix-blend-mode: multiply;
34
+ opacity: var(--paper-grain-opacity);
35
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
36
+ }
37
+
38
+ /* ---- Layout: one left-aligned column, generous air (DESIGN-SYSTEM §4/§7) ---- */
39
+ .container { max-width: var(--content-max); margin: var(--space-8) auto; padding: 0 var(--page-pad); }
40
+ /* .board is the SAME reading-column treatment as .container, for content composed inside the
41
+ app-shell's __main pane (portfolio pages + MILL-rendered docs/notes — content.ts, mill/serve.ts).
42
+ Kept as a separate name (not a .container alias) since it lives inside a shell pane, not a bare
43
+ page body — but must carry the identical padding, or MILL content renders flush to the edge. */
44
+ .board { max-width: var(--content-max); margin: var(--space-8) auto; padding: 0 var(--page-pad); }
45
+ h1, h2, h3 { font-weight: var(--font-weight-regular); letter-spacing: -0.01em; text-wrap: balance; }
46
+ p { margin: 0 0 var(--space-4); text-wrap: pretty; } /* no orphans/ragged breaks — no JS */
47
+
48
+ /* ---- Masthead (DESIGN-SYSTEM §5): eyebrow → display headline → hairline rule -- */
49
+ .eyebrow { font-size: var(--text-sm); color: var(--color-fg); margin: 0 0 var(--space-2); }
50
+ .eyebrow .name { text-decoration: underline; }
51
+ .masthead { font-size: var(--display); line-height: var(--leading-tight); letter-spacing: -0.01em; margin: 0 0 var(--space-3); }
52
+ .rule { border: 0; border-bottom: var(--rule); margin: 0 0 var(--space-6); }
53
+
54
+ /* ---- Section header: label left, underlined action right -------------------- */
55
+ .section-head {
56
+ display: flex; align-items: baseline; justify-content: space-between;
57
+ font-size: var(--text-xl); margin: var(--space-8) 0 var(--space-3);
58
+ }
59
+ .section-head .action { font-size: var(--text-sm); }
60
+
61
+ /* ---- Links: always underlined; the underline IS the affordance. Colour = the ONE accent
62
+ (hueless by default: accent = ink); an accented theme tints links with its signature hue. --- */
63
+ a { color: var(--color-accent); text-decoration: underline; text-underline-offset: 2px; }
64
+
65
+ /* ::selection — part of the accent's "full reach", kept SUBTLE: a low-alpha wash of the one accent
66
+ (text keeps its own colour, stays readable). Hueless by default (accent = ink → a quiet grey
67
+ tint); an accented theme tints the selection with its signature hue. */
68
+ ::selection { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
69
+
70
+ /* :focus-visible — the last of the accent's "full reach": keyboard focus draws a ring in the ONE
71
+ accent (hueless by default: accent = ink → an ink ring; an accented theme tints it with its
72
+ signature hue). Keyed off :focus-visible so pointer clicks stay quiet — only keyboard/AT users
73
+ see it. offset keeps it clear of the element's own edge/underline. */
74
+ :focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
75
+
76
+ /* form layout helper — a native <form> composed of atomic fields on a page */
77
+ .add-form { display: flex; gap: var(--space-2); align-items: flex-end; margin-bottom: var(--space-6); }
78
+
79
+ .muted { color: var(--color-muted); font-size: var(--text-sm); line-height: var(--leading-normal); }
80
+ .error { color: var(--color-fg); text-decoration: underline; } /* monochrome: no red */
@@ -0,0 +1,47 @@
1
+ /* grain/styles/grain.css — GRAIN's grade-as-signal MECHANISM (the inherited --type-font
2
+ switch + caret/settle). Reads token slots from variables.css (the default theme).
3
+ One of GRAIN's three page-level stylesheets, all LINKED (not bundled): variables.css
4
+ (tokens) → global.css (base/skin) → grain.css (this, the grade mechanism). The "AI is
5
+ acting" spotlight lives separately in the optional AI module, grain/ai/ai.css. */
6
+
7
+ /* ---- The typography atom: one inherited switch (DESIGN-SYSTEM §3) -----------
8
+ Every type primitive reads --type-font and knows nothing about grades. State
9
+ lives on ancestors; CSS inheritance distributes it. */
10
+ .t, h1, h2, h3, h4, h5, h6, p, li, label, button, input, textarea, a {
11
+ font-family: var(--type-font);
12
+ }
13
+ .is-ai, [data-grade="grain"] { --type-font: var(--font-grain); }
14
+ .is-human, [data-grade="smooth"] { --type-font: var(--font-smooth); }
15
+ [data-grade="accent"] { --type-font: var(--font-accent); }
16
+ /* An element that CARRIES a grade also renders in it — not only its covered descendants. So
17
+ data-grade works on any element (a bare <span>, a <div>), not just .t/p/li/h*. Children still
18
+ inherit and covered primitives still re-read --type-font, so nested grades keep working. */
19
+ [data-grade] { font-family: var(--type-font); }
20
+
21
+ /* a field is "yours, right now": draft (grain) at rest, clean while editing */
22
+ .field { --type-font: var(--font-grain); }
23
+ .field:focus-within { --type-font: var(--font-smooth); }
24
+
25
+ /* commit state == grade: anything the single writer hasn't committed reads grain
26
+ (in-transit), settling to clean on commit (AI-INTERFACE §5). */
27
+ [data-commit="pending"] { --type-font: var(--font-grain); }
28
+
29
+ /* ---- AI text + streaming (DESIGN-SYSTEM §3 "Typing / streaming") ------------- */
30
+ .ai-text { color: var(--color-fg); }
31
+ .caret {
32
+ display: inline-block; width: 0.5ch; margin-left: 1px;
33
+ border-right: 2px solid var(--color-fg);
34
+ animation: caret-blink 1s steps(1) infinite;
35
+ }
36
+ @keyframes caret-blink { 50% { opacity: 0; } }
37
+ .settled { animation: settle 0.5s ease both; } /* "fax developing into a clean page" */
38
+ @keyframes settle { from { opacity: 0.55; } to { opacity: 1; } }
39
+
40
+ @media (prefers-reduced-motion: reduce) {
41
+ .caret { animation: none; }
42
+ .settled { animation: none; }
43
+ }
44
+
45
+ /* NOTE: the "AI is acting" spotlight (dim/spotlit/label/confirm) is NOT here — it's in
46
+ the optional AI module, grain/ai/ai.css. This stylesheet is the design-system grade
47
+ mechanism alone, usable with no AI interface at all. */
@@ -0,0 +1,78 @@
1
+ /* grain/styles/lightbox.css — the image viewer modal (lightbox.js). Design tokens only,
2
+ no hardcoded colors. Native <dialog>: it owns the top-layer + ::backdrop, so no z-index
3
+ races and no scrim div. The dialog fills the viewport and centres the figure; the dark
4
+ gutter around the image IS the light-dismiss target. */
5
+ /* no `display` on the base rule: the UA hides a closed <dialog> with display:none, and setting a
6
+ display here would defeat that (the closed viewer would stay on screen). Layout goes on [open]. */
7
+ .lightbox {
8
+ width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
9
+ margin: 0; padding: 0; border: 0; background: transparent; color: var(--color-fg);
10
+ overflow: hidden;
11
+ opacity: 0; transition: opacity .16s ease;
12
+ }
13
+ .lightbox[open] {
14
+ display: grid; grid-template-columns: auto 1fr auto; align-items: center;
15
+ opacity: 1;
16
+ }
17
+ @starting-style { .lightbox[open] { opacity: 0; } }
18
+ .lightbox::backdrop { background: color-mix(in srgb, var(--ink) 82%, transparent); }
19
+ @media (prefers-reduced-motion: reduce) { .lightbox { transition: none; } }
20
+
21
+ /* the figure: the centre column, holds the image + its caption */
22
+ .lightbox__figure {
23
+ grid-column: 2; justify-self: center; align-self: center;
24
+ display: flex; flex-direction: column; gap: var(--space-2);
25
+ max-width: 100%; max-height: 100dvh; margin: 0; padding: var(--space-3);
26
+ box-sizing: border-box;
27
+ }
28
+ .lightbox__img {
29
+ display: block; max-width: 100%; max-height: calc(100dvh - 6rem);
30
+ width: auto; height: auto; object-fit: contain;
31
+ border-radius: var(--radius-md); background: var(--color-bg);
32
+ box-shadow: 0 8px 32px color-mix(in srgb, var(--ink) 55%, transparent);
33
+ }
34
+ .lightbox__caption {
35
+ text-align: center; font-size: .85rem; color: var(--color-bg);
36
+ text-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 85%, transparent);
37
+ }
38
+
39
+ /* the controls sit ABOVE the backdrop as fixed chrome. Drawn on the dark gutter, so their
40
+ ink is the inverted (page-bg) colour with a soft dark disc behind for contrast. */
41
+ .lightbox__close, .lightbox__nav {
42
+ position: fixed; z-index: 1;
43
+ display: inline-flex; align-items: center; justify-content: center;
44
+ width: 2.75rem; height: 2.75rem; padding: 0;
45
+ border: 0; border-radius: 999px; cursor: pointer;
46
+ color: var(--color-bg);
47
+ background: color-mix(in srgb, var(--ink) 45%, transparent);
48
+ transition: background .12s ease;
49
+ }
50
+ .lightbox__close:hover, .lightbox__nav:hover { background: color-mix(in srgb, var(--ink) 65%, transparent); }
51
+ .lightbox__close .icon, .lightbox__nav .icon { width: 1.25rem; height: 1.25rem; }
52
+ .lightbox__close { top: var(--space-3); right: var(--space-3); }
53
+ .lightbox__nav--prev { left: var(--space-3); }
54
+ .lightbox__nav--next { right: var(--space-3); }
55
+ .lightbox__nav { top: 50%; transform: translateY(-50%); }
56
+ .lightbox__nav[hidden], .lightbox__close[hidden] { display: none; }
57
+
58
+ /* the dot rail + counter: fixed to the bottom gutter, only for a real gallery (lightbox.js
59
+ hides both for a single image; dots give way to just the counter past ten photos). */
60
+ .lightbox__dots {
61
+ position: fixed; z-index: 1; left: 0; right: 0; bottom: calc(var(--space-3) + 1.5rem);
62
+ display: flex; justify-content: center; gap: var(--space-2); flex-wrap: wrap; padding: 0 var(--space-3);
63
+ }
64
+ .lightbox__dot {
65
+ width: .55rem; height: .55rem; padding: 0; border-radius: 999px; cursor: pointer;
66
+ border: 1px solid var(--color-bg);
67
+ background: color-mix(in srgb, var(--color-bg) 30%, transparent);
68
+ transition: background .12s ease;
69
+ }
70
+ .lightbox__dot:hover { background: color-mix(in srgb, var(--color-bg) 60%, transparent); }
71
+ .lightbox__dot[aria-selected="true"] { background: var(--color-bg); }
72
+ .lightbox__count {
73
+ position: fixed; z-index: 1; left: 0; right: 0; bottom: var(--space-3);
74
+ margin: 0; text-align: center; font-family: var(--font-mono);
75
+ font-size: .75rem; letter-spacing: .06em; color: var(--color-bg);
76
+ text-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 85%, transparent);
77
+ }
78
+ .lightbox__count[hidden], .lightbox__dots[hidden] { display: none; }
@@ -0,0 +1,48 @@
1
+ /* grain/styles/themes/_template.css — how to add a GRAIN flavor (a "bread variety").
2
+ ────────────────────────────────────────────────────────────────────────────────────────────
3
+ A flavor is a PURE TOKEN OVERRIDE on the `data-theme` axis — nothing else. You never touch a
4
+ component; every component restyles because it only ever reads the Layer-2 semantic aliases
5
+ (see variables.css). Sourdough is the hueless :root default; a flavor overrides some tokens.
6
+
7
+ TO ADD ONE (say "rye"):
8
+ 1. Copy this file to `rye.css`, replace `your-flavor` with `rye`, set the token values.
9
+ 2. `@import "themes/rye.css";` in variables.css (imports must precede the @font-face block).
10
+ 3. Declare it where it can be chosen: a page/control's `data-themes="sourdough rye …"` list
11
+ (theme.js reads that; the FIRST entry is the :root default and needs no block).
12
+ Boot's drift guard (server.ts checkThemingDrift) scans variables.css + this themes/ dir, so a
13
+ referenced flavor with no block warns at startup — no silent typos.
14
+
15
+ DOCTRINE (DESIGN-SYSTEM §2): ONE signature hue per flavor — override the four --color-accent
16
+ slots only; success/danger stay monochrome. Ship BOTH a light block and a composed dark block.
17
+ The flavor selectors (0,2,0 / 0,3,0) out-specify :root and the base dark block, so cascade
18
+ ORDER is irrelevant — importing at the top of variables.css is safe.
19
+ ──────────────────────────────────────────────────────────────────────────────────────────── */
20
+
21
+ /* ---- light ---- */
22
+ :root[data-theme="your-flavor"] {
23
+ --paper: #FFFFFF; --paper-2: #F2F2F0; --panel: #FFFFFF;
24
+ --ink: #1A1A1A; --ink-muted: #6B6B70; --ink-faint: #A6A6AB;
25
+ --hairline: #1A1A1A; --line-soft: rgba(26, 26, 26, 0.11);
26
+ --color-accent: #2F6FE0; --color-accent-hover: #2559C0; /* the ONE signature hue */
27
+ --color-accent-contrast: #FFFFFF; --color-accent-soft: #E7EEFB;
28
+ }
29
+ /* ---- dark: the @media block follows the OS unless the user forced light ---- */
30
+ @media (prefers-color-scheme: dark) {
31
+ :root[data-theme="your-flavor"]:not([data-color-scheme="light"]) {
32
+ --paper: #17181A; --paper-2: #202126; --panel: #202126;
33
+ --ink: #ECECEE; --ink-muted: #96969C; --ink-faint: #64646A;
34
+ --hairline: #ECECEE; --line-soft: rgba(236, 236, 238, 0.15);
35
+ --color-accent: #6FA0FF; --color-accent-hover: #8FB6FF;
36
+ --color-accent-contrast: #16181A; --color-accent-soft: rgba(111, 160, 255, 0.16);
37
+ --ai-veil: color-mix(in srgb, #000 50%, transparent);
38
+ }
39
+ }
40
+ /* ---- dark: forced (user toggled dark explicitly) — same values as the @media block ---- */
41
+ :root[data-theme="your-flavor"][data-color-scheme="dark"] {
42
+ --paper: #17181A; --paper-2: #202126; --panel: #202126;
43
+ --ink: #ECECEE; --ink-muted: #96969C; --ink-faint: #64646A;
44
+ --hairline: #ECECEE; --line-soft: rgba(236, 236, 238, 0.15);
45
+ --color-accent: #6FA0FF; --color-accent-hover: #8FB6FF;
46
+ --color-accent-contrast: #16181A; --color-accent-soft: rgba(111, 160, 255, 0.16);
47
+ --ai-veil: color-mix(in srgb, #000 50%, transparent);
48
+ }
@@ -0,0 +1,30 @@
1
+ /* grain/styles/themes/baguette.css — a GRAIN flavor (see _template.css for the pattern).
2
+ Baguette — clean / Notion: crisp near-white light, near-black dark, hairline greys, with a
3
+ soft-blue accent. A pure token override on the `data-theme="baguette"` axis; success/danger
4
+ stay monochrome (the one-hue doctrine — DESIGN-SYSTEM §2). Loaded via @import from
5
+ variables.css; the flavor selectors out-specify :root, so cascade order is irrelevant. */
6
+ :root[data-theme="baguette"] {
7
+ --paper: #FAFAF8; --paper-2: #F2F2F0; --panel: #FFFFFF;
8
+ --ink: #232326; --ink-muted: #6B6B70; --ink-faint: #A6A6AB;
9
+ --hairline: #232326; --line-soft: rgba(35, 35, 38, 0.11);
10
+ --color-accent: #2F6FE0; --color-accent-hover: #2559C0;
11
+ --color-accent-contrast: #FFFFFF; --color-accent-soft: #E7EEFB;
12
+ }
13
+ @media (prefers-color-scheme: dark) {
14
+ :root[data-theme="baguette"]:not([data-color-scheme="light"]) {
15
+ --paper: #17181A; --paper-2: #202126; --panel: #202126;
16
+ --ink: #ECECEE; --ink-muted: #96969C; --ink-faint: #64646A;
17
+ --hairline: #ECECEE; --line-soft: rgba(236, 236, 238, 0.15);
18
+ --color-accent: #6FA0FF; --color-accent-hover: #8FB6FF;
19
+ --color-accent-contrast: #16181A; --color-accent-soft: rgba(111, 160, 255, 0.16);
20
+ --ai-veil: color-mix(in srgb, #000 50%, transparent);
21
+ }
22
+ }
23
+ :root[data-theme="baguette"][data-color-scheme="dark"] {
24
+ --paper: #17181A; --paper-2: #202126; --panel: #202126;
25
+ --ink: #ECECEE; --ink-muted: #96969C; --ink-faint: #64646A;
26
+ --hairline: #ECECEE; --line-soft: rgba(236, 236, 238, 0.15);
27
+ --color-accent: #6FA0FF; --color-accent-hover: #8FB6FF;
28
+ --color-accent-contrast: #16181A; --color-accent-soft: rgba(111, 160, 255, 0.16);
29
+ --ai-veil: color-mix(in srgb, #000 50%, transparent);
30
+ }
@@ -0,0 +1,30 @@
1
+ /* grain/styles/themes/brioche.css — a GRAIN flavor (see _template.css for the pattern).
2
+ Brioche — warm cream + honey-gold accent (the one colorful theme). A pure token override on
3
+ the `data-theme="brioche"` axis; success/danger stay monochrome (the one-hue doctrine —
4
+ DESIGN-SYSTEM §2). Loaded via @import from variables.css; the flavor selectors out-specify
5
+ :root, so cascade order is irrelevant. */
6
+ :root[data-theme="brioche"] {
7
+ --paper: #F5EEDD; --paper-2: #FBF5E7; --panel: #FFFDF6;
8
+ --ink: #2C2416; --ink-muted: #6E6249; --ink-faint: #B9AC8E;
9
+ --hairline: #2C2416; --line-soft: rgba(44, 36, 22, 0.14);
10
+ --color-accent: #B77F1E; --color-accent-hover: #9A6A16;
11
+ --color-accent-contrast: #FFFFFF; --color-accent-soft: #F3E7CC;
12
+ }
13
+ @media (prefers-color-scheme: dark) {
14
+ :root[data-theme="brioche"]:not([data-color-scheme="light"]) {
15
+ --paper: #1D180F; --paper-2: #262016; --panel: #262016;
16
+ --ink: #EFE6D2; --ink-muted: #9C907A; --ink-faint: #6A6152;
17
+ --hairline: #EFE6D2; --line-soft: rgba(239, 230, 210, 0.16);
18
+ --color-accent: #E3B457; --color-accent-hover: #EEC777;
19
+ --color-accent-contrast: #1D180F; --color-accent-soft: rgba(227, 180, 87, 0.16);
20
+ --ai-veil: color-mix(in srgb, #000 50%, transparent);
21
+ }
22
+ }
23
+ :root[data-theme="brioche"][data-color-scheme="dark"] {
24
+ --paper: #1D180F; --paper-2: #262016; --panel: #262016;
25
+ --ink: #EFE6D2; --ink-muted: #9C907A; --ink-faint: #6A6152;
26
+ --hairline: #EFE6D2; --line-soft: rgba(239, 230, 210, 0.16);
27
+ --color-accent: #E3B457; --color-accent-hover: #EEC777;
28
+ --color-accent-contrast: #1D180F; --color-accent-soft: rgba(227, 180, 87, 0.16);
29
+ --ai-veil: color-mix(in srgb, #000 50%, transparent);
30
+ }
@@ -0,0 +1,217 @@
1
+ /* styles/variables.css — design tokens, TWO layers (see ARCHITECTURE).
2
+ Layer 1: raw PRIMITIVES (palette, grades, scale) — components never touch these.
3
+ Layer 2: SEMANTIC aliases that point at primitives — components use ONLY these.
4
+
5
+ This is the "Sourdough" theme (docs/DESIGN-SYSTEM.md): monochrome
6
+ e-ink / Swiss-editorial. The whole re-skin is done HERE — every existing
7
+ component restyles because it only ever read the Layer-2 aliases. */
8
+
9
+ /* FLAVORS (the `data-theme` axis) live as reference files under themes/ — each a pure token
10
+ override; see themes/_template.css to add one. Imported here (imports must precede all other
11
+ rules, so before @font-face) so the ONE stylesheet every page + the catalog already loads
12
+ carries them. The flavor selectors out-specify :root, so import order doesn't affect cascade.
13
+ Sourdough is the hueless :root default below and needs no file. */
14
+ @import "themes/baguette.css";
15
+ @import "themes/brioche.css";
16
+
17
+ /* ---- Redaction grades, self-hosted (docs/DESIGN-SYSTEM.md §3) ----------------
18
+ Each grade is its OWN family, so switching grade = swapping family (a class
19
+ change), which is how "grade as signal" works. */
20
+ @font-face {
21
+ font-family: "Redaction"; font-style: normal; font-weight: 400; font-display: swap;
22
+ src: url("/fonts/redaction-400.woff2") format("woff2");
23
+ }
24
+ @font-face {
25
+ font-family: "Redaction 35"; font-style: normal; font-weight: 400; font-display: swap;
26
+ src: url("/fonts/redaction-35-400.woff2") format("woff2");
27
+ }
28
+ @font-face {
29
+ font-family: "Redaction 50"; font-style: normal; font-weight: 400; font-display: swap;
30
+ src: url("/fonts/redaction-50-400.woff2") format("woff2");
31
+ }
32
+ @font-face {
33
+ font-family: "Redaction 70"; font-style: normal; font-weight: 400; font-display: swap;
34
+ src: url("/fonts/redaction-70-400.woff2") format("woff2");
35
+ }
36
+
37
+ :root {
38
+ /* ---- Layer 1: primitives ------------------------------------------------ */
39
+
40
+ /* monochrome paper + ink — six values do everything (DESIGN-SYSTEM §2) */
41
+ --paper: #E2E0D8; /* page background — dimmed warm grey, NOT bright */
42
+ --paper-2: #E8E6DF; /* subtle hover surface */
43
+ --panel: #E8E6DF; /* grouped "sheet" — a hair brighter than the page */
44
+ --ink: #1C1B17; /* primary text, filled dots, rules */
45
+ --ink-muted: #6E6C64; /* secondary text, section labels */
46
+ --ink-faint: #ABA89F; /* fading insights, empty/future dots */
47
+ --hairline: #1C1B17; /* solid rules (under headlines) */
48
+ --line-soft: rgba(28, 27, 23, .14); /* translucent border for quiet grouping */
49
+
50
+ /* grade font families (clean = human, grain = AI / in-transit). Grain is grade 50 —
51
+ one step up from the 35 working grade for more visible texture. */
52
+ --font-smooth: "Redaction", "Times New Roman", Georgia, serif;
53
+ --font-grain: "Redaction 50", "Redaction 35", "Times New Roman", Georgia, serif;
54
+ --font-accent: "Redaction 70", "Times New Roman", Georgia, serif;
55
+ /* the FINE grain face — grade 35 only, skipping the rougher 50. Grade texture only reads as
56
+ texture (not noise) at >= --text-2xl (CLAUDE.md lesson 4); a component that must show the
57
+ AI-grain signal in small text (a chat bubble, --text-sm) reads this instead of --font-grain so
58
+ the "AI wrote this" cue survives without Redaction 50's rough strokes collapsing into mush at
59
+ 14px. Still a Redaction face, still visibly not --font-smooth — the signal doesn't disappear,
60
+ it just doesn't demonstrate the roughest texture where it can't read anyway. */
61
+ --font-grain-fine: "Redaction 35", "Times New Roman", Georgia, serif;
62
+
63
+ /* monospace — code blocks / inline code (grade-independent: code stays mono, the AI
64
+ signal for code is the dashed edge, not a font swap). System stack, nothing to host. */
65
+ --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
66
+
67
+ --font-weight-regular: 400; /* house weight — even for headlines */
68
+ --font-weight-medium: 500;
69
+ --font-weight-semibold: 600;
70
+ --font-weight-bold: 700; /* reserved for rare extra punch */
71
+
72
+ /* type scale (mobile-first, rem @ 16px) — fluid display via clamp */
73
+ --text-xs: 0.8125rem; /* 13px caption */
74
+ --text-sm: 0.875rem; /* 14px label / eyebrow */
75
+ --text-base: 0.9375rem; /* 15px body */
76
+ --text-lg: 1.05rem;
77
+ --text-xl: 1.3rem; /* section heading */
78
+ --text-2xl: 1.6rem;
79
+ --text-3xl: 2.25rem;
80
+ --display: clamp(2rem, 6vw, 2.75rem); /* the masthead headline */
81
+
82
+ --leading-tight: 1.02; /* display */
83
+ --leading-normal: 1.5;
84
+ --leading-relaxed: 1.55; /* body */
85
+
86
+ /* spacing — 4px base scale */
87
+ --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
88
+ --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
89
+ --space-8: 2rem;
90
+
91
+ /* radius — crisp, almost square (DESIGN-SYSTEM §4) */
92
+ --radius-sm: 4px;
93
+ --radius-md: 4px;
94
+ --radius-pill: 2px; /* badges are near-rectangular here, not pills */
95
+
96
+ /* rules */
97
+ --rule: 1.5px solid var(--hairline); /* under-headline rule */
98
+ --border: 1px solid var(--hairline); /* buttons, hard edges you tap */
99
+
100
+ --content-max: 768px;
101
+ --page-pad: clamp(1.25rem, 5vw, 2.5rem);
102
+
103
+ /* ---- Layer 2: semantic aliases (the only tokens components touch) -------
104
+ Re-pointed at the monochrome primitives. Because components read these and
105
+ never the primitives, the whole app re-themes from the lines below. */
106
+
107
+ /* surfaces & text */
108
+ --color-bg: var(--paper);
109
+ --color-surface: var(--panel);
110
+ --color-fg: var(--ink);
111
+ --color-muted: var(--ink-muted);
112
+ --color-line: var(--line-soft);
113
+
114
+ /* ACCENT — the ONE signature hue (doctrine: "full reach, single hue"). This is the single
115
+ brand knob a theme/product sets. REACH is full — links, focus rings, ::selection, and the
116
+ primary button fill all point here. COUNT is one — the palette stays CLOSED: exactly one
117
+ accent, and success/danger NEVER get their own hue (below). The default (Sourdough) keeps
118
+ it HUELESS by setting it to ink, so nothing gains colour except a subtle ink ::selection.
119
+ An accented theme (Baguette, Brioche) overrides just these four. See DESIGN-SYSTEM.md §2. */
120
+ --color-accent: var(--ink); /* hueless default — a flavor overrides to its one hue */
121
+ --color-accent-hover: var(--ink);
122
+ --color-accent-contrast: var(--paper);
123
+ --color-accent-soft: var(--paper-2);
124
+
125
+ /* "primary" now chains to the accent (was hardcoded ink) — so the primary button fill follows
126
+ the one brand hue automatically; hueless by default because accent = ink. */
127
+ --color-primary: var(--color-accent);
128
+ --color-primary-hover: var(--color-accent-hover);
129
+ --color-primary-contrast: var(--color-accent-contrast);
130
+ --color-primary-soft: var(--color-accent-soft);
131
+
132
+ /* success / danger collapse to ink in monochrome — signalled by weight/treatment,
133
+ not hue (DESIGN-SYSTEM §2: states from opacity + size, palette stays closed —
134
+ the ONE hue is the accent above; states never get their own) */
135
+ --color-success: var(--ink);
136
+ --color-success-hover: var(--ink);
137
+ --color-success-contrast: var(--paper);
138
+ --color-success-soft: var(--paper-2);
139
+ --color-danger: var(--ink);
140
+ --color-danger-hover: var(--ink);
141
+ --color-danger-contrast: var(--paper);
142
+ --color-danger-soft: var(--paper-2);
143
+
144
+ /* status badge */
145
+ --color-ok-bg: transparent;
146
+ --color-ok-fg: var(--ink);
147
+ --color-archived-bg: transparent;
148
+ --color-archived-fg: var(--ink-muted);
149
+
150
+ /* the inheritable grade switch — DESIGN-SYSTEM §3 "As an atom".
151
+ Default = human/clean; ancestors flip it; CSS inheritance distributes it. */
152
+ --type-font: var(--font-smooth);
153
+
154
+ /* base font shorthand */
155
+ --font-base: var(--text-base)/var(--leading-relaxed) var(--type-font);
156
+
157
+ /* AI spotlight veil (GRAIN) — set ONCE here so every page fades the same way.
158
+ Pick ONE (CSS comments don't nest — keep exactly one line uncommented): */
159
+ --ai-veil-alpha: 22%; /* tweak this one number to change the dim depth everywhere */
160
+ --ai-veil: color-mix(in srgb, var(--ink) var(--ai-veil-alpha), transparent); /* dim: gentle ink recede */
161
+ /* --ai-veil: color-mix(in srgb, var(--paper) 70%, transparent); */ /* wash: bleach toward blank paper */
162
+ /* --ai-veil: transparent; */ /* lift: no veil, the element pops alone */
163
+
164
+ /* how slowly the spotlight box glides onto the next surface when the AI switches focus,
165
+ and its easing — gentle like a page transition (soft start, soft landing), never a snap.
166
+ Keep the duration ≤ the reasoner's SETTLE_MS (700ms) so the box lands before it acts. */
167
+ --ai-focus-move: 0.65s;
168
+ --ai-focus-ease: ease-in-out;
169
+
170
+ /* AI takeover STACKING — one source of truth so the AI module (grain/ai/ai.css) and any
171
+ consumer chrome (e.g. the app's portfolio-frame console/chat) agree without duplicating
172
+ magic z-index numbers. veil < spotlit surface < the AI surfaces that stay above the veil. */
173
+ --z-ai-veil: 9000; /* the dimming backdrop */
174
+ --z-ai-spot: 9001; /* the spotlit surface, lifted out of the dim */
175
+ --z-ai-surface: 9002; /* AI surfaces kept above the veil (acting label, console, chat) */
176
+
177
+ /* paper grain SVG overlay opacity (DESIGN-SYSTEM §6) — override in dark mode to reduce contrast */
178
+ --paper-grain-opacity: 0.09;
179
+ }
180
+
181
+ /* ============================================================================================
182
+ THEMING — two ORTHOGONAL axes, both pure TOKEN re-skins (the whole point of the two-layer
183
+ system): only Layer-1 PRIMITIVES flip; Layer-2 aliases point at them, so every component
184
+ re-colours with ZERO edits. See grain/README.md §4 + §6 (consumer guide).
185
+ • `data-color-scheme` = light | dark (follows the OS; force it on <html> to override)
186
+ • `data-theme` = the FLAVOR (default = Sourdough via :root; add bread varieties)
187
+ They compose: any flavor in either scheme. `grain/scripts/theme.js` sets both on <html> (persisted).
188
+ ============================================================================================ */
189
+
190
+ /* ---- Color scheme: dark (flavor-agnostic — applies to whatever flavor is active). Warm+soft,
191
+ no pure black/white, to keep the e-ink feel. Auto by OS unless forced light. ---- */
192
+ @media (prefers-color-scheme: dark) {
193
+ :root:not([data-color-scheme="light"]) {
194
+ --paper: #1B1A16; --paper-2: #232219; --panel: #232219;
195
+ --ink: #E4E1D8; --ink-muted: #9A968B; --ink-faint: #6B6862;
196
+ --hairline: #E4E1D8; --line-soft: rgba(228, 225, 216, 0.16);
197
+ --ai-veil: color-mix(in srgb, #000 50%, transparent); /* dark: dimming darkens further */
198
+ --paper-grain-opacity: 0.04;
199
+ }
200
+ }
201
+ :root[data-color-scheme="dark"] {
202
+ --paper: #1B1A16; --paper-2: #232219; --panel: #232219;
203
+ --ink: #E4E1D8; --ink-muted: #9A968B; --ink-faint: #6B6862;
204
+ --hairline: #E4E1D8; --line-soft: rgba(228, 225, 216, 0.16);
205
+ --ai-veil: color-mix(in srgb, #000 50%, transparent);
206
+ --paper-grain-opacity: 0.04;
207
+ }
208
+
209
+ /* ============================================================================================
210
+ FLAVORS (`data-theme`) — bread varieties, each a pure token override (light + composed dark).
211
+ Sourdough is the :root default above (hueless). The accented flavors now live as reference
212
+ files under themes/ (Baguette, Brioche) — @imported at the top of this file. An accented flavor
213
+ overrides the four --color-accent slots with its ONE signature hue; success/danger stay
214
+ monochrome (doctrine above). The flavor+dark selector (0,3,0) outranks the plain dark block
215
+ (0,2,0), so it wins in dark mode. `theme.js` switches any value; add a variety by copying
216
+ themes/_template.css. See grain/README §4/§6 + DESIGN-SYSTEM §2.
217
+ ============================================================================================ */