@hanzo/design 0.4.0 → 0.4.1

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.
package/tailwind.css CHANGED
@@ -39,9 +39,25 @@
39
39
  /* Hanzo is monochrome. One hue rendered through an opacity ladder.
40
40
  Base ladder = Tailwind neutral (tailwind.config.ts). Semantic names match
41
41
  hanzo.ai's CSS variables exactly, so code copies over 1:1.
42
- DARK IS THE DEFAULT THEME (hanzo.ai mounts ThemeProvider defaultTheme="dark"). */
42
+ DARK IS THE DEFAULT THEME (hanzo.ai mounts ThemeProvider defaultTheme="dark").
43
+
44
+ The dark palette is derived from the chat surface in hanzoai/extension
45
+ (packages/browser/src/sidebar.css), which is the reference aesthetic: a
46
+ #0a0a0a ground, #fafafa ink, and boundaries drawn as LOW-ALPHA HAIRLINES.
47
+ Two properties of that reference are load-bearing and easy to lose:
48
+
49
+ 1. Borders are alpha, not hex. rgb(255 255 255 / .10) composites correctly on
50
+ #0a0a0a AND on #262626; a solid #1f1f1f reads on the page and vanishes the
51
+ moment it lands on a lifted surface — which is why anyone who needed a
52
+ visible edge reached past it for the CONTROL rung and got a wireframe.
53
+ 2. Surfaces lift by tiny steps (0a -> 0f -> 17 -> 26), and ink is a graded
54
+ ramp (#fafafa -> .78 -> .55 -> #a3a3a3), not one flat white. Pure #ffffff
55
+ on pure #000000 is 21:1 — the maximum-contrast pair that exists, and it
56
+ halates. #fafafa on #0a0a0a is 18.1:1: still far past AAA, visibly softer. */
43
57
 
44
58
  :root{
59
+ color-scheme:dark;
60
+
45
61
  /* ——— base neutral ladder ——— */
46
62
  --neutral-50:#FAFAFA;
47
63
  --neutral-100:#F5F5F5;
@@ -61,45 +77,97 @@
61
77
  --hanzo-white:#FFFFFF;
62
78
 
63
79
  /* ——— the opacity ladder: the real palette ——— */
80
+ /* Every rung below .30 is a HAIRLINE or a LIFT — the two things this system
81
+ draws with. The rungs are the reference's own values, not a rounded ramp. */
64
82
  --white-05:rgb(255 255 255 / .05);
83
+ --white-06:rgb(255 255 255 / .06);
84
+ --white-08:rgb(255 255 255 / .08);
65
85
  --white-10:rgb(255 255 255 / .10);
66
86
  --white-15:rgb(255 255 255 / .15);
87
+ --white-16:rgb(255 255 255 / .16);
67
88
  --white-20:rgb(255 255 255 / .20);
89
+ --white-22:rgb(255 255 255 / .22);
68
90
  --white-30:rgb(255 255 255 / .30);
69
91
  --white-40:rgb(255 255 255 / .40);
92
+ --white-55:rgb(255 255 255 / .55);
70
93
  --white-60:rgb(255 255 255 / .60);
94
+ --white-78:rgb(255 255 255 / .78);
71
95
  --white-80:rgb(255 255 255 / .80);
72
96
 
73
97
  /* ——— semantic aliases (dark, the default) ——— */
74
- --background:#000000;
75
- --foreground:#ededed;
76
- --card:#0a0a0a;
77
- --card-foreground:#f5f5f5;
78
- --popover:#0a0a0a;
79
- --popover-foreground:#f5f5f5;
80
- --primary:#ffffff;
81
- --primary-foreground:#000000;
82
- --secondary:#1a1a1a;
83
- --secondary-foreground:#f5f5f5;
84
- --muted:#101010;
85
- --muted-foreground:#888888;
86
- --accent:#1a1a1a;
87
- --accent-foreground:#f5f5f5;
98
+ --background:#0a0a0a;
99
+ --foreground:#fafafa;
100
+ --card:#0f0f0f;
101
+ --card-foreground:#fafafa;
102
+ --popover:#0f0f0f;
103
+ --popover-foreground:#fafafa;
104
+ --primary:#fafafa;
105
+ --primary-hover:#d4d4d4;
106
+ --primary-foreground:#0a0a0a;
107
+ --secondary:#262626;
108
+ --secondary-foreground:#fafafa;
109
+ --muted:#171717;
110
+ --muted-foreground:#a3a3a3;
111
+ --accent:#262626;
112
+ --accent-foreground:#fafafa;
88
113
  --destructive:#666666;
89
- --destructive-foreground:#f5f5f5;
90
- --border:#1f1f1f;
91
- --input:#1f1f1f;
114
+ --destructive-foreground:#fafafa;
115
+
116
+ /* ——— boundaries ———
117
+ THREE tiers, and the split is the whole point. The first two are DECORATIVE:
118
+ they separate content, WCAG imposes no ratio on them, and they must stay
119
+ quiet. The third is PERCEIVABLE: it is the edge that IS the affordance.
120
+
121
+ --border the hairline. Every card, panel, divider, list row.
122
+ --border-strong the SAME hairline, one step up. Hover, active, emphasis.
123
+ --border-control a control's edge — input, select, textarea, checkbox,
124
+ switch. Must clear 3:1 on every surface in both themes
125
+ (WCAG 1.4.11); check-tokens.mjs pins it.
126
+
127
+ Before this split there were only two rungs and they were an octave apart:
128
+ --border at #1f1f1f (1.27:1, invisible on anything lifted) and
129
+ --border-strong at --neutral-500 (4.43:1). Nothing sat between, so every
130
+ surface that wanted a border it could actually SEE reached for the control
131
+ rung — and a 1px mid-grey box around a card on near-black is a wireframe.
132
+ That is the "garish outlines" complaint, and it is fixed by having a middle.
133
+
134
+ A boundary that is WCAG-perceivable on a near-black ground IS a mid-grey;
135
+ that cannot be tuned away. So it is not tuned away — it is NAMED, so it can
136
+ only be spent where it is owed. "strong" is a degree word and will always be
137
+ read as one; "control" is a duty.
138
+
139
+ Which ladder a boundary is cut from follows from that, and is the whole
140
+ rule: DECORATIVE edges come off the ALPHA ladder, because they owe quiet
141
+ and they must composite over whatever surface they land on. CONTROL edges
142
+ come off the NEUTRAL ladder, because they owe a contrast ratio, and a ratio
143
+ you can only meet at a fixed value is not something to express as alpha.
144
+ --border-focus is therefore one NEUTRAL rung above --border-control, not an
145
+ alpha step: a focused field has to read brighter than a resting one, and
146
+ the resting one already sits at the WCAG floor. */
147
+ --border:var(--white-10);
148
+ --border-strong:var(--white-16);
149
+ --border-control:var(--neutral-500); /* 4.43:1 worst case — see --ring */
150
+ --border-focus:var(--neutral-400); /* one rung up: the field is focused */
151
+ --input:var(--border-control); /* shadcn `border-input` — a control */
92
152
  /* A focus indicator is a NON-TEXT CONTRAST target: WCAG 2.4.11/1.4.11 require
93
153
  3:1 against every surface it can land on. --neutral-500 is the only rung on
94
- this ladder that clears 3:1 on all of them — #000000, #0a0a0a, #101010,
95
- #1a1a1a, AND the light theme's #ffffff/#f5f5f5 — so one value serves both
154
+ this ladder that clears 3:1 on all of them — #0a0a0a, #0f0f0f, #171717,
155
+ #262626, AND the light theme's #ffffff/#fafafa — so one value serves both
96
156
  themes. (Was #333333 = 1.66:1 on --background: not a focus indicator.) */
97
157
  --ring:var(--neutral-500);
98
158
  --brand:#e4e4e7;
99
159
  --brand-foreground:#09090b;
100
160
  --brand-muted:#a3a3a3;
101
161
  --black:#000000;
102
- --white:#f5f5f5;
162
+ --white:#fafafa;
163
+ --selection:var(--white-20);
164
+
165
+ /* ——— glass: the lift ———
166
+ How a surface rises WITHOUT a block fill. An alpha-white wash composites
167
+ over whatever it lands on, so one value works on the page, on a card and
168
+ inside a popover. This is the mechanism behind the reference's depth. */
169
+ --glass:var(--white-05);
170
+ --glass-strong:var(--white-08);
103
171
 
104
172
  /* ——— surface recipes (card fills used across hanzo.ai) ——— */
105
173
  --surface-page:var(--background);
@@ -109,29 +177,22 @@
109
177
  --surface-overlay:rgb(10 10 10 / .95); /* dropdown / popover panels */
110
178
  --surface-header:rgb(0 0 0 / .7); /* fixed nav, with backdrop blur */
111
179
  --surface-scrim:rgb(0 0 0 / .8); /* the dialog / sheet backdrop */
112
- /* Boundaries come in two kinds and they are NOT interchangeable.
113
- DECORATIVE (--border, --border-hairline, --border-card): separates content;
114
- WCAG imposes no ratio. Keep them quiet.
115
- PERCEIVABLE (--border-strong): identifies a CONTROL — an input edge, a
116
- switch, a checkbox — and must clear 3:1 (WCAG 1.4.11) on every surface.
117
- Reach for --border-strong whenever the boundary IS the affordance. */
118
- --border-hairline:var(--neutral-800);
119
- --border-card:var(--white-10);
120
- --border-strong:var(--neutral-500); /* 3.59:1 worst case — see --ring */
121
180
 
122
181
  /* ——— the numeric surface ladder ——— */
123
182
  /* Aliases onto the semantic canvases above, so a brand fork that retunes
124
183
  --card/--muted/--secondary retunes the ladder with it and the light theme
125
- inverts for free. Ascending lift: 0 is the page, 3 is a hovered control. */
184
+ inverts for free. Ascending lift: 0 is the page, 3 is a hovered control.
185
+ Dark resolves to the reference's own ladder — 0a / 0f / 17 / 26. */
126
186
  --surface-0:var(--background);
127
187
  --surface-1:var(--card);
128
188
  --surface-2:var(--muted);
129
189
  --surface-3:var(--secondary);
130
190
 
131
- /* ——— text ranks ——— */
132
- --text-primary:var(--pure-white);
133
- --text-secondary:var(--white-80);
134
- --text-tertiary:var(--white-60);
191
+ /* ——— text ranks ———
192
+ A graded ramp, not one flat white. The steps are the reference's. */
193
+ --text-primary:#fafafa;
194
+ --text-secondary:var(--white-78);
195
+ --text-tertiary:var(--white-55);
135
196
  --text-helper:var(--muted-foreground);
136
197
  --text-disabled:var(--white-30);
137
198
 
@@ -146,47 +207,55 @@
146
207
  --chrome-dot-green:rgb(34 197 94 / .6);
147
208
  }
148
209
 
149
- /* Light theme — the same tokens, inverted. Rare: only /brand-style docs pages. */
210
+ /* Light theme — the same tokens, inverted.
211
+ The white-opacity ladder does NOT invert: --white-16 is white-on-white here.
212
+ So EVERY token whose dark value is a --white-* rung must be restated below,
213
+ and check-tokens.mjs fails the build if one is missed — that class of bug is
214
+ silent (the border simply stops existing) and has shipped before. */
150
215
  .light{
216
+ color-scheme:light;
151
217
  --background:#ffffff;
152
218
  --foreground:#0a0a0a;
153
- --card:#f5f5f5;
219
+ /* A ladder, not four names for #f5f5f5. Light lifts by the same tiny steps
220
+ dark does — ~2% per rung — so --surface-0..3 mean something in both themes. */
221
+ --card:#fafafa;
154
222
  --card-foreground:#0a0a0a;
155
223
  --popover:#ffffff;
156
224
  --popover-foreground:#0a0a0a;
157
225
  --primary:#0a0a0a;
158
- --primary-foreground:#ffffff;
159
- --secondary:#f5f5f5;
226
+ --primary-hover:#262626;
227
+ --primary-foreground:#fafafa;
228
+ --secondary:#ededed;
160
229
  --secondary-foreground:#0a0a0a;
161
230
  --muted:#f5f5f5;
162
231
  --muted-foreground:#525252;
163
- --accent:#f5f5f5;
232
+ --accent:#ededed;
164
233
  --accent-foreground:#0a0a0a;
165
234
  --destructive:#999999;
166
235
  --destructive-foreground:#ffffff;
167
- --border:#e5e5e5;
168
- --input:#e5e5e5;
236
+ --border:rgb(0 0 0 / .10);
237
+ --border-strong:rgb(0 0 0 / .16);
238
+ --border-control:var(--neutral-500); /* 4.74:1 on #ffffff — conformant here too */
239
+ --border-focus:var(--neutral-600); /* one rung DOWN — darker reads as brighter here */
240
+ --input:var(--border-control);
169
241
  /* Same rung as dark: #d4d4d4 measured 1.48:1 on white and could not carry a
170
242
  focus indicator either. --neutral-500 is 4.74:1 on #ffffff / 4.38:1 on
171
243
  #f5f5f5, so ONE value is conformant in both themes. */
172
244
  --ring:var(--neutral-500);
173
245
  --black:#0a0a0a;
174
246
  --white:#ffffff;
175
- --surface-card:#f5f5f5;
247
+ --selection:rgb(0 0 0 / .16);
248
+ --glass:rgb(0 0 0 / .04);
249
+ --glass-strong:rgb(0 0 0 / .07);
250
+ --surface-card:#fafafa;
176
251
  --surface-card-emphasis:#ffffff;
177
- --surface-card-quiet:#fafafa;
252
+ --surface-card-quiet:#fcfcfc;
178
253
  --surface-overlay:rgb(255 255 255 / .95);
179
254
  --surface-header:rgb(255 255 255 / .8);
180
255
  --surface-scrim:rgb(0 0 0 / .5);
181
- --border-hairline:var(--neutral-200);
182
- --border-card:rgb(0 0 0 / .1);
183
- --border-strong:var(--neutral-500); /* was --neutral-300 = 1.48:1 on white */
184
- /* The white-opacity ladder does NOT invert, so --white-40 is white-on-white
185
- here (1.00:1). Anything that needs a visible edge in BOTH themes must use
186
- --border-strong, never a --white-* rung. */
187
256
  --text-primary:var(--neutral-950);
188
- --text-secondary:rgb(10 10 10 / .8);
189
- --text-tertiary:rgb(10 10 10 / .6);
257
+ --text-secondary:rgb(10 10 10 / .78);
258
+ --text-tertiary:rgb(10 10 10 / .55);
190
259
  --text-disabled:rgb(10 10 10 / .3);
191
260
  }
192
261
 
@@ -229,6 +298,19 @@
229
298
  --font-size-8xl:var(--text-8xl);
230
299
  --font-size-9xl:var(--text-9xl);
231
300
 
301
+ /* The size a FORM CONTROL renders at — and the ONE step in this scale that is
302
+ not a constant. iOS Safari zooms the viewport whenever a focused input
303
+ computes below 16px, and this scale's base is 14px, so every surface that
304
+ sized a field from --text-sm or --text-base bought the zoom.
305
+
306
+ It has to be a TOKEN rather than a rule because a control's size is almost
307
+ always set inline (every component in components/forms does), and an inline
308
+ style outranks any stylesheet — including a media query. A var() resolves
309
+ per-device inside that inline style, so this is the only construction that
310
+ actually reaches the control. Fields ask for --text-control; nothing else
311
+ should. */
312
+ --text-control:var(--text-sm);
313
+
232
314
  --weight-normal:400;
233
315
  --weight-medium:500;
234
316
  --weight-semibold:600;
@@ -257,6 +339,14 @@
257
339
  --type-eyebrow:600 0.625rem/1 var(--font-sans);
258
340
  }
259
341
 
342
+ /* On touch, a control goes to 16px. Below that iOS Safari zooms the viewport on
343
+ focus and never zooms back out, which is the single most common way a mobile
344
+ form feels broken. pointer:coarse is the real signal — a desktop mouse keeps
345
+ the compact 13px field. */
346
+ @media (pointer:coarse){
347
+ :root{--text-control:1rem}
348
+ }
349
+
260
350
  /* ── tokens/spacing.css ─────────────────────────────────────── */
261
351
  /* Spacing: the 4px Tailwind ramp is what ships. The golden-ratio ramp below is
262
352
  declared in hanzo.ai's tailwind.config.ts (legacy v3 config, kept for
@@ -290,18 +380,57 @@
290
380
  --golden-9:11.749rem;
291
381
  --golden-split:38.2% 61.8%; /* @kind other */
292
382
 
293
- /* layout rules (DESIGN.md §1.3) */
383
+ /* layout rules (DESIGN.md §1.3)
384
+ MOBILE-FIRST: the values authored here are the PHONE values, and the
385
+ min-width block at the bottom of this file scales them up. A surface that
386
+ uses the raw token therefore gets a layout that already breathes correctly
387
+ at 390px, with no media query of its own. (This is also the value the
388
+ generator captures for tokens.gen.ts — first occurrence wins, and the
389
+ authored default is the small one.) */
294
390
  --container-max:80rem; /* max-w-7xl — grids */
295
391
  --container-prose:48rem; /* max-w-3xl — centered text */
296
392
  --container-wide:72rem; /* max-w-6xl — landing sections */
297
- --gutter:1rem; /* px-4 */
393
+ /* The page gutter also clears a notch. env() is 0px on every device without
394
+ one, so this is exactly `1rem` in the ordinary case and the safe inset when
395
+ there is something to avoid — no per-app work, no landscape clipping.
396
+ Requires `<meta name="viewport" content="…,viewport-fit=cover">` on the
397
+ host page; without it the UA reports 0 and the max() is inert, not wrong. */
398
+ --gutter:max(1rem,var(--safe-left),var(--safe-right));
298
399
  --gutter-sm:1.5rem; /* sm:px-6 */
299
400
  --gutter-lg:2rem; /* lg:px-8 */
300
- --section-y:4rem; /* py-16 content sections */
301
- --section-y-lg:6rem; /* py-24 landing sections */
302
- --hero-y:5rem; /* py-20 */
303
- --hero-y-lg:8rem; /* lg:py-32 */
304
- --header-height:4rem;
401
+ --section-y:2.5rem; /* py-10 on a phone → py-16 at md */
402
+ --section-y-lg:3.5rem; /* py-14 on a phone → py-24 at md */
403
+ --hero-y:3rem; /* py-12 on a phone → py-20 at md */
404
+ --hero-y-lg:4.5rem; /* py-18 on a phone → py-32 at md */
405
+ --header-height:3.5rem; /* 56px is the phone bar; 64px from md */
406
+
407
+ /* ——— touch ——— */
408
+ /* 44px is the floor a pointer-coarse target may render at (Apple HIG 44pt /
409
+ WCAG 2.5.5 AAA / 2.5.8 AA's 24px, taken at the higher bar). base.css spends
410
+ it automatically under `@media (pointer:coarse)`, so a button does not have
411
+ to opt in. It was previously a bare `min-height:44px` literal in
412
+ hanzoai/id's stylesheet — one app knowing something the system did not. */
413
+ --tap-target:44px;
414
+
415
+ /* ——— safe areas ——— */
416
+ /* The notch/home-indicator insets, named once. Anything pinned to a viewport
417
+ edge — a fixed header, a bottom bar, a sheet — adds the matching one. */
418
+ --safe-top:env(safe-area-inset-top,0px);
419
+ --safe-right:env(safe-area-inset-right,0px);
420
+ --safe-bottom:env(safe-area-inset-bottom,0px);
421
+ --safe-left:env(safe-area-inset-left,0px);
422
+ }
423
+
424
+ /* Scale up from the phone. `md` (48rem) is the same breakpoint grid.css
425
+ declares and Tailwind compiles against — one value, not two that agree. */
426
+ @media (min-width:48rem){
427
+ :root{
428
+ --section-y:4rem; /* py-16 — content sections */
429
+ --section-y-lg:6rem; /* py-24 — landing sections */
430
+ --hero-y:5rem; /* py-20 … */
431
+ --hero-y-lg:8rem; /* … lg:py-32 */
432
+ --header-height:4rem;
433
+ }
305
434
  }
306
435
 
307
436
  /* ── tokens/grid.css ─────────────────────────────────────── */
@@ -509,19 +638,36 @@
509
638
  The same trap already bit `text-decoration` here once (see the a:hover note
510
639
  below). It was fixed by deleting that one declaration, which left the identical
511
640
  defect in `color` untouched. Layering fixes the whole class: these are
512
- DEFAULTS, and a default must lose to anything an app states deliberately. */
641
+ DEFAULTS, and a default must lose to anything an app states deliberately.
642
+
643
+ The rules added for controls, media and touch go one step further and wrap
644
+ their selectors in :where(), which has ZERO specificity. @layer decides who
645
+ wins BETWEEN layers; :where() decides who wins INSIDE this one. An app that
646
+ ships its own reset — `input { … }`, `img { … }` — very often lands in the
647
+ same base layer, and these defaults have to lose that collision too. */
513
648
  @layer base {
514
649
  *{box-sizing:border-box;border-color:var(--border)}
515
- html{-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;scroll-behavior:smooth}
650
+ html{
651
+ -webkit-font-smoothing:antialiased;
652
+ text-rendering:optimizeLegibility;
653
+ scroll-behavior:smooth;
654
+ /* iOS inflates text when a phone is rotated to landscape unless this is
655
+ pinned. It is the single most common reason a mobile layout that was
656
+ verified in portrait comes apart on its side. */
657
+ -webkit-text-size-adjust:100%;
658
+ }
516
659
  /* Each font-family carries the stack as a literal fallback. --font-sans lives in
517
660
  tokens/fonts.css, which a surface may legitimately import separately; without
518
661
  the fallback an unresolved var() makes font-family invalid and the UA drops to
519
662
  its SERIF default — the whole console silently rendered in Times. */
520
- body{margin:0;background:var(--background);color:var(--foreground);font-family:var(--font-sans,ui-sans-serif,system-ui,sans-serif);font-size:var(--text-base);line-height:var(--leading-base);font-feature-settings:var(--font-feature-settings)}
663
+ body{margin:0;background:var(--background);color:var(--foreground);font-family:var(--font-sans,ui-sans-serif,system-ui,sans-serif);font-size:var(--text-base);line-height:var(--leading-base);font-feature-settings:var(--font-feature-settings);overflow-wrap:break-word}
521
664
  h1,h2,h3,h4{margin:0;font-family:var(--font-display,var(--font-sans,ui-sans-serif,system-ui,sans-serif));letter-spacing:var(--tracking-tight);color:var(--text-primary)}
522
665
  p{margin:0;text-wrap:pretty}
523
666
  code,pre,kbd{font-family:var(--font-mono,ui-monospace,SFMono-Regular,monospace)}
524
- a{color:var(--text-primary);text-decoration:none;text-underline-offset:4px;transition:color var(--duration-fast) var(--ease-out)}
667
+ /* No `transition` here: the shared interactive rule below states one, and an
668
+ `a` selector (0,0,1) would outrank that :where() (0,0,0) and replace the
669
+ whole shorthand — anchors would transition colour and nothing else. */
670
+ a{color:var(--text-primary);text-decoration:none;text-underline-offset:4px}
525
671
  /* Underline is the accessible affordance for a link in RUNNING TEXT and a visual
526
672
  bug everywhere else: nav items, cards and anchor-buttons are all <a> too, so a
527
673
  blanket `a:hover` underlined every one of them on every surface that imports
@@ -530,8 +676,79 @@
530
676
  value `a` already has — a no-op that only served to outrank a component's own
531
677
  hover colour. */
532
678
  :is(p,li,blockquote,dd,dt,td,th,figcaption) a:hover{text-decoration:underline}
679
+
680
+ /* ——— the smooth ———
681
+ Every interactive element in the reference transitions its colour, its fill
682
+ and its EDGE. That is most of what separates "classy and smooth" from a
683
+ correct set of colours: a hairline that steps from .10 to .16 instantly
684
+ reads as a flicker, and over 150ms reads as a response. Granted once, here,
685
+ rather than restated on every component. tokens/motion.css already zeroes
686
+ all of it under prefers-reduced-motion. */
687
+ :where(a,button,[role=button],input,select,textarea,summary,[tabindex]){
688
+ transition:color var(--duration-fast) var(--ease-out),
689
+ background-color var(--duration-fast) var(--ease-out),
690
+ border-color var(--duration-fast) var(--ease-out),
691
+ box-shadow var(--duration-fast) var(--ease-out),
692
+ opacity var(--duration-fast) var(--ease-out);
693
+ }
694
+
695
+ /* ——— controls ———
696
+ A bare <input> renders in the UA's face (Arial) at the UA's size with the
697
+ UA's border, which puts two typefaces and a foreign blue focus ring inside
698
+ Hanzo cards on every surface that has not styled its own fields yet. The
699
+ rules below are what a control looks like here. --border-control, NOT
700
+ --border: the boundary IS the affordance, so it is the rung that owes 3:1. */
701
+ :where(input,select,textarea,button){font:inherit;color:inherit}
702
+ :where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),select,textarea){
703
+ background:var(--surface-2);
704
+ border:1px solid var(--border-control);
705
+ border-radius:var(--radius-sm);
706
+ padding:0 var(--space-3);
707
+ }
708
+ :where(textarea){padding:var(--space-2) var(--space-3);resize:vertical}
709
+ :where(input,select,textarea):focus-visible{border-color:var(--border-focus)}
710
+ :where(input,textarea)::placeholder{color:var(--text-disabled)}
711
+ :where(input,select,textarea,button):disabled{opacity:.5;cursor:not-allowed}
712
+ :where(button,[role=button],summary,label,select){cursor:pointer}
713
+
714
+ /* ——— media ———
715
+ An image, a video or an embed at its intrinsic width is the usual cause of a
716
+ 390px page that scrolls sideways. */
717
+ :where(img,svg,video,canvas,iframe,picture,object){max-width:100%}
718
+ :where(img,video){height:auto}
719
+ /* A code block scrolls ITSELF rather than widening the document. */
720
+ :where(pre){overflow-x:auto}
721
+
722
+ /* ——— touch ———
723
+ Everything a finger aims at clears 44px, and every field renders at 16px so
724
+ iOS does not zoom the viewport on focus. Both are keyed on pointer:coarse —
725
+ the actual signal — so a desktop mouse still gets compact controls. This is
726
+ the whole of "mobile-first without per-app work": an app that never thought
727
+ about phones still has hittable buttons and a viewport that stays put. */
728
+ @media (pointer:coarse){
729
+ :where(button,[role=button],a[role=button],summary,select,textarea,
730
+ input:not([type=checkbox]):not([type=radio]):not([type=hidden])){
731
+ min-height:var(--tap-target);
732
+ }
733
+ :where(input,select,textarea){font-size:var(--text-control)}
734
+ /* A checkbox, radio or switch must NOT grow to 44px — the box is 16px
735
+ because that is what a checkbox looks like. What has to reach 44px is the
736
+ area a finger may land in, so the target is expanded with a centred
737
+ pseudo-element that changes nothing about layout or paint. WCAG 2.5.8 puts
738
+ the floor at 24px; a 16px box misses it, and every one of these ships at
739
+ 16px. */
740
+ :where([role=checkbox],[role=radio],[role=switch],input[type=checkbox],input[type=radio]){position:relative}
741
+ :where([role=checkbox],[role=radio],[role=switch],input[type=checkbox],input[type=radio])::after{
742
+ content:'';position:absolute;top:50%;left:50%;
743
+ width:var(--tap-target);height:var(--tap-target);
744
+ transform:translate(-50%,-50%);
745
+ }
746
+ }
747
+
533
748
  :focus-visible{outline:2px solid var(--ring);outline-offset:2px}
534
- ::selection{background:var(--white-20);color:#fff}
749
+ /* --white-20 is white-on-white in the light theme, so selection reads through
750
+ --selection, which BOTH themes define. */
751
+ ::selection{background:var(--selection);color:var(--text-primary)}
535
752
  }
536
753
 
537
754
 
package/tokens/base.css CHANGED
@@ -12,19 +12,36 @@
12
12
  The same trap already bit `text-decoration` here once (see the a:hover note
13
13
  below). It was fixed by deleting that one declaration, which left the identical
14
14
  defect in `color` untouched. Layering fixes the whole class: these are
15
- DEFAULTS, and a default must lose to anything an app states deliberately. */
15
+ DEFAULTS, and a default must lose to anything an app states deliberately.
16
+
17
+ The rules added for controls, media and touch go one step further and wrap
18
+ their selectors in :where(), which has ZERO specificity. @layer decides who
19
+ wins BETWEEN layers; :where() decides who wins INSIDE this one. An app that
20
+ ships its own reset — `input { … }`, `img { … }` — very often lands in the
21
+ same base layer, and these defaults have to lose that collision too. */
16
22
  @layer base {
17
23
  *{box-sizing:border-box;border-color:var(--border)}
18
- html{-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;scroll-behavior:smooth}
24
+ html{
25
+ -webkit-font-smoothing:antialiased;
26
+ text-rendering:optimizeLegibility;
27
+ scroll-behavior:smooth;
28
+ /* iOS inflates text when a phone is rotated to landscape unless this is
29
+ pinned. It is the single most common reason a mobile layout that was
30
+ verified in portrait comes apart on its side. */
31
+ -webkit-text-size-adjust:100%;
32
+ }
19
33
  /* Each font-family carries the stack as a literal fallback. --font-sans lives in
20
34
  tokens/fonts.css, which a surface may legitimately import separately; without
21
35
  the fallback an unresolved var() makes font-family invalid and the UA drops to
22
36
  its SERIF default — the whole console silently rendered in Times. */
23
- body{margin:0;background:var(--background);color:var(--foreground);font-family:var(--font-sans,ui-sans-serif,system-ui,sans-serif);font-size:var(--text-base);line-height:var(--leading-base);font-feature-settings:var(--font-feature-settings)}
37
+ body{margin:0;background:var(--background);color:var(--foreground);font-family:var(--font-sans,ui-sans-serif,system-ui,sans-serif);font-size:var(--text-base);line-height:var(--leading-base);font-feature-settings:var(--font-feature-settings);overflow-wrap:break-word}
24
38
  h1,h2,h3,h4{margin:0;font-family:var(--font-display,var(--font-sans,ui-sans-serif,system-ui,sans-serif));letter-spacing:var(--tracking-tight);color:var(--text-primary)}
25
39
  p{margin:0;text-wrap:pretty}
26
40
  code,pre,kbd{font-family:var(--font-mono,ui-monospace,SFMono-Regular,monospace)}
27
- a{color:var(--text-primary);text-decoration:none;text-underline-offset:4px;transition:color var(--duration-fast) var(--ease-out)}
41
+ /* No `transition` here: the shared interactive rule below states one, and an
42
+ `a` selector (0,0,1) would outrank that :where() (0,0,0) and replace the
43
+ whole shorthand — anchors would transition colour and nothing else. */
44
+ a{color:var(--text-primary);text-decoration:none;text-underline-offset:4px}
28
45
  /* Underline is the accessible affordance for a link in RUNNING TEXT and a visual
29
46
  bug everywhere else: nav items, cards and anchor-buttons are all <a> too, so a
30
47
  blanket `a:hover` underlined every one of them on every surface that imports
@@ -33,6 +50,77 @@
33
50
  value `a` already has — a no-op that only served to outrank a component's own
34
51
  hover colour. */
35
52
  :is(p,li,blockquote,dd,dt,td,th,figcaption) a:hover{text-decoration:underline}
53
+
54
+ /* ——— the smooth ———
55
+ Every interactive element in the reference transitions its colour, its fill
56
+ and its EDGE. That is most of what separates "classy and smooth" from a
57
+ correct set of colours: a hairline that steps from .10 to .16 instantly
58
+ reads as a flicker, and over 150ms reads as a response. Granted once, here,
59
+ rather than restated on every component. tokens/motion.css already zeroes
60
+ all of it under prefers-reduced-motion. */
61
+ :where(a,button,[role=button],input,select,textarea,summary,[tabindex]){
62
+ transition:color var(--duration-fast) var(--ease-out),
63
+ background-color var(--duration-fast) var(--ease-out),
64
+ border-color var(--duration-fast) var(--ease-out),
65
+ box-shadow var(--duration-fast) var(--ease-out),
66
+ opacity var(--duration-fast) var(--ease-out);
67
+ }
68
+
69
+ /* ——— controls ———
70
+ A bare <input> renders in the UA's face (Arial) at the UA's size with the
71
+ UA's border, which puts two typefaces and a foreign blue focus ring inside
72
+ Hanzo cards on every surface that has not styled its own fields yet. The
73
+ rules below are what a control looks like here. --border-control, NOT
74
+ --border: the boundary IS the affordance, so it is the rung that owes 3:1. */
75
+ :where(input,select,textarea,button){font:inherit;color:inherit}
76
+ :where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),select,textarea){
77
+ background:var(--surface-2);
78
+ border:1px solid var(--border-control);
79
+ border-radius:var(--radius-sm);
80
+ padding:0 var(--space-3);
81
+ }
82
+ :where(textarea){padding:var(--space-2) var(--space-3);resize:vertical}
83
+ :where(input,select,textarea):focus-visible{border-color:var(--border-focus)}
84
+ :where(input,textarea)::placeholder{color:var(--text-disabled)}
85
+ :where(input,select,textarea,button):disabled{opacity:.5;cursor:not-allowed}
86
+ :where(button,[role=button],summary,label,select){cursor:pointer}
87
+
88
+ /* ——— media ———
89
+ An image, a video or an embed at its intrinsic width is the usual cause of a
90
+ 390px page that scrolls sideways. */
91
+ :where(img,svg,video,canvas,iframe,picture,object){max-width:100%}
92
+ :where(img,video){height:auto}
93
+ /* A code block scrolls ITSELF rather than widening the document. */
94
+ :where(pre){overflow-x:auto}
95
+
96
+ /* ——— touch ———
97
+ Everything a finger aims at clears 44px, and every field renders at 16px so
98
+ iOS does not zoom the viewport on focus. Both are keyed on pointer:coarse —
99
+ the actual signal — so a desktop mouse still gets compact controls. This is
100
+ the whole of "mobile-first without per-app work": an app that never thought
101
+ about phones still has hittable buttons and a viewport that stays put. */
102
+ @media (pointer:coarse){
103
+ :where(button,[role=button],a[role=button],summary,select,textarea,
104
+ input:not([type=checkbox]):not([type=radio]):not([type=hidden])){
105
+ min-height:var(--tap-target);
106
+ }
107
+ :where(input,select,textarea){font-size:var(--text-control)}
108
+ /* A checkbox, radio or switch must NOT grow to 44px — the box is 16px
109
+ because that is what a checkbox looks like. What has to reach 44px is the
110
+ area a finger may land in, so the target is expanded with a centred
111
+ pseudo-element that changes nothing about layout or paint. WCAG 2.5.8 puts
112
+ the floor at 24px; a 16px box misses it, and every one of these ships at
113
+ 16px. */
114
+ :where([role=checkbox],[role=radio],[role=switch],input[type=checkbox],input[type=radio]){position:relative}
115
+ :where([role=checkbox],[role=radio],[role=switch],input[type=checkbox],input[type=radio])::after{
116
+ content:'';position:absolute;top:50%;left:50%;
117
+ width:var(--tap-target);height:var(--tap-target);
118
+ transform:translate(-50%,-50%);
119
+ }
120
+ }
121
+
36
122
  :focus-visible{outline:2px solid var(--ring);outline-offset:2px}
37
- ::selection{background:var(--white-20);color:#fff}
123
+ /* --white-20 is white-on-white in the light theme, so selection reads through
124
+ --selection, which BOTH themes define. */
125
+ ::selection{background:var(--selection);color:var(--text-primary)}
38
126
  }