# Glassmorphism Design Language System (DLS) v1.0

Condensed specification for web (CSS / Tailwind) and Figma tokens.

## 1. Philosophy

Every surface is a sheet of frosted glass floating above a luminous environment. Hierarchy comes from blur, brightness, rim light and shadow, not from opaque color.

| Tier | Role | Blur | Fill (dark) | Z-index |
|---|---|---|---|---|
| G0 Canvas | Background, spheres | none | n/a | 0 |
| G1 Surface | Nav, sidebars | 12px | 8–12% white | 10 |
| G2 Raised | Cards, popovers | 20px | 12–16% white | 20–40 |
| G3 Overlay | Modals, sheets | 32px | 18–24% white | 50–60 |
| G4 Float | Tooltips, toasts, badges | 8–16px | 20–28% white | 70–90 |

**Light vs dark:** dark mode uses white glass at 8–24%. Light mode needs roughly 3x the fill (40–74% white), softer saturation (140–160%), indigo-tinted shadows, and dark text.

## 2. Backgrounds, Lighting & Color Tokens

Every screen needs a base color, a gradient mesh (2–3 radial gradients plus one linear), and 2–4 blurred ambient spheres partly hidden behind content.

```css
:root { --canvas-base: #0B0B1A; }
[data-theme="light"] { --canvas-base: #EEF1FB; }
.glass-canvas {
  background-color: var(--canvas-base);
  background-image:
    radial-gradient(60% 50% at 15% 10%, hsla(262 90% 60% / .45), transparent 70%),
    radial-gradient(50% 45% at 85% 20%, hsla(190 95% 55% / .35), transparent 70%),
    radial-gradient(55% 50% at 60% 95%, hsla(330 90% 60% / .35), transparent 70%);
}
.sphere { position: absolute; border-radius: 9999px; filter: blur(60px); opacity: .55; pointer-events: none; }
```

| Token | Dark | Light |
|---|---|---|
| `--glass-fill-subtle` | `hsla(0 0% 100% / .06)` | `hsla(0 0% 100% / .40)` |
| `--glass-fill-default` | `hsla(0 0% 100% / .10)` | `hsla(0 0% 100% / .52)` |
| `--glass-fill-strong` | `hsla(0 0% 100% / .16)` | `hsla(0 0% 100% / .64)` |
| `--glass-fill-overlay` | `hsla(0 0% 100% / .22)` | `hsla(0 0% 100% / .74)` |
| `--glass-scrim` | `hsla(240 40% 6% / .35)` | `hsla(230 40% 20% / .08)` |
| `--text-primary` | `hsl(0 0% 100% / .94)` | `hsl(230 35% 12% / .94)` |
| `--text-secondary` | `hsl(0 0% 100% / .72)` | `hsl(230 25% 20% / .74)` |

Accents: violet `#7C4DFF`, cyan `#12C8F0`, pink `#F0489A`, success `#22C583`, warning `#F8A21B`, danger `#F04545`. Glow (`0 0 24px accent / .5`) marks hover, focus and active states only.

## 3. The Glass Effect Math

| Tier | blur | saturate | Use |
|---|---|---|---|
| Clear | 8–10px | 150% | Tooltips, chips |
| Standard | 12–16px | 170% | Cards, nav |
| Frosted | 20–24px | 180% | Popovers, sidebars |
| Ultra-frost | 32–40px | 190% | Modals, text-heavy panels |

Raise blur before raising opacity when legibility drops.

```css
.glass {
  position: relative; isolation: isolate;
  background: var(--glass-fill-default);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
          backdrop-filter: blur(16px) saturate(170%);
  border-radius: 20px;
  box-shadow:
    inset 0 1px 0 hsla(0 0% 100% / .35),
    0 8px 32px -4px hsla(262 70% 8% / .45),
    0 2px 6px hsla(262 70% 8% / .25);
}
/* Gradient rim light: brightest at top-left */
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(135deg, hsla(0 0% 100% / .55), hsla(0 0% 100% / .12) 35%, hsla(0 0% 100% / .04) 65%, hsla(0 0% 100% / .12));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
```

Shadows are colored and soft (sampled from the palette), never pure black.

Tailwind: `relative isolate rounded-[20px] border border-white/20 bg-white/10 backdrop-blur-[16px] backdrop-saturate-[1.7] shadow-[0_8px_32px_-4px_hsla(262,70%,8%,.45)]`

## 4. Typography & Visibility

Inter (UI), Plus Jakarta Sans (headings), JetBrains Mono (code), with SF Pro / system-ui fallbacks. Body weight is 500, never below 400, never under 12px.

| Token | Size / line | Weight |
|---|---|---|
| display | 48 / 52 | 700 |
| h1 | 36 / 42 | 700 |
| h2 | 28 / 34 | 650 |
| h3 | 22 / 28 | 600 |
| body | 16 / 24 | 500 |
| caption | 12 / 16 | 600 |

Contrast techniques, in order: more blur, scrim tint, +100 weight, soft text-shadow (`0 1px 2px hsla(240 40% 4% / .35)`), keep text away from rim and glow.

## 5. Interactive Components

| Component | Spec |
|---|---|
| Button | Idle: default fill + gradient rim. Hover: stronger fill, accent glow, lift 1px. Press: fill drops to 5%, inner shadow `inset 0 2px 8px`, scale .98. Min height 44px |
| Card | G2, radius 24px, padding 24px. Hover lifts 4px with G3 shadow |
| Modal | Scrim blur 8px (z 50), panel blur 36px (z 60), radius 28px; bottom sheet under 640px |
| Input | Recessed: dark inset fill, inner top shadow, 48px high. Focus: cyan border + 3px halo |
| Tooltip | Darker tint (`hsla(240 40% 8% / .55)`), blur 12px, z 80 |
| Badge | Accent tint at 30%, 1px lighter accent border, blur 8px, pill radius |

Never nest backdrop-filter inside another glass element; use a plain translucent fill instead.

## 6. Accessibility & Fallbacks

```css
.glass { background: hsla(250 30% 16% / .92); } /* opaque default */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .glass { background: var(--glass-fill-default); }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .glass { -webkit-backdrop-filter: none; backdrop-filter: none; background: hsl(250 30% 16%); }
}
@media (prefers-reduced-motion: reduce) { .sphere { animation: none; } }
```

| WCAG 2.1 | Requirement | Glass guidance |
|---|---|---|
| 1.4.3 | 4.5:1 text, 3:1 large | Measure against the worst-case backdrop pixel |
| 1.4.11 | 3:1 for component edges and focus | Rim light alone usually fails; add border or ring |
| 1.4.1 | Not color alone | Pair glow with icon or text |
| 2.4.7 | Visible focus | 2px cyan ring with offset |
| 2.2.2 | Pause moving content | Stop sphere drift for reduced motion |

Performance: about 3–4 blurred layers per mobile viewport, animate only transform and opacity, no backdrop-filter on list rows, and provide a manual "Reduce transparency" toggle.

## Figma tokens

Blur: 10 / 16 / 24 / 36. Fills: white at 6 / 10 / 16 / 22%. Rim: 1px inside gradient stroke at 135deg (55% to 4% white). Specular: inner shadow Y1, white 35%. Save as Effect styles `Glass/G1–G3` and Variables with Light and Dark modes.
