# OKLCH Algorithmic Theme Engine
An algorithmic color design tool engineered to solve perceptual non-uniformity in digital interfaces. Built on the OKLCH color space, this library derives complete 10-step tonal scales, dark mode inversions, and high-contrast accessible tokens with zero manual tweaking.
## Why OKLCH?
Traditional HSL scales exhibit acute perceptual unevenness: pure yellow (hue 60°) produces significantly higher perceived luminance than pure blue (hue 240°), compromising accessible contrast calculations across design tokens. OKLCH aligns lightness and chroma with human ocular perception.
## Key Features
- **Perceptual Uniformity**: Constant lightness curves ensure WCAG 2.2 and APCA contrast targets are preserved across every generated hue.
- **Gamut Mapping**: Automatic fallback boundary clamping from P3 wide color into sRGB space without hue-shifting artifacts.
- **Design Token Export**: Generates copy-paste ready CSS variables for Tailwind CSS v4 and vanilla CSS token sheets.
- **Zero Runtime Dependencies**: Ultra-lightweight pure TypeScript math engine (<4KB minified).
## Quickstart
```typescript
import { generateTonalPalette, checkAPCAContrast } from "@/lib/palette";
const primary = generateTonalPalette({
hue: 250,
chroma: 0.18,
steps: 10,
});
console.log(primary[500].css); // "oklch(0.62 0.18 250)"
```