# Laying out a page of LightPane panes

Read `llms/embedding.md` first: it covers the loader, the container and
the identifiers. This covers where to put the containers.

## Widths — these are measured, not preferences

A pane watches its OWN container and re-measures whenever that container
changes width. You never write resize handling.

| Width of the container | What happens |
|---|---|
| under 280px | Compound panes push content outside their own box. Do not do this. |
| 280px | Hard floor. Every kind of pane renders cleanly. |
| 360px | Comfortable minimum — three columns on an inventory pane. |
| 480-720px | The sweet spot. Four to six columns. |
| over ~1400px | Stable, but shows nothing more than it did at 720px. |

A service inventory pane collapses columns from the RIGHT as space runs
out; collapsed columns move into the row's expandable drawer, so nothing
is lost. The FIRST column never collapses. Six columns is the maximum at
any width.

Padding comes off the pane's budget. A 320px phone viewport with 24px
padding each side leaves 272px, which is under the floor.

## The default layout: a reflowing card grid

Use this unless there is a reason not to. No media queries, no JavaScript.

```css
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}
.dashboard > div { min-width: 0; }
```

```html
<div class="dashboard">
  <div data-lp-service="ec2" data-lp-account="" data-lp-region=""></div>
  <div data-lp-service="rds_instances" data-lp-account="" data-lp-region=""></div>
</div>
```

- `minmax(min(360px, 100%), 1fr)` is what makes it responsive. The browser
  picks the column count. Do not replace it with a fixed column count.
- **Keep the `min(360px, 100%)`.** A bare `minmax(360px, 1fr)` track will not
  shrink below 360px even when the viewport is narrower, so the page scrolls
  sideways on a phone. Measured: a bare 360px track produces a 376px-wide
  document at both a 320px and a 360px viewport.
- **Keep `min-width: 0` on the children.** A grid item defaults to
  `min-width: auto` and refuses to shrink below its own content, so one wide
  table pushes the track past its share.
- `align-items: start` matters: without it every card in a row stretches
  to the tallest, leaving empty space under the shorter panes.
- Do NOT set a height on a pane's container unless you also set
  `data-lp-fill="true"`. A pane is as tall as its content, and its content
  depends on how many resources the account has. A fixed height clips it.

To let one pane span more room:

```css
@media (min-width: 760px) { .dashboard > .wide { grid-column: span 2; } }
```

## Framing a pane: borders, corners and spacing

A pane is already a card. It draws its own 1px frame, 10px rounded
corners, a faint shadow and its own background. The commonest mistake is
to put it inside a second bordered, rounded box with nothing between the
two: the borders touch and read as one heavy line, and the pane's corners
sit inside the card's at a different curve. Pick ONE of these two.

**1. Unframed (simplest).** No card. Put any heading or explanation above
the pane, on the page background, and let the pane's own frame be the
only one.

**2. Inset (a card holding text AND a pane).** Give the card padding, and
make the corners concentric: the card's radius is the pane's radius PLUS
the padding. Equal radii with a gap between them look wrong — the outer
curve is tighter than the inner one.

```css
.card {
  --inset: 12px;          /* the gap between card edge and pane */
  --pane-r: 10px;         /* the pane's own (fixed) corner radius */
  padding: var(--inset);
  border-radius: calc(var(--pane-r) + var(--inset));
  border: 1px solid #c8d0c0;
  background: #ffffff;
}
@media (max-width: 480px) { .card { --inset: 6px; } }
```

The padding comes off the pane's width budget. Measured at a 320px
viewport with a 12px page gutter, a 1px card border and the 6px phone
inset, the pane is 282px wide — just above the 280px floor. Thicker than
that and it drops below it.

Rules whichever you pick:

- **Never let two borders touch.** Either there is no card (unframed), or
  there is a gap between the card and the pane (inset).
- **Keep page borders no heavier than the pane's 1px.** A 2px card
  border around a 1px pane makes the pane look recessed and the page
  look heavy.
- **Spacing between panes comes from the grid `gap`**, not from margins
  on the containers. Panes have no outer margin of their own.
- **Never change the pane's own frame, corners, shadow or colours** — not
  through `--lp-pane-*` properties, not by styling `.lp-pane`. Panes are
  not restyled (see `llms/theming.md`); frame them, do not alter them.

## Comparing two accounts, regions or clouds

The same pane twice, pointed at different accounts, in two tinted columns.

```css
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compare > .cell { padding: 12px; border-radius: 22px; } /* 10 + 12 */
.compare > .cell:nth-child(odd)  { background: #eef3f8; }
.compare > .cell:nth-child(even) { background: #f3f0e8; }
@media (max-width: 820px) { .compare { grid-template-columns: 1fr; } }
```

Cells must alternate in strict pairs or the tinting inverts. ALWAYS put a
visible text label ("Source" / "Target", "AWS" / "GCP") in every cell:
the colour is not available to every reader, and on a narrow screen the
columns stack and there are no columns left to tell apart.

## Height

A pane is as tall as its content. Two consequences:

- A NARROWER pane is TALLER (more wrapping).
- A very WIDE pane can also be taller — panes with charts scale them with
  the width.

To fit a pane to a space you control, give the container a real height and
set `data-lp-fill="true"` (fixed header, one scrolling body, fixed footer)
or `data-lp-fill="paged"` with `data-lp-page-size="25"`.

## Hidden and moved panes

- A pane inside a `display:none` parent renders, measures zero width, and
  lays out correctly when the parent is shown. Tabs need no special code.
- Moving a pane's element in the DOM works, including into a `<dialog>`.
  MOVE the element; do not create a second container, which would be a
  second pane, a second request and a second copy that can disagree.
- Containers added to the DOM after page load are not seen until you call
  `window.lpEmbedRun()`. It skips panes that already rendered.

## Rules

- Never style the inside of a pane. The internal markup belongs to the
  runtime and changes between releases. Style the container only.
- Never put a pane in a container narrower than 280px.
- Count the panes. Each one is a request; past about a dozen on a page,
  split across tabs or pages.
- Prefer two panes at 700px over one at 1400px on a wide screen.
