docs: plan CHRNX character-led sections

This commit is contained in:
chrnx committed 2026-08-12 17:09:56 -05:00
1 parent cb545c316c
commit 7ffb1a72f2
2 files changed
+156

No files matched your search

@@ -0,0 +1,93 @@
# CHRNX Character-Led Sections Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Apply the approved mockup's alter-ego effect consistently across CHRNX section openings, center primary titles, and repair compressed podcast layouts.
**Architecture:** Add a small reusable character-stage class contract to existing WordPress patterns and dynamic topic heroes, while preserving their semantic content order. Reuse the current allowlisted responsive media helper and generated assets; CSS owns the shared frame, themed variants, layering, and responsive behavior.
**Tech Stack:** WordPress 6.9 block theme, PHP, CSS, PHPUnit, Node smoke tests, Playwright, wp-env/Colima.
---
### Task 1: Define shared character-stage markup
**Files:**
- Modify: `patterns/home-projects.php`
- Modify: `patterns/home-music.php`
- Modify: `patterns/music-landing.php`
- Modify: `patterns/podcast-landing.php`
- Modify: `patterns/about.php`
- Modify: `blocks/topic-hero/render.php`
- Test: `tests/php/PatternsTest.php`
- Test: `tests/php/BlockRenderingTest.php`
- Test: `tests/smoke/visual-integration.test.mjs`
- [ ] Add failing tests for this exact block-valid API: each opening contains one `.chrnx-character-stage`, with exactly three direct children ordered `.chrnx-character-stage__atmosphere[aria-hidden=true]`, `.chrnx-character-stage__content`, and `.chrnx-character-stage__art`; optional `.chrnx-character-facets` follows the stage, never sits inside it. The content layer contains the existing primary heading/copy/list in original semantic order. The art layer contains exactly one primary responsive `<picture>`. Home Projects places its decorative `.chrnx-character-stage__secondary-art` inside the atmosphere layer; Home/Home Landing Music likewise places `.chrnx-character-stage__collage` inside atmosphere; About places Life in primary art and Literature/Gaming in the later facets region.
- [ ] Add parse/serialize/editor-fidelity assertions on rendered pattern `$content`: `parse_blocks( $content )` finds no freeform corruption, `serialize_blocks( parse_blocks( $content ) )` reparses to the same ordered block-name tree, every pattern retains one intended primary heading and no H1, and existing content strings/order remain present. Never parse the PHP source itself.
- [ ] Add unknown/show render RED tests: an unknown `topic="future-topic"` outputs a labeled `.chrnx-topic-hero` plus decorative `.chrnx-topic-hero__fallback`; `/show/silicon-ranch/` uses Podcasts art but keeps `Silicon Ranch` as the visible title.
- [ ] Run `PATH=/opt/homebrew/opt/docker/bin:$PATH npm run test:php -- --filter 'PatternsTest|BlockRenderingTest'` and `npm run test:smoke`; expect failures for missing shared classes, absent unknown fallback, and show art mapping.
- [ ] Minimally wrap or class existing pattern content to implement the exact API. In `music-landing.php`, replace the raw collage JPEG with `chrnx_get_topic_portrait_markup( 'music-collage', __( 'The No Names collage', 'chrnx' ), 'chrnx-character-stage__collage' )`; it must retain meaningful nonempty alt, intrinsic dimensions, lazy loading, and AVIF/WebP sources. Other decorative portraits/collages retain `alt=""` plus `aria-hidden="true"`; the meaningful isolated Music portrait retains its approved nonempty alt.
- [ ] Re-run the two exact commands; expect focused PHP and smoke PASS. Run `npm run phpcs` and commit `refactor: unify CHRNX character stages`.
### Task 2: Implement the mockup character effect
**Files:**
- Modify: `assets/css/components.css`
- Test: `tests/e2e/visual-states.spec.mjs`
- Test: `tests/smoke/visual-integration.test.mjs`
- [ ] Add failing browser contracts at 375/768/1440/2560 in explicit light/dark for every Home/Projects/Music/Podcasts/About/show/topic stage: primary art bounding-box width is 35–48% of its stage on desktop and at least 62% on mobile; art bottom is within 2px of stage bottom; mobile content top precedes art top; content, art, subsequent cards, and facets do not intersect; document and stage have no horizontal overflow.
- [ ] Add human-inspection captures/contracts for visible face, torso, and defining prop. Automated tests additionally require the foreground `<picture>` to paint above atmosphere/secondary layers by computed `z-index`, a non-none shadow/filter or mask, and zero eager below-fold character requests.
- [ ] Add a long-copy regression that expands each representative content layer by 4x so translated content grows the frame instead of covering the character; assert text contrast at least 4.5:1 in both explicit themes. Add reduced-motion static-equivalence and no-JS visibility/containment checks.
- [ ] Run `PATH=/opt/homebrew/opt/docker/bin:$PATH npx playwright test tests/e2e/visual-states.spec.mjs --project=chromium --grep 'character stage'`; expect failures for current tiny/floating/stacked portraits and missing class API.
- [ ] Implement the shared 55/45 desktop stage and text-first mobile stage with themed halo, wash, collage fragments, grounded shadow, and per-topic accent variables.
- [ ] Ensure the Music musician remains foreground over the lazy collage and About facets remain visually secondary.
- [ ] Re-run the exact Playwright command expecting PASS, then run `npm run lint:css`, `npm run lint:js`, `uv run --with pillow --with pytest pytest tests/assets/test_alter_ego_assets.py -q`, and `PATH=/opt/homebrew/opt/docker/bin:$PATH npm run test:php -- --filter ResponsiveMediaTest`; all must PASS. Commit `style: apply CHRNX character-led sections`.
### Task 3: Center primary titles without harming reading alignment
**Files:**
- Modify: `assets/css/components.css`
- Test: `tests/e2e/visual-states.spec.mjs`
- Test: `tests/smoke/templates.test.mjs`
- [ ] Add failing tests for this exact positive selector matrix: `.chrnx-entry--page > .wp-block-post-title`, `.chrnx-entry--single > .wp-block-post-title`, `.chrnx-archive > .wp-block-query-title`, `.chrnx-search-results > .wp-block-query-title`, `.chrnx-entry--page .chrnx-home-projects .chrnx-character-stage__content > h2`, `.chrnx-music-landing .chrnx-character-stage__content > h2`, `.chrnx-podcast-landing .chrnx-character-stage__content > h2`, `.chrnx-about .chrnx-character-stage__content > h2`, and `.chrnx-topic-hero__title` compute `text-align:center` with auto inline margins.
- [ ] Add negative assertions that `.chrnx-entry__meta`, `.chrnx-page-kicker`, paragraphs, form labels, `.chrnx-home .chrnx-home-projects .chrnx-character-stage__content > h2`, every other `.chrnx-home > section > h2`, project/release headings, and card headings remain `start`/left aligned. Assert the single content measure remains 70ch and metadata still wraps without overflow at 200% root text.
- [ ] Run `PATH=/opt/homebrew/opt/docker/bin:$PATH npx playwright test tests/e2e/visual-states.spec.mjs --project=chromium --grep 'primary title alignment'`; expect current page/post/search/title failures.
- [ ] Add narrowly scoped selectors and balanced margins; do not use a global heading centering rule.
- [ ] Re-run the exact Playwright command expecting PASS, then run `npm run test:smoke`, `npm run lint:css`, and `PATH=/opt/homebrew/opt/docker/bin:$PATH npx playwright test tests/e2e/visual-states.spec.mjs --project=chromium --grep 'primary title alignment|long.*title'`; require PASS in explicit light/dark mobile and 200% root-text cases. Commit `style: center CHRNX primary titles`.
### Task 4: Repair podcast character and card geometry
**Files:**
- Modify: `assets/css/components.css`
- Modify: `blocks/latest-podcast/style.css` only if its base media rule must change
- Modify: `tests/fixtures/posts.json`
- Test: `tests/e2e/visual-states.spec.mjs`
- Test: `tests/php/BlockRenderingTest.php`
- Test: `tests/smoke/visual-integration.test.mjs`
- [ ] Extend the existing eligible `post-podcast-episode` fixture with a deliberately long podcast title and excerpt while preserving `topic=podcasts`, `show=silicon-ranch`, canonical metadata, and exact total fixture count. Add smoke assertions proving this is the eligible long-card case.
- [ ] Add a failing regression reproducing the screenshot: require an unobstructed Podcasts portrait, `.chrnx-podcast-card__content` width at least equal to an offscreen DOM probe with the same computed font family/size and `width:28ch`, `min-width:0`, media within its bounds, normal title/excerpt/badge wrapping, no clipping, and a content-aware stack when the viewport cannot preserve both columns.
- [ ] Add mobile missing-media plus long title/excerpt/badge cases; metadata is not part of this card and is explicitly out of this geometry contract.
- [ ] Run `npm run test:smoke` and `PATH=/opt/homebrew/opt/docker/bin:$PATH npx playwright test tests/e2e/visual-states.spec.mjs --project=chromium --grep 'long podcast composition'`; expect fixture/geometry failures.
- [ ] Fix grid `minmax()` geometry, media bounds, stacking breakpoint, and portrait/card separation without hiding content.
- [ ] Re-run those commands expecting PASS, then run `PATH=/opt/homebrew/opt/docker/bin:$PATH npx playwright test tests/e2e/visual-states.spec.mjs --project=chromium --project=firefox --project=webkit --grep 'long podcast composition'`, `PATH=/opt/homebrew/opt/docker/bin:$PATH npm run test:php -- --filter BlockRenderingTest`, `npm run lint:css`, and `npm run lint:js`; all must PASS. Commit `fix: preserve CHRNX podcast composition`.
### Task 5: Visual approval and full regression
**Files:**
- Modify: `scripts/capture-visual-review.mjs`
- Test: `tests/smoke/visual-integration.test.mjs`
- Create ignored: `tmp/imagegen/character-led-*.png`
- [ ] Add a failing bounded-capture contract with stage crops for Home Projects, Home Music, Projects, Music, Podcasts, About, `/show/silicon-ranch/`, long Podcast card, post-title, and all seven `/topic/{research,code,literature,music,podcasts,life,gaming}/` mappings. Every mapped stage is captured at 375x812, 768x1024, 1440x900, and 2560x1440 in explicit light/dark. Preserve the current fresh-browser-per-capture isolation regression: every image launches and closes its own Chromium instance so dark-to-light compositing state cannot leak.
- [ ] For unknown fallback only, navigate Chromium to `http://localhost:8888/topic/code/` so WordPress has loaded its generated `global-styles-inline-css`, block-support CSS, theme styles, and local font declarations. Obtain fallback markup without persistent content using `PATH=/opt/homebrew/opt/docker/bin:$PATH npx wp-env run cli --env-cwd=wp-content/themes/chrnx -- wp eval '$attributes=array("topic"=>"future-topic","headingLevel"=>2); ob_start(); include get_theme_file_path("blocks/topic-hero/render.php"); echo base64_encode(ob_get_clean());' | sed -n '/^[A-Za-z0-9+\/=]\+$/p' | tail -1`, decode it in the capture process, and replace only the existing `.chrnx-topic-hero` element via DOM APIs. Wait for `document.fonts.ready`, every linked stylesheet to report a loaded sheet, and two animation frames before capture. This creates no Page/term/post, keeps the 7-page/12-post invariant, retains the real local page URL/styles/fonts, and is captured under `character-led-unknown-fallback-*`.
- [ ] Run `npm run test:smoke -- --test-name-pattern='character-led capture'`; expect FAIL before script expansion and PASS afterward. Generate `tmp/imagegen/character-led-*.png` without committing PNGs.
- [ ] Inspect every capture for correct character, consistent scale/effect, centered primary title, readable card copy, containment, and footer/header regressions.
- [ ] Run `PATH=/opt/homebrew/opt/docker/bin:$PATH npm test`; expect smoke/lints/PHPCS/Jest/PHPUnit/160 Playwright tests (plus new tests) PASS with only documented axe skips. This preserves existing keyboard, permalink, WCAG, theme-preference, no-JS, and reduced-motion coverage.
- [ ] Run `./scripts/seed-test-content.sh default`; then run `PATH=/opt/homebrew/opt/docker/bin:$PATH npx wp-env run cli -- wp eval '$rows=get_posts(array("post_type"=>array("page","post"),"post_status"=>"any","posts_per_page"=>-1,"meta_key"=>"_chrnx_fixture_key")); $map=array(); foreach($rows as $row){$key=get_post_meta($row->ID,"_chrnx_fixture_key",true); if($key){$map[$key]=(int)$row->ID;}} ksort($map); global $wp_rewrite; echo wp_json_encode(array("fixtures"=>$map,"pages"=>count(array_filter($rows,fn($p)=>"page"===$p->post_type)),"posts"=>count(array_filter($rows,fn($p)=>"post"===$p->post_type)),"scenario"=>get_option("_chrnx_fixture_featured_limit","default"),"subscribe"=>(int)get_option("chrnx_subscribe_page_id"),"subscribe_status"=>get_post_status((int)get_option("chrnx_subscribe_page_id")),"option_permalink"=>get_option("permalink_structure"),"live_permalink"=>$wp_rewrite->permalink_structure));' | sed -n '/^{/p' > "${TMPDIR%/}/chrnx-character-fixtures-1.json"`. Repeat seed and command into `chrnx-character-fixtures-2.json`; run `cmp` and require exit 0, 19 keys, 7 pages, 12 posts, default scenario, published Subscribe, and both permalink fields `/%postname%/`.
- [ ] Run `TMP_REBUILD="$(mktemp -d "${TMPDIR%/}/chrnx-character.XXXXXX")"; ./scripts/build-responsive-images.sh "$TMP_REBUILD"`; compare all generated files byte-for-byte with `assets/images/generated`, then remove only the validated `chrnx-character.*` directory.
- [ ] Set `PROBE_DIR="$(mktemp -d "${TMPDIR%/}/chrnx-character-http.XXXXXX")"` and `POST_URL="$(PATH=/opt/homebrew/opt/docker/bin:$PATH npx wp-env run cli -- wp eval '$p=get_posts(array("post_type"=>"post","post_status"=>"publish","posts_per_page"=>1,"meta_key"=>"_chrnx_fixture_key")); echo get_permalink($p[0]);' 2>/dev/null | sed -n 's/^\(http[^[:space:]]*\).*$/\1/p' | tail -1)"`. For `/`, `/projects/`, `/music/`, `/podcasts/`, `/about/`, `/show/silicon-ranch/`, all seven topic URLs, `/?s=expressive`, and `$POST_URL`, run `curl -sS -o "$PROBE_DIR/<stable-name>.html" -w '%{http_code}' <url>` and require `200`; require `/definitely-missing-character-stage/` to return `404`. Run `! rg -n 'PHP (Warning|Notice|Fatal)|Stack trace' "$PROBE_DIR"` and `git diff --check`. Set `BASE_REF="$(git merge-base HEAD main)"`, export `git diff --name-only -z "$BASE_REF"...HEAD > "${TMPDIR%/}/chrnx-character-files.zlist"`, and pass that NUL-delimited list to an exact secrets/absolute-path scan for `api[_-]?key|secret|token|/Users/chrnx|var_dump|print_r`; require no matches. Review `console\.(log|warn|error)` separately: only the capture script's intentional CLI filename/dimension logging is allowed; production PHP/JS/CSS must contain none. Delete only the validated temp files/directories.
- [ ] Present `localhost:8888` and exact capture paths for human visual approval before local merge. Do not push, deploy, or publish.
@@ -0,0 +1,63 @@
# CHRNX Character-Led Sections Design
## Objective
Make the approved CHRNX alter ego the consistent visual anchor of every major section. The character must read as part of the identity, not as a small decoration, while content remains readable and standard WordPress data remains portable.
## Shared composition
Every major section opening uses the same visual grammar:
- a contained editorial frame with text occupying roughly 55–60% and one primary alter ego occupying 40–45% on desktop;
- a visible upper-body or three-quarter portrait anchored to the bottom edge, never reduced to a corner thumbnail or hidden behind a content card;
- one theme-aware color wash, halo, collage texture, and grounded shadow behind the portrait;
- clear separation between foreground character, atmospheric graphic layer, and readable content;
- text first and the complete character below it on mobile, with no overlap, clipping, or horizontal overflow;
- responsive AVIF/WebP markup, intrinsic dimensions, and lazy loading below the fold.
The visual effect follows the approved mockup: distressed character cutout, colored ambient field, soft depth, and graphic fragments behind the person. It does not create a generic rectangular image gallery.
## Surface mapping
- Home Projects and Projects: Code is the primary character. Research may appear only as a lower-opacity depth layer.
- Home Music and Music: the isolated musician is primary. The No Names collage is an atmospheric layer behind the character and remains secondary.
- Podcasts landing and the real `/show/silicon-ranch/` taxonomy archive: Podcasts is the primary character, fully visible above and beside podcast content. The unused insertable `podcast-show` pattern remains available but is not treated as a public page until real Buzzsprout/show data is supplied. Episode cards must never cover or compress the character.
- About: Life is the primary character. Literature and Gaming become a later secondary facets gallery, not coequal hero figures.
- Topic archives: the current topic's mapped character is primary. A show archive maps its art to Podcasts while preserving the show name as its title. Unknown contexts retain a labeled hero and an accessible decorative CSS fallback.
- Journal cards and individual post cards continue to use featured media or CSS topic fallbacks; alter egos are not repeated on every card.
## Title alignment
Primary visible titles are centered consistently:
- page and single-post H1;
- archive and search H1;
- landing-page primary H2 when the page template already supplies the semantic H1;
- topic-hero primary title.
Metadata, paragraphs, project names, release names, card titles, form labels, and internal section headings retain natural reading alignment. Centering must not reduce the post reading measure or disturb metadata wrapping.
## Podcast repair
The latest-podcast card must keep a viable text column at every supported width. Its media and copy use `minmax(0, ...)`, bounded media dimensions, and content-aware stacking. Long titles and excerpts must wrap normally; no narrow vertical strip, clipping, or hidden text is allowed.
## Accessibility and performance
- Decorative portraits use empty alternative text and `aria-hidden`; meaningful Music artwork keeps its approved alternative text.
- Text contrast remains WCAG 2.2 AA in explicit light and dark themes.
- No content is communicated only by the portrait or by color.
- No new eager below-fold image requests.
- Reduced motion produces the same static composition.
- The existing responsive derivative pipeline is reused; source PNG/JPEG files are never overwritten.
## Acceptance criteria
- Every mapped surface visibly uses the correct primary character at comparable prominence.
- Character width is 35–48% of its desktop frame and at least 62% of the available mobile frame where art is present.
- The portrait face, torso, and defining prop remain visible; no card covers the primary portrait.
- Music collage remains behind the isolated musician.
- About opens with Life and renders Literature/Gaming only in a secondary facets region.
- Main titles are centered according to the title-alignment matrix; internal/card titles are not globally centered.
- Podcast cards preserve at least a practical 28ch text measure on desktop and stack without clipping on mobile.
- Light/dark at 375, 768, 1440, and 2560 have no horizontal overflow or content overlap.
- Existing keyboard, no-JavaScript, theme-preference, permalink, and WCAG tests remain green.