1
1
/* Superscript and Subscript Typography Enhancement Styles */
2
- /* Pure CSS - Framework agnostic */
2
+ /* SmartScript (ss-) prefixed classes for automatic typography */
3
3
4
- /* Auto-generated superscript elements */
5
- sup .auto-super ,
6
- .text-super {
7
- /* Spacing for better readability */
8
- margin-left : 0.05em ; /* Small space before */
9
- margin-right : 0.1em ; /* Slightly more space after */
10
-
11
- /* Core superscript styling */
4
+ /* ============================================
5
+ Core Superscript Styling
6
+ Best practice: Use vertical-align: super with line-height: 0
7
+ ============================================ */
8
+ sup .ss-sup {
9
+ /* Size reduction */
12
10
font-size : 0.75em ;
11
+
12
+ /* Use browser's native superscript positioning */
13
+ vertical-align : super;
14
+
15
+ /* Prevent line-height disruption */
13
16
line-height : 0 ;
14
- vertical-align : super; /* Use browser's native superscript positioning - adapts to font metrics */
15
17
16
- /* Visual refinement */
18
+ /* Fine-tune position - bring down slightly from browser default */
19
+ position : relative;
20
+ top : 0.15em ; /* Scales with font size */
21
+
22
+ /* Spacing */
23
+ margin-left : 0.05em ;
24
+ margin-right : 0.1em ;
25
+
26
+ /* Inherit parent styles */
17
27
font-weight : inherit;
18
28
letter-spacing : 0.025em ;
19
29
}
20
30
21
- /* Auto-generated subscript elements */
22
- sub .auto-sub ,
23
- .text-sub {
24
- /* Spacing for better readability */
25
- margin-left : 0.05em ; /* Small space before */
26
- margin-right : 0.1em ; /* Slightly more space after */
27
-
28
- /* Core subscript styling */
31
+ /* ============================================
32
+ Core Subscript Styling
33
+ ============================================ */
34
+ sub .ss-sub {
35
+ /* Size reduction */
29
36
font-size : 0.75em ;
37
+
38
+ /* Use browser's native subscript positioning */
39
+ vertical-align : sub;
40
+
41
+ /* Prevent line-height disruption */
30
42
line-height : 0 ;
31
- vertical-align : sub; /* Use browser's native subscript positioning */
32
43
33
- /* Visual refinement */
44
+ /* Spacing */
45
+ margin-left : 0.05em ;
46
+ margin-right : 0.1em ;
47
+
48
+ /* Inherit parent styles */
34
49
font-weight : inherit;
35
50
letter-spacing : 0.025em ;
36
51
}
37
52
38
- /* Special handling for consecutive super/subscripts */
39
- sup .auto-super + sup .auto-super ,
40
- sub .auto-sub + sub .auto-sub {
41
- margin-left : 0 ; /* No extra space between consecutive elements */
53
+ /* ============================================
54
+ Headings: Slightly smaller for visual balance
55
+ ============================================ */
56
+ : is (h1 , h2 , h3 , h4 , h5 , h6 ) sup .ss-sup ,
57
+ : is (h1 , h2 , h3 , h4 , h5 , h6 ) sub .ss-sub {
58
+ font-size : 0.65em ;
42
59
}
43
60
44
- /* In headings, adjust sizing */
45
- h1 sup .auto-super , h1 sub .auto-sub ,
46
- h2 sup .auto-super , h2 sub .auto-sub ,
47
- h3 sup .auto-super , h3 sub .auto-sub {
48
- font-size : 0.65em ; /* Slightly smaller in headings */
49
- }
61
+ /* ============================================
62
+ Special Cases
63
+ ============================================ */
50
64
51
- /* Special handling for Unicode trademark and registered symbols */
52
- /* These already have some superscript positioning built into the character */
53
- /* So we need less vertical adjustment */
54
- sup .trademark-symbol {
55
- font-size : 0.8em ; /* Slightly larger since the Unicode character is already small */
56
- vertical-align : baseline;
57
- position : relative;
58
- top : -0.3em ; /* Reduced from -0.5em to better match registered symbol */
59
- margin-left : 0.05em ;
60
- margin-right : 0.05em ;
65
+ /* Remove spacing between consecutive super/subscripts */
66
+ : is (sup .ss-sup , sub .ss-sub ) + : is (sup .ss-sup , sub .ss-sub ) {
67
+ margin-left : 0 ;
61
68
}
62
69
63
- /* Registered symbol needs different positioning due to the circle */
64
- sup .registered-symbol {
65
- font-size : 0.8em ;
66
- vertical-align : baseline;
67
- position : relative;
68
- top : -0.25em ; /* Lower than TM to account for circle - adjusted for better alignment */
69
- margin-left : 0.05em ;
70
- margin-right : 0.05em ;
70
+ /* Specific symbol classes for semantic clarity */
71
+ sup .ss-tm {
72
+ /* Inherits from ss-sup */
71
73
}
72
74
73
- /* In headings, raise trademark and registered symbols higher */
74
- h1 sup .trademark-symbol ,
75
- h2 sup .trademark-symbol ,
76
- h3 sup .trademark-symbol ,
77
- h4 sup .trademark-symbol ,
78
- h5 sup .trademark-symbol ,
79
- h6 sup .trademark-symbol {
80
- top : -0.5em ; /* Reduced from -0.7em for better balance */
81
- font-size : 0.65em ;
82
- }
83
-
84
- /* Registered in headings - slightly lower than TM */
85
- h1 sup .registered-symbol ,
86
- h2 sup .registered-symbol ,
87
- h3 sup .registered-symbol ,
88
- h4 sup .registered-symbol ,
89
- h5 sup .registered-symbol ,
90
- h6 sup .registered-symbol {
91
- top : -0.4em ; /* Slightly lower than TM to account for circle */
92
- font-size : 0.65em ;
75
+ sup .ss-reg {
76
+ /* Inherits from ss-sup */
93
77
}
94
78
95
- /* Specific adjustments for chemical formulas */
96
- /* Removed first-child rule as it was incorrectly removing margins */
79
+ /* ============================================
80
+ Media Queries & Accessibility
81
+ ============================================ */
97
82
98
- /* Print styles */
83
+ /* Print optimization */
99
84
@media print {
100
- sup .auto-super ,
101
- sub .auto -sub {
102
- font-size : 0.7em ; /* Slightly smaller for print */
85
+ sup .ss-sup ,
86
+ sub .ss -sub {
87
+ font-size : 0.7em ;
103
88
}
104
89
}
105
90
106
- /* High contrast mode support */
91
+ /* High contrast mode */
107
92
@media (prefers-contrast : high) {
108
- sup .auto-super ,
109
- sub .auto -sub {
110
- font-weight : bold; /* Make more visible in high contrast */
93
+ sup .ss-sup ,
94
+ sub .ss -sub {
95
+ font-weight : bold;
111
96
}
112
97
}
113
98
114
- /* Reduce motion support */
99
+ /* Reduced motion */
115
100
@media (prefers-reduced-motion : reduce) {
116
- sup .auto-super ,
117
- sub .auto -sub {
118
- transition : none; /* Remove any transitions */
101
+ sup .ss-sup ,
102
+ sub .ss -sub {
103
+ transition : none;
119
104
}
120
105
}
0 commit comments