Files
docs/publishing/typography.css
T
inference-bot 4e44793aaf docs site: scale headings with the viewport so the title stops breaking mid-word
At 360px wide the h1 was still 52px, because Material keeps a 20px root on mobile, so
"Cooperative" (297px at that size) left only ~30px of slack before breaking mid-word.

Headings now use clamp() to track the viewport and reach the same desktop sizes, with
word-break: normal, hyphens: none and text-wrap: balance so wrapping happens at the
space and the two lines are balanced rather than one word sitting alone.
2026-11-03 20:50:27 +00:00

68 lines
2.3 KiB
CSS

/* Typography for the co-op documentation site.
*
* Loaded after publishing/brand.css on purpose: the font has to be declared on the
* elements themselves. Material renders body and headings with
* var(--md-text-font-family), which it defines on <body>, so a :root-level value
* loses to it by DOM proximity no matter how the cascade is ordered.
*
* Figtree is self-hosted -- see the @font-face rules in brand.css. No CDN, no
* third-party font service.
*/
body,
.md-typeset,
.md-nav,
.md-header,
.md-tabs,
.md-footer {
font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto,
"Helvetica Neue", Arial, sans-serif;
}
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6,
.md-header__title,
.md-nav__title {
font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto,
"Helvetica Neue", Arial, sans-serif;
letter-spacing: -0.01em;
}
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-header__title {
/* Never break a word mid-way; wrap at the space, and let the browser balance the
two lines rather than leaving one word on its own. */
overflow-wrap: break-word;
word-break: normal;
hyphens: none;
text-wrap: balance;
}
/* Fluid scale. Fixed rem sizes do not shrink on a phone -- Material keeps a 20px root
* even at 360px wide -- so a 2.6rem h1 stays 52px and "Cooperative" (297px at that
* size) runs out of room on anything narrower than ~370px and breaks mid-word.
* These track the viewport instead and land at the same desktop size.
*/
.md-typeset h1 { font-size: clamp(1.6rem, 1.5rem + 3.2vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; }
.md-typeset h2 { font-size: clamp(1.3rem, 1.1rem + 1.6vw, 1.7rem); font-weight: 600; }
.md-typeset h3 { font-size: clamp(1.1rem, 1rem + 0.7vw, 1.25rem); font-weight: 600; }
.md-header__title { font-size: clamp(0.85rem, 0.7rem + 0.8vw, 0.95rem); font-weight: 600; }
/* Long prose stays readable; measured in characters rather than pixels. */
.md-typeset { line-height: 1.65; }
/* Colour is scheme-specific, so it stays out of the rules above. */
[data-md-color-scheme="default"] .md-typeset h1,
[data-md-color-scheme="default"] .md-typeset h2,
[data-md-color-scheme="default"] .md-typeset h3,
[data-md-color-scheme="default"] .md-typeset h4 {
color: #2d3327;
}