layout-cat 0.1.0

Box-model layout: cascade + block layout over a dom-cat tree using css-cat stylesheets. Produces a LayoutBox tree with positions and dimensions. No mut, no Rc/Arc, no interior mutability, no panics, exhaustive matches. Fourth sub-crate of a Servo-replacement webview runtime targeting Tauri.
# CLAUDE.md -- Rust Project Conventions

## Philosophy

Functional, type-driven, domain-driven.

## Architecture

- Modules by domain context.
- One module per concern (length, color, style, cascade, box_tree, block, layout).
- Thin lib.rs that wires them together and exposes `layout(doc, sheet)`.

## Types

- Newtypes for `Length`, `Px`.
- Sum types for `LengthValue` (Auto / Px / Em / Percent), `Display`, etc.
- No public struct fields.
- `#[must_use]` on getters.

## Error Handling

- Single project-wide `Error` enum.
- Display + std::error::Error impls by hand; no thiserror, no anyhow.
- Never panic.  Unresolvable lengths fall back to 0; unsupported display types fall back to block.

## Style

- Prefer match over if/else, except on bool.
- No `return` keyword.
- No `mut`.
- Combinators over loops.
- Never match on Option<_>; use combinators.
- No unwrap()/expect() anywhere.
- No loop or for.
- No scan.
- No Rc/Arc.
- No naked `as` casts.
- Exhaustive matches; no `_` wildcard arm on enums.

## Traits

- No dyn Trait.
- Implement standard traits over ad-hoc methods.

## Linting

```toml
[lints.clippy]
all = { level = "deny", priority = -1 }
pedantic = { level = "warn", priority = -1 }
needless_pass_by_value = "warn"
manual_map = "warn"
```

## Verification

- Always run `RUSTFLAGS="-D warnings" cargo clippy --all-targets`.
- Always run `cargo fmt`.

## Testing

- Tests return `Result<(), Error>` and propagate failures with `?`.
- No assert!, assert_eq!, panic!, unreachable!, unwrap, expect.

## Dependencies

- `dom-cat = "0.1"` -- DOM tree input.
- `css-cat = "0.1"` -- stylesheet input.
- `proptest` dev-dep; `html-cat` dev-dep for test setup.
- No path dependencies.

## Documentation

- `///` doc comments on every public item.
- `# Examples` with runnable code blocks.

## Layer context

This crate is the **layout engine**:

1. `html-cat`, `css-cat`, `dom-cat` -- input layers.
2. **`layout-cat`** -- computes box positions and dimensions.
3. `paint-cat` -- consumes the layout tree to produce a display list.
4. `net-cat`, `web-api-cat`, `tauri-runtime-servocat` -- glue layers.

## v0 scope

- Cascade: match css-cat rules against dom-cat elements via selector matching (delegating to dom-cat's matcher); resolve declarations to a `ComputedStyle` per element.
- Length resolution: px directly; em as font-size multiplier; % against containing-block width; auto = 0 or "fill" depending on context.
- Box model: margin / border / padding / content per element, computed from `ComputedStyle`.
- Block layout: vertical stacking, width from `width` or fill containing block, height as sum of children + own padding/border.
- Output: a `LayoutTree` of `LayoutBox` carrying `Rect`s and a back-reference to the originating dom-cat `NodeId`.

## Deferred to v0.2+

- Inline layout / line boxes / text shaping (anything with text is currently treated as a 0-height block).
- Flexbox / grid / floats / positioning (other than `static`).
- Real font metrics; v0 uses a fixed default font size (`16px`).
- Logical properties (`block-size`, `inline-size`).
- Tables.
- Transforms.