# Round 09 — Mobile-First CSS Strategy + RTL

**Date**: 2026-04-30
**Time**: 30 min (of 2h)
**Status**: ✅ COMPLETE
**Round Type**: Critical Path — CSS architecture

---

## 🎯 שאלה מרכזית

**איך master.css עובד מצוין ב-mobile/iPad/desktop ב-RTL מלא, בלי כפילויות?**

---

## 🏆 Verdict: 3 breakpoints + Logical Properties + Container Queries

**Mobile-first** · 3 ε-points · CSS Logical Properties (`margin-inline-start` במקום `margin-left`) · Container queries לcomponents.

---

## 📐 ה-3 Breakpoints

```css
/* Mobile-first base — אין media query */
:root {
  --container-padding: 16px;
  --grid-cols: 1;
  --headline-size: 28px;
  --body-size: 16px;
}

/* Tablet — 768px+ */
@media (min-width: 768px) {
  :root {
    --container-padding: 24px;
    --grid-cols: 2;
    --headline-size: 36px;
  }
}

/* Desktop — 1024px+ */
@media (min-width: 1024px) {
  :root {
    --container-padding: 32px;
    --grid-cols: 3;
    --headline-size: 48px;
  }
}

/* Wide — 1440px+ (אופציונלי) */
@media (min-width: 1440px) {
  :root {
    --container-padding: 48px;
    --grid-cols: 4;
  }
}
```

**אזולאי כותב CSS פעם אחת**. כל component משתמש ב-`var(--grid-cols)` — אין `@media` בכל component.

---

## 🌐 RTL — Automatic via Logical Properties

```css
/* ❌ ישן — שובר ב-RTL */
.card { margin-left: 16px; padding-right: 24px; }

/* ✅ מודרני — RTL automatic */
.card { margin-inline-start: 16px; padding-inline-end: 24px; }
```

**קווי המתאר**:
- `margin-left` → `margin-inline-start`
- `margin-right` → `margin-inline-end`
- `padding-left/right` → `padding-inline-start/end`
- `border-left/right` → `border-inline-start/end`
- `text-align: left` → `text-align: start`
- `transform: translateX(20px)` → ⚠️ עדיין צריך `dir`-aware (אין logical equivalent ב-CSS)

ה-`<html dir="rtl">` משנה את כל הlogical הללו אוטומטית. **0 שורות JS, 0 כפילות CSS**.

---

## 🎁 Container Queries — הקסם החדש

```css
/* רכיב מודע לרוחב ה-CONTAINER שלו, לא רוחב המסך */
.context-card-grid {
  container-type: inline-size;
  display: grid;
  gap: 16px;
}

@container (inline-size < 480px) {
  .context-card-grid {
    grid-template-columns: 1fr;
  }
}

@container (inline-size >= 480px) {
  .context-card-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@container (inline-size >= 800px) {
  .context-card-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
```

**תחנות-מתי?**
- Drawer 50% נפתח על דסקטופ → grid יודע שהcontainer ~600px → 2 cols
- Drawer 92% נפתח → ~900px → 3 cols
- כל זה **בלי שינוי ב-A2UI** — ה-LLM לא צריך לדעת על rendering width!

זה ה-**holy grail** של responsive: רכיב יודע לרנדר נכון בכל container בלי breakpoints גלובליים.

תמיכה ב-2026: Chrome 105+, Safari 16+, Firefox 110+ (בעצם **הכל**).

---

## 🎨 Mobile-First Cascading

```css
/* Default — mobile */
.press-flow-stepper {
  font-size: 11px;
  padding: 12px;
  gap: 8px;
  flex-direction: column;  /* vertical on mobile */
}

@media (min-width: 768px) {
  .press-flow-stepper {
    font-size: 13px;
    padding: 16px;
    gap: 16px;
    flex-direction: row;  /* horizontal on tablet+ */
  }
}
```

מובייל מקבל **את הכי פחות סטיילים**. כל הוספה היא enhancement.

---

## 🌗 Dark Mode

```css
/* Light mode — default */
:root {
  --bg-page: var(--paper-100);
  --text-primary: var(--ink-900);
  --hairline: rgba(20,20,19,0.08);
}

/* Dark mode — based on user preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: var(--ink-900);
    --text-primary: var(--paper-100);
    --hairline: rgba(255,255,255,0.08);
  }
}

/* Manual override (user choice) */
[data-theme="dark"] {
  --bg-page: var(--ink-900);
  --text-primary: var(--paper-100);
}
```

ה-LLM שולח `theme.mode: "dark"` ב-A2UI → renderer מוסיף `data-theme="dark"` על root. **0 changes ב-CSS** — הקובץ אותו קובץ.

---

## 📱 Touch Targets

iOS HIG דורש מינימום **44×44px** למגע. Material 3 דורש **48×48px**.

```css
:root {
  --touch-min: 44px;
}

button, [role="button"], .clickable {
  min-block-size: var(--touch-min);
  min-inline-size: var(--touch-min);
  /* iOS: ביטל highlight כחול-default */
  -webkit-tap-highlight-color: transparent;
}
```

---

## ⚡ Performance Optimizations

### 1. CSS containment
```css
.article-card {
  contain: layout paint style;  /* רכיב לא יוצר re-layout בstu */
}
```

### 2. content-visibility (נטען רק כשנראה)
```css
.context-card-list > * {
  content-visibility: auto;
  contain-intrinsic-size: 100px 200px;  /* placeholder size */
}
```

### 3. font-display
```css
@font-face {
  font-family: 'Frank Ruhl Libre';
  src: url('https://assets.clastop.app/fonts/frank-ruhl-libre-900.woff2') format('woff2');
  font-display: swap;  /* מציג fallback מיד */
}
```

### 4. transform/opacity only (animations)
```css
.context-card.entering {
  /* רק transform + opacity = GPU only, 60 FPS guaranteed */
  transform: translateY(10px);
  opacity: 0;
  animation: fadeIn 0.3s var(--ease-smooth) forwards;
}
```

---

## 🎯 הקובץ הסופי — `master.css`

```
/master.css (~80KB total, gzipped ~15KB)
├── @font-face (4 fonts)                                 ~1KB
├── :root tokens (L1+L2+L4 ~400 vars)                   ~6KB
├── @media base styles (mobile-first)                    ~15KB
├── @media tablet (min-width: 768px)                     ~5KB
├── @media desktop (min-width: 1024px)                   ~8KB
├── @container queries (per-component)                   ~12KB
├── @media prefers-color-scheme: dark                    ~5KB
├── Component classes (Card, Stack, BottomSheet, ...)    ~25KB
└── Animations (@keyframes, transitions)                 ~3KB
```

`/tenant-{slug}.css` (~2KB, gzipped ~500 bytes) — רק 10-30 token overrides.

**Total CSS network cost**: ~15-17KB gzipped first-load · cached forever after.

---

## 📊 Browser Support Matrix (May 2026)

| Feature | Chrome | Firefox | Safari | iOS Safari |
|---|---|---|---|---|
| CSS Variables | ✅ all | ✅ all | ✅ 9.1+ | ✅ 9.3+ |
| Logical Properties | ✅ 89+ | ✅ 41+ | ✅ 14.1+ | ✅ 14.5+ |
| Container Queries | ✅ 105+ | ✅ 110+ | ✅ 16+ | ✅ 16.4+ |
| `:has()` selector | ✅ 105+ | ✅ 121+ | ✅ 15.4+ | ✅ 15.4+ |
| `view-transition-name` | ✅ 111+ | ❌ | ✅ 18+ | ✅ 18.2+ |
| `accent-color` | ✅ 93+ | ✅ 92+ | ✅ 15.4+ | ✅ 15.4+ |
| OKLCH colors | ✅ 111+ | ✅ 113+ | ✅ 15.4+ | ✅ 15.4+ |
| `subgrid` | ✅ 117+ | ✅ 71+ | ✅ 16+ | ✅ 16+ |

✅ **כל הfeatures שאני משתמש בהם נתמכים ב-95%+ של ה-traffic ב-2026**.

---

## ✅ Closure

- [x] 3 breakpoints (768/1024/1440)
- [x] Logical Properties (RTL automatic)
- [x] Container Queries (per-component responsive)
- [x] Mobile-first cascade
- [x] Dark mode (auto + manual)
- [x] Touch targets (44px iOS HIG)
- [x] Performance (containment, content-visibility, font-display)
- [x] Browser support matrix verified

✅ **Round 09 closed.**

---

## 🛣️ Next: Round 10 — POC Architecture (file tree + sequence diagram)
