Proportional Layout Scaling — Research Results
Date: 2026-03-10/11 (overnight run) Spec: 2026-03-10-proportional-scaling-design.md Implementation: 2026-03-10-proportional-scaling-implementation.md
What We Changed
-
Body font:
font-size: 1.3remreplaced withclamp(0.85rem, 1.9vw, 1.3rem). Font scales proportionally from 13.6px floor to 20.8px ceiling. -
Grid minimums:
minmax(12rem, 0.33fr)/minmax(22rem, 1fr)converted tominmax(10em, 0.33fr)/minmax(28em, 1fr). Grid now scales with body font. -
Margin font ratio: Changed from 0.85rem (65% of body) to 0.8em (80% of body). Clear visual hierarchy at all sizes.
-
Unified breakpoints: The 768px/800px split replaced with a single 700px threshold in both CSS and JS. Fixes the footnote dead zone bug.
-
Removed 640px font override: The
@media (max-width: 640px) { body { font-size: 1.2rem } }rule conflicted with clamp() and was removed. -
Margin-box internals:
font-size: 0.9remon.margin-boxchanged to1em,.subscribe-formfrom0.85remto1em,.video-chapter-tocfrom0.8remto0.8em,.video-chapter-toc-headingfrom0.7remto0.875em. All now scale with margin font.
The Test Matrix
Viewport metrics (default CSS)
| Viewport | Body font | Center | Margin | Margin font | Ratio | Mode | Overflow |
|---|---|---|---|---|---|---|---|
| 320px | 13.6px | 320px | 0 | 10.9px | 0.800 | fallback | YES (405) |
| 480px | 13.6px | 480px | 0 | 10.9px | 0.800 | fallback | no |
| 640px | 13.6px | 585px | 0 | 10.9px | 0.800 | fallback | no |
| 700px | 13.6px | 585px | 0 | 10.9px | 0.800 | fallback | no |
| 768px | 14.6px | 409px | 146px | 11.7px | 0.800 | broadsheet | no |
| 800px | 15.2px | 428px | 152px | 12.2px | 0.800 | broadsheet | no |
| 850px | 16.1px | 456px | 162px | 12.9px | 0.800 | broadsheet | no |
| 1000px | 19.0px | 542px | 190px | 15.2px | 0.800 | broadsheet | no |
| 1200px | 20.8px | 606px | 208px | 16.6px | 0.800 | broadsheet | no |
| 1440px | 20.8px | 645px | 213px | 16.6px | 0.800 | broadsheet | no |
Invariant test results (default thresholds: 8 words center, 5 words margin, 0.80 ratio)
| Test | Result | Notes |
|---|---|---|
| No horizontal overflow | 1 fail | 320px only (pre-existing; 405px scroll width from body padding + masthead) |
| Mode consistency | PASS | All widths clean |
| Footnotes reachable | PASS | All widths clean (768/800 dead zone fixed) |
| Center column width | PASS | All broadsheet widths >= 8 words/line |
| Margin column width | PASS | All broadsheet widths >= 5 words/line |
| Body font floor | PASS | Never below 10px absolute minimum |
| Font hierarchy | PASS | 0.800 ratio at all broadsheet widths |
| rem->em regression | PASS | Column widths stable at 1280px |
Totals: 1 failed, 58 passed, 12 skipped (narrower-than-broadsheet tests correctly skipped).
With tighter thresholds (9 words center, 5 words margin, 0.80 ratio)
Same results: 1 fail (320px overflow), 58 pass. The proportional scaling keeps words-per-line constant so tighter thresholds don’t change the failure set.
Discovered Relationships
The font-size floor: 0.85rem (13.6px)
The clamp floor of 0.85rem is appropriate. The broadsheet layout starts at 768px where the body font is 14.6px. Below 768px the page is in fallback mode (single column) where the floor only affects overall text size, not column proportions.
At the floor, the three-column grid minimum is:
2 x 10em + 28em + 2 x 1.2em + 2 x 1em = 52.4em
52.4 x 13.6px = 713px
The JS threshold at 700px is slightly below this, meaning the grid always has
room when it appears. The gap between 700px and 768px (where broadsheet actually
starts in headless Chromium with pointer: fine) exists because the CSS breakpoint
at 700px matches the JS threshold of > 700.
The clamp ceiling: 1.3rem (20.8px)
At 1.9vw, the ceiling is reached at:
1.3rem / 1.9vw = 20.8px / 0.019 = 1095px
Above 1095px the font freezes at 20.8px and the grid expands via fr units until
it hits the max-width: 72rem (Codex). This is the intended behaviour.
The scaling coefficient: 1.9vw
Chosen so the ceiling is reached at ~1095px. At the broadsheet entry (768px), 1.9vw = 14.6px. This is a comfortable reading size on narrower screens.
The ratio: 0.800
The 80% margin-to-body ratio is achieved exactly at all viewport widths because
.margin { font-size: 0.8em } is relative to the body font. No drift, no
breakpoint-dependent adjustment needed.
Comparison with Feb 2026 Experiment
The February font enlargement experiment (reverted) attempted to increase the base font from 1.3rem to 1.43rem at all viewports. It broke because:
- Fixed pixel breakpoints didn’t move with the larger font
- Grid minimums in
remgrew with root font but viewport didn’t - Margin internals in
remdidn’t track the margin font-size change
The proportional scaling approach solves all three:
- No breakpoint dependency:
clamp()scales continuously; the single 700px threshold is derived from grid minimums, not hardcoded from observation - Grid in
em: minimums scale with body font, so the grid fits at any size - Margin internals in
em: one.margin { font-size }change scales everything
The key insight: the Feb experiment changed the magnitude of the font while keeping the mechanism the same (fixed values at fixed breakpoints). Proportional scaling changes the mechanism to eliminate the coupling entirely.
Post-Review Tuning (2026-03-13)
After eyeballing the overnight results in the browser, three adjustments were made:
1. Font size bump
The original clamp(0.85rem, 1.9vw, 1.3rem) was tuned against the first
paragraph (which renders at 1.5rem with small-caps), making regular body text
noticeably smaller than it was before proportional scaling. Adjusted to:
font-size: clamp(1rem, 2.1vw, 1.3rem);
- Floor: 0.85rem → 1rem (16px). Body text never drops below a comfortable size.
- Preferred: 1.9vw → 2.1vw. At 1000px this gives ~21px, matching the old 1.3rem.
- Ceiling: unchanged at 1.3rem (20.8px), reached at ~990px.
2. Fallback mode font restore
The clamp scaling is for broadsheet (three-column) mode. In fallback (single-column,
below 700px), the shrunk font served no purpose — there are no columns to fit. Added
body { font-size: 1.2rem } to both fallback media queries, restoring the previous
narrow-screen reading size.
3. Fallback mode polish
- Horizontal padding:
padding: 0→padding: 0 1.5emon.margins-layoutin both fallback modes. Text was flush against the viewport edge. - Footnote figures: Added
max-width: 33%to.footnote .figurein fallback. These images were designed for margin columns (~33% of layout width) but stretched to 100% of the center column when displayed as bottom-of-page footnotes.
4. Grid rebalance
The font bump made em-based grid minimums larger, causing the right margin to clip
at some widths. Rebalanced from 10em / 28em / 10em to 10em / 22em / 10em — the
center column has plenty of room from the 1fr expansion, and margins keep their
minimum readable width. All 55 invariant tests pass with these values.
Updated tuning parameters
:root {
--margin-font-ratio: 0.8;
--body-font-max: 1.3rem;
--body-font-preferred: 2.1vw;
--body-font-floor: 1rem;
}
body {
font-size: clamp(1rem, 2.1vw, 1.3rem);
}
.margins-layout {
grid-template-columns:
minmax(10em, 0.33fr)
minmax(22em, 1fr)
minmax(10em, 0.33fr);
}
Remaining Issues
-
320px overflow:
scrollWidth=405 > innerWidth=320. This is a pre-existing issue, likely frombody { padding: 50px }or masthead elements. Not a regression from this work, and 320px is below any three-column threshold. -
clamp() with var() doesn’t work: The initial implementation used
clamp(var(--body-font-floor), var(--body-font-preferred), var(--body-font-max))which Playwright’s Chromium (v131) silently ignored, falling back to inherited font-size. The literalclamp(0.85rem, 1.9vw, 1.3rem)works correctly. The CSS custom properties are kept for documentation but the body font-size uses literal values. -
Margin nudge test failure:
TestMarginNudge::test_grow_nudges_items_belowfails on both this branch and main. Pre-existing, unrelated to this work. -
Broadsheet entry point: The three-column layout enters at 768px (not 700px as the JS threshold suggests) because headless Chromium with
pointer: finetriggers the CSSmax-width: 700pxmedia query at widths <= 700px. The layout appears at 768px where the grid fits comfortably. On touch devices, the pocket (swipe) mode would handle narrower widths separately.
Recommended Tuning Parameters
These CSS custom properties document the scaling system. The body font-size
uses literal values for browser compatibility, but changes should update both:
:root {
--margin-font-ratio: 0.8;
--body-font-max: 1.3rem; /* Ceiling: current Broadsheet size */
--body-font-preferred: 2.1vw; /* Scaling coefficient */
--body-font-floor: 1rem; /* Minimum: tuned post-review */
}
body {
font-size: clamp(1rem, 2.1vw, 1.3rem);
}
.margin {
font-size: 0.8em; /* 80% of body */
}
.margins-layout {
grid-template-columns:
minmax(10em, 0.33fr)
minmax(22em, 1fr)
minmax(10em, 0.33fr);
gap: 1.2em;
}
To change the body font maximum (e.g., to 1.43rem as attempted in Feb):
1. Update --body-font-max and the literal clamp ceiling
2. The grid, margins, and margin internals scale automatically
3. Run pytest src/tests/test_layout_invariants.py -v to verify all invariants hold
4. If the broadsheet threshold moves, update the 700px breakpoints and JS CONFIG