# CSS Responsive Modernization Design Spec

**Date:** 2026-03-31
**Scope:** All CSS files in `web/themes/custom/kaindl_theme/css/`

## Problem

The theme CSS has accumulated 12+ unique breakpoints across 8 files with no shared system. Media queries use a mix of `min-width`, `max-width`, and compound `min-width AND max-width` ranges, making the responsive behavior hard to reason about and maintain.

### Specific issues

1. **Near-duplicate breakpoints:** `639/640px`, `1180/1199px`, `1299/1300px` — off-by-one confusion
2. **Leaking queries:** `@media (max-width: 1280px)` in navigation.css affects mobile unintentionally
3. **Compound ranges:** `(min-width: 1025px) and (max-width: 1500px)` in megamenu.css — confusing cascade
4. **No shared breakpoint system:** each file defines its own breakpoints independently
5. **Desktop-first leftovers:** base styles assume desktop, then override for mobile with `max-width`

## Consolidated breakpoint system

| Token | Value | Purpose |
|-------|-------|---------|
| `bp-sm` | `640px` | Small mobile to larger mobile / small tablet |
| `bp-md` | `1025px` | Mobile to desktop (primary breakpoint, matches JS) |
| `bp-lg` | `1280px` | Desktop to wide desktop (nav spacing, megamenu columns) |
| `bp-xl` | `1536px` | Wide to full-width desktop |

### Merge map

| Old breakpoints | New breakpoint | Rationale |
|----------------|---------------|-----------|
| 575, 639, 640 | 640px | All target small-screen adjustments |
| 860, 899 | 640px or content-driven | Tablet-range, most rules absorbable into 640 |
| 1024, 1025 | 1025px | Already the primary mobile/desktop split |
| 1180, 1199, 1280, 1299, 1300 | 1280px | All target "narrower desktop" adjustments |
| 1400, 1420, 1440, 1500, 1536, 1680 | 1536px | All target "wide desktop" polish |

## Approach: Mobile-first with ascending min-width

```css
/* Base = mobile styles (no media query) */
.element { mobile-value; }

@media (min-width: 640px)  { /* tablet adjustments */ }
@media (min-width: 1025px) { /* desktop layout */ }
@media (min-width: 1280px) { /* wide desktop refinements */ }
@media (min-width: 1536px) { /* full-width polish */ }
```

### Rules

- **No `max-width` queries** (except `prefers-reduced-motion` and `prefers-color-scheme` which are not breakpoint-related)
- **No compound range queries** like `(min-width: X) and (max-width: Y)`
- Each breakpoint builds on the previous — ascending cascade
- Breakpoint tokens documented in `variables.css` as CSS comments (media queries cannot use custom properties)

## Files affected

### 1. variables.css
- Add breakpoint documentation block as CSS comments

### 2. header.css
- Move `@media (max-width: 1024px)` mobile styles into base (no query)
- Keep `@media (min-width: 1025px)` desktop block
- Remove redundant property resets between mobile and desktop
- Keep all compact header transitions untouched

### 3. navigation.css
- Move `@media (max-width: 1024px)` mobile sidebar/toggle styles into base
- Keep `@media (min-width: 1025px)` desktop nav block
- Convert `(min-width: 1025px) and (max-width: 1680px)` to: set smaller values in `1025px` block, override to full values in `1536px` block
- Convert `@media (max-width: 1280px)` to: set smaller padding in `1025px`, override in `1280px`
- Keep all mobile sidebar animations untouched

### 4. megamenu.css
- Convert `(min-width: 1025px) and (max-width: 1180px)` to: set 2-col/no-media-panel as default in `1025px`, show media panel in `1280px`
- Convert `(min-width: 1025px) and (max-width: 1420px)` to: 2-col default in `1025px`, 3-col in `1280px`
- Convert `(min-width: 1025px) and (max-width: 1500px)` font adjustments to: smaller fonts in `1025px`, larger in `1536px`
- Convert `@media (max-width: 1440px)` padding to: set adjusted padding in `1025px`, full padding in `1536px`
- Keep all megamenu animations and stagger transitions untouched

### 5. layout.css
- Convert `@media (max-width: 1024px)` to mobile-first base
- Keep `@media (min-width: 1280px)` as-is (already correct)

### 6. footer.css
- Convert `@media (max-width: 639px)` to mobile-first base
- Convert `@media (max-width: 899px)` to `@media (min-width: 640px)` override
- Convert `@media (max-width: 1199px)` to `@media (min-width: 1025px)` or absorb
- Convert `@media (max-width: 1299px)` to `@media (min-width: 1280px)` override

### 7. home.css (heaviest refactor — 24 media queries)
- Consolidate all queries into the 4-breakpoint system
- Map: `575/860` to `640px`, `1024/1180` to `1025px`, `1300/1400` to `1280px`, `1536` stays
- Remove duplicate/conflicting declarations

### 8. page-header.css
- Convert `@media (max-width: 640px)` to mobile-first base, override at `640px`

## Constraints

- **Keep current visual appearance** — verify at 375px, 768px, 1024px, 1280px, 1536px, 1920px
- **Do not touch animations or transitions** — all keyframes, transition properties, and timing functions stay as-is
- **Do not touch JS** — the `1025px` / `1024px` breakpoints in JS remain unchanged
- **Remove dead/duplicate CSS** found during refactoring
- **No new features** — pure refactor for maintainability

## Verification

After each file is refactored:
1. Screenshot at 375px, 768px, 1024px, 1280px, 1920px
2. Compare against pre-refactor baseline
3. Confirm no visual regressions
