Origami Hero System
This skill is the distilled front-end system from the 38 commits that rebuilt
nirvana-website (upstream PR #1, head 8151cad). It lets you reproduce the
exact architecture and motion while swapping in completely different
artwork, colours, type, copy or device styling.
The quality bar is: at first paint the page is calm and fully readable; then a single clock drives one continuous formation — particles assemble into the artwork, a layered mandala unfolds behind it, the device frame wipes in, the copy and navigation settle on the same spring, and the page below dissolves in without a single seam. Nothing janks, nothing flashes on hydration, and reduced -motion users get the settled final state immediately.
Repo note. This site runs a breaking-change Next.js 16.4.6. Before writing code in this repository, read the relevant guide in
node_modules/next/dist/docs/(resolved from this file's directory). Heed deprecation notices.AGENTS.mdis regenerated bynext dev— commit it with your work.
The composition (four layers, one clock)
.hero
├─ .hero-phone ← device layer (pointer-events: none)
│ ├─ .hero-phone__glow warm halo, fades in with settled device
│ ├─ .hero-phone__fade edge dissolves (exact --warm-paper colour)
│ ├─ .hero-phone__shadow neutral shadow, separate from clipped frame
│ └─ .hero-phone__screen
│ ├─ .hero-phone__screen-fill tint rides in WITH the card, never ahead
│ └─ .hero-art__stage square, aspect-ratio:1, no distortion
│ ├─ <BinaryChakra/> z0 vector mandala (CSS rotation)
│ ├─ .hero-art__occluder z1 silhouette mask — hides mandala gaps
│ └─ <canvas> z2 WebGL particle sculpture
│ └─ .hero-phone__frame z4 bezel, clip-path left-to-right wipe
│ └─ .hero-phone__notch
└─ .hero-shell → <HeroTextReveal/> copy and CTAs on the same clock
heroTimeline is a single requestAnimationFrame publisher owned by
origami-hero.tsx. The mandala, header and copy subscribe to it and write
style.transform / style.opacity straight to the DOM. There is no React state
per frame and no second timer.
File map (templates are verbatim reference implementations)
| Template in this skill | Destination | Role |
|---|---|---|
templates/app/components/hero-timeline.ts | app/components/ | Shared clock + easeOutBack spring |
templates/app/components/origami-hero.tsx | app/components/ | WebGL2 particle sculpture, masks, quality tiers, rAF owner |
templates/app/components/binary-chakra.tsx | app/components/ | Nine-layer mandala, deployment + rotation |
templates/app/components/hero-text-reveal.tsx | app/components/ | Hero copy reveal on the clock |
templates/app/components/site-header.tsx | app/ | Nav reveal + accessible hamburger |
templates/app/components/icons.tsx | app/components/ | Inline SVG icons |
templates/app/page.tsx | app/ | Editorial sections + principles grid |
templates/app/site-footer.tsx | app/ | Sine-wave dot field footer |
templates/app/layout.tsx | app/ | Fonts, metadata, hydration guard, no-script fallback |
templates/app/globals.css | app/ | Full design system + every breakpoint |
templates/scripts/generate-particles.py | scripts/ | Image → particle bin + mask + occluder |
templates/scripts/cdp-screenshot.py | scripts/ | Exact-viewport screenshot / QA helper |
Start by copying the templates into the target project, then apply the swap map below. Keep the architecture and timing constants; replace only the visuals.
Workflow
- Decide the new visual. Get the source artwork (an image with the subject on a clean background) and the new palette/font/copy.
- Generate assets. Edit the
EDIT THIS BLOCKconfig at the top ofgenerate-particles.py:SOURCE,NAME,REGION,CHAKRA_CX/CY,PX_TO_NDC,PALETTE, subject-isolate thresholds andANATOMY_BLOBS. Runpython scripts/generate-particles.py. Inspect the preview PNG — the figure must be continuous, evenly dense and free of rectangular edges. - Point the component at the new assets. In
origami-hero.tsxupdateDATA_URL,MASK_URL,MASK_WIDTH/HEIGHTand any count constants. Inglobals.cssupdate the occludermask-imageURL and--screen-bg. - Re-skin the mandala. In
binary-chakra.tsxchangeRED,DEEP,LIGHT,BINARY, theRINGSschedule and the geometry helpers if a different motif is wanted. Keep the two nested<g>structure (deploy outside, rotate inside) and thechakra-glyph/chakra-detailCSS reveal hooks. - Re-skin the shell.
:roottokens inglobals.css, fonts inlayout.tsx, copy inpage.tsx/hero-text-reveal.tsx, logo SVGs inpublic/logos/. - Verify at every breakpoint with the CDP helper and the checklist below.
Visual swap map
| What to change | Where |
|---|---|
| Artwork / figure | generate-particles.py config + generated .bin files |
| Particle colour | PALETTE in generator; aColor in RECON_VS; --cardinal* tokens |
| Mask protection + gaps | *-mask.bin, *-occluder.png, .hero-art__occluder |
| Mandala colour / glyphs | RED, DEEP, LIGHT, BINARY, RINGS in binary-chakra.tsx |
| Device colour / shape | --screen-bg, .hero-phone__frame border, --phone-radius |
| Page atmosphere | --warm-paper, --fog, section[id] wash, footer gradient |
| Typography | Inter / Space_Grotesk in layout.tsx; --font-site / --font-display |
| Copy / CTAs | hero-text-reveal.tsx, page.tsx, site-header.tsx |
| Motion timing | RINGS, GROUPS, ASSEMBLY_SECONDS, SETTLE_SECONDS; keep them coordinated |
Non-negotiable rules
One clock, zero per-frame layout reads
- Only
origami-hero.tsxownsrequestAnimationFrame. Everyone else subscribes. - Read
clientWidth/clientHeight/getBoundingClientRect()only on resize, never in the frame loop. Per-frame layout reads are the main jank source. - After settling, stop the clock: drop to a ~10fps
setTimeoutfor the near-static breath and removewill-changevia thehero-settledclass. - Feature-detect capabilities once (
hardwareConcurrency,deviceMemory); sample only the deterministic prefix of the buffer for low-end/narrow devices so any prefix still reconstructs the whole figure.
WebGL particle field
- WebGL2, instanced
TRIANGLE_STRIPquads, all attributes exceptaCornerusevertexAttribDivisor(..., 1).mulberry32seed keeps start positions and seeds deterministic. - Formation: cubic Bezier from a wide ring outside the viewport to each target,
per-particle delay/flight from
aSeed,easeOutCubic, wobble that decays to a sub-pixel ambient breath so the settled figure never dissolves. - Cursor interaction is a soft radial push that is multiplied by
(1.0 - maskSample)and then re-tested against the mask: particles may never be nudged into the protected silhouette. - Two passes: a faint undersized depth pass (~0.07 reveal) and the main pass.
- Fade by proximity to target and by distance to the canvas edge — otherwise a hard rectangle appears around the formation.
- Blend
ONE, ONE_MINUS_SRC_ALPHAfor premultiplied alpha; clear to transparent. - Always
tick()the clock to completion in the fetch-failure / unsupported / reduced-motion paths so the page is never left hidden.
Mandala deployment
- Outer
<g class="chakra-deploy">is JS-driven (scale + opacity); inner<g class="chakra-ring">is CSS-rotating. Never put both transforms on one node. - Rotation starts at each ring's
rotationStartprogress by flippinganimationPlayStatefrompausedtorunning— no angular jump. - Fine detail uses
--deploy,--d,--boandclamp()so glyphs light up progressively around the circumference. Batch tiny geometry into path strings. apply(0)before subscribing; server-render rings compressed and invisible.
Seamless attachment (the detail that sells it)
--warm-papermust be the exact page background. Every dissolve overlay uses it, so the overlay is invisible over the page and only softens the device.- Desktop: bottom-only bridge
.hero::afterfades to--warm-paperwell above the boundary;section[id]opens on the same warm value with a hairline red wash. - Stacked mobile: four-edge dissolve (vertical + horizontal gradients stacked),
plus
.hero-shell::beforeas a quiet 56px bridge above the copy. - Tablet (700–900px): bottom-only bridge again, no side fades.
- Screen/frame tints and shadow arrive only at ~3300ms with the settled device — no white rectangle on first paint.
- Shadow is separate from the clipped frame so it is never cut off; it is hidden on desktop where it read as a hard bottom edge.
Responsive composition
| Width | Composition |
|---|---|
| ≥1400px | Two columns: copy column 600px, device clamp(440px,46vw,700px) |
| 901–1400px | Both sides scale together; clamp(300px,42vw,620px) device, copy min(480px,42vw) |
| 700–900px | Balanced two-column grid, bottom-only bridge, no side fade |
| <700px | Stacked: device first (order:-1), square, four-edge dissolve, copy below |
| <767px | Compact editorial: panel-style Genesis block, icon/title/desc feature rows |
| <479px | Two pills stay on one row; repo label text hidden |
Accessibility, hydration, performance
prefers-reduced-motion: draw the settled figure once, force all rings/copy/nav to final state, disable CSS animations, repaint on resize.- Server-render reveal items hidden (
style={hidden(i)}) so there is no flash before hydration; a<noscript>rule makes them visible without JS. - Strip only known extension-injected attributes (
bis_skin_checked,bis_register,cz-shortcut-listen,__processed_*__) with abeforeInteractiveNext<Script>+ short-livedMutationObserver, then disconnect at 5s. Never touch anything else in the DOM. - Hamburger: real
<button>witharia-expanded,aria-controls, labels that change Open/Close, and bars that fold into an X. Hide secondary nav at <767px. aria-hiddenon all decorative art; skip link; focus-visible outlines.- Pin Next.js and the whole lockfile; keep
cacheComponents,partialPrefetching,devIndicators: false, Tailwind v4 Turbopack rule innext.config.ts.
Provenance — what each original commit contributed
| Commit | Contribution |
|---|---|
5b6e917 | Shared hero timeline + easeOutBack spring |
1dcff15 | Shared inline GitHub / Android icons |
37e8daa | Nine-layer binary chakra mandala |
eb4628e | Staggered hero copy reveal on the clock |
ebe750f | WebGL Buddha particle hero with cursor interaction |
7d75f52 | Particle field binary consumed by the shader |
8b416f0 | Silhouette mask for shader protection |
b239a37 | White silhouette occluder image |
3194de8 | Particle/mask generator script |
5b3939d | CDP screenshot helper for viewport testing |
eeed045 | Ignore _archive |
7634cde | Security agent upgrade, hide dev indicator |
b8eeaef / 64b9215 | Next.js 16.4.6 bump and lock |
10e73d4 | Inter + Space Grotesk, no-script reveal fallback |
3a76b28 | Global styles for origami hero and new typography |
0bdc629 | Header navigation on the shared clock |
055943b | Sine-wave particle footer |
b04431b | Homepage rebuilt around origami hero + principles grid |
9f37929 / 2cef8ce | OG alt text fix, font-pairing docs |
46c9935 → 0d5f9d7 | Remove default assets and placeholder page |
dead7f5 | Responsive layout redesign, release settled animation layers |
4805c4a | Mobile-only Genesis editorial index + tagline |
192d98f | Accessible hamburger navigation |
fd7b6bb | Remove per-frame layout reads and idle animation work |
801d39a / 8151cad | Extension-attribute hydration cleanup via beforeInteractive script |
QA checklist
npm run buildandnpm run lintclean.- Run the dev server, then for each viewport
(
390x1400,768x1200,1280x900,1600x1000):python scripts/cdp-screenshot.py <w> <h> shot.png http://localhost:3000The helper forces reduced motion, reportsscrollWidthvsinnerWidthand the canvasdata-state(complete/error/unsupported). - Check: no horizontal overflow (
scrollWidth == innerWidth); no white rectangle or hard bottom edge on the device; no seam between hero and next section; headline never overlaps the device; both CTAs on one row at 390px. - Check with JS disabled: copy/nav/sections are visible.
- Check with reduced motion: figure and mandala are settled on first paint.
- Confirm
data-state="complete"and that the clock stops (no constant rAF).
Do not report done until every item passes at every viewport.