# Site Responsive Rules

Rules for making public-site Blade components (`resources/views/components/site/**`) responsive.
Figma designs are drawn for **desktop / big desktop**; these rules derive the tablet and mobile
versions so every section scales the same way.

Tokens live in `resources/css/site/` (typography, spacing, layout). Use only those tokens — the
rules below are written in them.

Reference implementation: `resources/views/components/site/home/hero.blade.php` (and the site header/footer in `components/site/layout/`).

---

## 1. Breakpoints (screen tiers)

Write classes **mobile-first**: the bare class is the mobile value, then override upward.

| Tier          | Width         | Prefix    | Notes                                            |
| ------------- | ------------- | --------- | ------------------------------------------------ |
| Mobile        | `< 768px`     | _(none)_  | One column, touch, thumb reach                   |
| Tablet        | `768–1023px`  | `md:`     | Still mostly stacked; touch                      |
| Desktop       | `1024–1535px` | `lg:`     | **The Figma design** — multi-column layouts start |
| Big desktop   | `≥ 1536px`    | `2xl:`    | Same as desktop; `site-container` caps at 1488px |

- The desktop values from Figma go on `lg:`. Never let the mobile value leak into desktop — desktop
  must look exactly like the design.
- `sm:` (640px) and `xl:` (1280px) are not tiers. Don't use them unless a layout truly breaks
  between tiers (and say why in a comment).
- Big desktop needs no overrides by default: the container cap keeps line lengths and proportions
  the same. Don't scale type up past the design.

---

## 2. Font sizes

Headings step **down the scale** on smaller screens. Small text never shrinks.

| Designed as | Mobile        | Tablet (`md:`) | Desktop (`lg:`) | Class string                          |
| ----------- | ------------- | -------------- | --------------- | ------------------------------------- |
| `text-h1` 49 | `text-h3` 31 | `text-h2` 39   | `text-h1` 49    | `text-h3 md:text-h2 lg:text-h1`       |
| `text-h2` 39 | `text-h4` 25 | `text-h3` 31   | `text-h2` 39    | `text-h4 md:text-h3 lg:text-h2`       |
| `text-h3` 31 | `text-h4` 25 | `text-h3` 31   | `text-h3` 31    | `text-h4 md:text-h3`                  |
| `text-h4` 25 | `text-h5` 20 | `text-h4` 25   | `text-h4` 25    | `text-h5 md:text-h4`                  |
| `text-h5` 20 | `text-body` 16 | `text-h5` 20 | `text-h5` 20    | `text-body md:text-h5`                |
| `text-h6` / `text-body` / `text-sm` / `text-xs` | same | same | same | no override            |

Why: a 39–49px heading on a 360px screen fits 2–3 Arabic words per line and pushes content below
the fold. One step down keeps the hierarchy while fitting the width. Body and small text are
already at the readability floor, so they stay fixed.

**Readability floor:** `text-xs` (10.4px) is only for short labels — badges, chips, counters,
meta lines (name/job), stat captions (≤ ~5 words). If the design sets a **paragraph** in `text-xs`,
raise it on touch screens: `text-sm lg:text-xs`.

---

## 3. Font weight

Only two weights exist: `font-regular` (400, the default) and `font-bold` (700).
`font-medium`, `font-semibold`, etc. do **not** exist in the site theme.

- Weight **never changes between breakpoints**. Hierarchy on small screens comes from size and
  spacing, not from swapping weights.
- `font-bold`: headings that the design bolds, numbers/stats, names, labels, counters.
- Body paragraphs stay regular. Avoid bold for text longer than ~2 lines (heavy Cairo blocks are
  hard to read on mobile).

---

## 4. Line height

Only two line-height tokens exist:

| Token              | Value | Use                    |
| ------------------ | ----- | ---------------------- |
| `leading-heading`  | 1.1   | headings (`text-h*` already include it) |
| `leading-body`     | 1.4   | paragraphs (`text-body/sm/xs` already include it) |

- The `text-*` tokens carry their own line height, so usually **no `leading-*` class is needed**.
- A heading that wraps to 3+ lines on mobile may use `leading-body` for Arabic readability
  (Cairo's tall marks crowd at 1.1).
- `leading-snug`, `leading-relaxed`, `leading-normal`, `leading-tight` **compile to nothing**
  (the theme resets `--leading-*`). Don't use them.

---

## 5. Letter spacing

- **Arabic: letter-spacing is always 0.** Arabic is a connected script; any tracking breaks the
  joins between letters. Since the site defaults to Arabic, the default is `tracking-default` (0).
- `tracking-decreased` (-0.05em) / `tracking-increased` (1.5em) are not used in components. If
  ever needed for an English-only display heading, scope it: `ltr:tracking-decreased`.
- Letter spacing never changes between breakpoints.
- `tracking-tight`, `tracking-wide`, `tracking-wider` **compile to nothing**. Don't use them.

---

## 6. Spacing

Use the named tokens: `xs` 4 · `sm` 8 · `md` 16 · `lg` 32 · `xl` 64 (px). Numeric steps
(`p-6`, `gap-10`) only where the design already uses them.

| What                                   | Mobile          | Tablet (`md:`) | Desktop (`lg:`) |
| -------------------------------------- | --------------- | -------------- | --------------- |
| Section vertical padding               | `py-lg` 32      | `py-xl` 64     | `py-xl` 64      |
| Container side gutter                  | 16 (built into `site-container`) | 32 | 32       |
| Section heading → content              | `mt-lg` 32      | `mt-lg` 32     | design (e.g. `mt-10`) |
| Gap between stacked cards / grid cols  | `gap-md` 16     | `gap-lg` 32    | design (e.g. `gap-10`) |
| Card inner padding (design 24px)       | `p-md` 16       | `p-6` 24       | `p-6` 24        |
| Card inner padding (design 40px)       | `p-md` 16 / `py-lg` 32 | `p-10` 40 | `p-10` 40     |
| Inner element gaps (`gap-sm`, `gap-md`) | same            | same           | same            |

Rule of thumb: **outer spacing halves on mobile, inner spacing stays.** Sections and cards lose
breathing room on small screens; the spacing between a label and its value doesn't.

---

## 7. Layout

- Multi-column grids start at `lg:` (`lg:grid-cols-12` + `lg:col-span-*`). Below that, stack in
  DOM order — put the most important content first in the markup.
- **Every grid sets its mobile columns explicitly**: `grid grid-cols-1 … lg:grid-cols-12`, never
  bare `grid`. Without a template the implicit column is `auto` and grows to its widest child's
  content — a slider/scroll strip (all slides side by side) makes the whole section wider than the
  screen and cuts it off. `grid-cols-1` is `minmax(0, 1fr)`, which caps it to the screen.
- Grid/flex children that hold sliders, scroll strips, long words or URLs get `min-w-0`.
- Tablet may use 2 columns for **repeated items** (cards, stats, logos): `md:grid-cols-2`, then
  the design's count at `lg:`.
- Fixed media heights scale down: design `h-82` (328px) → `h-56 md:h-72 lg:h-82`.
- No horizontal page scroll at 360px. Sections using `data-reveal="fade-start|fade-end"` (which
  slide sideways) get `overflow-x-clip` on the `<section>`.
- Text containers keep a readable measure: `max-w-3xl` for centered headings/intro text.

---

## 8. Touch & interaction

- Primary tap targets (arrows, buttons, menu toggles) are **≥ 40px** (`size-10`), ideally 44px
  (`size-11`).
- Secondary small controls (slider dots, pagination pips) are **≥ 24px** (WCAG 2.5.8): a
  `h-6 min-w-6` button wrapping the small visual `<span>`, styled with `group-data-*` / `group-*`.
- Hover styles are fine but must never be the only way to reveal content or actions.
- Swipeable sliders keep their arrows/dots visible on mobile — swipe isn't discoverable alone.

---

## 9. Checklist for a component

1. Desktop (`lg:`) still matches Figma exactly.
2. Headings use the class strings from §2; small text untouched; paragraphs not below `text-sm` on touch.
3. No dead classes (`leading-snug/relaxed/normal`, `tracking-tight/wide`, `font-medium`).
4. Outer spacing per §6; inner gaps unchanged.
5. Grids start with `grid-cols-1` and stack below `lg:`; slider/scroll children have `min-w-0`; media heights scale.
6. Tap targets ≥ 40px (primary) / ≥ 24px (dots, pips).
7. Checked at 360, 768, 1024, 1536px, in both `ar` (RTL) and `en` (LTR); no horizontal scroll.
