chaincss 2.3.0 → 2.3.2

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.
@@ -0,0 +1,1168 @@
1
+ # ChainCSS v2.3 — Comprehensive Tutorial
2
+
3
+ > **The CSS Intelligence Platform** — Write styles as JavaScript. Compiler-enforced quality. Zero runtime.
4
+
5
+ ---
6
+
7
+ # Table of Contents
8
+
9
+ 1. [Installation & Setup](#1-installation--setup)
10
+ 2. [The Chain API](#2-the-chain-api)
11
+ 3. [Shorthands](#3-shorthands)
12
+ 4. [Macros](#4-macros)
13
+ 5. [Intent API](#5-intent-api)
14
+ 6. [Semantic Tokens](#6-semantic-tokens)
15
+ 7. [Responsive Design](#7-responsive-design)
16
+ 8. [Conditional Styles](#8-conditional-styles)
17
+ 9. [Nested Selectors & Mixins](#9-nested-selectors--mixins)
18
+ 10. [Math Engine](#10-math-engine)
19
+ 11. [Constraint-Based Styling](#11-constraint-based-styling)
20
+ 12. [Design Tokens & Themes](#12-design-tokens--themes)
21
+ 13. [Recipe System](#13-recipe-system)
22
+ 14. [Animations](#14-animations)
23
+ 15. [Scroll Timeline Engine](#15-scroll-timeline-engine)
24
+ 16. [Self-Healing CSS](#16-self-healing-css)
25
+ 17. [Compiler Intelligence](#17-compiler-intelligence)
26
+ 18. [Accessibility Engine](#18-accessibility-engine)
27
+ 19. [Source-Aware Optimization](#19-source-aware-optimization)
28
+ 20. [CLI Commands](#20-cli-commands)
29
+ 21. [Framework Integration](#21-framework-integration)
30
+ 22. [Configuration](#22-configuration)
31
+
32
+ ---
33
+
34
+ # 1. Installation & Setup
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ npm install chaincss
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Vite Setup
45
+
46
+ ```ts
47
+ // vite.config.ts
48
+ import { defineConfig } from "vite";
49
+ import chaincss from "chaincss/plugin/vite";
50
+
51
+ export default defineConfig({
52
+ plugins: [
53
+ chaincss({
54
+ atomic: true,
55
+ minify: false,
56
+ verbose: false,
57
+ hmr: true,
58
+ }),
59
+ ],
60
+ });
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Quick Start
66
+
67
+ ```ts
68
+ import { chain } from "chaincss";
69
+
70
+ const styles = chain()
71
+ .display("flex")
72
+ .padding(20)
73
+ .color("red")
74
+ .$el("my-component");
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Three Modes
80
+
81
+ | Mode | API | Use Case |
82
+ |---|---|---|
83
+ | Build-time | `chain()` | Static styles |
84
+ | Runtime | `chain()` in browser | Dynamic styles |
85
+ | Hybrid | `smartChain()` | Static + dynamic |
86
+
87
+ ```ts
88
+ import { smartChain } from "chaincss";
89
+
90
+ const styles = smartChain()
91
+ .display("flex")
92
+ .padding(20)
93
+ .color(props.textColor)
94
+ .fontSize(theme.sizes.lg)
95
+ .$el("hybrid-card");
96
+ ```
97
+
98
+ ---
99
+
100
+ # 2. The Chain API
101
+
102
+ Every chain starts with `chain()` and ends with `$el()`.
103
+
104
+ ## Basic Usage
105
+
106
+ ```ts
107
+ const card = chain()
108
+ .display("flex")
109
+ .flexDirection("column")
110
+ .gap(16)
111
+ .padding(24)
112
+ .backgroundColor("white")
113
+ .borderRadius(12)
114
+ .boxShadow("0 2px 8px rgba(0,0,0,0.1)")
115
+ .$el("card");
116
+ ```
117
+
118
+ ---
119
+
120
+ ## The `$el()` Method
121
+
122
+ ```ts
123
+ // Single selector
124
+ chain().color("red").$el("heading");
125
+
126
+ // Multiple selectors
127
+ chain().color("red").$el("h1", "h2", "h3");
128
+
129
+ // Raw styles
130
+ chain().color("red").$el();
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Debugging
136
+
137
+ ```ts
138
+ chain()
139
+ .debug()
140
+ .explain("bg")
141
+ .bg("white")
142
+ .$el("debugged");
143
+ ```
144
+
145
+ ---
146
+
147
+ # 3. Shorthands
148
+
149
+ ## Spacing
150
+
151
+ ```ts
152
+ chain()
153
+ .m(16)
154
+ .mt(8)
155
+ .mr(12)
156
+ .mb(8)
157
+ .ml(12)
158
+ .mx(20)
159
+ .my(10)
160
+ .p(24)
161
+ .pt(16)
162
+ .pr(16)
163
+ .pb(16)
164
+ .pl(16)
165
+ .px(20)
166
+ .py(12);
167
+ ```
168
+
169
+ ---
170
+
171
+ ## Sizing
172
+
173
+ ```ts
174
+ chain()
175
+ .w(200)
176
+ .h(100)
177
+ .minW(300)
178
+ .maxW(1200)
179
+ .minH(200)
180
+ .maxH(800)
181
+ .size(50);
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Typography
187
+
188
+ ```ts
189
+ chain()
190
+ .bg("#f0f0f0")
191
+ .c("#333")
192
+ .fs(16)
193
+ .fw(700)
194
+ .lh(1.5)
195
+ .ls("0.5px")
196
+ .ta("center");
197
+ ```
198
+
199
+ ---
200
+
201
+ # 4. Macros
202
+
203
+ ## Layout
204
+
205
+ ```ts
206
+ chain().flex();
207
+ chain().inlineFlex();
208
+ chain().flexCenter();
209
+ chain().grid();
210
+ chain().gridCenter();
211
+ chain().stack(16);
212
+ chain().bento(4);
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Effects
218
+
219
+ ```ts
220
+ chain()
221
+ .glass()
222
+ .glow("#6366f1")
223
+ .textGradient(["#667eea", "#764ba2"])
224
+ .meshGradient(["#f0f", "#0ff", "#ff0"]);
225
+ ```
226
+
227
+ ---
228
+
229
+ ## State & Interaction
230
+
231
+ ```ts
232
+ chain()
233
+ .clickScale(0.95)
234
+ .pressable()
235
+ .focusRing("#3b82f6")
236
+ .skeleton(true);
237
+ ```
238
+
239
+ ---
240
+
241
+ # 5. Intent API
242
+
243
+ ```ts
244
+ // Layout
245
+ chain().intent("center-content").$el("centered");
246
+ chain().intent("stack").$el("stack");
247
+ chain().intent("sidebar-layout").$el("dashboard");
248
+
249
+ // Components
250
+ chain().intent("card").$el("card");
251
+ chain().intent("button-primary").$el("cta");
252
+ chain().intent("modal").$el("dialog");
253
+
254
+ // Semantic
255
+ chain().intent("hero-section").$el("hero");
256
+ chain().intent("sticky-header").$el("nav");
257
+
258
+ // Interaction
259
+ chain().intent("hover-lift").$el("interactive");
260
+ chain().intent("focus-ring").$el("accessible");
261
+ ```
262
+
263
+ ---
264
+
265
+ # 6. Semantic Tokens
266
+
267
+ ```ts
268
+ chain()
269
+ .surface("interactive")
270
+ .text("primary")
271
+ .elevation("floating")
272
+ .spacing("comfortable")
273
+ .state("hover")
274
+ .state("focus")
275
+ .$el("composed");
276
+ ```
277
+
278
+ ---
279
+
280
+ # 7. Responsive Design
281
+
282
+ ```ts
283
+ chain()
284
+ .display("flex")
285
+ .flexDirection("column")
286
+ .responsive("md", c =>
287
+ c.flexDirection("row")
288
+ )
289
+ .$el("responsive");
290
+ ```
291
+
292
+ ---
293
+
294
+ ## Container Queries
295
+
296
+ ```ts
297
+ chain()
298
+ .containerQuery("(min-width: 400px)", c =>
299
+ c.gridTemplateColumns("1fr 1fr")
300
+ )
301
+ .$el("container-responsive");
302
+ ```
303
+
304
+ ---
305
+
306
+ # 8. Conditional Styles
307
+
308
+ ## `when()`
309
+
310
+ ```ts
311
+ chain()
312
+ .padding(12)
313
+ .when(isActive, c =>
314
+ c.background("#10b981")
315
+ .color("white")
316
+ )
317
+ .when(isDisabled, c =>
318
+ c.opacity(0.5)
319
+ .cursor("not-allowed")
320
+ )
321
+ .$el("stateful-btn");
322
+ ```
323
+
324
+ ---
325
+
326
+ ## CSS `if()`
327
+
328
+ ```ts
329
+ chain()
330
+ .background("if(style(--theme: dark): #1a1a1a else #ffffff)")
331
+ .color("if(style(--theme: dark): white else black)")
332
+ .$el("theme-aware");
333
+ ```
334
+
335
+ ---
336
+
337
+ # 9. Nested Selectors & Mixins
338
+
339
+ ## Nested Selectors
340
+
341
+ ```ts
342
+ chain()
343
+ .display("flex")
344
+ .nest("& > *", c => c.flex(1))
345
+ .nest("&:first-child", c => c.fontWeight(700))
346
+ .nest(".child", c => c.color("red"))
347
+ .$el("flex-container");
348
+ ```
349
+
350
+ ---
351
+
352
+ ## Mixins
353
+
354
+ ```ts
355
+ const flexCenter = {
356
+ display: "flex",
357
+ justifyContent: "center",
358
+ alignItems: "center",
359
+ };
360
+
361
+ chain()
362
+ .use(flexCenter)
363
+ .padding(24)
364
+ .$el("composed-card");
365
+ ```
366
+
367
+ ---
368
+
369
+ # 10. Math Engine
370
+
371
+ ## Import
372
+
373
+ ```ts
374
+ import {
375
+ math,
376
+ add,
377
+ subtract,
378
+ multiply,
379
+ divide,
380
+ fluidType,
381
+ convert,
382
+ scale
383
+ } from "chaincss";
384
+ ```
385
+
386
+ ---
387
+
388
+ ## Basic Arithmetic
389
+
390
+ ```ts
391
+ add("10px", "20px");
392
+ subtract("50px", "20px");
393
+ multiply("10px", 3);
394
+ divide("100px", 4);
395
+ ```
396
+
397
+ ---
398
+
399
+ ## Fluid Typography
400
+
401
+ ```ts
402
+ fluidType({
403
+ minSize: 14,
404
+ maxSize: 20
405
+ });
406
+ ```
407
+
408
+ ---
409
+
410
+ # 11. Constraint-Based Styling
411
+
412
+ ```ts
413
+ chain()
414
+ .constrain("width", "< parent")
415
+ .constrain("height", "= width * 0.5")
416
+ .constrain("columns", ">= 3 when > 768px")
417
+ .$el("responsive-card");
418
+ ```
419
+
420
+ ---
421
+
422
+ # 12. Design Tokens & Themes
423
+
424
+ ## Creating Tokens
425
+
426
+ ```ts
427
+ import { createTokens } from "chaincss";
428
+
429
+ const tokens = createTokens({
430
+ colors: {
431
+ primary: "#2563eb",
432
+ success: "#10b981",
433
+ },
434
+
435
+ spacing: {
436
+ sm: "8px",
437
+ md: "16px",
438
+ lg: "24px",
439
+ },
440
+ });
441
+ ```
442
+
443
+ ---
444
+
445
+ ## Theme Contracts
446
+
447
+ ```ts
448
+ import {
449
+ createThemeContract,
450
+ createTheme
451
+ } from "chaincss";
452
+
453
+ const contract = createThemeContract({
454
+ colors: {
455
+ primary: "",
456
+ background: "",
457
+ },
458
+ });
459
+
460
+ const lightTheme = createTheme(contract, {
461
+ colors: {
462
+ primary: "#3b82f6",
463
+ background: "#ffffff",
464
+ },
465
+ });
466
+ ```
467
+
468
+ ---
469
+
470
+ # 13. Recipe System
471
+
472
+ ```ts
473
+ import { recipe } from "chaincss";
474
+
475
+ const button = recipe({
476
+ base: {
477
+ selectors: ["btn"],
478
+ display: "inline-flex",
479
+ borderRadius: "8px",
480
+ },
481
+
482
+ variants: {
483
+ size: {
484
+ sm: { padding: "8px 16px" },
485
+ lg: { padding: "16px 32px" },
486
+ },
487
+ },
488
+ });
489
+ ```
490
+
491
+ ---
492
+
493
+ # 14. Animations
494
+
495
+ ## Presets
496
+
497
+ ```ts
498
+ chain().fadeIn().$el("el");
499
+ chain().slideInUp().$el("el");
500
+ chain().zoomIn().$el("el");
501
+ chain().bounce().$el("el");
502
+ chain().pulse().$el("el");
503
+ chain().spin().$el("el");
504
+ ```
505
+
506
+ ---
507
+
508
+ ## Custom Animation
509
+
510
+ ```ts
511
+ chain()
512
+ .animate(
513
+ "myBounce",
514
+ {
515
+ "0%": { transform: "scale(1)" },
516
+ "50%": { transform: "scale(1.2)" },
517
+ "100%": { transform: "scale(1)" },
518
+ },
519
+ {
520
+ duration: "0.5s",
521
+ timing: "ease-in-out",
522
+ }
523
+ )
524
+ .$el("custom-animated");
525
+ ```
526
+
527
+ ---
528
+
529
+ # 15. Scroll Timeline Engine
530
+
531
+ ```ts
532
+ import {
533
+ createScrollAnimation,
534
+ compileScrollAnimation,
535
+ } from "chaincss";
536
+
537
+ const fadeIn = createScrollAnimation(
538
+ "fadeIn",
539
+ ".reveal"
540
+ );
541
+ ```
542
+
543
+ ---
544
+
545
+ # 16. Self-Healing CSS
546
+
547
+ ```ts
548
+ import { correct, heal } from "chaincss";
549
+
550
+ correct("display", "flexbox");
551
+ correct("position", "abs");
552
+
553
+ heal(
554
+ {
555
+ display: "flexbox",
556
+ position: "abs",
557
+ },
558
+ "smart"
559
+ );
560
+ ```
561
+
562
+ ---
563
+
564
+ # 17. Compiler Intelligence
565
+
566
+ ```ts
567
+ chain()
568
+ .width("1200px")
569
+ .fontSize("48px")
570
+ .$el("hero");
571
+ ```
572
+
573
+ The compiler can:
574
+ - prevent mobile overflow
575
+ - infer responsive layouts
576
+ - detect inaccessible font sizes
577
+ - optimize layouts automatically
578
+
579
+ ---
580
+
581
+ # 18. Accessibility Engine
582
+
583
+ | Check | WCAG | Auto Fix |
584
+ |---|---|---|
585
+ | Contrast ratio | 1.4.3 AA | No |
586
+ | Font size | 1.4.4 AA | Yes |
587
+ | Touch target | 2.5.8 AA | Yes |
588
+ | Focus indicator | 2.4.7 AA | Yes |
589
+
590
+ ---
591
+
592
+ # 19. Source-Aware Optimization
593
+
594
+ Detects:
595
+ - duplicate styles
596
+ - dead CSS
597
+ - specificity wars
598
+ - animation conflicts
599
+ - redundant media queries
600
+
601
+ ---
602
+
603
+ # 20. CLI Commands
604
+
605
+ ```bash
606
+ chaincss init
607
+ chaincss build
608
+ chaincss watch
609
+ chaincss cache clear
610
+ chaincss cache stats
611
+ chaincss optimize --report
612
+ chaincss doctor
613
+ ```
614
+
615
+ ---
616
+
617
+ # 21. Framework Integration
618
+
619
+ ## React
620
+
621
+ ```tsx
622
+ import { chain } from "chaincss";
623
+
624
+ function Card({ children }) {
625
+ const styles = chain()
626
+ .intent("card")
627
+ .$el("card");
628
+
629
+ return (
630
+ <div className={styles.selectors[0]}>
631
+ {children}
632
+ </div>
633
+ );
634
+ }
635
+ ```
636
+
637
+ ---
638
+
639
+ ## Vue
640
+
641
+ ```vue
642
+ <script setup>
643
+ import { chain } from "chaincss";
644
+
645
+ const styles = chain()
646
+ .grid()
647
+ .cols(3)
648
+ .gap(16)
649
+ .$el("grid");
650
+ </script>
651
+
652
+ <template>
653
+ <div :class="styles.selectors[0]">
654
+ <slot />
655
+ </div>
656
+ </template>
657
+ ```
658
+
659
+ ---
660
+
661
+ ## Svelte
662
+
663
+ ```svelte
664
+ <script>
665
+ import { chain } from "chaincss";
666
+
667
+ const styles = chain()
668
+ .flex()
669
+ .center()
670
+ .$el("centered");
671
+ </script>
672
+
673
+ <div class={styles.selectors[0]}>
674
+ <slot />
675
+ </div>
676
+ ```
677
+
678
+ ---
679
+
680
+ # 22. Configuration
681
+
682
+ ```ts
683
+ // chaincss.config.ts
684
+ import { defineConfig } from "chaincss";
685
+
686
+ export default defineConfig({
687
+ atomic: {
688
+ enabled: true,
689
+ mode: "hybrid",
690
+ },
691
+
692
+ tokens: {
693
+ enabled: true,
694
+ prefix: "$",
695
+ },
696
+
697
+ breakpoints: {
698
+ sm: "(min-width: 640px)",
699
+ md: "(min-width: 768px)",
700
+ },
701
+ });
702
+ ```
703
+
704
+ ## 23. Power Macros
705
+
706
+ ### `autoContrast()`
707
+
708
+ Automatically generates accessible foreground colors based on WCAG contrast rules.
709
+
710
+ ```ts
711
+ import { intent } from "chaincss";
712
+
713
+ intent.autoContrast("#1a1a1a"); // "#ffffff"
714
+ intent.autoContrast("#ffffff"); // "#000000"
715
+ intent.autoContrast("#a0c4ff"); // "#000000"
716
+
717
+ chain()
718
+ .backgroundColor("#1a1a1a")
719
+ .color(intent.autoContrast("#1a1a1a"))
720
+ .$el("accessible");
721
+ ```
722
+
723
+ ### Smart Layout Macros
724
+
725
+ ```ts
726
+ chain()
727
+ .stack("vertical center gap-4")
728
+ .glass()
729
+ .hoverLift()
730
+ .$el("smart-layout");
731
+ ```
732
+
733
+ ### Auto Grid
734
+
735
+ Automatically creates responsive grid layouts.
736
+
737
+ ```ts
738
+ chain()
739
+ .autoGrid({
740
+ min: 250,
741
+ gap: 24,
742
+ })
743
+ .$el("gallery");
744
+ ```
745
+
746
+ Compiles to:
747
+
748
+ ```css
749
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
750
+ gap: 24px;
751
+ ```
752
+
753
+ ### Smart Container
754
+
755
+ ```ts
756
+ chain()
757
+ .containerMacro(1200)
758
+ .$el("container");
759
+ ```
760
+
761
+ Compiles to:
762
+
763
+ ```css
764
+ width: min(100%, 1200px);
765
+ margin-inline: auto;
766
+ padding-inline: 24px;
767
+ ```
768
+
769
+ ### Glassmorphism Macro
770
+
771
+ ```ts
772
+ chain()
773
+ .glass()
774
+ .$el("glass-card");
775
+
776
+ chain()
777
+ .glass(12)
778
+ .$el("strong-glass");
779
+ ```
780
+
781
+ ### Frosted Navigation
782
+
783
+ ```ts
784
+ chain()
785
+ .frostedNav(16)
786
+ .$el("navbar");
787
+ ```
788
+
789
+ ### Skeleton Loader
790
+
791
+ ```ts
792
+ chain()
793
+ .skeleton(true)
794
+ .$el("loading-card");
795
+
796
+ chain()
797
+ .skeleton({
798
+ active: true,
799
+ color: "#e5e7eb",
800
+ shimmer: true,
801
+ })
802
+ .$el("advanced-loader");
803
+ ```
804
+
805
+ ### Interactive Macros
806
+
807
+ ```ts
808
+ chain()
809
+ .pressable()
810
+ .clickScale(0.96)
811
+ .focusRing("#3b82f6")
812
+ .$el("interactive-button");
813
+ ```
814
+
815
+ ### Accessibility Helpers
816
+
817
+ ```ts
818
+ chain()
819
+ .visuallyHidden()
820
+ .$el("screen-reader-only");
821
+
822
+ chain()
823
+ .focusVisible()
824
+ .$el("accessible-focus");
825
+ ```
826
+
827
+ ### Macro Autocomplete
828
+
829
+ ```ts
830
+ import {
831
+ getSuggestion,
832
+ getAutocompleteSuggestions,
833
+ KNOWN_MACROS,
834
+ } from "chaincss";
835
+
836
+ getSuggestion("card");
837
+ // → "card"
838
+
839
+ getSuggestion("glsas");
840
+ // → "glass"
841
+
842
+ getAutocompleteSuggestions("sticky", 10);
843
+ // → ["sticky", "stickyHeader", "stickyFooter"]
844
+
845
+ KNOWN_MACROS.length;
846
+ // → total available macros
847
+ ```
848
+
849
+ ---
850
+
851
+ ## 24. Complete API Reference
852
+
853
+ ### Core Imports
854
+
855
+ ```ts
856
+ import {
857
+ chain,
858
+ $,
859
+ smartChain,
860
+
861
+ // Intent API
862
+ intentAPI,
863
+ resolveIntent,
864
+ getAvailableIntents,
865
+
866
+ // Semantic Tokens
867
+ semanticTokens,
868
+ resolveSemantic,
869
+ getSemanticIntents,
870
+
871
+ // Math Engine
872
+ math,
873
+ add,
874
+ subtract,
875
+ multiply,
876
+ divide,
877
+ fluidType,
878
+ convert,
879
+ scale,
880
+ toPx,
881
+
882
+ // Constraint System
883
+ constraintSolver,
884
+ resolveConstraint,
885
+
886
+ // Self-Healing CSS
887
+ intent,
888
+ correct,
889
+ heal,
890
+ validateValue,
891
+ getIntent,
892
+
893
+ // Scroll Timeline Engine
894
+ scrollTimeline,
895
+ createScrollAnimation,
896
+ compileScrollAnimation,
897
+ getScrollPresets,
898
+
899
+ // Accessibility Engine
900
+ accessibilityEngine,
901
+ auditAccessibility,
902
+
903
+ // Optimization
904
+ sourceOptimizer,
905
+ optimizeSource,
906
+
907
+ // Pattern Learning
908
+ patternLearner,
909
+ learnPatterns,
910
+
911
+ // Compiler Intelligence
912
+ orchestrator,
913
+ contrastRatio,
914
+ checkContrast,
915
+ layoutIntelligence,
916
+ recognizeLayout,
917
+ suggestMacro,
918
+ responsiveInference,
919
+ analyzeResponsive,
920
+
921
+ // CSS if() Engine
922
+ compileIfConditions,
923
+ generateIfCSS,
924
+
925
+ // Compiler IR
926
+ styleIR,
927
+ parseIR,
928
+ generateCSS,
929
+ applyPass,
930
+
931
+ // Pipeline
932
+ PassManager,
933
+ runDefaultPipeline,
934
+ DEFAULT_PIPELINE,
935
+
936
+ // Suggestions
937
+ getSuggestion,
938
+ getSuggestions,
939
+ KNOWN_MACROS,
940
+
941
+ // Design Tokens
942
+ createTokens,
943
+ createThemeContract,
944
+ createTheme,
945
+ validateTheme,
946
+ Theme,
947
+
948
+ // Recipes
949
+ recipe,
950
+
951
+ // Animations
952
+ animationPresets,
953
+ createAnimation,
954
+
955
+ // Shorthands & Macros
956
+ shorthandMap,
957
+ macros,
958
+ handleShorthand,
959
+
960
+ // Timeline
961
+ enableTimeline,
962
+ getStyleHistory,
963
+ getStyleDiff,
964
+
965
+ // Compiler
966
+ ChainCSSCompiler,
967
+ compileChainCSS,
968
+
969
+ // Runtime
970
+ injectChainStyles,
971
+ setManifest,
972
+ setTokens,
973
+ } from "chaincss";
974
+ ```
975
+
976
+ ---
977
+
978
+ # Quick Reference Cards
979
+
980
+ ## Chain Lifecycle
981
+
982
+ ```txt
983
+ chain() -> [methods] -> $el("selector")
984
+ ```
985
+
986
+ ---
987
+
988
+ ## Three Modes
989
+
990
+ ```txt
991
+ chain() -> build-time (zero runtime)
992
+ chain() -> runtime (browser injection)
993
+ smartChain() -> hybrid auto-detection
994
+ ```
995
+
996
+ ---
997
+
998
+ ## Method Categories
999
+
1000
+ ### Shorthand Methods
1001
+
1002
+ ```ts
1003
+ .bg()
1004
+ .c()
1005
+ .m()
1006
+ .p()
1007
+ .w()
1008
+ .h()
1009
+ .br()
1010
+ .fs()
1011
+ .fw()
1012
+ ```
1013
+
1014
+ ### Layout Macros
1015
+
1016
+ ```ts
1017
+ .flex()
1018
+ .grid()
1019
+ .center()
1020
+ .stack()
1021
+ .cols()
1022
+ .rows()
1023
+ .glass()
1024
+ .pill()
1025
+ ```
1026
+
1027
+ ### Intent API
1028
+
1029
+ ```ts
1030
+ .intent("card")
1031
+ .intent("button-primary")
1032
+ .intent("hero-section")
1033
+ .intent("sidebar-layout")
1034
+ ```
1035
+
1036
+ ### Semantic Tokens
1037
+
1038
+ ```ts
1039
+ .surface()
1040
+ .text()
1041
+ .elevation()
1042
+ .spacing()
1043
+ .state()
1044
+ ```
1045
+
1046
+ ### Math Helpers
1047
+
1048
+ ```ts
1049
+ .add()
1050
+ .calc()
1051
+ .clamp()
1052
+ .fluidType()
1053
+ .scale()
1054
+ .convert()
1055
+ ```
1056
+
1057
+ ### Constraints
1058
+
1059
+ ```ts
1060
+ .constrain("width", "< parent")
1061
+ .constrain("height", "= width * 0.5")
1062
+ ```
1063
+
1064
+ ### State Methods
1065
+
1066
+ ```ts
1067
+ .hover()
1068
+ .when()
1069
+ .responsive()
1070
+ .dark()
1071
+ .light()
1072
+ .focusRing()
1073
+ ```
1074
+
1075
+ ### Animation Methods
1076
+
1077
+ ```ts
1078
+ .fadeIn()
1079
+ .slideInUp()
1080
+ .zoomIn()
1081
+ .animate()
1082
+ .duration()
1083
+ .delay()
1084
+ ```
1085
+
1086
+ ---
1087
+
1088
+ # Compiler Pipeline
1089
+
1090
+ ```txt
1091
+ Chain API
1092
+
1093
+ Parser
1094
+
1095
+ Style IR
1096
+
1097
+ Validation
1098
+
1099
+ Accessibility Engine
1100
+
1101
+ Optimization Passes
1102
+
1103
+ Atomic Extraction
1104
+
1105
+ CSS Generation
1106
+
1107
+ Output Files
1108
+ ```
1109
+
1110
+ ---
1111
+
1112
+ # Architecture Overview
1113
+
1114
+ | Layer | Purpose |
1115
+ |---|---|
1116
+ | Chain API | Fluent style authoring |
1117
+ | Intent Engine | Semantic layout resolution |
1118
+ | Semantic Tokens | Theme-aware styling |
1119
+ | Compiler IR | Intermediate style representation |
1120
+ | Accessibility Engine | WCAG validation |
1121
+ | Responsive Inference | Mobile-aware optimization |
1122
+ | Source Optimizer | Deduplication & dead-code removal |
1123
+ | Runtime Injector | Browser style injection |
1124
+ | Timeline Engine | Style history tracking |
1125
+
1126
+ ---
1127
+
1128
+ # Feature Summary
1129
+
1130
+ | Feature | Count |
1131
+ |---|---|
1132
+ | Intents | 22 |
1133
+ | Semantic Tokens | 30 |
1134
+ | Layout Patterns | 35+ |
1135
+ | Macros | 57+ |
1136
+ | Shorthands | 80+ |
1137
+ | Animations | 42 |
1138
+ | Breakpoints | 20 |
1139
+ | Compiler Passes | 10 |
1140
+ | WCAG Detectors | 6 |
1141
+ | Scroll Presets | 7 |
1142
+ | Framework Integrations | 4 |
1143
+ | CLI Commands | 7 |
1144
+ | Test Suites | 39 |
1145
+ | Passing Tests | 708 |
1146
+
1147
+ ---
1148
+
1149
+ # Final Notes
1150
+
1151
+ ChainCSS is designed to combine:
1152
+
1153
+ - **Tailwind-level utility speed**
1154
+ - **CSS-in-JS flexibility**
1155
+ - **Compiler intelligence**
1156
+ - **Accessibility enforcement**
1157
+ - **Semantic design systems**
1158
+ - **Zero-runtime extraction**
1159
+
1160
+ The result is a styling platform that understands intent — not just CSS properties.
1161
+
1162
+ ---
1163
+
1164
+ <p align="center">
1165
+ <strong>⛓️ ChainCSS v2.3</strong><br>
1166
+ <em>The CSS Intelligence Platform</em><br><br>
1167
+ 708 tests · 17 modules · Zero runtime · WCAG-aware
1168
+ </p>