motif-design 0.1.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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -0
  3. package/bin/install.js +724 -0
  4. package/core/references/context-engine.md +190 -0
  5. package/core/references/design-inputs.md +421 -0
  6. package/core/references/runtime-adapters.md +180 -0
  7. package/core/references/state-machine.md +124 -0
  8. package/core/references/verticals/ecommerce.md +251 -0
  9. package/core/references/verticals/fintech.md +226 -0
  10. package/core/references/verticals/health.md +235 -0
  11. package/core/references/verticals/saas.md +248 -0
  12. package/core/templates/STATE-TEMPLATE.md +28 -0
  13. package/core/templates/SUMMARY-TEMPLATE.md +21 -0
  14. package/core/templates/VERTICAL-TEMPLATE.md +144 -0
  15. package/core/templates/token-showcase-template.html +946 -0
  16. package/core/workflows/compose-screen.md +163 -0
  17. package/core/workflows/evolve.md +64 -0
  18. package/core/workflows/fix.md +64 -0
  19. package/core/workflows/generate-system.md +336 -0
  20. package/core/workflows/quick.md +23 -0
  21. package/core/workflows/research.md +233 -0
  22. package/core/workflows/review.md +126 -0
  23. package/package.json +26 -0
  24. package/runtimes/claude-code/CLAUDE-MD-SNIPPET.md +34 -0
  25. package/runtimes/claude-code/agents/motif-design-reviewer.md +207 -0
  26. package/runtimes/claude-code/agents/motif-fix-agent.md +119 -0
  27. package/runtimes/claude-code/agents/motif-researcher.md +100 -0
  28. package/runtimes/claude-code/agents/motif-screen-composer.md +157 -0
  29. package/runtimes/claude-code/agents/motif-system-architect.md +120 -0
  30. package/runtimes/claude-code/commands/motif/compose.md +7 -0
  31. package/runtimes/claude-code/commands/motif/evolve.md +6 -0
  32. package/runtimes/claude-code/commands/motif/fix.md +7 -0
  33. package/runtimes/claude-code/commands/motif/help.md +29 -0
  34. package/runtimes/claude-code/commands/motif/init.md +229 -0
  35. package/runtimes/claude-code/commands/motif/progress.md +11 -0
  36. package/runtimes/claude-code/commands/motif/quick.md +7 -0
  37. package/runtimes/claude-code/commands/motif/research.md +4 -0
  38. package/runtimes/claude-code/commands/motif/review.md +7 -0
  39. package/runtimes/claude-code/commands/motif/system.md +4 -0
  40. package/runtimes/claude-code/hooks/motif-aria-check.js +164 -0
  41. package/runtimes/claude-code/hooks/motif-context-monitor.js +40 -0
  42. package/runtimes/claude-code/hooks/motif-font-check.js +192 -0
  43. package/runtimes/claude-code/hooks/motif-token-check.js +221 -0
  44. package/runtimes/cursor/README.md +24 -0
  45. package/runtimes/gemini/README.md +13 -0
  46. package/runtimes/opencode/README.md +28 -0
  47. package/scripts/contrast-checker.js +114 -0
  48. package/scripts/token-counter.js +107 -0
@@ -0,0 +1,180 @@
1
+ # Motif — Runtime Adapter Reference
2
+
3
+ Motif uses a core + adapters architecture. The core (references, workflows, templates, verticals) is shared across all runtimes. Each runtime gets a thin adapter layer that handles three things: file placement, subagent spawning, and config injection.
4
+
5
+ ---
6
+
7
+ ## What's Shared (core/)
8
+
9
+ These files are **identical** regardless of runtime:
10
+
11
+ | Directory | Contents | Why Shared |
12
+ |---|---|---|
13
+ | `core/references/` | State machine, context engine, design inputs, verticals | Pure design knowledge — no runtime dependencies |
14
+ | `core/workflows/` | Research, system, compose, review, fix, evolve, quick | Orchestration logic with runtime-agnostic spawn markers |
15
+ | `core/templates/` | Vertical template, STATE template, SUMMARY template, token showcase | Output formats — no runtime dependencies |
16
+ | `scripts/` | Contrast checker, token counter | Node.js utilities — runtime-independent |
17
+
18
+ ## What's Runtime-Specific (runtimes/)
19
+
20
+ | Component | Claude Code | OpenCode | Gemini CLI | Cursor/Windsurf |
21
+ |---|---|---|---|---|
22
+ | **Commands** | `.claude/commands/motif/*.md` | `.opencode/commands/motif/*.md` | `.gemini/commands/motif/*.md` | N/A (no slash commands) |
23
+ | **Agent defs** | `.claude/agents/motif-*.md` | `.opencode/agents/motif-*.md` | `.gemini/agents/motif-*.md` | N/A |
24
+ | **Hooks** | `.claude/hooks/*.js` (PostToolUse) | Runtime-specific or skip | Runtime-specific or skip | N/A |
25
+ | **Config injection** | Append to `.claude/CLAUDE.md` | Append to `.opencode/AGENTS.md` | Append to `GEMINI.md` | Append to `.cursorrules` |
26
+ | **Subagent spawn** | `Task()` tool | `agent()` or equivalent | Runtime-specific | N/A (single context) |
27
+ | **Core files installed to** | `.claude/get-motif/` | `.opencode/get-motif/` | `.gemini/get-motif/` | `.motif/` |
28
+
29
+ ---
30
+
31
+ ## Subagent Spawning Abstraction
32
+
33
+ Workflows use a spawn marker pattern. The marker is runtime-agnostic — the command layer translates it for the specific runtime.
34
+
35
+ ### In workflow files (core/workflows/):
36
+ ```xml
37
+ <agent_spawn id="compose-{SCREEN_NAME}">
38
+ **Task prompt:**
39
+ [... agent instructions ...]
40
+ </agent_spawn>
41
+ ```
42
+
43
+ ### How each runtime interprets this:
44
+
45
+ **Claude Code:** The command files and agent definitions use `Task()` directly:
46
+ ```
47
+ Spawn a subagent using Task() with the following prompt:
48
+ [agent instructions from workflow]
49
+ ```
50
+
51
+ **OpenCode:** Uses OpenCode's agent spawning mechanism:
52
+ ```
53
+ Spawn a subagent using agent() with type "general":
54
+ [agent instructions from workflow]
55
+ ```
56
+
57
+ **Gemini CLI:** Uses Gemini's task delegation:
58
+ ```
59
+ Delegate to a fresh context:
60
+ [agent instructions from workflow]
61
+ ```
62
+
63
+ **Cursor/Windsurf:** No subagent support. The workflow runs in the main context:
64
+ ```
65
+ Execute the following directly (no subagent — single context mode):
66
+ [agent instructions from workflow]
67
+ ```
68
+ ⚠️ This means Cursor/Windsurf will experience context degradation on large projects. The workflows still function but without fresh-context isolation.
69
+
70
+ ---
71
+
72
+ ## Installer Behavior Per Runtime
73
+
74
+ The installer (`bin/install.js`) detects or is told which runtime to target:
75
+
76
+ ### Detection
77
+ ```javascript
78
+ function detectRuntime() {
79
+ if (fs.existsSync('.claude')) return 'claude-code';
80
+ if (fs.existsSync('.opencode')) return 'opencode';
81
+ if (fs.existsSync('.gemini')) return 'gemini';
82
+ if (fs.existsSync('.cursorrules')) return 'cursor';
83
+ if (fs.existsSync('.windsurfrules')) return 'cursor'; // same adapter
84
+ return null; // ask user
85
+ }
86
+ ```
87
+
88
+ ### Flags
89
+ ```
90
+ npx motif-design@latest # Auto-detect
91
+ npx motif-design@latest --runtime claude-code
92
+ npx motif-design@latest --runtime opencode
93
+ npx motif-design@latest --runtime gemini
94
+ npx motif-design@latest --runtime cursor
95
+ ```
96
+
97
+ ### Install Mapping
98
+
99
+ **Claude Code (--runtime claude-code):**
100
+ ```
101
+ core/references/ → .claude/get-motif/references/
102
+ core/workflows/ → .claude/get-motif/workflows/
103
+ core/templates/ → .claude/get-motif/templates/
104
+ scripts/ → .claude/get-motif/scripts/
105
+ runtimes/claude-code/commands/motif/ → .claude/commands/motif/
106
+ runtimes/claude-code/agents/ → .claude/get-motif/agents/
107
+ runtimes/claude-code/hooks/ → .claude/hooks/ (merge, don't overwrite)
108
+ runtimes/claude-code/CLAUDE-MD-SNIPPET.md → append to .claude/CLAUDE.md
109
+ ```
110
+
111
+ **OpenCode (--runtime opencode):**
112
+ ```
113
+ core/references/ → .opencode/get-motif/references/
114
+ core/workflows/ → .opencode/get-motif/workflows/
115
+ core/templates/ → .opencode/get-motif/templates/
116
+ scripts/ → .opencode/get-motif/scripts/
117
+ runtimes/opencode/commands/motif/ → .opencode/commands/motif/
118
+ runtimes/opencode/agents/ → .opencode/get-motif/agents/
119
+ runtimes/opencode/config-snippet.md → append to .opencode/AGENTS.md
120
+ ```
121
+
122
+ **Gemini CLI (--runtime gemini):**
123
+ ```
124
+ core/* → .gemini/get-motif/
125
+ runtimes/gemini/commands/motif/ → .gemini/commands/motif/
126
+ runtimes/gemini/config-snippet.md → append to GEMINI.md
127
+ ```
128
+
129
+ **Cursor/Windsurf (--runtime cursor):**
130
+ ```
131
+ core/* → .motif/
132
+ runtimes/cursor/rules-snippet.md → append to .cursorrules or .windsurfrules
133
+ ```
134
+ Note: No commands, no agents, no hooks. The rules snippet contains condensed Motif instructions that work in single-context mode.
135
+
136
+ ---
137
+
138
+ ## Command Path References
139
+
140
+ The thin command files in each runtime need to point to the core workflows at the correct installed path. This is the ONE thing that differs in command files across runtimes:
141
+
142
+ **Claude Code:** `Load and follow the workflow at .claude/get-motif/workflows/research.md`
143
+ **OpenCode:** `Load and follow the workflow at .opencode/get-motif/workflows/research.md`
144
+ **Gemini:** `Load and follow the workflow at .gemini/get-motif/workflows/research.md`
145
+
146
+ The installer handles this by either:
147
+ 1. Generating command files at install time with the correct path prefix, OR
148
+ 2. Using a path variable in the command files that the runtime resolves
149
+
150
+ Option 1 is simpler and more reliable. The installer reads each command template, replaces the path prefix, and writes to the target.
151
+
152
+ ---
153
+
154
+ ## Priority: What to Build When
155
+
156
+ ### v1.0 — Claude Code Only
157
+ Ship with full Claude Code support. The core/runtimes split is in the codebase but only `runtimes/claude-code/` is populated.
158
+
159
+ ### v1.1 — OpenCode
160
+ Add `runtimes/opencode/` with adapted commands, agent definitions, and config snippet. Test agent spawning with OpenCode's mechanism.
161
+
162
+ ### v1.2 — Cursor/Windsurf
163
+ Add `runtimes/cursor/` with condensed rules snippet. No subagents — test that workflows still produce quality in single-context mode.
164
+
165
+ ### v1.3 — Gemini CLI
166
+ Add `runtimes/gemini/` when Gemini CLI stabilizes.
167
+
168
+ ---
169
+
170
+ ## Creating a New Runtime Adapter
171
+
172
+ To add support for a new runtime:
173
+
174
+ 1. Create `runtimes/{runtime-name}/`
175
+ 2. Copy command files from `runtimes/claude-code/commands/motif/` and update the workflow path prefix
176
+ 3. Create agent definitions adapted to the runtime's agent format (or skip if no agent support)
177
+ 4. Create a config snippet in the runtime's format
178
+ 5. Create hooks in the runtime's format (or skip if no hook support)
179
+ 6. Add the runtime to the installer's detection and mapping logic
180
+ 7. Test the full workflow: init → research → system → compose → review
@@ -0,0 +1,124 @@
1
+ # Motif State Machine
2
+
3
+ This file defines the legal state transitions for a Motif project. Every command MUST check state before executing and MUST update state after completing. No exceptions.
4
+
5
+ ## Phases
6
+
7
+ ```
8
+ UNINITALIZED → INITIALIZED → RESEARCHED → SYSTEM_GENERATED → COMPOSING → REVIEWING → ITERATING
9
+ ↑ ↑ ↑ │
10
+ └──────────────┴──────────────┴──────────────────────────────────────┘
11
+ (evolve loops back)
12
+ ```
13
+
14
+ ## Phase Definitions
15
+
16
+ | Phase | Set By | Prerequisites | Artifacts Created |
17
+ |---|---|---|---|
18
+ | `UNINITIALIZED` | (default) | None | None |
19
+ | `INITIALIZED` | `/motif:init` | None | PROJECT.md, DESIGN-BRIEF.md, STATE.md |
20
+ | `RESEARCHED` | `/motif:research` | INITIALIZED | DESIGN-RESEARCH.md, research/*.md |
21
+ | `SYSTEM_GENERATED` | `/motif:system` | RESEARCHED | system/tokens.css, system/DESIGN-SYSTEM.md, system/COMPONENT-SPECS.md, system/token-showcase.html |
22
+ | `COMPOSING` | `/motif:compose` | SYSTEM_GENERATED | screens/[name].*, screens/[name]-SUMMARY.md |
23
+ | `REVIEWING` | `/motif:review` | ≥1 screen composed | reviews/[name]-REVIEW.md |
24
+ | `ITERATING` | `/motif:fix` | ≥1 review exists | Updated screen files, updated reviews |
25
+
26
+ ## Gate Checks
27
+
28
+ Every command reads STATE.md and validates before executing:
29
+
30
+ ```xml
31
+ <gate_check>
32
+ <command>/motif:init</command>
33
+ <requires_phase>UNINITIALIZED</requires_phase>
34
+ <blocks_if>PROJECT.md already exists. Tell user to delete .planning/design/ to restart.</blocks_if>
35
+ </gate_check>
36
+
37
+ <gate_check>
38
+ <command>/motif:research</command>
39
+ <requires_phase>INITIALIZED</requires_phase>
40
+ <blocks_if>PROJECT.md or DESIGN-BRIEF.md missing. Tell user to run /motif:init first.</blocks_if>
41
+ </gate_check>
42
+
43
+ <gate_check>
44
+ <command>/motif:system</command>
45
+ <requires_phase>RESEARCHED</requires_phase>
46
+ <blocks_if>DESIGN-RESEARCH.md missing. Tell user to run /motif:research first.</blocks_if>
47
+ </gate_check>
48
+
49
+ <gate_check>
50
+ <command>/motif:compose</command>
51
+ <requires_phase>SYSTEM_GENERATED or COMPOSING or ITERATING</requires_phase>
52
+ <blocks_if>tokens.css or COMPONENT-SPECS.md missing. Tell user to run /motif:system first.</blocks_if>
53
+ </gate_check>
54
+
55
+ <gate_check>
56
+ <command>/motif:review</command>
57
+ <requires_phase>COMPOSING or REVIEWING or ITERATING</requires_phase>
58
+ <blocks_if>No composed screens exist. Tell user to run /motif:compose first.</blocks_if>
59
+ </gate_check>
60
+
61
+ <gate_check>
62
+ <command>/motif:fix</command>
63
+ <requires_phase>REVIEWING or ITERATING</requires_phase>
64
+ <blocks_if>No reviews exist. Tell user to run /motif:review first.</blocks_if>
65
+ </gate_check>
66
+
67
+ <gate_check>
68
+ <command>/motif:evolve</command>
69
+ <requires_phase>COMPOSING or REVIEWING or ITERATING</requires_phase>
70
+ <blocks_if>No composed screens exist. Need at least one screen to learn from.</blocks_if>
71
+ </gate_check>
72
+
73
+ <gate_check>
74
+ <command>/motif:quick</command>
75
+ <requires_phase>ANY except UNINITIALIZED</requires_phase>
76
+ <blocks_if>No PROJECT.md. Tell user to run /motif:init first (or use without Motif).</blocks_if>
77
+ <note>Quick mode works with or without a full design system, but warns about consistency risk if tokens.css is missing.</note>
78
+ </gate_check>
79
+ ```
80
+
81
+ ## STATE.md Format
82
+
83
+ ```markdown
84
+ # Motif State
85
+
86
+ ## Phase
87
+ [UNINITIALIZED|INITIALIZED|RESEARCHED|SYSTEM_GENERATED|COMPOSING|REVIEWING|ITERATING]
88
+
89
+ ## Vertical
90
+ [detected vertical]
91
+
92
+ ## Stack
93
+ [technical stack]
94
+
95
+ ## Screens
96
+ | # | Screen | Status | Review Score | Last Updated |
97
+ |---|--------|--------|-------------|-------------|
98
+ | 1 | login | composed | — | 2026-03-01 |
99
+ | 2 | dashboard | reviewed | 78/100 | 2026-03-01 |
100
+ | 3 | settings | planned | — | — |
101
+
102
+ ## Decisions Log
103
+ - [ISO date] [decision description]
104
+
105
+ ## Context Budget
106
+ | File | Tokens (approx) | Budget |
107
+ |---|---|---|
108
+ | PROJECT.md | ~800 | ≤1,000 |
109
+ | DESIGN-BRIEF.md | ~600 | ≤1,000 |
110
+ | DESIGN-RESEARCH.md | ~2,500 | ≤3,000 |
111
+ | tokens.css | ~2,000 | ≤3,000 |
112
+ | COMPONENT-SPECS.md | ~3,000 | ≤5,000 |
113
+ ```
114
+
115
+ ## State Update Protocol
116
+
117
+ After any command completes:
118
+ 1. Read current STATE.md
119
+ 2. Update the Phase field if phase changed
120
+ 3. Update the Screens table if screen status changed
121
+ 4. Append to Decisions Log if a design decision was made
122
+ 5. Update Context Budget if files were created/modified
123
+ 6. Write STATE.md back
124
+ 7. Commit with appropriate prefix
@@ -0,0 +1,251 @@
1
+ # E-commerce Design Intelligence
2
+
3
+ ## Core Design Principle
4
+ **Desire drives conversion.** Users are shopping — the UI must showcase products beautifully, reduce friction to purchase, and build enough trust to complete payment. Every element either moves the user closer to checkout or gets out of the way.
5
+
6
+ ## Navigation Patterns
7
+
8
+ ### Standard Models
9
+ - **Mobile:** Bottom tab bar, 4-5 items. Home/Discover, Search/Browse, Cart (with badge count), Wishlist/Saved, Account. Persistent cart icon top-right. Primary action (Cart) always visible with item count badge.
10
+ - **Desktop:** Horizontal top nav with mega-menus for product categories. Utility bar above (account, orders, language/currency). Prominent search bar (center or right). Sticky cart icon with count. Breadcrumb trail on product/category pages.
11
+ - **Overlays:** Slide-in cart drawer from right (don't navigate away from browsing). Quick-view modal for product details without leaving the grid. Filter drawer on mobile (full-sheet with apply/clear).
12
+
13
+ ### Vertical-Specific Rules
14
+ - Cart accessible from every screen — 1 tap/click maximum
15
+ - Product category browsing within 2 taps from home
16
+ - Search with autocomplete, visual results (thumbnail + price), and recent/trending queries
17
+ - Back-to-results preserves scroll position and applied filters
18
+ - Checkout progress indicator visible at all steps (shipping → payment → review)
19
+
20
+ ## Color System
21
+
22
+ ### Palette A: Warm Commerce (Amber)
23
+ | Token | Light Mode | Dark Mode | Usage |
24
+ |---|---|---|---|
25
+ | primary-50 | #FFF7ED | #431407 | Subtle backgrounds |
26
+ | primary-100 | #FFEDD5 | #7C2D12 | Hover states on light |
27
+ | primary-200 | #FED7AA | #9A3412 | Borders, dividers |
28
+ | primary-300 | #FDBA74 | #C2410C | Icons, decorative |
29
+ | primary-400 | #FB923C | #EA580C | Secondary actions |
30
+ | primary-500 | #EA580C | #FB923C | Primary actions, brand (HSL 21°) |
31
+ | primary-600 | #C2410C | #FDBA74 | Hover on primary |
32
+ | primary-700 | #9A3412 | #FED7AA | Active/pressed |
33
+ | primary-800 | #7C2D12 | #FFEDD5 | Text on light bg |
34
+ | primary-900 | #431407 | #FFF7ED | Headings |
35
+ | surface-primary | #FFFFFF | #171717 | Main background |
36
+ | surface-secondary | #FAFAF9 | #262626 | Cards, product grid bg |
37
+ | surface-tertiary | #F5F5F4 | #404040 | Nested elements, filters |
38
+ | text-primary | #1C1917 | #F5F5F4 | Body text (13.1:1 ✓ AAA) |
39
+ | text-secondary | #57534E | #A8A29E | Supporting (5.6:1 ✓ AA) |
40
+
41
+ ### Palette B: Clean Minimal (Achromatic)
42
+ | Token | Light Mode | Dark Mode | Usage |
43
+ |---|---|---|---|
44
+ | primary-500 | #171717 | #FAFAFA | Brand accent (monochrome) |
45
+ | surface-primary | #FFFFFF | #09090B | Main background |
46
+ | surface-secondary | #F5F5F5 | #18181B | Cards |
47
+ | text-primary | #171717 | #FAFAFA | Body (15.8:1 ✓ AAA) |
48
+ | text-secondary | #525252 | #A3A3A3 | Supporting (5.3:1 ✓ AA) |
49
+
50
+ ### Semantic Colors
51
+ | Semantic | Hex (Light) | Hex (Dark) | E-commerce Meaning |
52
+ |---|---|---|---|
53
+ | Success | #16A34A | #4ADE80 | Order confirmed, item added to cart, delivery complete |
54
+ | Error | #DC2626 | #F87171 | Payment failed, out of stock, address invalid |
55
+ | Warning | #D97706 | #FBBF24 | Low stock, price increase pending, shipping delay |
56
+ | Info | #2563EB | #60A5FA | Free shipping threshold, new arrival, back in stock |
57
+
58
+ ### Color Anti-Patterns
59
+ - ❌ Blue primary competing with product photography (draws eye away from products)
60
+ - ❌ Too many accent colors distracting from product imagery (max 1 accent + semantics)
61
+ - ❌ Dark backgrounds behind product images (reduces perceived quality, kills white-bg photography)
62
+ - ❌ Neon sale badges on premium brands (clashes with brand positioning)
63
+ - ❌ Saturated CTA buttons that clash with product imagery (CTA should complement, not fight)
64
+
65
+ ## Typography
66
+
67
+ ### Pairing A: Editorial Commerce
68
+ - **Display:** Syne 700 at -0.02em — distinctive geometric personality, stands out in hero banners and collection titles
69
+ - **Body:** Work Sans 400/500 at 0em — clean humanist readability, excellent at 14-16px for descriptions and UI
70
+ - **Prices:** JetBrains Mono 500 with `font-variant-numeric: tabular-nums` — perfect column alignment in grids
71
+
72
+ ### Pairing B: Clean Commerce
73
+ - **Display:** Manrope 700 at -0.015em — modern geometric, warm roundness for approachable premium feel
74
+ - **Body:** Karla 400/500 at 0em — humanist warmth, slightly quirky character, excellent small-size rendering
75
+ - **Prices:** DM Mono 500 with `tabular-nums` — compact monospace suited for price-dense layouts
76
+ - Note: Clash Display (Fontshare) and Gambetta (Fontshare) are alternative display options per generate-system.md
77
+
78
+ ### Type Scale
79
+ | Token | Size | Line Height | E-commerce Usage |
80
+ |---|---|---|---|
81
+ | text-xs | 0.75rem (12px) | 1.4 | Badge labels, stock count, trust seal text |
82
+ | text-sm | 0.875rem (14px) | 1.45 | Product titles in grid, price labels, filter chips |
83
+ | text-base | 1rem (16px) | 1.5 | Product descriptions, form inputs, cart item details |
84
+ | text-lg | 1.125rem (18px) | 1.45 | Category headings, cart totals, section titles |
85
+ | text-xl | 1.25rem (20px) | 1.35 | Collection titles, checkout step headings |
86
+ | text-2xl | 1.5rem (24px) | 1.3 | Featured product name, order total |
87
+ | text-3xl | 1.875rem (30px) | 1.2 | Hero product name, sale banner headline |
88
+
89
+ ### Typography Rules
90
+ - ALL prices: --font-mono with `tabular-nums`. Non-negotiable for grid alignment.
91
+ - Currency symbols: 80% of number size, --weight-medium
92
+ - Original price: strike-through in --text-secondary (de-emphasized)
93
+ - Sale price: --color-error or primary accent, --weight-semibold
94
+ - Savings badge: percentage in --weight-bold, parenthetical or chip format
95
+
96
+ ### Typography Anti-Patterns
97
+ - ❌ Ultra-lightweight display fonts that get lost against product imagery
98
+ - ❌ Monospaced fonts for product descriptions (feels technical, not retail)
99
+ - ❌ Too many font weights creating inconsistent visual hierarchy
100
+ - ❌ Price text below 14px (must be instantly scannable, especially on mobile)
101
+
102
+ ## Spacing & Density
103
+
104
+ ### Recommended Density: Dual — Spacious Browsing + Compact Cart
105
+ Product browsing needs breathing room for imagery. Cart and checkout need density for efficiency.
106
+
107
+ ### Concrete Values
108
+ | Context | Value | Token |
109
+ |---|---|---|
110
+ | Product grid gap | 16-24px | --space-4 to --space-6 |
111
+ | Card internal padding | 16px | --space-4 |
112
+ | Cart item row height | 72-80px | — |
113
+ | Section gap | 32-48px | --space-8 to --space-12 |
114
+ | Form field gap | 16px | --space-4 |
115
+ | Button padding | 12px 24px | --space-3 --space-6 |
116
+ | Touch target minimum | 48×48px | — |
117
+ | Mega-menu column gap | 32px | --space-8 |
118
+
119
+ ## Component Specifications
120
+
121
+ ### ProductCard
122
+ ```xml
123
+ <component name="ProductCard" category="data-display">
124
+ <description>Product in a grid or list. The most-viewed component in any e-commerce app — drives browsing and discovery.</description>
125
+ <structure>
126
+ Image: aspect-ratio 3:4 or 1:1, object-fit: cover, lazy-loaded, --surface-secondary placeholder
127
+ Title: --font-body --text-sm --weight-medium --text-primary, max 2 lines with ellipsis
128
+ Price: --font-mono --text-sm --weight-semibold, tabular-nums
129
+ Sale price: --color-error, original price --text-secondary with line-through
130
+ Rating: star icons --text-xs, count in --text-secondary
131
+ Quick-add: --text-xs --weight-medium, appears on hover (desktop) or always visible (mobile)
132
+ Wishlist: heart icon top-right overlay, toggles fill on tap
133
+ </structure>
134
+ <dimensions>
135
+ width: fluid (grid column), image height: aspect-ratio driven
136
+ padding: --space-3 (below image for text content)
137
+ gap: --space-1 between text lines
138
+ </dimensions>
139
+ <states>
140
+ default: --shadow-sm, --radius-md on image
141
+ hover: --shadow-md, image scale(1.03) with overflow hidden, quick-add slides up
142
+ loading: skeleton shimmer matching image aspect ratio + 3 text lines
143
+ out-of-stock: image at 60% opacity, "Sold Out" overlay badge, quick-add disabled
144
+ </states>
145
+ <tap-target>Full card for product detail, distinct targets for quick-add and wishlist (48×48px each)</tap-target>
146
+ </component>
147
+ ```
148
+
149
+ ### CartItem
150
+ ```xml
151
+ <component name="CartItem" category="data-display">
152
+ <description>Single item in cart — compact for sidebar drawer, scannable for cart page.</description>
153
+ <structure>
154
+ Thumbnail: 64×64px, --radius-sm, object-fit: cover
155
+ Title: --font-body --text-sm --weight-medium --text-primary, max 1 line ellipsis
156
+ Variant: --font-body --text-xs --text-secondary (e.g., "Size: M / Color: Navy")
157
+ Quantity: [-] [count] [+] inline selector, --text-sm, buttons 32×32px
158
+ Line total: --font-mono --text-sm --weight-semibold, right-aligned
159
+ Remove: X icon or "Remove" text link, --text-secondary, --text-xs
160
+ </structure>
161
+ <dimensions>
162
+ height: 72-80px, padding: --space-3, gap: --space-3
163
+ Thumbnail: 64×64px fixed
164
+ Compact variant (drawer): height 64px, thumbnail 48×48px
165
+ </dimensions>
166
+ <states>
167
+ default: --surface-primary background, --border-primary bottom border
168
+ updating-quantity: line total shows spinner (200ms debounce)
169
+ removing: slide-left exit animation 250ms, height collapse 200ms
170
+ error: --color-error border-left, "Price changed" or "Only X left" inline warning
171
+ </states>
172
+ <tap-target>Quantity buttons 32×32px minimum, remove button 48×48px touch area</tap-target>
173
+ </component>
174
+ ```
175
+
176
+ ### PriceDisplay
177
+ ```xml
178
+ <component name="PriceDisplay" category="data-display">
179
+ <description>Formatted price with optional sale, savings, and installment info.</description>
180
+ <structure>
181
+ Current price: --font-mono --text-base (or contextual size) --weight-semibold --text-primary
182
+ Compare-at price: --font-mono --text-sm --weight-normal --text-secondary, text-decoration: line-through
183
+ Savings badge: "--weight-bold percentage OFF" in --color-error bg at 10% opacity, --radius-sm, --text-xs
184
+ Installment: "or 4x $X.XX with [provider]" --text-xs --text-secondary
185
+ Currency symbol: 80% font-size, --weight-medium, no line-break between symbol and amount
186
+ </structure>
187
+ <dimensions>
188
+ inline or stacked layout depending on context (grid card: stacked, cart: inline)
189
+ gap: --space-1 between price elements
190
+ </dimensions>
191
+ <states>
192
+ regular: current price only, --text-primary
193
+ on-sale: current price in --color-error + compare-at struck through + savings badge
194
+ sold-out: "Sold Out" replaces price, --text-secondary, --weight-medium
195
+ loading: skeleton shimmer, width 80px
196
+ </states>
197
+ <formatting>
198
+ tabular-nums always, currency before amount (locale-aware), 2 decimal places,
199
+ thousands separator for amounts ≥1000, no trailing zeros on whole amounts optional
200
+ </formatting>
201
+ </component>
202
+ ```
203
+
204
+ ## Interaction Patterns
205
+
206
+ ### Core Flows
207
+ 1. **Add to Cart:** Tap quick-add → micro-confirmation (button state change + cart badge bounce 250ms) → optional "View Cart" toast 3s → continue browsing. Never navigate away from the grid.
208
+ 2. **Checkout:** Progressive disclosure — shipping → payment → review → confirm. Each step validates before advancing. Back button preserves all entered data.
209
+ 3. **Product Gallery:** Swipe between images (mobile), thumbnail strip click (desktop), pinch-to-zoom or loupe on hover. Fullscreen lightbox on tap.
210
+
211
+ ### States
212
+ **Loading:** Skeleton screens maintaining product grid layout and card aspect ratios. Shimmer animation left-to-right, 1.5s cycle. Show 8-12 skeleton cards matching expected grid density.
213
+ **Empty:** Cart empty: large illustration + "Your cart is empty" + "Continue Shopping" CTA + "You might like" product suggestions. Search no results: "No products found" + suggested categories + clear filters CTA.
214
+ **Error:** Payment error: specific reason (card declined, expired, insufficient funds) + retry button + alternative payment methods. NEVER lose cart contents on error. Network error: "Connection lost — your cart is saved. Retrying..."
215
+
216
+ ### Motion
217
+ **Appropriate:** Add-to-cart fly animation or badge bounce (250-300ms), image zoom on hover (200ms ease-out), cart badge count increment (250ms spring), price update crossfade (200ms), drawer slide-in (300ms ease-out).
218
+ **Inappropriate:** ❌ Auto-playing product carousels (users want control), ❌ aggressive countdown timers with flashing (dark pattern), ❌ parallax scroll effects on mobile (performance and motion sensitivity), ❌ full-page transitions between product pages (breaks browsing flow).
219
+
220
+ ## Accessibility Specifics
221
+ - Product images: descriptive alt text including product name, color, and key feature — never just "product image"
222
+ - Prices: announced with currency by screen reader (e.g., "twenty-four dollars and ninety-nine cents")
223
+ - Cart count: `aria-live="polite"` region, announces updates (e.g., "Cart updated, 3 items")
224
+ - Color/size selectors: `aria-pressed` or `aria-checked` state, announce "selected" and "unavailable"
225
+ - Checkout progress: `aria-current="step"` on active step, steps announced as "Step 2 of 4, Payment"
226
+ - Star ratings: `aria-label="4.5 out of 5 stars, 128 reviews"` — never rely on visual stars alone
227
+
228
+ ## Border Radius
229
+ | Token | Value | Reasoning |
230
+ |---|---|---|
231
+ | radius-sm | 4px | Badges, chips, small elements — crisp and clean |
232
+ | radius-md | 8px | Buttons, inputs, cart items — modern and approachable |
233
+ | radius-lg | 12-16px | Product cards, modals — friendly without being childish |
234
+
235
+ ## Shadow Style
236
+ | Token | Value | Usage |
237
+ |---|---|---|
238
+ | shadow-sm | 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04) | Default card resting state |
239
+ | shadow-md | 0 4px 8px -2px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04) | Card hover, elevated elements |
240
+ | shadow-lg | 0 12px 24px -4px rgba(0,0,0,0.10), 0 4px 8px -4px rgba(0,0,0,0.05) | Modals, cart drawer, mega-menu |
241
+ | shadow-xl | 0 20px 40px -8px rgba(0,0,0,0.12), 0 8px 16px -8px rgba(0,0,0,0.06) | Lightbox overlay, elevated popovers |
242
+
243
+ ## E-commerce-Specific Additions
244
+ - **Product image gallery:** Thumbnail strip below main image (desktop), swipe carousel with dot indicators (mobile), pinch-to-zoom, fullscreen lightbox with arrow navigation
245
+ - **Size/variant selectors:** Chip group layout, selected chip gets primary border + fill, out-of-stock chips show diagonal strike-through and reduced opacity, size guide link adjacent
246
+ - **Cart count badge:** Circular badge on cart icon, --color-error bg, --text-inverse text, scales with bounce animation (250ms spring) on increment, minimum 20×20px
247
+ - **Sale price formatting:** Original price in --text-secondary with line-through, sale price in --color-error or accent, savings as percentage badge or "(Save $X.XX)" suffix
248
+ - **Star rating display:** Half-star precision using filled/half/empty star icons, count displayed as "(128)" in --text-secondary --text-xs, minimum touch target 48px for "write review"
249
+ - **Free shipping progress bar:** Horizontal bar showing progress toward threshold, "--color-success fill, "$X.XX away from free shipping" label, celebrates on completion
250
+ - **Trust badges:** Row of payment method icons (Visa, Mastercard, PayPal, Apple Pay) + security seal, placed near checkout CTA, monochrome or subtle color, 24-32px icon height
251
+ - **Breadcrumb navigation:** Home > Category > Subcategory > Product, --text-xs, --text-secondary with --text-primary on current, separator "/" or "›", truncate middle on mobile