# Utilities

> Value-driven CSS utilities, bracketed raw values, shorthand syntax, dark mode, opacity mixes, and runtime states.

0build utilities pair one generic class per property with a CSS custom property so the stylesheet stays compact without a build step. Scaled utilities (such as `.m` and `.p`) multiply by `var(--spacing)`; bracketed utilities (such as `.[m]` and `.[p]`) accept raw CSS values.

| Class token | CSS variable | Behavior |
| --- | --- | --- |
| `m` | `--m` | Scaled by `var(--spacing)` |
| `[m]` | `--m` | Raw CSS value (no spacing scale) |
| `sm:m` | `--sm-m` | Wrapped in `@media (min-width: 40rem)` |
| `dark:bg` | `--dark-bg` | Scoped under `.dark` ancestor |
| `bg/o` | `--bg`, `--bg-o` | `color-mix` with opacity percentage |
| `dark:sm:bg:hover` | `--dark-sm-bg-hover` | Generated on demand by `zRuntime` |

Token order is fixed: optional `dark:` first, then breakpoint prefix (`sm:`, `md:`, `lg:`, `xl:`, `2xl:`), then the base class, then state (`:hover`, `:focus-visible`, etc.) and pseudo-element (`::before`, `::after`).

```html
<!-- Standard paired class + CSS variable -->
<div class="m sm:m md:m" style="--m: 4; --sm-m: 8; --md-m: 16"></div>

<!-- Raw value escape hatch -->
<div class="[m]" style="--m: 4px"></div>

<!-- Shorthand (=) syntax with scale auto-redirect, color, and /o opacity -->
<div class="p=4 m=4px bg=pink-500 bg/o=var(--color-blue-800)/80 dark:bg/o=var(--color-green-800)/80"></div>
```

Any token containing `=` is expanded by the `inline-vars` runtime plugin into its class and inline variable: color tokens such as `bg=pink-500` resolve to `var(--color-pink-500)`, `/o` splits `color/opacity`, and non-numeric values on scaled keys (like `m=4px`) automatically redirect to `.[m]`. One-off CSS properties not in the built-in utility set can use `[property]={value}`.

```html
<!-- Interactive states & pseudo-elements -->
<button
  class="bg=blue-600 bg:hover=blue-800 dark:bg=pink-600 dark:bg:hover=pink-700 px=5 py=2.5"
>
  Action
</button>

<div
  class="content-before bg::before color::before"
  style="--content-before: '0build'; --bg-before: var(--color-blue-600); --color-before: var(--color-white)"
></div>

<!-- Arbitrary CSS property ([property]={value}) -->
<div class="[writing-mode]={vertical-lr} md:[writing-mode]={horizontal-tb}"></div>
```

> **Note:** Pseudo-elements require a paired `content-before` or `content-after` class so the browser generates the pseudo-box. Include `z-not-ready` on `<html>` when using pseudo-elements or `=` shorthands to avoid layout shift before `zRuntime` injects styles.
