@sofyan/glass 0.1.6 → 0.3.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.
@@ -0,0 +1,1117 @@
1
+ /*
2
+ * @sofyan/glass: Liquid Glass material, unlayered build
3
+ * ---------------------------------------------------------------------------
4
+ * Generated from src/glass.css by the build: the same rules in the same order, with the
5
+ * cascade layers taken out. Edit the source, not this file.
6
+ *
7
+ * Use it instead of glass.css when your app's own CSS is unlayered, or when it must
8
+ * support browsers without cascade layers (before Safari 15.4, Chrome 99, Firefox 97),
9
+ * which drop layered CSS entirely.
10
+ *
11
+ * A translucent, light-bending material inspired by Apple's Liquid Glass:
12
+ * - backdrop blur + saturation boost so content behind the layer glows through
13
+ * - a specular rim (bright top edge that fades) drawn as a masked gradient ring,
14
+ * so it follows any border-radius
15
+ * - a near-invisible sheen, soft depth shadows and a gentle spring on press
16
+ *
17
+ * Every visual decision is a CSS custom property (--lg-*). Override any of them on
18
+ * :root (or on an element) to retune the material without touching components.
19
+ *
20
+ * Cascade: no cascade layers here, so normal specificity and source order decide.
21
+ * Tailwind utilities no longer win automatically: an unlayered utility overrides a glass
22
+ * rule only when it is more specific, or as specific and loaded later, and a layered one
23
+ * never does. So load the glass files before your own CSS.
24
+ *
25
+ * Accessibility (bottom of file):
26
+ * - no backdrop-filter support → denser fill
27
+ * - prefers-reduced-transparency → near-opaque fill, no blur
28
+ * - prefers-contrast: more → solid edges, no sheen
29
+ * - prefers-reduced-motion → no lift, press or slide animations
30
+ */
31
+
32
+ /* ── Tokens ───────────────────────────────────────────────────────────── */
33
+ :root {
34
+ /* Derived tokens. Not declared here: a var() in a :root value is resolved at :root, so
35
+ it would ignore --color-* or --lg-c-* overrides set lower down (e.g. on a `.dark`
36
+ wrapper). Each use site falls back to the default below instead. Set any of them,
37
+ on :root or on an element, to override it.
38
+ --lg-accent default var(--color-primary, #0a84ff)
39
+ --lg-accent-strong default var(--color-primary-dark, #0060df)
40
+ --lg-accent-2 default var(--color-secondary, #5e5ce6)
41
+ --lg-accent-2-strong default var(--color-secondary-dark, #4b49c9)
42
+ --lg-sheet-fill default rgb(var(--lg-c-paper)), the <dialog> sheet's fill */
43
+ --lg-danger: #ff3b30; /* iOS system red */
44
+ --lg-danger-strong: #e5352b;
45
+ /* Danger as a fill under white text (buttons, error toasts): 5.4:1 and 7.4:1 (WCAG 1.4.3).
46
+ White on --lg-danger is only 3.6:1, so that one stays for edges and rings. */
47
+ --lg-danger-fill: #d70015;
48
+ --lg-danger-fill-strong: #b00012;
49
+ /* Danger as text (field errors). --lg-danger is a fill and too light for text; this one
50
+ has 4.5:1 or more on the paper and canvas neutrals (WCAG 1.4.3). dark.css retunes it. */
51
+ --lg-danger-text: #d70015;
52
+
53
+ /* Theme-aware neutrals as RGB triplets, so `rgb(var(--lg-c-ink) / 0.5)` works.
54
+ tailwind.css maps them to `lg-*` colours. Redefine them for dark mode. */
55
+ --lg-c-canvas: 245 245 247;
56
+ --lg-c-paper: 255 255 255;
57
+ --lg-c-raised: 255 255 255;
58
+ --lg-c-ink: 29 29 31;
59
+ --lg-c-ink-2: 110 110 115;
60
+ --lg-c-ink-3: 160 160 166;
61
+ --lg-c-line: 0 0 0;
62
+
63
+ /* Material */
64
+ --lg-blur: 24px;
65
+ --lg-blur-thin: 12px;
66
+ --lg-blur-thick: 40px;
67
+ --lg-saturate: 180%;
68
+
69
+ /* Light glass (over light or colourful content) */
70
+ --lg-light-fill: rgba(255, 255, 255, 0.66);
71
+ --lg-light-fill-hover: rgba(255, 255, 255, 0.8);
72
+ --lg-light-text: #0b1220;
73
+ --lg-light-rim: rgba(255, 255, 255, 0.8);
74
+ --lg-light-rim-low: rgba(255, 255, 255, 0);
75
+ --lg-light-edge: rgba(15, 23, 42, 0.06);
76
+
77
+ /* Dark glass (over dark or photographic content) */
78
+ --lg-dark-fill: rgba(30, 30, 34, 0.5);
79
+ --lg-dark-fill-hover: rgba(44, 44, 50, 0.58);
80
+ --lg-dark-text: #ffffff;
81
+ --lg-dark-rim: rgba(255, 255, 255, 0.16);
82
+ --lg-dark-rim-low: rgba(255, 255, 255, 0);
83
+ --lg-dark-edge: rgba(255, 255, 255, 0.08);
84
+
85
+ /* Clear glass (minimal tint, floating over media) */
86
+ --lg-clear-fill: rgba(255, 255, 255, 0.1);
87
+ --lg-clear-fill-hover: rgba(255, 255, 255, 0.18);
88
+
89
+ /* Sheen: deliberately near-invisible. A visible gloss band reads as 2009-era Aero;
90
+ modern glass is flat and lit only at the edge. */
91
+ --lg-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 30%);
92
+ --lg-sheen-dark: none;
93
+
94
+ /* Depth: one large, faint, diffuse shadow, no hard contact shadows. */
95
+ --lg-shadow-sm: 0 2px 12px rgba(15, 23, 42, 0.05);
96
+ --lg-shadow-md: 0 8px 32px rgba(15, 23, 42, 0.08);
97
+ --lg-shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.12);
98
+ --lg-shadow-dark: 0 12px 40px rgba(0, 0, 0, 0.35);
99
+
100
+ /* Shape: soft, not bubbly. */
101
+ --lg-radius-sm: 10px;
102
+ --lg-radius-md: 14px;
103
+ --lg-radius-lg: 16px;
104
+ --lg-radius-xl: 20px;
105
+ --lg-radius-sheet: 20px;
106
+
107
+ /* Motion: a gentle settle, not a bouncy overshoot. */
108
+ --lg-ease-spring: cubic-bezier(0.32, 1.2, 0.5, 1);
109
+ --lg-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
110
+ --lg-duration: 380ms;
111
+ --lg-duration-fast: 180ms;
112
+
113
+ /* Overlays */
114
+ --lg-scrim: rgba(0, 0, 0, 0.4);
115
+ --lg-sheet-max-height: 85dvh;
116
+ --lg-sheet-max-width: 640px;
117
+ }
118
+
119
+ /* Fallbacks that change tokens. */
120
+ @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
121
+ :root {
122
+ --lg-light-fill: rgba(255, 255, 255, 0.92);
123
+ --lg-light-fill-hover: rgba(255, 255, 255, 0.98);
124
+ --lg-dark-fill: rgba(16, 16, 20, 0.9);
125
+ --lg-dark-fill-hover: rgba(28, 28, 34, 0.94);
126
+ --lg-clear-fill: rgba(16, 16, 20, 0.6);
127
+ --lg-clear-fill-hover: rgba(16, 16, 20, 0.7);
128
+ }
129
+ }
130
+
131
+ @media (prefers-reduced-transparency: reduce) {
132
+ :root {
133
+ --lg-light-fill: rgba(255, 255, 255, 0.97);
134
+ --lg-light-fill-hover: #ffffff;
135
+ --lg-dark-fill: rgba(18, 18, 22, 0.97);
136
+ --lg-dark-fill-hover: #1c1c22;
137
+ --lg-clear-fill: rgba(18, 18, 22, 0.85);
138
+ --lg-clear-fill-hover: rgba(18, 18, 22, 0.92);
139
+ --lg-blur: 0px;
140
+ --lg-blur-thin: 0px;
141
+ --lg-blur-thick: 0px;
142
+ --lg-saturate: 100%;
143
+ }
144
+ }
145
+
146
+ @media (prefers-contrast: more) {
147
+ :root {
148
+ --lg-light-edge: rgba(15, 23, 42, 0.45);
149
+ --lg-dark-edge: rgba(255, 255, 255, 0.55);
150
+ --lg-sheen: none;
151
+ --lg-sheen-dark: none;
152
+ }
153
+ }
154
+
155
+ /* ── Base material ──────────────────────────────────────────────────── */
156
+ /* Every class in this list is a glass surface; the composites below add to it. */
157
+ :where(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip, .glass-toast, .glass-tabs) {
158
+ --lg-fill: var(--lg-light-fill);
159
+ --lg-fill-hover: var(--lg-light-fill-hover);
160
+ --lg-rim: var(--lg-light-rim);
161
+ --lg-rim-low: var(--lg-light-rim-low);
162
+ --lg-edge: var(--lg-light-edge);
163
+ --lg-shadow: var(--lg-shadow-md);
164
+ --lg-surface-sheen: var(--lg-sheen);
165
+ --lg-surface-blur: var(--lg-blur);
166
+ }
167
+
168
+ .glass,
169
+ .glass-btn,
170
+ .glass-menu,
171
+ .glass-sheet,
172
+ .glass-chip,
173
+ .glass-toast,
174
+ .glass-tabs {
175
+ position: relative;
176
+ isolation: isolate;
177
+ color: var(--lg-light-text);
178
+ background-color: var(--lg-fill);
179
+ background-image: var(--lg-surface-sheen);
180
+ border-radius: var(--lg-radius-md);
181
+ box-shadow:
182
+ inset 0 0 0 1px var(--lg-edge),
183
+ var(--lg-shadow);
184
+ -webkit-backdrop-filter: blur(var(--lg-surface-blur)) saturate(var(--lg-saturate));
185
+ backdrop-filter: blur(var(--lg-surface-blur)) saturate(var(--lg-saturate));
186
+ }
187
+
188
+ /* Specular rim: a 1px gradient ring that follows the border radius. Light catches the
189
+ top edge only, then fades. Not on the tab track: it scrolls, and the ring would scroll
190
+ away with the tabs. */
191
+ :is(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip, .glass-toast)::before {
192
+ content: '';
193
+ position: absolute;
194
+ inset: 0;
195
+ z-index: 1;
196
+ border-radius: inherit;
197
+ padding: 1px;
198
+ pointer-events: none;
199
+ background: linear-gradient(180deg, var(--lg-rim) 0%, var(--lg-rim-low) 40%);
200
+ -webkit-mask:
201
+ linear-gradient(#000 0 0) content-box,
202
+ linear-gradient(#000 0 0);
203
+ -webkit-mask-composite: xor;
204
+ mask:
205
+ linear-gradient(#000 0 0) content-box exclude,
206
+ linear-gradient(#000 0 0);
207
+ }
208
+
209
+ /* ── Interaction ────────────────────────────────────────────────────── */
210
+ .glass-interactive,
211
+ .glass-btn {
212
+ cursor: pointer;
213
+ transition:
214
+ transform var(--lg-duration) var(--lg-ease-spring),
215
+ background-color var(--lg-duration-fast) ease,
216
+ box-shadow var(--lg-duration) var(--lg-ease-out);
217
+ }
218
+
219
+ :is(.glass-interactive, .glass-btn):hover {
220
+ background-color: var(--lg-fill-hover);
221
+ }
222
+
223
+ :is(.glass-interactive, .glass-btn):active {
224
+ transform: scale(0.97);
225
+ transition-duration: var(--lg-duration-fast);
226
+ }
227
+
228
+ :is(.glass-interactive, .glass-btn):focus-visible {
229
+ outline: 2px solid
230
+ color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 70%, white);
231
+ outline-offset: 2px;
232
+ }
233
+
234
+ /* Cards that float up on hover. */
235
+ .glass-lift {
236
+ transition:
237
+ transform var(--lg-duration) var(--lg-ease-spring),
238
+ box-shadow var(--lg-duration) var(--lg-ease-out),
239
+ background-color var(--lg-duration-fast) ease;
240
+ }
241
+
242
+ .glass-lift:hover {
243
+ --lg-shadow: var(--lg-shadow-lg);
244
+ transform: translateY(-4px);
245
+ }
246
+
247
+ /* ── Composite components ───────────────────────────────────────────── */
248
+
249
+ /* Buttons: small radius, interactive, 44px touch target. */
250
+ .glass-btn {
251
+ display: inline-flex;
252
+ align-items: center;
253
+ justify-content: center;
254
+ gap: 0.5rem;
255
+ min-height: 44px;
256
+ padding: 0.625rem 1.25rem;
257
+ border-radius: var(--lg-radius-sm);
258
+ font-size: 0.875rem;
259
+ line-height: 1.25rem;
260
+ font-weight: 600;
261
+ }
262
+
263
+ .glass-btn-sm {
264
+ padding: 0.375rem 0.875rem;
265
+ font-size: 0.75rem;
266
+ line-height: 1rem;
267
+ }
268
+
269
+ .glass-btn-lg {
270
+ padding: 0.875rem 1.75rem;
271
+ font-size: 1rem;
272
+ line-height: 1.5rem;
273
+ }
274
+
275
+ .glass-block {
276
+ width: 100%;
277
+ }
278
+
279
+ .glass-btn:disabled,
280
+ .glass-btn[aria-disabled='true'] {
281
+ cursor: not-allowed;
282
+ opacity: 0.5;
283
+ transform: none;
284
+ }
285
+
286
+ /* Popover / dropdown menus: thick, large radius, dense enough that saturated content
287
+ (badges, red buttons) doesn't read through. */
288
+ .glass-menu {
289
+ --lg-surface-blur: var(--lg-blur-thick);
290
+ --lg-shadow: var(--lg-shadow-lg);
291
+ --lg-fill: rgba(250, 250, 252, 0.86);
292
+ padding: 0.375rem;
293
+ border-radius: var(--lg-radius-lg);
294
+ animation: lg-pop var(--lg-duration) var(--lg-ease-spring) both;
295
+ transform-origin: top right;
296
+ }
297
+
298
+ .glass-menu-item {
299
+ display: flex;
300
+ width: 100%;
301
+ align-items: center;
302
+ gap: 0.75rem;
303
+ padding: 0.625rem 0.875rem;
304
+ border-radius: 0.75rem;
305
+ text-align: left;
306
+ font-size: 0.875rem;
307
+ line-height: 1.25rem;
308
+ font-weight: 500;
309
+ transition:
310
+ background-color var(--lg-duration-fast) ease,
311
+ transform var(--lg-duration-fast) ease;
312
+ }
313
+
314
+ .glass-menu-item:hover,
315
+ .glass-menu-item:focus-visible {
316
+ background-color: rgba(15, 23, 42, 0.06);
317
+ outline: none;
318
+ }
319
+
320
+ .glass-menu-item:active {
321
+ transform: scale(0.985);
322
+ }
323
+
324
+ .glass-menu-separator {
325
+ height: 1px;
326
+ margin: 0.25rem 0.5rem;
327
+ background: linear-gradient(90deg, transparent, rgba(15, 23, 42, 0.1), transparent);
328
+ }
329
+
330
+ /* Modal surface + scrim (for overlays you position yourself; see .glass-dialog for the
331
+ native <dialog> sheet). */
332
+ .glass-scrim {
333
+ background-color: var(--lg-scrim);
334
+ /* Fade the colour, not opacity: an opacity animation would make the scrim a backdrop
335
+ root and stop the sheet inside it from blurring the page. */
336
+ animation: lg-scrim-in var(--lg-duration-fast) ease;
337
+ }
338
+
339
+ .glass-sheet {
340
+ --lg-surface-blur: var(--lg-blur-thick);
341
+ --lg-shadow: var(--lg-shadow-lg);
342
+ --lg-fill: rgba(255, 255, 255, 0.9);
343
+ border-radius: var(--lg-radius-xl);
344
+ animation: lg-sheet-in var(--lg-duration) var(--lg-ease-spring) both;
345
+ }
346
+
347
+ /* Inputs */
348
+ .glass-input {
349
+ width: 100%;
350
+ padding: 0.625rem 1rem;
351
+ border-radius: 0.75rem;
352
+ font-size: 0.875rem;
353
+ line-height: 1.25rem;
354
+ color: rgb(var(--lg-c-ink));
355
+ background-color: rgb(var(--lg-c-paper) / 0.55);
356
+ box-shadow:
357
+ inset 0 1px 2px rgb(var(--lg-c-line) / 0.08),
358
+ inset 0 0 0 1px rgb(var(--lg-c-line) / 0.08);
359
+ -webkit-backdrop-filter: blur(var(--lg-blur-thin));
360
+ backdrop-filter: blur(var(--lg-blur-thin));
361
+ transition:
362
+ background-color var(--lg-duration-fast) ease,
363
+ box-shadow var(--lg-duration-fast) ease;
364
+ }
365
+
366
+ .glass-input::placeholder {
367
+ color: rgb(var(--lg-c-ink-2));
368
+ }
369
+
370
+ .glass-input:focus {
371
+ outline: none;
372
+ background-color: rgb(var(--lg-c-paper) / 0.85);
373
+ box-shadow:
374
+ inset 0 0 0 1.5px
375
+ color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 70%, transparent),
376
+ 0 0 0 4px color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 16%, transparent);
377
+ }
378
+
379
+ /* Invalid (aria-invalid, which the field components set once there is an error): a danger
380
+ ring, 3:1 against paper. The error text is the cue that does not rely on colour. */
381
+ .glass-input[aria-invalid='true'] {
382
+ box-shadow: inset 0 0 0 1.5px var(--lg-danger);
383
+ }
384
+
385
+ /* The first box-shadow is for engines without color-mix(). */
386
+ .glass-input[aria-invalid='true']:focus {
387
+ box-shadow: inset 0 0 0 2px var(--lg-danger);
388
+ box-shadow:
389
+ inset 0 0 0 1.5px var(--lg-danger),
390
+ 0 0 0 4px color-mix(in srgb, var(--lg-danger) 16%, transparent);
391
+ }
392
+
393
+ textarea.glass-input {
394
+ min-height: 5.5rem;
395
+ resize: vertical;
396
+ }
397
+
398
+ /* Fields (<GlassInput />, <GlassTextarea />, <GlassSelect />): label, control, hint and
399
+ error, one under the other. Margins, not flex gap, which needs Safari 14.1. */
400
+ .glass-field .glass-input {
401
+ display: block;
402
+ }
403
+
404
+ .glass-field .glass-input:disabled {
405
+ cursor: not-allowed;
406
+ opacity: 0.5;
407
+ }
408
+
409
+ .glass-field-label {
410
+ display: block;
411
+ margin-bottom: 0.375rem;
412
+ font-size: 0.875rem;
413
+ line-height: 1.25rem;
414
+ font-weight: 500;
415
+ color: rgb(var(--lg-c-ink));
416
+ }
417
+
418
+ /* hideLabel: out of sight, still read. */
419
+ .glass-field-label-hidden {
420
+ position: absolute;
421
+ width: 1px;
422
+ height: 1px;
423
+ margin: -1px;
424
+ padding: 0;
425
+ overflow: hidden;
426
+ clip: rect(0 0 0 0);
427
+ clip-path: inset(50%);
428
+ white-space: nowrap;
429
+ }
430
+
431
+ /* The asterisk is decoration (aria-hidden): the control's `required` carries the meaning. */
432
+ .glass-field-required {
433
+ margin-inline-start: 0.125rem;
434
+ color: var(--lg-danger-text);
435
+ }
436
+
437
+ .glass-field-hint,
438
+ .glass-field-error {
439
+ margin-top: 0.375rem;
440
+ font-size: 0.8125rem;
441
+ line-height: 1.125rem;
442
+ }
443
+
444
+ .glass-field-hint {
445
+ color: rgb(var(--lg-c-ink-2));
446
+ }
447
+
448
+ .glass-field-error {
449
+ font-weight: 500;
450
+ color: var(--lg-danger-text);
451
+ }
452
+
453
+ /* A drop-down <select> in a .glass-select wrapper: the native arrow goes, and a chevron
454
+ drawn in the ink colour takes its place, so it follows the theme. Physical `right` first
455
+ for engines without inset-inline (before Safari 14.1). */
456
+ .glass-select {
457
+ position: relative;
458
+ }
459
+
460
+ .glass-select > select {
461
+ -webkit-appearance: none;
462
+ appearance: none;
463
+ padding-inline-end: 2.5rem;
464
+ cursor: pointer;
465
+ }
466
+
467
+ .glass-select::after {
468
+ content: '';
469
+ position: absolute;
470
+ top: 50%;
471
+ right: 1rem;
472
+ inset-inline-start: auto;
473
+ inset-inline-end: 1rem;
474
+ width: 0.5rem;
475
+ height: 0.5rem;
476
+ margin-top: -0.375rem;
477
+ border-right: 1.5px solid;
478
+ border-bottom: 1.5px solid;
479
+ color: rgb(var(--lg-c-ink-2));
480
+ transform: rotate(45deg);
481
+ pointer-events: none;
482
+ }
483
+
484
+ /* iOS zooms into a focused control whose text is under 16px. */
485
+ @media (pointer: coarse) {
486
+ .glass-field .glass-input {
487
+ font-size: 1rem;
488
+ line-height: 1.5rem;
489
+ }
490
+ }
491
+
492
+ /* Small chip / badge: thin, pill. */
493
+ .glass-chip {
494
+ --lg-surface-blur: var(--lg-blur-thin);
495
+ --lg-shadow: var(--lg-shadow-sm);
496
+ display: inline-flex;
497
+ align-items: center;
498
+ gap: 0.375rem;
499
+ padding: 0.25rem 0.75rem;
500
+ border-radius: 9999px;
501
+ font-size: 0.75rem;
502
+ line-height: 1rem;
503
+ font-weight: 600;
504
+ }
505
+
506
+ /* Toasts (<GlassToasts />): a stack at the top (or bottom) of the viewport, clear of the
507
+ notch and the home indicator. The stack lets taps through to the page; only the toasts
508
+ take them. Margins, not flex gap, which needs Safari 14.1. */
509
+ .glass-toasts {
510
+ position: fixed;
511
+ top: 0;
512
+ left: 0;
513
+ right: 0;
514
+ z-index: 9999;
515
+ display: flex;
516
+ flex-direction: column;
517
+ align-items: center;
518
+ padding: max(env(safe-area-inset-top), 0.75rem) max(env(safe-area-inset-right), 1rem) 0
519
+ max(env(safe-area-inset-left), 1rem);
520
+ pointer-events: none;
521
+ }
522
+
523
+ .glass-toasts-bottom {
524
+ top: auto;
525
+ bottom: 0;
526
+ padding-top: 0;
527
+ padding-bottom: max(env(safe-area-inset-bottom), 0.75rem);
528
+ }
529
+
530
+ /* The two live regions (status, then alert). Never display: none, even when empty: a live
531
+ region that is not rendered is not listening. */
532
+ .glass-toasts-region {
533
+ display: flex;
534
+ flex-direction: column;
535
+ align-items: center;
536
+ width: 100%;
537
+ }
538
+
539
+ .glass-toast + .glass-toast,
540
+ .glass-toasts-region:not(:empty) + .glass-toasts-region:not(:empty) {
541
+ margin-top: 0.5rem;
542
+ }
543
+
544
+ /* A pill while it holds one line; a rounded box when the message wraps. */
545
+ .glass-toast {
546
+ --lg-surface-blur: var(--lg-blur-thick);
547
+ --lg-shadow: var(--lg-shadow-lg);
548
+ display: flex;
549
+ align-items: center;
550
+ max-width: 28rem;
551
+ min-height: 44px;
552
+ padding: 0.625rem 1.25rem;
553
+ border-radius: 22px;
554
+ font-size: 0.875rem;
555
+ line-height: 1.25rem;
556
+ font-weight: 500;
557
+ pointer-events: auto;
558
+ animation: lg-pop var(--lg-duration) var(--lg-ease-spring) both;
559
+ transform-origin: top center;
560
+ }
561
+
562
+ .glass-toasts-bottom .glass-toast {
563
+ transform-origin: bottom center;
564
+ }
565
+
566
+ /* Danger: the solid danger fill. */
567
+ .glass-toast-danger {
568
+ --lg-fill: var(--lg-danger-fill);
569
+ --lg-rim: rgba(255, 255, 255, 0.28);
570
+ --lg-rim-low: rgba(255, 255, 255, 0);
571
+ --lg-edge: transparent;
572
+ --lg-surface-sheen: none;
573
+ color: #fff;
574
+ }
575
+
576
+ .glass-toast-message {
577
+ flex: 1 1 auto;
578
+ min-width: 0;
579
+ overflow-wrap: break-word;
580
+ }
581
+
582
+ /* 44px target, pulled into the padding so the toast stays 44px tall. */
583
+ .glass-toast-dismiss {
584
+ display: flex;
585
+ flex-shrink: 0;
586
+ align-items: center;
587
+ justify-content: center;
588
+ width: 44px;
589
+ height: 44px;
590
+ margin-top: -0.625rem;
591
+ margin-bottom: -0.625rem;
592
+ margin-inline-start: 0.25rem;
593
+ margin-inline-end: -1rem;
594
+ padding: 0;
595
+ border: 0;
596
+ border-radius: 9999px;
597
+ color: inherit;
598
+ background-color: transparent;
599
+ cursor: pointer;
600
+ transition: background-color var(--lg-duration-fast) ease;
601
+ }
602
+
603
+ .glass-toast-dismiss:hover {
604
+ background-color: rgba(127, 127, 127, 0.18);
605
+ }
606
+
607
+ .glass-toast-dismiss:focus-visible {
608
+ outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
609
+ outline-offset: -2px;
610
+ }
611
+
612
+ .glass-toast-danger .glass-toast-dismiss:focus-visible {
613
+ outline-color: currentColor;
614
+ }
615
+
616
+ /* Tabs (<GlassTabList />): a pill track that scrolls sideways, without a scrollbar, when
617
+ the tabs do not fit. The selected tab is a raised pill. Focus rings sit inside the tabs,
618
+ where the scrolling track cannot clip them. */
619
+ .glass-tabs {
620
+ --lg-surface-blur: var(--lg-blur-thin);
621
+ --lg-shadow: var(--lg-shadow-sm);
622
+ display: flex;
623
+ width: max-content;
624
+ max-width: 100%;
625
+ padding: 0.25rem;
626
+ border-radius: 9999px;
627
+ overflow-x: auto;
628
+ overscroll-behavior-x: contain;
629
+ scrollbar-width: none;
630
+ }
631
+
632
+ .glass-tabs::-webkit-scrollbar {
633
+ display: none;
634
+ }
635
+
636
+ .glass-tabs[aria-orientation='vertical'] {
637
+ flex-direction: column;
638
+ border-radius: var(--lg-radius-lg);
639
+ }
640
+
641
+ .glass-tab {
642
+ display: inline-flex;
643
+ flex-shrink: 0;
644
+ align-items: center;
645
+ justify-content: center;
646
+ gap: 0.375rem;
647
+ min-height: 44px;
648
+ padding: 0.5rem 1rem;
649
+ border: 0;
650
+ border-radius: 9999px;
651
+ font-family: inherit;
652
+ font-size: 0.875rem;
653
+ line-height: 1.25rem;
654
+ font-weight: 500;
655
+ white-space: nowrap;
656
+ color: inherit;
657
+ background-color: transparent;
658
+ cursor: pointer;
659
+ transition:
660
+ background-color var(--lg-duration-fast) ease,
661
+ box-shadow var(--lg-duration-fast) ease;
662
+ }
663
+
664
+ /* Concentric with the track's corners. */
665
+ .glass-tabs[aria-orientation='vertical'] .glass-tab {
666
+ justify-content: flex-start;
667
+ border-radius: calc(var(--lg-radius-lg) - 0.25rem);
668
+ }
669
+
670
+ .glass-tab:not(:disabled):hover {
671
+ background-color: rgb(var(--lg-c-line) / 0.06);
672
+ }
673
+
674
+ /* Selected: raised, outlined and bolder, not only a different colour. */
675
+ .glass-tab[aria-selected='true'] {
676
+ font-weight: 600;
677
+ color: rgb(var(--lg-c-ink));
678
+ background-color: rgb(var(--lg-c-raised));
679
+ box-shadow:
680
+ inset 0 0 0 1px rgb(var(--lg-c-line) / 0.08),
681
+ 0 1px 3px rgb(0 0 0 / 0.12);
682
+ }
683
+
684
+ .glass-tab:focus-visible {
685
+ outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
686
+ outline-offset: -2px;
687
+ }
688
+
689
+ .glass-tab:disabled {
690
+ cursor: not-allowed;
691
+ opacity: 0.4;
692
+ }
693
+
694
+ .glass-tab-panel:focus-visible {
695
+ outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
696
+ outline-offset: 2px;
697
+ }
698
+
699
+ /* Stays hidden even if a class of yours sets `display` on the panel. */
700
+ .glass-tab-panel[hidden] {
701
+ display: none;
702
+ }
703
+
704
+ /* ── Tones ──────────────────────────────────────────────────────────── */
705
+ .glass-dark {
706
+ --lg-fill: var(--lg-dark-fill);
707
+ --lg-fill-hover: var(--lg-dark-fill-hover);
708
+ --lg-rim: var(--lg-dark-rim);
709
+ --lg-rim-low: var(--lg-dark-rim-low);
710
+ --lg-edge: var(--lg-dark-edge);
711
+ --lg-shadow: var(--lg-shadow-dark);
712
+ --lg-surface-sheen: var(--lg-sheen-dark);
713
+ color: var(--lg-dark-text);
714
+ }
715
+
716
+ .glass-dark .glass-menu-item:hover,
717
+ .glass-dark .glass-menu-item:focus-visible {
718
+ background-color: rgba(255, 255, 255, 0.1);
719
+ }
720
+
721
+ .glass-dark .glass-menu-separator {
722
+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
723
+ }
724
+
725
+ .glass-clear {
726
+ --lg-fill: var(--lg-clear-fill);
727
+ --lg-fill-hover: var(--lg-clear-fill-hover);
728
+ --lg-rim: rgba(255, 255, 255, 0.6);
729
+ --lg-rim-low: rgba(255, 255, 255, 0.12);
730
+ --lg-edge: rgba(255, 255, 255, 0.08);
731
+ --lg-shadow: var(--lg-shadow-sm);
732
+ color: #fff;
733
+ }
734
+
735
+ /* Solid tones for primary actions. */
736
+ .glass-tinted,
737
+ .glass-tinted-secondary,
738
+ .glass-danger {
739
+ --lg-rim: rgba(255, 255, 255, 0.28);
740
+ --lg-rim-low: rgba(255, 255, 255, 0);
741
+ --lg-edge: transparent;
742
+ --lg-shadow: 0 0 #0000;
743
+ --lg-surface-sheen: none;
744
+ color: #fff;
745
+ }
746
+
747
+ .glass-tinted {
748
+ --lg-fill: var(--lg-accent, var(--color-primary, #0a84ff));
749
+ --lg-fill-hover: var(--lg-accent-strong, var(--color-primary-dark, #0060df));
750
+ }
751
+
752
+ .glass-tinted-secondary {
753
+ --lg-fill: var(--lg-accent-2, var(--color-secondary, #5e5ce6));
754
+ --lg-fill-hover: var(--lg-accent-2-strong, var(--color-secondary-dark, #4b49c9));
755
+ }
756
+
757
+ .glass-danger {
758
+ --lg-fill: var(--lg-danger-fill);
759
+ --lg-fill-hover: var(--lg-danger-fill-strong);
760
+ }
761
+
762
+ /* ── Thickness ──────────────────────────────────────────────────────── */
763
+ .glass-thin {
764
+ --lg-surface-blur: var(--lg-blur-thin);
765
+ --lg-shadow: var(--lg-shadow-sm);
766
+ }
767
+
768
+ .glass-thick {
769
+ --lg-surface-blur: var(--lg-blur-thick);
770
+ --lg-shadow: var(--lg-shadow-lg);
771
+ }
772
+
773
+ .glass-flat {
774
+ --lg-shadow: 0 0 #0000;
775
+ }
776
+
777
+ /* ── Shape ──────────────────────────────────────────────────────────── */
778
+ .glass-sm {
779
+ border-radius: var(--lg-radius-sm);
780
+ }
781
+
782
+ .glass-lg {
783
+ border-radius: var(--lg-radius-lg);
784
+ }
785
+
786
+ .glass-xl {
787
+ border-radius: var(--lg-radius-xl);
788
+ }
789
+
790
+ .glass-pill {
791
+ border-radius: 9999px;
792
+ }
793
+
794
+ /* Denser fills for floating overlays in dark mode. */
795
+ .glass-menu.glass-dark {
796
+ --lg-fill: rgba(20, 20, 24, 0.9);
797
+ }
798
+
799
+ .glass-sheet.glass-dark {
800
+ --lg-fill: rgba(20, 20, 24, 0.8);
801
+ }
802
+
803
+ /* ── Backgrounds ────────────────────────────────────────────────────── */
804
+ /* Page backgrounds behind glass: flat and neutral. */
805
+ .glass-canvas {
806
+ background-color: rgb(var(--lg-c-canvas));
807
+ }
808
+
809
+ /* Chromium-only refraction: <GlassFilter /> sets data-lg-refract on <html> when the
810
+ browser supports SVG filters inside backdrop-filter. Elsewhere this is a no-op. */
811
+ [data-lg-refract] .glass-refract {
812
+ -webkit-backdrop-filter: url(#lg-refract) blur(var(--lg-surface-blur))
813
+ saturate(var(--lg-saturate));
814
+ backdrop-filter: url(#lg-refract) blur(var(--lg-surface-blur)) saturate(var(--lg-saturate));
815
+ }
816
+
817
+ /* ── Dialog sheet (<GlassSheet />, or a <dialog class="glass-dialog">) ──── */
818
+ /* Centred card from 640px up; a bottom sheet on phones. The header and grabber drag the
819
+ sheet; the body scrolls. */
820
+ dialog.glass-dialog {
821
+ width: 100%;
822
+ max-width: var(--lg-sheet-max-width);
823
+ max-height: 80dvh;
824
+ margin: auto;
825
+ padding: 0;
826
+ border: 0;
827
+ overflow: hidden;
828
+ border-radius: var(--lg-radius-xl);
829
+ color: rgb(var(--lg-c-ink));
830
+ background-color: var(--lg-sheet-fill, rgb(var(--lg-c-paper)));
831
+ box-shadow:
832
+ inset 0 0 0 1px rgb(var(--lg-c-line) / 0.1),
833
+ var(--lg-shadow-lg);
834
+ overscroll-behavior: contain;
835
+ }
836
+
837
+ dialog.glass-dialog[open] {
838
+ display: flex;
839
+ flex-direction: column;
840
+ }
841
+
842
+ dialog.glass-dialog:focus {
843
+ outline: none;
844
+ }
845
+
846
+ dialog.glass-dialog::backdrop {
847
+ background-color: var(--lg-scrim);
848
+ overflow: hidden;
849
+ overscroll-behavior: contain;
850
+ /* Both ways: out on a swipe-close, back in if the sheet comes back. No effect on open,
851
+ where the backdrop is new and has nothing to transition from. */
852
+ transition: background-color var(--lg-duration-fast) var(--lg-ease-out);
853
+ }
854
+
855
+ /* Set by the swipe hook from release until the sheet has closed. iOS Safari can leave a
856
+ closed dialog's backdrop painted, so it must already be clear when the close happens. */
857
+ dialog.glass-dialog[data-closing]::backdrop {
858
+ background-color: transparent;
859
+ }
860
+
861
+ .glass-dialog-grabber {
862
+ display: none;
863
+ }
864
+
865
+ .glass-dialog-header {
866
+ display: flex;
867
+ flex-shrink: 0;
868
+ align-items: flex-start;
869
+ gap: 0.75rem;
870
+ padding: 1rem 1.5rem;
871
+ border-bottom: 1px solid rgb(var(--lg-c-line) / 0.08);
872
+ }
873
+
874
+ .glass-dialog-heading {
875
+ min-width: 0;
876
+ flex: 1 1 auto;
877
+ }
878
+
879
+ .glass-dialog-eyebrow {
880
+ margin: 0;
881
+ font-size: 13px;
882
+ line-height: 1rem;
883
+ color: rgb(var(--lg-c-ink-2));
884
+ }
885
+
886
+ .glass-dialog-title {
887
+ margin: 0.25rem 0 0;
888
+ font-size: 1.25rem;
889
+ line-height: 1.75rem;
890
+ font-weight: 600;
891
+ color: rgb(var(--lg-c-ink));
892
+ }
893
+
894
+ .glass-dialog-close {
895
+ display: flex;
896
+ flex-shrink: 0;
897
+ align-items: center;
898
+ justify-content: center;
899
+ width: 44px;
900
+ height: 44px;
901
+ padding: 0;
902
+ border: 0;
903
+ border-radius: 9999px;
904
+ color: rgb(var(--lg-c-ink-2));
905
+ background-color: rgb(var(--lg-c-line) / 0.05);
906
+ cursor: pointer;
907
+ transition: background-color var(--lg-duration-fast) ease;
908
+ }
909
+
910
+ .glass-dialog-close:hover {
911
+ background-color: rgb(var(--lg-c-line) / 0.1);
912
+ }
913
+
914
+ .glass-dialog-close:focus-visible {
915
+ outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
916
+ outline-offset: 2px;
917
+ }
918
+
919
+ /* flex-auto, not flex-1: Safari resolves a 0% basis to zero in this auto-height column
920
+ dialog and collapses the body (WebKit bug 281973). */
921
+ .glass-dialog-body {
922
+ min-height: 0;
923
+ flex: 1 1 auto;
924
+ overflow-y: auto;
925
+ overscroll-behavior: contain;
926
+ padding: 1.25rem 1.5rem;
927
+ }
928
+
929
+ .glass-dialog-footer {
930
+ flex-shrink: 0;
931
+ padding: 1rem 1.5rem;
932
+ border-top: 1px solid rgb(var(--lg-c-line) / 0.08);
933
+ }
934
+
935
+ @media (max-width: 639.98px) {
936
+ dialog.glass-dialog[open] {
937
+ max-width: none;
938
+ max-height: var(--lg-sheet-max-height);
939
+ margin: auto 0 0;
940
+ border-radius: var(--lg-radius-sheet) var(--lg-radius-sheet) 0 0;
941
+ /* Slides up on open. A keyframe animation, not a transition from @starting-style:
942
+ iOS Safari could leave that transition stuck part way. */
943
+ animation: lg-dialog-up 0.28s var(--lg-ease-out);
944
+ }
945
+
946
+ /* The grabber: a visible hint that the sheet can be pulled down. */
947
+ .glass-dialog-grabber {
948
+ display: block;
949
+ flex-shrink: 0;
950
+ padding: 6px 0 0;
951
+ touch-action: none;
952
+ }
953
+
954
+ .glass-dialog-grabber::after {
955
+ content: '';
956
+ display: block;
957
+ width: 36px;
958
+ height: 5px;
959
+ margin: 0 auto;
960
+ border-radius: 9999px;
961
+ background-color: rgb(var(--lg-c-line) / 0.2);
962
+ }
963
+
964
+ .glass-dialog-header {
965
+ padding-top: 0.5rem;
966
+ }
967
+
968
+ /* Like a native sheet: no ✕ on phones. A pull down or a tap outside closes it. The
969
+ button stays for screen readers, and shows when the keyboard focuses it. */
970
+ .glass-dialog-close:not(:focus-visible) {
971
+ position: absolute;
972
+ width: 1px;
973
+ height: 1px;
974
+ margin: -1px;
975
+ padding: 0;
976
+ overflow: hidden;
977
+ clip-path: inset(50%);
978
+ white-space: nowrap;
979
+ }
980
+
981
+ /* Clear the home indicator under the last line. */
982
+ .glass-dialog-body:last-child,
983
+ .glass-dialog-footer {
984
+ padding-bottom: max(env(safe-area-inset-bottom), 20px);
985
+ }
986
+ }
987
+
988
+ /* While a finger drags the sheet, it follows exactly (no easing). The hook switches the
989
+ open animation off inline, and keeps it off until the sheet closes. */
990
+ dialog.glass-dialog[data-dragging] {
991
+ transition: none;
992
+ user-select: none;
993
+ }
994
+
995
+ /* ── Confirm (<GlassConfirm />, or a <dialog class="glass-confirm">) ─── */
996
+ /* A centred box on every width: a question has to be answered, so it is never a sheet to
997
+ swipe away. The vh line is for engines without dvh (before Safari 15.4). */
998
+ dialog.glass-confirm {
999
+ width: 100%;
1000
+ max-width: min(28rem, calc(100% - 2rem));
1001
+ max-height: calc(100vh - 2rem);
1002
+ max-height: calc(100dvh - 2rem);
1003
+ margin: auto;
1004
+ padding: 1.5rem;
1005
+ border: 0;
1006
+ overflow-y: auto;
1007
+ overscroll-behavior: contain;
1008
+ border-radius: var(--lg-radius-xl);
1009
+ color: rgb(var(--lg-c-ink));
1010
+ background-color: var(--lg-sheet-fill, rgb(var(--lg-c-paper)));
1011
+ box-shadow:
1012
+ inset 0 0 0 1px rgb(var(--lg-c-line) / 0.1),
1013
+ var(--lg-shadow-lg);
1014
+ }
1015
+
1016
+ dialog.glass-confirm[open] {
1017
+ animation: lg-sheet-in var(--lg-duration) var(--lg-ease-spring) both;
1018
+ }
1019
+
1020
+ dialog.glass-confirm:focus {
1021
+ outline: none;
1022
+ }
1023
+
1024
+ /* With a fallback: before Chrome 122, ::backdrop inherits no custom properties. */
1025
+ dialog.glass-confirm::backdrop {
1026
+ background-color: var(--lg-scrim, rgba(0, 0, 0, 0.4));
1027
+ }
1028
+
1029
+ .glass-confirm-title {
1030
+ margin: 0;
1031
+ font-size: 1.125rem;
1032
+ line-height: 1.5rem;
1033
+ font-weight: 600;
1034
+ color: rgb(var(--lg-c-ink));
1035
+ }
1036
+
1037
+ .glass-confirm-message {
1038
+ margin-top: 0.5rem;
1039
+ font-size: 0.9375rem;
1040
+ line-height: 1.375rem;
1041
+ color: rgb(var(--lg-c-ink-2));
1042
+ }
1043
+
1044
+ .glass-confirm-details {
1045
+ margin-top: 1rem;
1046
+ }
1047
+
1048
+ /* Side by side when they fit, one above the other when they do not. */
1049
+ .glass-confirm-actions {
1050
+ display: flex;
1051
+ flex-wrap: wrap;
1052
+ gap: 0.75rem;
1053
+ margin-top: 1.5rem;
1054
+ }
1055
+
1056
+ .glass-confirm-actions > * {
1057
+ flex: 1 1 8rem;
1058
+ }
1059
+
1060
+ /* ── Keyframes ──────────────────────────────────────────────────────── */
1061
+ /* Pop-ins animate transform only: an element with opacity < 1 can't sample its
1062
+ backdrop in Chromium, so fading would show unblurred content until it settles. */
1063
+ @keyframes lg-pop {
1064
+ from {
1065
+ transform: scale(0.92) translateY(-6px);
1066
+ }
1067
+ to {
1068
+ transform: scale(1) translateY(0);
1069
+ }
1070
+ }
1071
+
1072
+ @keyframes lg-sheet-in {
1073
+ from {
1074
+ transform: scale(0.94) translateY(12px);
1075
+ }
1076
+ to {
1077
+ transform: scale(1) translateY(0);
1078
+ }
1079
+ }
1080
+
1081
+ @keyframes lg-dialog-up {
1082
+ from {
1083
+ transform: translateY(100%);
1084
+ }
1085
+ }
1086
+
1087
+ @keyframes lg-scrim-in {
1088
+ from {
1089
+ background-color: transparent;
1090
+ }
1091
+ }
1092
+
1093
+ /* ── Reduced motion (last, so it wins over everything above) ────────── */
1094
+ @media (prefers-reduced-motion: reduce) {
1095
+ .glass-btn,
1096
+ .glass-interactive,
1097
+ .glass-lift,
1098
+ .glass-menu,
1099
+ .glass-menu-item,
1100
+ .glass-sheet,
1101
+ .glass-scrim,
1102
+ .glass-toast,
1103
+ .glass-toast-dismiss,
1104
+ .glass-tab,
1105
+ dialog.glass-dialog[open],
1106
+ dialog.glass-dialog::backdrop,
1107
+ dialog.glass-confirm[open] {
1108
+ animation: none;
1109
+ transition: none;
1110
+ }
1111
+
1112
+ :is(.glass-interactive, .glass-btn):active,
1113
+ .glass-menu-item:active,
1114
+ .glass-lift:hover {
1115
+ transform: none;
1116
+ }
1117
+ }