# Drag / resize handles

A **handle** is the grab affordance for moving or resizing an object — a
splitter grip, a resize edge, a reorder handle. `handleStyles`
(`src/styles/handle.js`) is the one shared look, so every draggable component
reads the same and themes through the same variables.

Before this module the library had six unrelated handle idioms (two of them
near-duplicate 3-dot implementations, two hard-coded Unicode glyphs). Don't add a
seventh.

---

## Usage

```ts
import { themeFallbacks } from '../styles/fallbacks.js';
import { handleStyles } from '../styles/handle.js';

class MyComponent extends LitElement {
  static styles = [themeFallbacks, handleStyles, css`
    .hit-zone { /* your resize / drag target */ }
  `];

  render() {
    return html`
      <div class="hit-zone" @pointerdown=${this.#onDown}>
        <span class="ixfx-handle" data-handle="flat" data-shape="horizontal" part="handle"></span>
      </div>`;
  }
}
```

Bind pointer handlers to the **hit-zone**, not the handle — the handle is
`pointer-events: none`.

---

## Two independent axes

| Attribute | Values | Meaning |
|---|---|---|
| `data-handle` | `flat` (default) · `dotted` · `dimpled` · `grated` | **texture** — how the mark looks |
| `data-shape`  | `horizontal` (default) · `vertical` · `spot` | **topology** — a wide bar, a tall bar, or a small centred point handle |

Any texture combines with any shape.

- **flat** — a solid rounded capsule (a bar) or dot (`spot`), filled with
  `--ixfx-handle-color`. The `ixfx-drawer` resize handle.
- **dotted** — marks in the [Lucide *grip*](https://lucide.dev/icons/grip)
  arrangement: **three in a row** (`horizontal`), **three in a column**
  (`vertical`), or a **3×3 block** (`spot`). Drawn as one `::before` mark plus
  `box-shadow` copies, so each mark's corner rounding is `--ixfx-handle-radius`
  (→ the theme `--radius-l`): **round** normally, **square** under a flat theme
  (`--radius-l: 0`, e.g. `theme-cyberpunk`). Tinted by `--ixfx-handle-color`. The
  `ixfx-data-grid` column reorder handle, `ixfx-timeline-track-tab` reorder
  handle, `ixfx-dock-host` junction handles.
- **dimpled** — that same layout, but each **bar** mark is pressed in: a lighter
  copy peeking out above-left and a darker copy below-right (`spot` stays plain —
  the 3D is imperceptible at that size). Splitter grips (`ixfx-split-layout`,
  `ixfx-twosplit-layout`).
- **grated** — fine 45° knurling: parallel ridges, each a **lit edge, the base
  colour, then a shaded edge**. `spot` is the same hatch cropped square.

`dotted`, `dimpled` and `grated` are texture only — no plate, box or border; the
gaps are transparent, so the surface behind shows through. The base is
`--ixfx-handle-color` (`currentColor`); `--ixfx-handle-highlight` /
`--ixfx-handle-shadow` default to that colour lightened / darkened, so `dimpled`
stays as prominent as `dotted` and re-tones with the theme.

---

## Active state

The handle goes to `--ixfx-handle-opacity-active` (and, for `flat` / `dotted`,
`--ixfx-handle-color-active`) when:

- its **immediate parent** (the hit-zone) is `:hover` or `:focus-visible`, or
- the hit-zone or the handle carries `[data-active]`.

While a drag is live the pointer may leave the hit-zone, so set `[data-active]`
on the hit-zone yourself for the duration and the handle stays lit.

To suppress the reveal entirely, set `--ixfx-handle-opacity-active` equal to
`--ixfx-handle-opacity`.

---

## CSS variables

Defaults resolve through `themeFallbacks`. Override on the handle element or any
ancestor (`:host`, the hit-zone, …).

| Variable | Default | Purpose |
|---|---|---|
| `--ixfx-handle-color` | `var(--surface-muted-text)` | `flat` / `dotted` fill |
| `--ixfx-handle-color-active` | `var(--accent)` | `flat` / `dotted` hover / focus / `[data-active]` |
| `--ixfx-handle-thickness` | `6px` | cross-axis size of a bar |
| `--ixfx-handle-length` | `44px` | long-axis size of a bar (`100%` fills) |
| `--ixfx-handle-spot-size` | `14px` | width = height of a `spot` |
| `--ixfx-handle-radius` | `var(--radius-l)` | `flat` capsule + `dotted` / `dimpled` mark rounding (0 ⇒ squares) |
| `--ixfx-handle-opacity` | `0.55` | rest opacity |
| `--ixfx-handle-opacity-active` | `1` | active opacity |
| `--ixfx-handle-dot-size` | `4px` | mark size (dotted / dimpled) |
| `--ixfx-handle-dot-gap` | `length / 6` (bar) · `spot / 3` | mark centre-to-centre step |
| `--ixfx-handle-tile` | `5px` | knurl period (grated) |
| `--ixfx-handle-highlight` | `color-mix(currentColor 35%, #fff)` | lit deboss edge (dimpled / grated) |
| `--ixfx-handle-shadow` | `color-mix(currentColor 60%, #000)` | shaded deboss edge (dimpled / grated) |

---

## Notes & limits

- **Host-as-handle** (`:host(.ixfx-handle)`) is not supported yet — always wrap
  the class on a child element inside the hit-zone.
- The handle exposes `part="handle"` (rename per component where a more specific
  part name already exists, e.g. `part="grip"` / `part="reorder-handle"`).
- No motion beyond the colour / opacity transition; nothing to gate for reduced
  motion (the module still drops the transition under
  `prefers-reduced-motion: reduce`).

See it live: `demo/handle.html` (4 textures × 3 shapes + variable knobs).
