> For the complete documentation index, see [llms.txt](https://fanny.gitbook.io/memo-cda/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fanny.gitbook.io/memo-cda/vocabulaire-cda/css-themes.md).

# CSS / Thèmes

### Variables CSS (custom properties)

| Terme                  | Définition                                                                                                 |
| ---------------------- | ---------------------------------------------------------------------------------------------------------- |
| `:root`                | Sélecteur ciblant la racine du document (`<html>`) — portée globale                                        |
| `--nom-variable`       | Déclare une variable CSS (custom property)                                                                 |
| `var(--nom-variable)`  | Utilise la valeur d'une variable CSS                                                                       |
| `var(--nom, repli)`    | Variable avec valeur de secours si elle n'est pas définie                                                  |
| **Custom property**    | Nom technique des variables CSS ; suit les règles de cascade/héritage comme les autres propriétés          |
| **Cascade / héritage** | Une variable définie sur `:root` est accessible partout, sauf si un sélecteur plus spécifique la redéfinit |

### Créer un thème (clair/sombre) dans `globals.css`

| Terme                                               | Définition                                                                                                                  |
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `globals.css`                                       | Fichier CSS global (souvent dans Next.js) où l'on définit `:root` et les styles de base                                     |
| `:root { --bg: #fff; --text: #111; }`               | Définit les valeurs par défaut (thème clair)                                                                                |
| `[data-theme="dark"] { --bg: #111; --text: #fff; }` | Redéfinit les mêmes variables quand l'attribut est présent (thème sombre)                                                   |
| `@media (prefers-color-scheme: dark) { ... }`       | Applique un thème selon la préférence système, en pur CSS                                                                   |
| **Design token**                                    | Nom donné aux variables qui représentent des choix de design (couleurs, espacements, rayons...) réutilisés dans toute l'app |

### Architecture à 3 fichiers (Exemple Dossier `/styles`)

Une architecture propre consiste à séparer le stockage du thème, la structure générale, et le point d'entrée global.

#### 1. `variables.css`

*Rôle : Stocke uniquement les Design Tokens (le dictionnaire des couleurs et thèmes).*

```css
/* Définition du thème par défaut (Clair) */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f4f4f9;
  --text-main: #222222;
  --text-muted: #666666;
  --accent-color: #00b0f0;
}

/* Redéfinition pour le thème Sombre */
[data-theme="dark"] {
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --text-main: #ffffff;
  --text-muted: #aaaaaa;
  --accent-color: #33c2ff;
}
```

***

<p align="center"><a href="/pages/13uxSKv7XYwnXeh3NnUr"><img src="https://img.shields.io/badge/-PR%C3%89C%C3%89DENT-2E86AB?style=for-the-badge" alt="Précédent"></a> <a href="/pages/2t2m7kTxwRaIufwgrKFz"><img src="https://img.shields.io/badge/-SUIVANT-2E86AB?style=for-the-badge" alt="Suivant"></a></p>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://fanny.gitbook.io/memo-cda/vocabulaire-cda/css-themes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
