@behavioral-agentic-design-system/core 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +30 -5
  3. package/scripts/bads-sync.mjs +1 -1
  4. package/scripts/build-fonts.cjs +15 -8
  5. package/scripts/build-tokens.cjs +139 -23
  6. package/src/api/brand-fonts.ts +27 -6
  7. package/src/api/layers/file.ts +4 -3
  8. package/src/api/layers.ts +8 -7
  9. package/src/api/site-auth.ts +50 -0
  10. package/src/app/font-ready.tsx +1 -1
  11. package/src/app/layout.tsx +9 -3
  12. package/src/app/preview/components/page.tsx +78 -1
  13. package/src/app/preview/icons/page.tsx +5 -0
  14. package/src/app/shell.tsx +27 -22
  15. package/src/app/site-login/page.tsx +82 -0
  16. package/src/brand-fonts.css +5 -0
  17. package/src/components/Foundations/Motion.stories.tsx +66 -0
  18. package/src/components/customize/letter-spacing.tsx +3 -2
  19. package/src/components/customize/type-scale.tsx +3 -2
  20. package/src/components/customize-tab.tsx +8 -7
  21. package/src/components/home-tab.tsx +498 -235
  22. package/src/components/layers-tab.tsx +141 -3
  23. package/src/components/ui/alert.tsx +2 -2
  24. package/src/components/ui/bottom-sheet.tsx +124 -0
  25. package/src/components/ui/button.tsx +1 -1
  26. package/src/components/ui/chart.tsx +115 -14
  27. package/src/components/ui/checkbox.tsx +3 -2
  28. package/src/components/ui/dialog.tsx +3 -3
  29. package/src/components/ui/index.ts +1 -0
  30. package/src/components/ui/radio-group.tsx +4 -3
  31. package/src/components/ui/sheet.tsx +1 -1
  32. package/src/components/ui/switch.tsx +3 -3
  33. package/src/components/ui/tabs.tsx +6 -0
  34. package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
  35. package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
  36. package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
  37. package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
  38. package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
  39. package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
  40. package/src/fonts/InterVariable-Italic.woff2 +0 -0
  41. package/src/fonts/InterVariable.woff2 +0 -0
  42. package/src/fonts.css +99 -0
  43. package/src/hooks/use-global-primary-color.ts +114 -68
  44. package/src/hooks/use-global-serif-font.ts +1 -1
  45. package/src/lib/storage.ts +2 -2
  46. package/src/styles.css +151 -61
  47. package/src/tokens.default.json +4 -4
  48. package/src/tokens.json +159 -162
  49. package/src/app/preview/login/page.tsx +0 -5
  50. package/src/app/preview/mail/page.tsx +0 -4
  51. package/src/app/preview/pricing/page.tsx +0 -4
  52. package/src/components/admin-menu.stories.tsx +0 -68
  53. package/src/components/admin-menu.tsx +0 -59
package/src/fonts.css ADDED
@@ -0,0 +1,99 @@
1
+ /* @behavioral-agentic-design-system/core — canonical brand fonts.
2
+ *
3
+ * Static, hand-maintained @font-face block for the SIL OFL-licensed
4
+ * defaults that ship with the package (currently Hyperlegible Sans, 6
5
+ * weights). The .woff2 binaries live in ./fonts/ inside the published
6
+ * tarball.
7
+ *
8
+ * URLs resolve to /fonts/<file>.woff2 at runtime — the consumer is
9
+ * responsible for copying the binaries from
10
+ * `node_modules/@behavioral-agentic-design-system/core/fonts/` into
11
+ * their own `public/fonts/` so Next.js (or any static host) serves them
12
+ * at the expected path. See CLIENT_ONBOARDING.md → "Shipping fonts" for
13
+ * the canonical postinstall recipe.
14
+ *
15
+ * Styles.css `@import`s this file automatically — consumers don't need
16
+ * to import it themselves. Brand-uploaded faces (Season, custom client
17
+ * fonts) live in the generated companion file `./brand-fonts.css`,
18
+ * also auto-imported.
19
+ */
20
+
21
+ /* ============================================================
22
+ * Inter — primary sans (SIL OFL 1.1), VARIABLE.
23
+ * A single woff2 per style covers the full 100–900 weight axis, so
24
+ * font-weight resolves continuously and forks can tune the wght/opsz
25
+ * axes via --font-variation-settings (tokens.json → fontVariationSettings)
26
+ * without shipping extra files. Latin subset (wght axis). Source:
27
+ * fontsource Inter VF. font-display: swap to avoid invisible text.
28
+ * https://rsms.me/inter/
29
+ * ============================================================ */
30
+ @font-face {
31
+ font-family: 'Inter';
32
+ src: url('/fonts/InterVariable.woff2') format('woff2');
33
+ font-weight: 100 900;
34
+ font-style: normal;
35
+ font-display: swap;
36
+ }
37
+
38
+ @font-face {
39
+ font-family: 'Inter';
40
+ src: url('/fonts/InterVariable-Italic.woff2') format('woff2');
41
+ font-weight: 100 900;
42
+ font-style: italic;
43
+ font-display: swap;
44
+ }
45
+
46
+ /* ============================================================
47
+ * Hyperlegible Sans — accessibility-preserving fallback (SIL OFL 1.1).
48
+ * The Braille Institute's low-vision face. Stays self-hosted and second
49
+ * in the --font-sans stack so a low-vision-heavy fork can reorder
50
+ * tokens.json fontFamily.sans to lead with it. Static weights.
51
+ * https://www.brailleinstitute.org/freefont
52
+ * ============================================================ */
53
+ @font-face {
54
+ font-family: 'Hyperlegible Sans';
55
+ src: url('/fonts/HyperlegibleSans-Regular.woff2') format('woff2');
56
+ font-weight: 400;
57
+ font-style: normal;
58
+ font-display: swap;
59
+ }
60
+
61
+ @font-face {
62
+ font-family: 'Hyperlegible Sans';
63
+ src: url('/fonts/HyperlegibleSans-Italic.woff2') format('woff2');
64
+ font-weight: 400;
65
+ font-style: italic;
66
+ font-display: swap;
67
+ }
68
+
69
+ @font-face {
70
+ font-family: 'Hyperlegible Sans';
71
+ src: url('/fonts/HyperlegibleSans-Medium.woff2') format('woff2');
72
+ font-weight: 500;
73
+ font-style: normal;
74
+ font-display: swap;
75
+ }
76
+
77
+ @font-face {
78
+ font-family: 'Hyperlegible Sans';
79
+ src: url('/fonts/HyperlegibleSans-MediumItalic.woff2') format('woff2');
80
+ font-weight: 500;
81
+ font-style: italic;
82
+ font-display: swap;
83
+ }
84
+
85
+ @font-face {
86
+ font-family: 'Hyperlegible Sans';
87
+ src: url('/fonts/HyperlegibleSans-Bold.woff2') format('woff2');
88
+ font-weight: 700;
89
+ font-style: normal;
90
+ font-display: swap;
91
+ }
92
+
93
+ @font-face {
94
+ font-family: 'Hyperlegible Sans';
95
+ src: url('/fonts/HyperlegibleSans-BoldItalic.woff2') format('woff2');
96
+ font-weight: 700;
97
+ font-style: italic;
98
+ font-display: swap;
99
+ }
@@ -163,6 +163,12 @@ const PRIMARY_OVERRIDE_VARIABLES = [
163
163
  "--sidebar-primary",
164
164
  "--sidebar-primary-foreground",
165
165
  "--sidebar-ring",
166
+ // Chart vars are written inline by applyColor / writeChartRamp below.
167
+ // The stylesheet rule (oklch(from var(--primary) ...)) emitted by
168
+ // build-tokens.cjs gets precompiled by Next 16's Lightning CSS into a
169
+ // static lab() fallback that wins on every modern browser. Writing
170
+ // inline forces runtime resolution against the live --primary so picker
171
+ // changes actually reach charts.
166
172
  "--chart-1",
167
173
  "--chart-2",
168
174
  "--chart-3",
@@ -170,68 +176,50 @@ const PRIMARY_OVERRIDE_VARIABLES = [
170
176
  "--chart-5",
171
177
  ];
172
178
 
173
- // Chart ramp config — must stay in sync with tokens.json chart.lightnessSteps
174
- // and chart.chromaSteps. Build-tokens.cjs reads the same values to emit the
175
- // CSS derivation block, but we also write the ramp inline at runtime because
176
- // Lightning CSS precomputes oklch(from var(--primary) ...) into a static
177
- // lab() fallback inside @supports — which wins over the relative-color rule
178
- // and freezes the chart palette to the build-time --primary. Writing inline
179
- // bypasses the bundler and lets the browser resolve the relative color at
180
- // runtime against whatever --primary the brand picker just set.
181
- const CHART_RAMP = [
182
- { l: "0.58", c: "1.00" },
183
- { l: "0.50", c: "0.95" },
184
- { l: "0.42", c: "0.80" },
185
- { l: "0.34", c: "0.60" },
186
- { l: "0.27", c: "0.40" },
187
- ] as const;
188
- const CHART_RAMP_DARK = [
189
- { l: "0.78", c: "1.00" },
190
- { l: "0.70", c: "0.95" },
191
- { l: "0.62", c: "0.80" },
192
- { l: "0.56", c: "0.60" },
193
- { l: "0.52", c: "0.40" },
194
- ] as const;
195
-
196
- // Variables managed elsewhere (Customize tab token swatch picker) that we
197
- // should NOT overwrite on a brand change. Read fresh from localStorage so
198
- // the brand picker honors them without needing a hook subscription.
199
- function readUserTokenOverrides(): Set<string> {
179
+ // Chart ramp constants — mirror tokens.json → chart.lightness / hueRotation /
180
+ // chroma2Damping. Update both files together when retuning the chart palette.
181
+ const CHART_LIGHTNESS_LIGHT = 0.58;
182
+ const CHART_LIGHTNESS_DARK = 0.78;
183
+ const CHART_HUE_ROTATIONS = [0, 35, 70, 105, 140] as const;
184
+ const CHART_CHROMA2_DAMPING = 0.65;
185
+
186
+ function readOverriddenChartVars(): Set<string> {
200
187
  if (typeof window === "undefined") return new Set();
201
188
  try {
202
- const raw =
203
- window.localStorage.getItem(storageKey("tokenOverrides")) ??
204
- window.localStorage.getItem("tokenOverrides");
189
+ const raw = readMigrated("tokenOverrides");
205
190
  if (!raw) return new Set();
206
191
  const parsed = JSON.parse(raw) as Record<string, string>;
207
- return new Set(Object.keys(parsed ?? {}));
192
+ if (!parsed || typeof parsed !== "object") return new Set();
193
+ return new Set(Object.keys(parsed).filter((k) => k.startsWith("--chart-")));
208
194
  } catch {
209
195
  return new Set();
210
196
  }
211
197
  }
212
198
 
213
- function chartRampValue(index: 0 | 1 | 2 | 3 | 4, dark: boolean): string {
214
- const step = (dark ? CHART_RAMP_DARK : CHART_RAMP)[index];
215
- const c = step.c === "1.00" ? "c" : `calc(c * ${step.c})`;
216
- return `oklch(from var(--primary) ${step.l} ${c} h)`;
199
+ function writeChartRamp() {
200
+ if (typeof document === "undefined") return;
201
+ const root = document.documentElement;
202
+ const style = root.style;
203
+ const isDark = root.classList.contains("dark");
204
+ const L = isDark ? CHART_LIGHTNESS_DARK : CHART_LIGHTNESS_LIGHT;
205
+ const overridden = readOverriddenChartVars();
206
+ for (let i = 0; i < 5; i++) {
207
+ const name = `--chart-${i + 1}`;
208
+ if (overridden.has(name)) continue;
209
+ const hue = CHART_HUE_ROTATIONS[i];
210
+ const chroma = i === 1 ? `calc(c * ${CHART_CHROMA2_DAMPING})` : "c";
211
+ style.setProperty(name, `oklch(from var(--primary) ${L} ${chroma} calc(h + ${hue}))`);
212
+ }
217
213
  }
218
214
 
219
215
  /**
220
- * Re-apply the chart ramp inline based on the current --primary and dark
221
- * mode. Use after clearing a chart-N user override so the cascade doesn't
222
- * fall through to the Lightning CSS lab() precomputation. Skips any chart
223
- * variable still listed in user token overrides.
216
+ * Re-evaluate the chart ramp against the current --primary and dark-mode
217
+ * state. Called when the user resets a chart-N override so the cleared
218
+ * variable falls back to the brand-derived ramp instead of the frozen
219
+ * build-time lab() value Lightning CSS precomputed.
224
220
  */
225
- export function reapplyChartRamp() {
226
- if (typeof document === "undefined") return;
227
- const root = document.documentElement.style;
228
- const userOverrides = readUserTokenOverrides();
229
- const isDark = document.documentElement.classList.contains("dark");
230
- for (let i = 0; i < 5; i++) {
231
- const varName = `--chart-${i + 1}`;
232
- if (userOverrides.has(varName)) continue;
233
- root.setProperty(varName, chartRampValue(i as 0 | 1 | 2 | 3 | 4, isDark));
234
- }
221
+ export function reapplyChartRamp(): void {
222
+ writeChartRamp();
235
223
  }
236
224
 
237
225
  function buildCustom(hex: string, label?: string): PrimaryColorOption {
@@ -296,22 +284,75 @@ function applyColor(opt: PrimaryColorOption) {
296
284
  root.setProperty("--primary", opt.primary);
297
285
  root.setProperty("--primary-foreground", opt.primaryForeground);
298
286
  root.setProperty("--ring", opt.primary);
299
- root.setProperty("--accent-foreground", opt.primary);
287
+
288
+ // --accent-foreground used to be set unconditionally to opt.primary. That
289
+ // produced silent contrast failures when the brand color was too close in
290
+ // luminance to the dark-mode accent surface (the wcag-audit script can't
291
+ // see runtime overrides, so this bug stayed hidden). Now we read the live
292
+ // --accent value, compute contrast for both candidates (brand color +
293
+ // brand-foreground), and pick whichever passes AAA. If neither does, we
294
+ // skip the override and let the stylesheet default win — it's already
295
+ // luminance-tuned.
296
+ const accentFg = pickAccentForeground(opt);
297
+ if (accentFg) {
298
+ root.setProperty("--accent-foreground", accentFg);
299
+ } else {
300
+ root.removeProperty("--accent-foreground");
301
+ }
302
+
300
303
  root.setProperty("--sidebar-primary", opt.primary);
301
304
  root.setProperty("--sidebar-primary-foreground", opt.primaryForeground);
302
305
  root.setProperty("--sidebar-ring", opt.primary);
306
+ // Inline-write the chart ramp so brand picker changes reach charts. The
307
+ // stylesheet rule is precomputed by Lightning CSS into a frozen lab().
308
+ writeChartRamp();
309
+ }
303
310
 
304
- // Apply the chart ramp inline. This duplicates the CSS derivation but is
305
- // necessary because Lightning CSS bakes the CSS rule into a static lab()
306
- // fallback that wins over the relative-color form. Inline values escape
307
- // that precomputation. Per-chart user overrides (token swatch picker) are
308
- // preserved by reading the tokenOverrides map and skipping those keys.
309
- const userOverrides = readUserTokenOverrides();
310
- const isDark = document.documentElement.classList.contains("dark");
311
- for (let i = 0; i < 5; i++) {
312
- const varName = `--chart-${i + 1}`;
313
- if (userOverrides.has(varName)) continue;
314
- root.setProperty(varName, chartRampValue(i as 0 | 1 | 2 | 3 | 4, isDark));
311
+ const ACCENT_TEXT_FLOOR = 4.5; // AA for text — accent surfaces typically host UI labels, not body.
312
+
313
+ function pickAccentForeground(opt: PrimaryColorOption): string | null {
314
+ if (typeof document === "undefined") return null;
315
+ const accentValue = getComputedStyle(document.documentElement)
316
+ .getPropertyValue("--accent")
317
+ .trim();
318
+ if (!accentValue) return null;
319
+ const accentRgb = parseCssColorToRgb(accentValue);
320
+ if (!accentRgb) return null;
321
+ const candidates: string[] = [opt.primary, opt.primaryForeground];
322
+ for (const cand of candidates) {
323
+ const candRgb = rgbFromHex(cand);
324
+ if (contrastRatio(candRgb, accentRgb) >= ACCENT_TEXT_FLOOR) return cand;
325
+ }
326
+ // Both candidates fail — give up and let the stylesheet default ride.
327
+ return null;
328
+ }
329
+
330
+ // Parses a computed-style color (hex, rgb(), oklch(), lab()) into [r,g,b].
331
+ // Returns null if the browser hasn't resolved the value or the parse fails.
332
+ function parseCssColorToRgb(value: string): [number, number, number] | null {
333
+ if (typeof document === "undefined") return null;
334
+ // Cheapest path: hex literal.
335
+ if (/^#([0-9a-fA-F]{3,8})$/.test(value)) {
336
+ try {
337
+ return rgbFromHex(value);
338
+ } catch {
339
+ return null;
340
+ }
341
+ }
342
+ // Fall through to canvas: every other CSS color string parses uniformly.
343
+ try {
344
+ const canvas = document.createElement("canvas");
345
+ canvas.width = 1;
346
+ canvas.height = 1;
347
+ const ctx = canvas.getContext("2d");
348
+ if (!ctx) return null;
349
+ ctx.fillStyle = "#000";
350
+ ctx.fillStyle = value;
351
+ ctx.fillRect(0, 0, 1, 1);
352
+ const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
353
+ return [r / 255, g / 255, b / 255];
354
+ } catch {
355
+ return null;
315
356
  }
316
357
  }
317
358
 
@@ -396,14 +437,19 @@ function bootstrap() {
396
437
  }
397
438
  });
398
439
 
399
- // Re-apply the chart ramp when dark mode toggles. The ramp values differ
400
- // between light (L=0.58 → 0.27) and dark (L=0.78 → 0.52) because the AAA
401
- // contrast floor against the card background is mode-dependent.
402
- const darkObserver = new MutationObserver(() => {
403
- const merged = { ...BUILTIN_PRIMARY_COLORS, ...snapshot.customs };
404
- applySelectedColor(snapshot.color, merged);
440
+ // Dark-mode toggle: re-evaluate the chart ramp at the new mode's L. The
441
+ // shell toggles `.dark` on documentElement; we observe that class attribute
442
+ // and re-run applySelectedColor so writeChartRamp picks up the new mode.
443
+ const themeObserver = new MutationObserver((mutations) => {
444
+ for (const m of mutations) {
445
+ if (m.attributeName === "class") {
446
+ const merged = { ...BUILTIN_PRIMARY_COLORS, ...snapshot.customs };
447
+ applySelectedColor(snapshot.color, merged);
448
+ break;
449
+ }
450
+ }
405
451
  });
406
- darkObserver.observe(document.documentElement, {
452
+ themeObserver.observe(document.documentElement, {
407
453
  attributes: true,
408
454
  attributeFilter: ["class"],
409
455
  });
@@ -36,7 +36,7 @@ export type SerifFontKey = string;
36
36
  import { storageKey, readMigrated } from "@behavioral-agentic-design-system/core/lib/storage";
37
37
 
38
38
  const STORAGE_KEY = storageKey("serifFont");
39
- const DEFAULT: SerifFontKey = "season-serif";
39
+ const DEFAULT: SerifFontKey = "georgia";
40
40
 
41
41
  function isValidKey(value: string | null): value is SerifFontKey {
42
42
  return !!value && value in SERIF_FONT_OPTIONS;
@@ -4,13 +4,13 @@
4
4
  *
5
5
  * Why this exists
6
6
  * ----------------
7
- * Before 0.4.0, every hook had `const STORAGE_KEY = "SWIMTOPIA-AGENTIC-DESIGN-SYSTEM.sansFont"` (and
7
+ * Before 0.4.0, every hook had `const STORAGE_KEY = "BADS.sansFont"` (and
8
8
  * similar) inlined. `scripts/rename.mjs` rewrote those strings at fork time
9
9
  * so a renamed fork stored data under "<SLUG_UPPER>.sansFont" instead.
10
10
  *
11
11
  * Once @core started shipping the hooks via npm (0.3.0), rename.mjs could no
12
12
  * longer reach the hook source — it lives in node_modules, not the consumer
13
- * tree. Forks ended up reading "SWIMTOPIA-AGENTIC-DESIGN-SYSTEM.sansFont" from localStorage even though
13
+ * tree. Forks ended up reading "BADS.sansFont" from localStorage even though
14
14
  * their saved customizations were under "<SLUG_UPPER>.sansFont", silently
15
15
  * losing every Customize-tab edit they had made.
16
16
  *
package/src/styles.css CHANGED
@@ -12,8 +12,26 @@
12
12
  * Override any token by re-declaring it after this @import.
13
13
  */
14
14
 
15
+ /* Inter Variable leads (the default sans) as the zero-setup CDN fallback;
16
+ * Atkinson Hyperlegible stays as the accessibility-preserving secondary.
17
+ * Self-hosted equivalents in fonts.css win when consumers copy the binaries
18
+ * (see note below). */
19
+ @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
15
20
  @import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
16
21
 
22
+ /* Self-hosted brand faces shipped inside this package. fonts.css holds the
23
+ * canonical SIL OFL defaults (Hyperlegible Sans, 6 weights). brand-fonts.css
24
+ * is generated from brand-fonts.json by `pnpm build:fonts` and carries any
25
+ * client-uploaded faces (Season, etc.). Both reference URLs at /fonts/<file>
26
+ * — consumers copy the binaries from
27
+ * `node_modules/@behavioral-agentic-design-system/core/fonts/` into their own
28
+ * `public/fonts/` so the URLs resolve. See CLIENT_ONBOARDING.md → Shipping
29
+ * fonts. CSS @import order: Google Fonts first (lowest priority fallback),
30
+ * then local @font-face rules so the brand stack wins.
31
+ */
32
+ @import "./fonts.css";
33
+ @import "./brand-fonts.css";
34
+
17
35
  /* Tailwind v4 only generates classes it scans. The shell components, hooks,
18
36
  * and app routes shipped in this package use plenty of Tailwind classes that
19
37
  * the consumer's own source code never references — Button's variants,
@@ -35,9 +53,10 @@
35
53
  /* Brand sans from tokens.json leads. Atkinson Hyperlegible (loaded via the
36
54
  Google Fonts @import above) is the canonical fallback so unbranded
37
55
  consumers still get a high-legibility face out of the box. */
38
- --font-sans: 'Season', 'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
56
+ --font-sans: 'Inter', 'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
39
57
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
40
- --font-serif: 'Season Serif', 'Season', ui-serif, Georgia, serif;
58
+ --font-serif: ui-serif, Georgia, serif;
59
+ --font-variation-settings: normal;
41
60
  --font-size-scale: 1;
42
61
 
43
62
  --background: oklch(1 0 0);
@@ -46,7 +65,7 @@
46
65
  --card-foreground: oklch(0.1450 0 0);
47
66
  --popover: oklch(1 0 0);
48
67
  --popover-foreground: oklch(0.1450 0 0);
49
- --primary: #025FFF;
68
+ --primary: #1F1F1F;
50
69
  --primary-foreground: #FAFAFA;
51
70
  --link: var(--primary);
52
71
  --secondary: oklch(0.9700 0 0);
@@ -60,12 +79,12 @@
60
79
  --border: oklch(0.6100 0 0);
61
80
  --input: oklch(0.6100 0 0);
62
81
  --ring: oklch(0.4500 0 0);
63
- --chart-1: oklch(0.5836 0.2469 264.05);
64
- --chart-2: oklch(0.5000 0.2345 264.05);
65
- --chart-3: oklch(0.4200 0.1975 264.05);
66
- --chart-4: oklch(0.3400 0.1481 264.05);
67
- --chart-5: oklch(0.2700 0.0988 264.05);
68
- --sidebar: oklch(0.9700 0 0);
82
+ --chart-1: oklch(0.6200 0.2000 220);
83
+ --chart-2: oklch(0.6200 0.2200 145);
84
+ --chart-3: oklch(0.6700 0.2000 70);
85
+ --chart-4: oklch(0.6000 0.2600 340);
86
+ --chart-5: oklch(0.6200 0.2200 25);
87
+ --sidebar: oklch(0.9850 0 0);
69
88
  --sidebar-foreground: oklch(0.1450 0 0);
70
89
  --sidebar-primary: oklch(0.2050 0 0);
71
90
  --sidebar-primary-foreground: oklch(0.9850 0 0);
@@ -103,58 +122,73 @@
103
122
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
104
123
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
105
124
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
125
+ --spring-gentle: cubic-bezier(0.4, 0, 0.2, 1);
126
+ --spring-snappy: cubic-bezier(0.3, 0, 0, 1);
127
+ --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
128
+ --motion-fade-duration: 200ms;
129
+ --motion-fade-ease: cubic-bezier(0, 0, 0.2, 1);
130
+ --motion-slide-duration: 200ms;
131
+ --motion-slide-ease: cubic-bezier(0, 0, 0.2, 1);
132
+ --motion-scale-duration: 150ms;
133
+ --motion-scale-ease: cubic-bezier(0.3, 0, 0, 1);
134
+ --motion-expand-duration: 300ms;
135
+ --motion-expand-ease: cubic-bezier(0.4, 0, 0.2, 1);
136
+ --motion-spin-duration: 300ms;
137
+ --motion-spin-ease: cubic-bezier(0, 0, 1, 1);
106
138
  --spacing: 0.25rem;
107
139
 
108
140
  /* Chart palette — derives from --primary so brand changes propagate.
109
141
  Override individual --chart-N inline (documentElement.style) to opt out. */
110
- --chart-1: oklch(from var(--primary) 0.58 c h);
111
- --chart-2: oklch(from var(--primary) 0.50 calc(c * 0.95) h);
112
- --chart-3: oklch(from var(--primary) 0.42 calc(c * 0.80) h);
113
- --chart-4: oklch(from var(--primary) 0.34 calc(c * 0.60) h);
114
- --chart-5: oklch(from var(--primary) 0.27 calc(c * 0.40) h);
142
+ --chart-lightness: 0.58;
143
+ --chart-1: oklch(from var(--primary) var(--chart-lightness) c calc(h + 0));
144
+ --chart-2: oklch(from var(--primary) var(--chart-lightness) calc(c * 0.65) calc(h + 35));
145
+ --chart-3: oklch(from var(--primary) var(--chart-lightness) c calc(h + 70));
146
+ --chart-4: oklch(from var(--primary) var(--chart-lightness) c calc(h + 105));
147
+ --chart-5: oklch(from var(--primary) var(--chart-lightness) c calc(h + 140));
115
148
  }
116
149
 
117
150
  .dark {
118
- --background: #040D20;
119
- --foreground: #FAFCFC;
120
- --card: #09142A;
121
- --card-foreground: #FAFCFC;
122
- --popover: #0E295E;
123
- --popover-foreground: #FAFCFC;
151
+ --background: oklch(0.1450 0 0);
152
+ --foreground: oklch(0.9850 0 0);
153
+ --card: oklch(0.2050 0 0);
154
+ --card-foreground: oklch(0.9850 0 0);
155
+ --popover: oklch(0.2690 0 0);
156
+ --popover-foreground: oklch(0.9850 0 0);
124
157
  --primary: #FAFAFA;
125
158
  --primary-foreground: #1F1F1F;
126
159
  --link: var(--primary);
127
- --secondary: #0A1D42;
128
- --secondary-foreground: #FAFCFC;
129
- --muted: #0A1D42;
130
- --muted-foreground: #B8D6E5;
131
- --accent: #0E295E;
132
- --accent-foreground: #FAFCFC;
160
+ --secondary: oklch(0.2690 0 0);
161
+ --secondary-foreground: oklch(0.9850 0 0);
162
+ --muted: oklch(0.2690 0 0);
163
+ --muted-foreground: oklch(0.7800 0 0);
164
+ --accent: oklch(0.3710 0 0);
165
+ --accent-foreground: oklch(0.9850 0 0);
133
166
  --destructive: oklch(0.7500 0.1600 22.2160);
134
167
  --destructive-foreground: oklch(0.1500 0 0);
135
- --border: rgb(255 255 255 / 0.10);
136
- --input: rgb(255 255 255 / 0.10);
137
- --ring: #B8D6E5;
138
- --chart-1: oklch(0.7800 0.1850 264.05);
139
- --chart-2: oklch(0.7000 0.2100 264.05);
140
- --chart-3: oklch(0.6200 0.1975 264.05);
141
- --chart-4: oklch(0.5600 0.1481 264.05);
142
- --chart-5: oklch(0.5200 0.0988 264.05);
143
- --sidebar: #09142A;
144
- --sidebar-foreground: #FAFCFC;
168
+ --border: oklch(0.5500 0 0);
169
+ --input: oklch(0.5500 0 0);
170
+ --ring: oklch(0.7000 0 0);
171
+ --chart-1: oklch(0.7800 0.1800 220);
172
+ --chart-2: oklch(0.8000 0.2000 145);
173
+ --chart-3: oklch(0.8500 0.2000 75);
174
+ --chart-4: oklch(0.7600 0.2200 340);
175
+ --chart-5: oklch(0.7800 0.1800 25);
176
+ --sidebar: oklch(0.1450 0 0);
177
+ --sidebar-foreground: oklch(0.9850 0 0);
145
178
  --sidebar-primary: oklch(0.4200 0.2000 264.3760);
146
- --sidebar-primary-foreground: #FAFCFC;
147
- --sidebar-accent: #0E295E;
148
- --sidebar-accent-foreground: #FAFCFC;
149
- --sidebar-border: #527081;
150
- --sidebar-ring: #B8D6E5;
179
+ --sidebar-primary-foreground: oklch(0.9850 0 0);
180
+ --sidebar-accent: oklch(0.2690 0 0);
181
+ --sidebar-accent-foreground: oklch(0.9850 0 0);
182
+ --sidebar-border: oklch(0.5500 0 0);
183
+ --sidebar-ring: oklch(0.7000 0 0);
151
184
 
152
185
  /* Chart palette (dark) — same derivation, mode-specific L floor for AAA. */
153
- --chart-1: oklch(from var(--primary) 0.78 c h);
154
- --chart-2: oklch(from var(--primary) 0.70 calc(c * 0.95) h);
155
- --chart-3: oklch(from var(--primary) 0.62 calc(c * 0.80) h);
156
- --chart-4: oklch(from var(--primary) 0.56 calc(c * 0.60) h);
157
- --chart-5: oklch(from var(--primary) 0.52 calc(c * 0.40) h);
186
+ --chart-lightness: 0.78;
187
+ --chart-1: oklch(from var(--primary) var(--chart-lightness) c calc(h + 0));
188
+ --chart-2: oklch(from var(--primary) var(--chart-lightness) calc(c * 0.65) calc(h + 35));
189
+ --chart-3: oklch(from var(--primary) var(--chart-lightness) c calc(h + 70));
190
+ --chart-4: oklch(from var(--primary) var(--chart-lightness) c calc(h + 105));
191
+ --chart-5: oklch(from var(--primary) var(--chart-lightness) c calc(h + 140));
158
192
  }
159
193
 
160
194
  @theme inline {
@@ -228,6 +262,9 @@
228
262
  --ease-out: var(--ease-out);
229
263
  --ease-in-out: var(--ease-in-out);
230
264
  --ease-spring: var(--ease-spring);
265
+ --ease-spring-gentle: var(--spring-gentle);
266
+ --ease-spring-snappy: var(--spring-snappy);
267
+ --ease-spring-bounce: var(--spring-bounce);
231
268
 
232
269
  /* Accessibility floor — minimum 14px for text-xs (vs Tailwind's 12px default).
233
270
  Font sizes are dynamically computed by useGlobalTypeScale hook and set as
@@ -279,7 +316,10 @@
279
316
  imports stylesheets in. Both rules live in @layer base; within a layer,
280
317
  specificity decides. `:root *` is (0,1,0), `*` is (0,0,0) — we win. Utility
281
318
  classes in @layer utilities still beat both because later layers trump
282
- specificity, so `border-red-500` and friends keep working normally. */
319
+ specificity, so `border-red-500` and friends keep working normally.
320
+ Without this bump, consumers who @import the design system BEFORE
321
+ tailwindcss get a cascade-order race where preflight wins and naked
322
+ `border` utilities render as text color (near-white on dark themes). */
283
323
  :root * {
284
324
  @apply border-border outline-ring/50;
285
325
  }
@@ -290,6 +330,11 @@
290
330
  fall through to system-ui regardless of the brand-font selection. */
291
331
  html {
292
332
  font-family: var(--font-sans);
333
+ /* Variable-font axis settings (Inter Variable ships by default). Sourced
334
+ from tokens.json → --font-variation-settings so forks tune optical
335
+ size / weight axes without touching component source. "normal" is a
336
+ no-op for static fonts. */
337
+ font-variation-settings: var(--font-variation-settings, normal);
293
338
  }
294
339
  /* Match: monospace elements pick up --font-mono without each component
295
340
  having to remember a `font-mono` class. */
@@ -323,23 +368,20 @@
323
368
  }
324
369
  /* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
325
370
  text. Scope to <p> only — UI primitives stay tight. Last-child has
326
- no trailing margin so containers don't get extra padding.
327
-
328
- The second rule bows out of flex / grid contexts because by the
329
- time an author has wrapped content in display:flex or display:grid,
330
- they are clearly building UI layout (rows of chips, tile metadata,
331
- calendar entries, etc.) and not running prose. Without this
332
- carve-out, every <p> used as a UI label inside a flex row gets
333
- an extra 1.5em margin-bottom, which silently inflates its margin
334
- box and breaks vertical alignment with adjacent items (a dot
335
- beside an uppercase eyebrow drops below the visible text, the
336
- classic symptom). The proper semantic fix is to use <span> for
337
- UI labels, but the design system shouldn't punish authors who
338
- reach for <p> in obvious UI contexts. Specificity 0,2,1 wins
339
- over the bare 0,1,1 rule above. */
371
+ no trailing margin so containers don't get extra padding. */
340
372
  p:not(:last-child) {
341
373
  margin-bottom: 1.5em;
342
374
  }
375
+ /* Flex / grid layout carve-out for the rule above. When <p> is used as
376
+ a UI label inside a flex row or grid cell, the 1.5em ghost margin-
377
+ bottom inflates its margin box, which drags its geometric center
378
+ down. items-center then aligns siblings (org-color dots, icons,
379
+ badges) to a lower y than the visible text. Zero the block margins
380
+ on <p> one level deep into any flex/grid container, and through one
381
+ wrapper, so authors who reach for <p> in obvious UI contexts don't
382
+ silently break alignment. Specificity ties the bare prose rule at
383
+ 0,1,1 — source order resolves the tie, which is why this block must
384
+ follow the rule above. */
343
385
  :is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) p,
344
386
  :is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) > * > p {
345
387
  margin-block: 0;
@@ -366,6 +408,54 @@
366
408
  scroll-behavior: auto !important;
367
409
  }
368
410
  }
411
+ /* Windows High Contrast Mode (forced-colors). Supports SC 1.4.1 (Use of
412
+ Color) and 1.4.11 (Non-text Contrast) for the ~3% of Windows users who
413
+ run HCM. When the OS forces its own palette it discards our custom
414
+ background fills — so a ghost/secondary Button, a selected tab, or a
415
+ checked control that relied on a background tint to read as distinct
416
+ collapses into the body text. The UA keeps token *borders* (mapping
417
+ them to system colors) but cannot invent a boundary where none was
418
+ drawn. These rules restore the structure the override drops; they do
419
+ NOT hardcode brand colors (that's forbidden) — they use the CSS
420
+ system-color keywords HCM actually honors. */
421
+ @media (forced-colors: active) {
422
+ /* Every interactive control gets a drawn boundary so it survives the
423
+ loss of its background fill. ButtonBorder is the system color the UA
424
+ uses for control edges. */
425
+ button,
426
+ [role="button"],
427
+ input,
428
+ select,
429
+ textarea {
430
+ border: 1px solid ButtonBorder;
431
+ }
432
+ /* Focus ring maps to the system Highlight so it is never invisible,
433
+ regardless of the user's chosen high-contrast theme. */
434
+ :focus-visible {
435
+ outline: 2px solid Highlight;
436
+ outline-offset: 2px;
437
+ }
438
+ /* Selected / checked / pressed / active states lose their background
439
+ tint under HCM. Opt out of forced-color-adjust for just these state
440
+ markers and paint the system Highlight so on/off stays legible on
441
+ toggles, switches, selected tabs, and checkboxes. */
442
+ [aria-selected="true"],
443
+ [aria-checked="true"],
444
+ [aria-pressed="true"],
445
+ [data-state="checked"],
446
+ [data-state="active"],
447
+ [data-state="on"] {
448
+ forced-color-adjust: none;
449
+ background-color: Highlight;
450
+ color: HighlightText;
451
+ }
452
+ /* Disabled controls should read as dimmed via the system GrayText color
453
+ rather than our muted token (which the override would flatten). */
454
+ :disabled,
455
+ [aria-disabled="true"] {
456
+ color: GrayText;
457
+ }
458
+ }
369
459
  }
370
460
 
371
461
  /* Global tracking offset — the Letter Spacing slider in the Customize