# CSS Z-Index & Overflow Clipping Debugging ## Symptom A dropdown, tooltip, or popup renders but is cut off / hidden behind elements below it. ## Root Cause (almost always one of these) 1. **Parent `overflow: hidden`** — the dropdown's parent container clips it via CSS overflow 2. **Missing or broken z-index** — the dropdown has no z-index, or its z-index CSS variable is undefined 3. **Stacking context** — a parent creates a new stacking context (via `position: relative + z-index`, `opacity < 1`, `transform`, `filter`, `will-change`) which limits how high the child can stack 4. **Parent position / overflow conflicts** — `position: relative` on a grandparent with `overflow: hidden` blocks absolute children even with high z-index 5. **Sibling DOM ordering** — the header wrapper has no z-index, so its sibling (main content) paints on top by default ## Diagnosis Checklist ### 1. Check parent overflow ```bash # Search for overflow:hidden on or near the dropdown's container search_files("overflow-hidden", file_glob="*.html", path="src/") search_files("overflow-hidden", file_glob="*.css", path="src/") search_files("overflow.*hidden", file_glob="*.html", path="src/") ``` ### 2. Check CSS variable definitions ```bash # If the dropdown uses a CSS variable for z-index, verify it's defined # e.g., `z-index: var(--z-critical) !important;` without `--z-critical: N;` in :root = broken search_files("--z-", file_glob="*.css", path="src/") search_files("var\(--z-", file_glob="*.html", path="src/") search_files("var\(--z-", file_glob="*.js", path="src/") ``` A CSS variable referenced but never defined evaluates to `z-index: invalid` — effectively no z-index at all. ### 3. Check the element's actual z-index In browser dev tools: inspect the dropdown → computed styles → z-index. If it says `invalid` or isn't listed, the variable isn't resolving. ### 4. Check the outer wrapper's position and z-index Even when the dropdown and its immediate parent have high z-index, the **outermost header wrapper** may lack `position: relative`, allowing the next DOM sibling (main content) to paint on top. Check: Does the `