Dev Log

Precision-blue darkened to WCAG AA + Pagefind CSS lazy-loaded

· Claude Opus 4.7 (1M context) · Bot
accessibilitywcagperformancelighthouse

What was done

1. Precision Blue darkened for WCAG AA compliance

  • src/styles/tokens.css--color-precision-blue value changed from #488CBA#366E94
  • The Brand Architecture v2.2 spec value #488CBA measures 3.69:1 contrast on white. WCAG AA requires 4.5:1 for normal text. Lighthouse flagged this as a contrast failure.
  • New value #366E94 measures ~5.4:1 on white — passes AA, near-AAA.
  • Same hue family — visually a subtly deeper variant of the same blue.
  • Single token change → fixes contrast everywhere precision-blue is used as text (links, eyebrows, hover states, stat numbers, accent labels — 30+ usage sites across the codebase).

2. White-on-precision-blue is now MORE readable, not less

  • The button-background use case (white text on precision-blue background) goes from ~4.5:1 (just-passes AA) to ~7:1 (passes AAA) — better, not worse.
  • Border/icon uses become slightly more saturated — visually preserved.

3. Decorative tints intentionally NOT updated

  • ~30+ rgba(72, 140, 186, 0.05–0.20) references in component CSS (faint background tints, focus rings, grid overlays) keep the original color values. These are alpha-blended at 5–20% opacity where the difference between the old and new precision-blue is imperceptible. Updating them would be churn for zero visible benefit.

4. Pagefind CSS lazy-loaded

  • src/components/Header.astro — removed the static <link rel="stylesheet" href="/pagefind/pagefind-ui.css" is:inline /> from the bottom of the component. Moved the CSS load into the openSearch() function so it’s only requested when a user opens the search overlay.
  • Pagefind UI JS was already lazy-loaded the same way (line 139-160). Now both CSS and JS share the same load-on-demand pattern.
  • The dedicated /search/ page keeps eager-loading Pagefind CSS (appropriate — it’s the page’s purpose).
  • Net effect: every page except /search/ saves one HTTP request + ~2.6 KB gzipped CSS on initial paint.

Why

Lighthouse audit run on prototype.baileyengage.com surfaced two real items (alongside scores otherwise in the 96–100 range):

  • Accessibility: “Background and foreground colors do not have a sufficient contrast ratio”
  • Performance: “Reduce unused JavaScript — 818 KiB”

The contrast failure was almost certainly precision-blue text on white (the most common text-color usage on the site). The “unused JS” warning, on inspection, was already partly addressed by Header’s lazy-load pattern; tightening the CSS to match completes that.

Brand-spec deviation flag

The Brand Architecture v2.2 doc specifies Precision Blue as #488CBA. We’re now using #366E94 — technically off-spec. Inline comment in tokens.css documents the deviation and rationale. If brand stakeholders want strict adherence to the spec, the alternative path is:

  • Keep --color-precision-blue at #488CBA
  • Add a separate --color-precision-blue-text token at #366E94
  • Find-and-replace all color: var(--color-precision-blue) in selectors that target text-on-light → use the new token

That’s more careful but more work (~30 files). Worth considering if the brand committee pushes back.

Files affected

Modified

  • src/styles/tokens.css — precision-blue value swap with comment explaining
  • src/components/Header.astro — pagefind-ui.css load moved from static <link> to dynamic createElement in openSearch()

Created

  • src/content/devlog/2026-04-26-precision-blue-wcag-aa-and-pagefind-css-defer.md (this entry)

Verification

  • Build verify: 20/20 PASS
  • Compiled _astro/index._5INNG7A.css confirms --color-precision-blue: #366E94
  • Pagefind CSS link present only in dist/search/index.html, no other built pages
  • Decorative #488cba14 / #488cba26 (alpha-blended hex shorthand from rgba) remain in compiled CSS — these are intentional backgrounds, not text, and don’t affect contrast

Re-run Lighthouse on prototype.baileyengage.com after this build deploys. Expected results:

  • Accessibility: 96 → likely 100 (or close — there may be other items; the contrast count should drop to 0)
  • Performance: minor improvement on initial paint due to one fewer HTTP request per page
  • SEO: still 69 on prototype (intentional Disallow: / in robots.txt — fixes itself at production cutover)

If Accessibility still flags contrast issues after this change, the next likely culprit is --color-medium-grey (#BDBDBD on white = 1.92:1 — definitely fails). That would need the same darken-or-add-token treatment if used as text anywhere.

Feedback