1 Commits
Author SHA1 Message Date
CatoandClaude Opus 5 398b472978 fix(nav): make the mobile section rail actually stick, and give the header one height (#104)
THE DEFECT, FOUND BY MEASURING RATHER THAN READING. `SectionNav` carries a
full mobile treatment — `sticky top-0 z-20`, a translucent background, a
backdrop blur, a bottom border — for a state that could never occur. Scrolled
to 2500px on `/de/method` at 375px wide, the rail sat at `top: -1489`: it had
scrolled away like any static block.

A sticky element can only travel inside its containing block, and
`SectionNavLayout` wrapped the rail in a grid-item div exactly as tall as the
rail itself. Zero room to travel, so `position: sticky` did nothing and every
style written for the stuck state was decoration. `display: contents` below
`lg` takes the wrapper out of layout, the nav becomes the grid item, and it
inherits the grid's full height.

And it had pinned to `top: 0`, which is where the 69px site header already is
with a higher z-index — so had it ever stuck, it would have stuck underneath
the header.

WHILE FIXING IT, THE ROW GOT HONEST ABOUT SIZE. Seven sections wrapped to four
rows: 153px, a fifth of an 800px phone screen, held permanently to show a table
of contents nobody asked to keep looking at. It is now one row that scrolls
sideways — 57px — which is what documentation sites converged on for the same
reason. Measured after: pinned at exactly 69px, links clickable, and the
document still 375px wide in a 375px viewport.

ONE HEADER HEIGHT, REPLACING FOUR GUESSES. The header had no height; 69px
emerged from `min-h-11` plus `py-3` plus a border. Headings meanwhile carried
`scroll-mt-20`, `scroll-mt-24` AND `scroll-mt-28` — 2, 15 and 7 of them — three
answers to "how far below the top does an anchor land", each clearing 69px by
luck. `--header-height` in globals.css is now the single value: the header is
given it, the rail pins below it, and one `scroll-mt-anchor` utility (which
also accounts for the rail on phones) replaced all 24 occurrences.

TWO MORE DUPLICATIONS, EACH WITH A COPY THAT HAD DRIFTED:

- `lib/text/words.ts` replaces FIVE whole-word matchers. `saysWord`,
  `says` and `demonstrates` were byte-identical under three names; `check.ts`
  and `text.ts` each kept a private `escape`. `display.ts` says in its own
  comment that it is copying the variety gate — the author knew they were
  writing the second one, because there was nowhere to put it. `text.ts` opens
  by arguing these operations belong "in one place" while holding a fifth copy.
  Eight tests pin the cases the five copies each half-knew.

- `lib/i18n/dates.ts` replaces THREE date formatters whose comments all said
  "the reader's own date format, never a hardcoded one" and which then
  disagreed about the month and the fallback. The tag was resolved at three
  different layers: not at all, at the caller, and at the use site — so
  `SavedWords` declared `locale: string` and was handed a pre-resolved
  `de-CH`. Now the formatter owns it and the prop is `Locale`. A test asserts
  the chat workspace's date is byte-identical in all seven locales, because a
  refactor that changes a glyph is not one. Also ends `essays/[slug]`
  importing a helper out of another page module.

THE AUDIT LEARNED TWO THINGS, BOTH PROVEN BY MUTATION:

- Its two checks disagreed about scrollers. `clipped` exempts a deliberate
  `overflow-x: auto` ("a real scroller is a deliberate choice"); the horizontal
  `over` check did not, and reported four findings against a correct page whose
  document did not overflow. They now agree. Mutation-tested: widened the rail
  to 900px and `OVER` still fires, on the nav itself.
- It now fails if the header's CONTENT outgrows the token height. The first
  version compared the header to the token and could never fail — the header
  IS the token — which is worse than no check. Mutation-tested at `2rem`:
  "the header contains 68px of content in a 32px bar".

Note that lint and type-check both passed while globals.css was unparseable
(`@utility` cannot nest inside `@media`); neither compiles CSS. The dev server
was what said so.

Verified: verify exit 0 — 852 tests, 72 suites; audit:language 20 pages / 0
English; audit:responsive 116 renders across de/fr/ru, 320–375px, light and
dark — 0 overflow, 0 header drift; `/de/method` screenshotted at 390px
scrolled to 2200, rail pinned under the header.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-24 02:12:43 -07:00