# Implementation Plan: Clean Theme Abstraction

## Objective
Decouple the NERV theme logic and FX from `src/gui_2.py` by introducing a semantic theme layer in `src/theme_2.py`. This will remove scattered `is_nerv_active()` checks and keep the ImGui hierarchy clean.

## Key Files & Context
- `src/theme_2.py`: The primary theming interface.
- `src/gui_2.py`: The main GUI module containing the "cruft".
- `src/theme_nerv.py` & `src/theme_nerv_fx.py`: NERV-specific colors and effects.
- `src/imgui_scopes.py`: Context managers for ImGui scopes.

## Implementation Steps

### Phase 1: Semantic Theme Layer Foundations
- [ ] Task: In `src/theme_2.py`, define semantic color functions (e.g., `ai_text_color()`, `alert_color()`, `warning_color()`) that return theme-specific colors.
- [ ] Task: In `src/theme_2.py`, implement context manager helpers (e.g., `ai_text_style()`, `alert_style()`) that wrap `imscope.style_color`.
- [ ] Task: In `src/theme_2.py`, add a `render_post_fx(width, height, ai_status, crt_enabled)` hook that encapsulates CRT and Alert pulsing effects.
- [ ] Task: Move `CRTFilter`, `AlertPulsing`, and `StatusFlicker` instances from `App` class to `src/theme_2.py` (private module state).

### Phase 2: Refactor `gui_2.py`
- [ ] Task: In `gui_2.py`, remove all NERV-specific filter/flicker/alert instances from `__init__`.
- [ ] Task: In `_gui_func`, replace the NERV FX rendering block with a single call to `theme.render_post_fx()`.
- [ ] Task: Systematically replace scattered `if is_nerv_active(): push_style_color(...)` blocks with the new semantic style context managers.
- [ ] Task: Standardize status indicators (e.g., "PIPELINE PAUSED", "LIVE") to use semantic theme colors rather than manual `vec4` overrides.

### Phase 3: Verification & Cleanup
- [ ] Task: Run the custom AST linter to ensure no unclosed scopes were introduced during refactoring.
- [ ] Task: Run fast render tests to ensure UI stability.
- [ ] Task: Verify that both NERV and standard themes still render correctly (visual verification).

## Verification & Testing
- **AST Linting**: `uv run python scripts/check_imgui_scopes.py src/gui_2.py`
- **Fast Render Tests**: `uv run pytest tests/test_gui_fast_render.py`
- **Manual Verification**: Toggle NERV theme and verify CRT filter, alert pulsing, and DATA highlights are still active and correctly colored.
