website: one header on every page, one contents drawer that starts closed

The docs page used to swap the site's links for its own three and unfold the
chapter rail on arrival, so half the navigation vanished the moment you opened
the documentation and a sidebar you never asked for was already there. Both are
gone. Every page — home, about, docs, API — now serves a byte-identical nav bar
and navigation sheet; which page you are on is marked with aria-current at
runtime, so nothing is ever added or dropped from the markup to say it.

The rail is now separate from the header and the same object everywhere: closed
in CSS at every width, opened by one Contents pill, closed by the ✕ in its own
sticky header, by Escape, or by a tap on the dimmed page. No preference is
remembered any more and the stale og_rail key is cleared on sight. One panel
controller in site.js drives both the sheet and the drawer, traps focus while
either is open and hands it back to the button that opened it. api.html no
longer carries a private copy of any of this.

Also: visibility is switched at one instant instead of being transitioned —
interpolating it left both panels hidden through their own opening animation,
so they popped in at the end and nothing inside could take focus until then.
Long inline code breaks instead of widening the page (docs ran 21px wide of a
320px screen), the header folds at one breakpoint rather than three, and every
control in the rail clears 44px.

246 headless assertions across four pages and five widths: nav and sheet
markup identical, drawer shut on first paint, no horizontal overflow, focus
returned, reduced motion honoured, no console errors.
This commit is contained in:
Duarte Santos committed 2026-08-31 14:32:32 +02:00
1 parent 572f50cd4f
commit 523cfc9df7
7 files changed
+1275 -409

No files matched your search

+192 -61
View File
@@ -12,7 +12,7 @@
--fg: #f5f5f7;
--fg-2: #a1a1a6;
--fg-3: #6e6e73;
--fg-3: #7d7d85; /* >=4.5:1 on every panel — WCAG AA for small text */
--acc: #32d74b;
--acc-ink: #04150a;
@@ -128,8 +128,12 @@ h3 { font-size: clamp(19px, 2.3vw, 21px); letter-spacing: -.02em; line-height: 1
/* ----------------------------------------------------------------- nav bar */
/* The bar is the one fixed point of the site: the same links in the same order on
every page, and nothing ever slides out of it. It therefore outranks the
navigation sheet, the contents drawer and their scrim — none of them may cover
it, so a reader always knows where they are and how to get out. */
nav {
position: sticky; top: 0; z-index: 60;
position: sticky; top: 0; z-index: 90;
background: rgba(0, 0, 0, .68);
backdrop-filter: saturate(180%) blur(20px);
-webkit-backdrop-filter: saturate(180%) blur(20px);
@@ -145,9 +149,11 @@ nav {
.brand:hover { text-decoration: none; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
/* The bar keeps only the three things worth reaching from anywhere: the repo, the
Discord, and the download. Everything else lives in the topic rail. */
.nav-quick { display: flex; align-items: center; gap: 24px; }
/* One header, everywhere. Every page carries this identical set of links in this
identical order; which page you are on is marked at runtime with aria-current,
never by adding or dropping links. Below 1000px they fold into the navigation
sheet — the same links again, nothing lost. */
.nav-quick { display: flex; align-items: center; gap: 20px; }
.nav-quick .ql {
color: var(--fg-2); font-size: 14px; font-weight: 400; letter-spacing: 0;
transition: color .2s var(--ease);
@@ -160,15 +166,23 @@ nav {
padding: 7px 15px; border-radius: 999px;
}
.nav-quick .cta:hover { background: #4ade63; text-decoration: none; }
@media (max-width: 620px) { .nav-quick .ql { display: none; } }
.nav-quick .ql[aria-current="page"] { color: var(--fg); }
.nav-toggle {
display: none;
position: relative;
width: 42px; height: 42px; margin-right: -9px;
width: 44px; height: 44px; margin-right: -11px;
align-items: center; justify-content: center;
border-radius: 10px; cursor: pointer;
}
/* One breakpoint for the whole header: above it the links are in the bar, below it
they are in the sheet. No page has a second answer. Placed after .nav-toggle's
own rule — same specificity, so the later one has to be the one that wins. */
@media (max-width: 999.98px) {
.nav-quick .ql { display: none; }
.nav-toggle { display: flex; }
}
.nav-toggle span {
position: absolute; width: 18px; height: 1.5px; border-radius: 2px; background: var(--fg);
transition: transform .3s var(--ease);
@@ -178,10 +192,135 @@ nav {
.nav-toggle[aria-expanded="true"] span:first-child { transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { transform: rotate(-45deg); }
/* ---------------------------------------------------------------- topic rail
One list of everything on the site — a title with a one-line subtitle per topic.
On a wide screen it is a fixed column beside the page; below that, the exact
same markup is the sheet behind the hamburger. */
/* ------------------------------------------------------- navigation sheet
The header's links, for the widths where the bar shows only the brand and the
download. Same links, same order — the sheet is the bar, folded. It drops from
under the bar, and the hamburger it came from turns into the ✕ that closes it. */
.navsheet {
position: fixed; left: 0; right: 0; top: 54px; z-index: 80;
padding: 12px var(--pad) calc(20px + env(safe-area-inset-bottom));
background: #000;
border-bottom: 1px solid var(--hair-soft);
box-shadow: 0 30px 60px rgba(0, 0, 0, .8);
max-height: calc(100dvh - 54px); overflow-y: auto; overscroll-behavior: contain;
transform: translateY(-8px); opacity: 0; visibility: hidden; pointer-events: none;
/* visibility is switched at one instant, never interpolated: transitioning it
leaves the panel hidden through its own opening animation — it would pop in
at the end, and nothing inside it could take focus until then. Zero delay on
the way in, the full duration on the way out. */
transition: opacity .28s var(--ease), transform .28s var(--ease), visibility 0s linear .28s;
}
body.menu-open .navsheet {
transform: none; opacity: 1; visibility: visible; pointer-events: auto;
transition: opacity .28s var(--ease), transform .28s var(--ease), visibility 0s;
}
@media (min-width: 1000px) { .navsheet { display: none; } }
/* A row per link, comfortably past the 44px touch target. */
.navsheet .nl {
display: flex; align-items: center; justify-content: space-between; gap: 16px;
min-height: 52px; padding: 0 12px; margin: 0 -12px; border-radius: 12px;
color: var(--fg); font-size: 17px; font-weight: 500; letter-spacing: -.02em;
border-bottom: 1px solid var(--hair-soft);
transition: background-color .2s var(--ease);
}
.navsheet .nl:last-of-type { border-bottom: 0; }
.navsheet .nl:hover { text-decoration: none; background: rgba(255, 255, 255, .05); }
.navsheet .nl[aria-current="page"] { color: var(--acc); }
.navsheet .nl [data-gh] { color: var(--fg-3); font-size: 14px; font-variant-numeric: tabular-nums; }
/* No second Download button in here: the bar keeps its own at every width, a
finger-width above, and two identical green calls to action is one too many. */
/* -------------------------------------------------------- contents drawer
Every page that has one gets the same one: closed on load, at every width,
with no remembered state. The Contents pill opens it; the ✕ inside it, Escape,
or a tap on the dimmed page closes it. Nothing else opens or closes it. */
.toc-btn {
position: fixed; z-index: 62;
left: max(16px, env(safe-area-inset-left));
bottom: max(16px, env(safe-area-inset-bottom));
display: inline-flex; align-items: center; gap: 9px;
min-height: 44px; padding: 0 19px 0 16px; border-radius: 999px; cursor: pointer;
/* Opaque enough to read against running text on its own, so the pill still works
where backdrop-filter does not. */
background: rgba(20, 21, 24, .94);
backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
border: 1px solid var(--hair);
color: var(--fg-2); font-size: 14px; font-weight: 500; letter-spacing: -.01em;
box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
transition: color .2s var(--ease), background-color .2s var(--ease),
border-color .2s var(--ease), opacity .2s var(--ease);
}
.toc-btn:hover { color: var(--fg); border-color: rgba(255, 255, 255, .25); background: rgba(32, 33, 37, .92); }
.toc-btn svg { width: 16px; height: 16px; }
/* The pill steps aside whenever a panel is up: with the drawer open the ✕ inside it
is the control, and under the navigation sheet it is just a shape behind glass. */
body.contents-open .toc-btn, body.menu-open .toc-btn { opacity: 0; pointer-events: none; }
.side {
position: fixed; left: 0; top: 54px; bottom: 0; z-index: 80;
width: min(340px, 88vw);
padding: 0 24px calc(30px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
background: #0a0b0c;
border-right: 1px solid var(--hair-soft);
box-shadow: 40px 0 80px rgba(0, 0, 0, .5);
overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
transform: translateX(-102%); visibility: hidden;
/* Same one-instant switch as the sheet above, for the same two reasons. */
transition: transform .32s var(--ease), visibility 0s linear .32s;
}
body.contents-open .side {
transform: none; visibility: visible;
transition: transform .32s var(--ease), visibility 0s;
}
/* The close button rides along at the top of a long chapter list, so it is never
more than a glance away. */
.side-top {
position: sticky; top: 0; z-index: 1;
display: flex; align-items: center; justify-content: space-between;
margin: 0 -24px 8px calc(-24px - env(safe-area-inset-left));
padding: 12px 14px 12px calc(24px + env(safe-area-inset-left));
background: #0a0b0c;
border-bottom: 1px solid var(--hair-soft);
}
.side-title { font-size: 15px; font-weight: 600; letter-spacing: -.02em; color: var(--fg); }
.rail-close {
flex: none;
display: flex; align-items: center; justify-content: center;
width: 44px; height: 44px; margin: -6px -8px -6px 0;
border-radius: 11px; color: var(--fg-2); cursor: pointer;
transition: color .2s var(--ease), background-color .2s var(--ease);
}
.rail-close:hover { color: var(--fg); background: rgba(255, 255, 255, .07); }
.rail-close svg { width: 17px; height: 17px; }
/* Whatever the sheet or the drawer does not cover is dimmed, so the page behind
stops competing for attention and a tap out there reads as "close". It starts
below the bar: the header stays legible whatever is open. */
body::after {
content: ""; position: fixed; inset: 54px 0 0; z-index: 70;
background: rgba(0, 0, 0, .55);
backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
opacity: 0; pointer-events: none;
transition: opacity .3s var(--ease);
}
body.menu-open::after, body.contents-open::after { opacity: 1; pointer-events: auto; }
/* The panels still open and close, they just stop travelling. The delay has to go
with the duration: it is what holds visibility back until a slide has finished,
and there is no slide left to wait for. */
@media (prefers-reduced-motion: reduce) {
.side, .navsheet, .toc-btn, body::after {
transition-duration: .01ms !important;
transition-delay: 0s !important;
}
}
/* --------------------------------------------------------------- rail contents
One list per page — a title with a one-line subtitle per topic. */
.side-label {
font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
@@ -190,7 +329,9 @@ nav {
}
.side-label:first-child { margin-top: 0; }
.side-link {
display: block; padding: 9px 12px; margin: 0 -12px; border-radius: 10px;
display: flex; flex-direction: column; justify-content: center;
min-height: 44px; /* a chapter without a subtitle is still tappable */
padding: 8px 12px; margin: 0 -12px; border-radius: 10px;
color: var(--fg);
transition: background-color .2s var(--ease);
}
@@ -203,55 +344,10 @@ nav {
.side-link.on, .side-link[aria-current="page"] { background: rgba(255, 255, 255, .045); }
.side-link.on b, .side-link[aria-current="page"] b { color: var(--acc); }
@media (min-width: 1300px) {
.nav-toggle { display: none !important; }
/* The rail owns the left edge; the page centres in what is left. */
body { padding-left: calc(264px + env(safe-area-inset-left)); }
.side {
position: fixed; left: 0; top: 0; bottom: 0; z-index: 70;
width: calc(264px + env(safe-area-inset-left));
padding: 30px 24px 34px calc(26px + env(safe-area-inset-left));
overflow-y: auto; overscroll-behavior: contain;
background: #060707;
border-right: 1px solid var(--hair-soft);
scrollbar-width: thin;
}
}
@media (max-width: 1299.98px) {
.nav-toggle { display: flex; }
.side {
position: fixed; left: 0; right: 0; top: 54px; z-index: 55;
padding: 20px var(--pad) calc(28px + env(safe-area-inset-bottom));
background: #000;
border-bottom: 1px solid var(--hair-soft);
box-shadow: 0 30px 60px rgba(0, 0, 0, .8);
max-height: calc(100dvh - 54px); overflow-y: auto;
transform: translateY(-8px); opacity: 0; pointer-events: none;
transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.side.open { transform: none; opacity: 1; pointer-events: auto; }
/* Whatever the sheet does not cover is dimmed, so the page behind it stops
competing for attention and a tap out there reads as "close". */
body::after {
content: ""; position: fixed; inset: 0; z-index: 50;
background: rgba(0, 0, 0, .55);
backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
opacity: 0; pointer-events: none;
transition: opacity .3s var(--ease);
}
body.menu-open::after { opacity: 1; pointer-events: auto; }
}
/* A tablet-wide sheet with one narrow column looks abandoned; two columns fill it. */
@media (min-width: 640px) and (max-width: 1299.98px) {
.side { display: grid; grid-template-columns: 1fr 1fr; column-gap: 36px; align-items: start; }
.side-label { grid-column: 1 / -1; }
.side-label + .side-link { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
.side, body::after { transition-duration: .01ms !important; }
/* A wide sheet with one narrow column of links looks abandoned; two columns fill it. */
@media (min-width: 640px) and (max-width: 999.98px) {
.navsheet .nl { border-bottom: 0; }
.navsheet .nl-rows { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
}
/* --------------------------------------------------------------------- hero */
@@ -640,6 +736,10 @@ code { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, mo
p code, li code, td code {
background: var(--surface-2); border-radius: 6px; padding: 2px 6px;
font-size: .88em; color: #e4e4e8;
/* An env var or a URL in running text is one unbreakable word wider than a
320px phone; without this it pushes the whole page sideways. A <pre> block is
left alone — it scrolls inside its own box. */
overflow-wrap: anywhere;
}
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 4px; }
@@ -783,3 +883,34 @@ table.cfg td:first-child { white-space: nowrap; width: 1%; padding-right: 26px;
.js.intro .hero .actions,
.js.intro .hero-stage { opacity: 1; animation: none; }
}
/* ------------------------------------------------------- rail: subchapters
Chapters are .side-link rows inside a .side-group; the group's subchapters sit
in .side-subs and unfold for the chapter being read (scrollspy) or on tap. */
.side-group .side-subs {
display: none;
margin: 2px 0 6px;
}
.side-group.open .side-subs { display: block; }
.side-sub {
display: block; padding: 5px 12px 5px 24px; margin: 0 -12px; border-radius: 8px;
color: var(--fg-2); font-size: 13px; line-height: 1.4;
transition: color .2s var(--ease), background-color .2s var(--ease);
}
.side-sub:hover { text-decoration: none; color: var(--fg); background: rgba(255, 255, 255, .04); }
.side-sub.on { color: var(--acc); }
/* A subchapter is a tap target too, not just a line of text. */
@media (pointer: coarse) { .side-sub { padding-top: 9px; padding-bottom: 9px; } }
/* --------------------------------------------------------- a11y: link affordance
Links inside running text can't rely on color alone (WCAG 1.4.1 / Lighthouse
link-in-text-block): give them a quiet underline. Nav, cards and the rail keep
their color-only look — they are recognisable as controls by placement. */
.prose p a, .prose li a, .prose td a, .foot .c a, .note a {
text-decoration: underline;
text-decoration-color: rgba(50, 215, 75, .45);
text-underline-offset: 2.5px;
}
.prose p a:hover, .prose li a:hover, .prose td a:hover, .foot .c a:hover, .note a:hover {
text-decoration-color: currentColor;
}