ADDED Requirements

Requirement: Toggle button visible in masthead

The site SHALL display a dark/light mode toggle button in the masthead navigation on all pages.

Scenario: Button is present on every page

Scenario: Button icon reflects current mode

Requirement: Dark mode activates correct color scheme

When dark mode is active, the site SHALL apply a dark color scheme that provides sufficient contrast for all text, links, code blocks, masthead, footer, and sidebar elements.

Scenario: Dark mode colors applied

Scenario: Light mode colors applied

Requirement: User preference persisted across sessions

The site SHALL remember the user’s dark/light mode preference between page loads and browser sessions using localStorage.

Scenario: Preference saved on toggle

Scenario: Preference restored on return visit

Requirement: OS dark mode preference respected on first visit

On a user’s first visit (no saved preference), the site SHALL default to dark mode if the OS prefers-color-scheme: dark media query is active.

Scenario: First visit with OS dark mode

Scenario: First visit with OS light mode

Requirement: No flash of wrong theme on load

The site SHALL apply the correct theme before the browser renders visible content, eliminating a flash of the wrong theme.

Scenario: Correct theme applied before render

Requirement: Graceful degradation without JavaScript

If JavaScript is disabled or unavailable, the site SHALL remain fully functional and display in its default light mode.

Scenario: No JS environment