---
name: responsive-grid-typography
description: Build resilient responsive web layouts from 390px mobile to 1440px+ desktop using intrinsic CSS Grid, min-w-0 flex/grid overflow guards, fluid clamp() headings, 60-68ch body measure limits, tabular-nums numeric alignment, and safe mobile table/code scrolling.
---
# Responsive Layout Grid & Fluid Editorial Typography Protocol
Whenever implementing page sections, pricing matrices, documentation layouts, or editorial cards in Astro, React, or Tailwind CSS v4, strictly apply these layout and typographic engineering standards:
## 1. Zero Mobile Horizontal Overflow (`390px` Guarantee)
The top #1 bug in AI-generated frontends is accidental horizontal scrolling on `375px–390px` viewports. Prevent it structurally:
- **Add `min-w-0` on flex and grid columns** that contain `<pre>`, `<code>`, URLs, or long titles (`min-width: auto` is CSS's default and lets children blow past grid tracks).
- **Wrap every `<table>` in a horizontal scroll container:** `<div class="w-full overflow-x-auto"><table class="w-full ...">` with `whitespace-nowrap` strictly on compact numeric cells—never on long narrative descriptions.
- **Never hardcode wide fixed pixel widths** (`w-[520px]`); use `w-full max-w-[520px]` or intrinsic grids (`grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))]`).
- **Keep `<pre>` code boxes self-scrolling:** Always apply `max-w-full overflow-x-auto` to code blocks so long shell commands scroll inside the box instead of pushing the page body wide.
## 2. Typographic Measure, Scale & Alignment Discipline
- **Reading measure (`ch`):** Cap body paragraphs and editorial prose at **`max-w-[64ch]` to `max-w-[68ch]`** (never let 16px sentences stretch 1,200 pixels across a widescreen monitor).
- **Fluid headings (`clamp()`):** Scale display headings smoothly across viewports (e.g., `clamp(1.85rem, 1.3rem + 2.2vw, 3.25rem)`) with tight optical tracking (`-0.025em` to `-0.03em`) and balanced wrapping (`text-wrap: balance`).
- **Tabular figures (`font-variant-numeric: tabular-nums`):** Always apply `tabular-nums` on pricing columns, unit rates (`$0.04`), index codes (`01`..`45`), timestamps, and comparison metrics so digits align vertically.
- **Mobile input zoom guard:** Keep `<input>`, `<select>`, and `<textarea>` font sizes at `>= 16px` (`text-base sm:text-sm`) on touch viewports so iOS Safari never auto-zooms awkwardly on focus.
## 3. Touch Target & Spacing Rhythm
- Maintain a consistent `4px / 8px` spatial scale (`gap-3`, `gap-4`, `gap-6`, `p-5 sm:p-6`); avoid odd magic gaps (`gap-[19px]`).
- Ensure buttons, filter chips, and nav links maintain a comfortable `>= 40–44px` hit height on mobile viewports.
## 4. Verification Assertion
After rendering any new section, verify at both `1440x900` and `390x844` (via Playwright MCP `Skill 26`):
`document.documentElement.scrollWidth <= window.innerWidth` MUST evaluate `true`.