Rule handbook metadata
- Rule
DET.AMBIENT.Z_INDEX· lanedeterministic- Page status
- stale
- page_version
c85b9d27a8f29b758a41bb53c76bfb4ec754f10bf5d2ec9e8eafeebd799ea335- generated_at
- 2026-05-19T18:30:00.000Z
- registry_fingerprint
6773fda516344e110b5a7b1435e655e1264e773825ca8bbe62194189891c42ba
How this rule is fixed
Pilot deterministic fixer: handbook_after · harness mode standalone · verify expect_rule_clean.
- Harness:
apply-harness-fixture-remediation.pycopies the After example HTML from this handbook page onto the defect fixture, theninvoke-det-ruleset-remediation-verify.shre-audits and expects zero findings for this rule. - Production sites:
run-website-ux-remediation-loop.shrunshandbook_html_patch(HTML patches inlib/ux-deterministic-fixers/fixers/patches/) before invoking the Cursor agent when the quality gate still fails.
Detection module: docs/design/ux-audit/deterministic-design-rules.md#det-ambient-z-index. Scroll down for Before / After examples and Evidence and remediation steps.
Purpose
Kitchen Sink ships two ambient systems that share a stacking contract:
- Forge ambient —
.forge-ambientwith.forge-ambient-bg, optional.forge-ambient-scrim, and.forge-ambient-content(css/forge-ambient.css). - Animated backgrounds —
.ks-has-ambient-bgwith.ks-ambient-bg,.ks-ambient-bg-overlay, and.ks-content(css/ks-animated-backgrounds.css). - Living background —
#ks-living-scene/.ks-living-sceneand section-local.ks-living-sectionbands (css/ks-living-background.css).
The contract is bg at z-index 0, scrim/overlay at z-index 1, foreground content at z-index 2, and pointer-events: none on every decorative plane. Ambient layers must never intercept clicks, cover CTAs, or stack above prose and controls.
This deterministic rule samples computed styles in Playwright and flags stack inversions, elevated ambient z-index, and interactive canvases inside ambient containers.
Plan: Identify pages with ambient markup on the first screen. Do: Use KS slot classes and avoid inline z-index overrides on bg/canvas layers. Check: Run the auditor metrics phase or inspect computed z-index and pointer-events in DevTools. Adjust: Move drawing surfaces into the bg slot and wrap interactive UI in .forge-ambient-content or .ks-content.
Passing signals
.forge-ambient-bg/.ks-ambient-bg(including.ks-section-bg.ks-ambient-bgand.ks-living-scene__global.ks-ambient-bg) report z-index 0–1 andpointer-events: none.- Foreground copy and controls live in
.forge-ambient-contentor.ks-contentwith z-index ≥ 2 (or.container/.container-fluiddirect children of.ks-living-sectionat z-index 1 when the section bg is 0). - Optional scrims use
.forge-ambient-scrimor.ks-ambient-bg-overlayat z-index 1, also withpointer-events: none. #ks-living-scene/.ks-living-scenestays at z-index 0 withpointer-events: noneso the global parallax field never blocks the page.<canvas>elements inside.forge-ambient,.ks-has-ambient-bg, or.ks-living-scenesit in the bg slot at z-index 0 withpointer-events: none, or are omitted in favor of SVG loaded viadata-ks-bg-src.
Failing signals
- Ambient bg/canvas
z-index > 1(for example inlinestyle="z-index: 5"on.forge-ambient-bg). pointer-events: auto(or unset on an absolutely positioned canvas/SVG) on a decorative layer that overlaps buttons or links.- Stack inversion: ambient layer z-index ≥ content wrapper z-index inside the same
.forge-ambient/.ks-has-ambient-bg/.ks-living-sectioncontainer. - Hero markup places headings and CTAs in a bare
<div>while a canvas or bg layer sits above them in paint order. .ks-living-scenewithz-index > 0orpointer-eventsother thannone, blocking interaction with the document below.
Before example
Before (failing example)
Governed agent delivery
Clicks may hit the canvas or SVG instead of the button below.
Failing KS markup: canvas and ambient bg elevated above prose; no content wrapper; pointer events enabled on decorative layers.
After example
After (passing example)
Governed agent delivery
Ambient stays behind scrim and content; controls remain clickable.
Passing KS markup: canonical Forge ambient slots — bg 0, scrim 1, content 2 — with no pointer capture on decorative planes.
Alternative passing pattern for asset-gallery sections:
<section class="forge-section ks-has-ambient-bg ks-bg-overlay--soft">
<div class="ks-ambient-bg" data-ks-bg-src="assets/svg/bg/mesh-soft.svg" aria-hidden="true"></div>
<div class="ks-ambient-bg-overlay" aria-hidden="true"></div>
<div class="ks-content container py-5">
<h2 class="h3 mb-3">Section with animated background</h2>
<a class="btn btn-outline-primary" href="#next">Continue</a>
</div>
</section>
Evidence and remediation
Evidence: Auditor report fields ambientZIndexReport.violations[] with kinds pointer-events, z-index-high, stack-inversion, or canvas-layer. Each finding includes the offending class, computed z-index, and page URL. In DevTools, select .forge-ambient-bg / .ks-ambient-bg and confirm z-index: 0 and pointer-events: none.
Remediate (in order):
- Remove inline or custom CSS that raises ambient bg/canvas above z-index 1.
- Set
pointer-events: noneon every decorative SVG, canvas, and global living-scene root. - Wrap interactive UI in
.forge-ambient-contentor.ks-content; add.forge-ambient-scrimor.ks-ambient-bg-overlaywhen readability needs separation (seeAI.AMBIENT.READABILITY_CONFLICT). - For particle/canvas effects, mount the canvas inside the bg slot (sibling before content wrapper), not as a sibling above prose.
- Re-run
analyze-website-ux.mjsmetrics on first-screen URLs; stack inversions often co-occur with unreadable hero bands.