/* Design Patterns : feuille de style unique.
   Le thème suit le système ; <html data-theme="light|dark"> force un choix. */

:root {
  color-scheme: light dark;

  --bg: light-dark(#f7f7fd, #0d1122);
  --surface: light-dark(#ffffff, #151b31);
  --sunken: light-dark(#eef0fa, #1d2542);
  --ink: light-dark(#17203a, #e8eaf6);
  --muted: light-dark(#56607a, #9aa4c2);
  --line: light-dark(#dfe2f1, #2a3355);

  /* Chaque famille de patterns a un dégradé : une couleur de départ et une d'arrivée.
     --cat / --cat-end désignent la famille de la page courante. */
  --creation: light-dark(#4338ca, #9d9bff);
  --creation-end: light-dark(#c026d3, #f0a3ff);
  --structure: light-dark(#0a7568, #4fd1bd);
  --structure-end: light-dark(#1d6fd8, #7cc4ff);
  --behavior: light-dark(#be185d, #ff8fc7);
  --behavior-end: light-dark(#e2600a, #ffb27a);
  --cat: var(--creation);
  --cat-end: var(--creation-end);
  --grad: linear-gradient(120deg, var(--cat), var(--cat-end));
  --rainbow: linear-gradient(120deg, var(--creation), var(--behavior) 55%, var(--behavior-end));
  --glow: color-mix(in srgb, var(--cat) 28%, transparent);
  --tint: linear-gradient(120deg, color-mix(in srgb, var(--cat) 14%, var(--surface)), color-mix(in srgb, var(--cat-end) 9%, var(--surface)));

  --code-bg: light-dark(#f3f4fb, #0a0e1c);
  --t-kw: light-dark(#6d28d9, #c4a7ff);
  --t-str: light-dark(#0f6b63, #7ee2b8);
  --t-com: light-dark(#6f7890, #7a84a0);
  --t-num: light-dark(#b93d0a, #ffb27a);
  --t-ty: light-dark(#1d4ed8, #7cc4ff);
  --t-fn: light-dark(#a61e6e, #ff8fd0);
  --t-var: light-dark(#8a5a00, #ffd479);
  --t-dec: light-dark(#0e7490, #67e8f9);

  --prose: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;

  --topbar: 3.5rem;
  --radius: 12px;
  --radius-small: 8px;
  --pill: 99px;
}
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

/* Les variables dérivées (--grad, --glow, --tint) sont redéclarées pour suivre la famille. */
.cat-c, .cat-s, .cat-b {
  --grad: linear-gradient(120deg, var(--cat), var(--cat-end));
  --glow: color-mix(in srgb, var(--cat) 28%, transparent);
  --tint: linear-gradient(120deg, color-mix(in srgb, var(--cat) 14%, var(--surface)), color-mix(in srgb, var(--cat-end) 9%, var(--surface)));
}
.cat-c { --cat: var(--creation); --cat-end: var(--creation-end); }
.cat-s { --cat: var(--structure); --cat-end: var(--structure-end); }
.cat-b { --cat: var(--behavior); --cat-end: var(--behavior-end); }

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar) + 1rem); scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font: 1rem/1.5 var(--ui);
  /* Deux halos de couleur fixes derrière le contenu. */
  background:
    radial-gradient(60rem 40rem at 100% -10%, color-mix(in srgb, var(--cat) 16%, transparent), transparent 70%),
    radial-gradient(50rem 36rem at -10% 110%, color-mix(in srgb, var(--cat-end) 13%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cat); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html:not(.js) .js-only { display: none; }

.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: 0.5rem 0.75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-small); }
.skip:focus { top: 0.5rem; }

.icon { flex: none; font-style: normal; }

/* Texte en dégradé. Les emojis restent en dehors de cet élément, sinon ils deviennent transparents. */
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.btn { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.5rem 1.1rem; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); font: 600 0.9rem/1.4 var(--ui); text-decoration: none; cursor: pointer; transition: translate 0.15s, box-shadow 0.15s, border-color 0.15s; }
.btn:hover { border-color: var(--cat); translate: 0 -2px; box-shadow: 0 6px 18px var(--glow); }
.btn.primary { border-color: transparent; background: var(--grad) border-box; color: var(--bg); box-shadow: 0 4px 14px var(--glow); }

.icon-btn { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; transition: rotate 0.3s, border-color 0.15s; }
.icon-btn:hover { border-color: var(--cat); }
#theme-btn:hover { rotate: 25deg; }

/* ---------- Barre du haut ---------- */

.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 0.75rem; height: var(--topbar); padding: 0 1rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(12px); }

/* Le filet arc-en-ciel sert de barre de lecture : il se remplit à mesure que la page défile.
   Sans prise en charge du défilement piloté par CSS, il reste simplement plein. */
.topbar::after { content: ''; position: absolute; inset: auto 0 -1px; height: 3px; background: var(--rainbow); transform-origin: left; }
@supports (animation-timeline: scroll()) {
  .topbar::after { animation: read-progress linear both; animation-timeline: scroll(root); }
}
@keyframes read-progress { from { scale: 0 1; } to { scale: 1 1; } }

.brand { display: flex; align-items: center; gap: 0.6rem; margin-right: auto; font-weight: 800; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 10px; background: var(--rainbow); color: var(--bg); font-size: 0.8rem; rotate: -6deg; box-shadow: 0 4px 12px color-mix(in srgb, var(--behavior) 35%, transparent); transition: rotate 0.2s, scale 0.2s; }
.brand:hover .brand-mark { rotate: 6deg; scale: 1.08; }
.brand-name { background: var(--rainbow); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 1.05rem; }

.lang-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--sunken); font-size: 0.8rem; font-weight: 700; }
.lang-switch a { padding: 0.25rem 0.7rem; border-radius: var(--pill); color: var(--muted); text-decoration: none; transition: color 0.15s; }
.lang-switch a:hover { color: var(--ink); }
.lang-switch a[aria-current] { background: var(--rainbow); color: var(--bg); }

/* Bouton de thème : il montre le thème vers lequel on bascule (lune en clair, soleil en sombre). */
.icon-sun { display: none; }
:root[data-theme='dark'] .icon-sun { display: block; }
:root[data-theme='dark'] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .icon-sun { display: block; }
  :root:not([data-theme='light']) .icon-moon { display: none; }
}

/* Affichés seulement quand le sommaire est replié (voir « Écrans étroits »). */
.menu-btn, .search-btn { display: none; }

/* ---------- Mise en page à trois colonnes ---------- */

.layout { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr) 14rem; max-width: 90rem; margin: 0 auto; }
main { min-width: 0; padding: 2rem clamp(1rem, 4vw, 3.5rem) 4rem; container: main / inline-size; }
.doc { max-width: 46rem; }

.sidebar, .toc { position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto; padding: 1.25rem 1rem 3rem; font-size: 0.9rem; }
.sidebar { border-right: 1px solid var(--line); }

/* ---------- Sommaire ---------- */

.sidebar { padding: 0 0 3rem; background: color-mix(in srgb, var(--surface) 45%, transparent); scrollbar-width: thin; }

/* La recherche reste en haut du sommaire quand il défile. */
.search { position: sticky; top: 0; z-index: 1; padding: 1rem 1rem 0.7rem; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); }
.search input { width: 100%; padding: 0.55rem 3.4rem 0.55rem 2.3rem; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.search input:focus { outline: 0; border-color: var(--cat); box-shadow: 0 0 0 3px var(--glow); }
.search .search-icon { position: absolute; left: 1.75rem; top: calc(1rem + 0.72rem); color: var(--muted); pointer-events: none; }
.search kbd { position: absolute; right: 1.6rem; top: calc(1rem + 0.62rem); padding: 0 0.35rem; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font: 0.7rem var(--ui); pointer-events: none; }

.nav { padding: 0 0.8rem; }
.nav a { position: relative; display: flex; align-items: center; gap: 0.55rem; padding: 0.35rem 0.6rem; border-radius: var(--radius-small); color: var(--muted); text-decoration: none; transition: translate 0.15s, background 0.15s, color 0.15s; }
.nav a:hover { color: var(--ink); background: var(--sunken); translate: 3px 0; }
.nav a[aria-current] { color: var(--ink); font-weight: 700; background: var(--tint); }
.nav-name { margin-right: auto; }
.nav .nav-home { margin-bottom: 0.3rem; padding-block: 0.5rem; color: var(--ink); font-weight: 700; }

/* Une famille : un bloc légèrement teinté, son titre, puis ses patterns le long d'un rail. */
.nav-group { margin-top: 0.7rem; padding: 0.35rem; border-radius: var(--radius); background: color-mix(in srgb, var(--cat) 7%, transparent); }
.nav h2 { margin: 0; font-size: inherit; }
.nav h2 a { color: var(--ink); font-weight: 700; }
.nav-count { padding: 0 0.5rem; border-radius: var(--pill); background: color-mix(in srgb, var(--cat) 20%, transparent); color: var(--cat); font-size: 0.72rem; font-weight: 700; }
.nav ol { margin: 0.15rem 0 0.2rem 1.2rem; padding: 0 0 0 0.6rem; list-style: none; border-left: 2px solid color-mix(in srgb, var(--cat) 28%, var(--line)); }
.nav-num { color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums; opacity: 0.8; }
/* La page en cours est marquée par une pastille posée sur le rail. */
.nav ol a[aria-current]::before { content: ''; position: absolute; top: 50%; left: calc(-0.6rem - 5px); width: 8px; height: 8px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat) 25%, transparent); translate: 0 -50%; }
.nav ol a[aria-current] .nav-num { color: var(--cat); opacity: 1; }
.no-result { padding: 0 1.4rem; color: var(--muted); }

/* ---------- Table des matières ---------- */

.toc { padding-left: 0.25rem; scrollbar-width: thin; }
.toc-card { padding: 0.9rem 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 65%, transparent); }
.toc h2 { display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.6rem 0.2rem; font-size: 0.82rem; }

/* Un rail vertical relie les sections : pastille vide à venir, pleine une fois passée, en dégradé pour celle en cours. */
.toc ol { position: relative; margin: 0; padding: 0 0 0 1rem; list-style: none; }
.toc ol::before { content: ''; position: absolute; top: 0.8rem; bottom: 0.8rem; left: 3px; width: 2px; border-radius: 2px; background: var(--line); }
.toc a { position: relative; display: flex; align-items: baseline; gap: 0.45rem; padding: 0.32rem 0.5rem; border-radius: var(--radius-small); color: var(--muted); font-size: 0.85rem; line-height: 1.35; text-decoration: none; transition: color 0.15s, background 0.15s; }
.toc a::before { content: ''; position: absolute; top: 0.72rem; left: -1rem; width: 8px; height: 8px; border: 2px solid var(--line); border-radius: 50%; background: var(--bg); transition: scale 0.2s, background 0.2s, border-color 0.2s; }
.toc a:hover { color: var(--ink); background: var(--sunken); }
.toc a.is-past { color: var(--ink); }
.toc a.is-past::before { border-color: var(--cat); background: var(--cat); }
.toc a[aria-current] { color: var(--ink); font-weight: 700; background: var(--tint); }
.toc a[aria-current]::before { border-color: transparent; background: var(--grad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat) 25%, transparent); scale: 1.2; }
.toc .icon { font-size: 0.82rem; }

/* ---------- Contenu ---------- */

.doc { font: 1.08rem/1.7 var(--prose); }
.doc h1, .doc h2, .doc h3 { font-family: var(--ui); line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
.doc h1 { margin: 0.4rem 0 0.6rem; font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -0.03em; }
.doc h1 .icon { display: inline-block; animation: hello 0.9s ease 0.2s both; }
@keyframes hello { 0% { scale: 0.3; rotate: -30deg; } 55% { scale: 1.2; rotate: 12deg; } 100% { scale: 1; rotate: 0deg; } }
.doc h2 { margin: 2.8rem 0 0.7rem; padding-top: 1.3rem; border-top: 2px solid; border-image: linear-gradient(90deg, var(--cat), var(--cat-end) 35%, transparent 80%) 1; font-size: 1.45rem; }
.doc h3 { margin: 1.6rem 0 0.4rem; font-size: 1.1rem; }
.doc p, .doc ul, .doc ol { margin: 0 0 1rem; }
.doc li { margin: 0.3rem 0; }
.doc li::marker { color: var(--cat); font-weight: 700; }
.doc a:not(.btn) { text-decoration-color: var(--cat); text-underline-offset: 0.18em; }
.doc :not(pre) > code { padding: 0.1em 0.4em; border-radius: 6px; background: color-mix(in srgb, var(--cat) 12%, var(--sunken)); font: 0.85em var(--mono); overflow-wrap: anywhere; }

.crumbs { font: 0.85rem var(--ui); color: var(--muted); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1.2rem; padding: 0; list-style: none; }
.crumbs li { margin: 0; }
.crumbs li + li::before { content: '/'; margin-right: 0.4rem; }

.doc-meta { display: inline-block; margin: 0; padding: 0.2rem 0.8rem; border-radius: var(--pill); background: var(--tint); font: 600 0.85rem var(--ui); color: var(--cat); }
.aka { margin: 0; font: 0.9rem var(--ui); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.4rem; }

.balance { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.balance > div { padding: 1rem 1.2rem; border: 1px solid var(--line); border-top-width: 3px; border-radius: var(--radius); background: var(--surface); }
.balance .pros { border-top-color: var(--structure); }
.balance .cons { border-top-color: var(--behavior-end); }
.balance h3 { margin-top: 0; }
.balance ul { margin: 0; padding-left: 1.2rem; }

details { margin-bottom: 0.6rem; padding: 0 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details[open] { border-color: var(--cat); }
summary { padding: 0.7rem 0; font: 600 1rem var(--ui); cursor: pointer; }
summary::marker { color: var(--cat); }
details p { color: var(--muted); }

/* Cartes des patterns (accueil et pages de famille) */
.family h3 a { color: var(--cat); }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.9rem; padding: 0; list-style: none; }
.lessons li { position: relative; margin: 0; padding: 1rem 1rem 0.9rem; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: translate 0.18s, box-shadow 0.18s, border-color 0.18s; }
.lessons li::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--grad); }
.lessons li:hover { translate: 0 -4px; border-color: var(--cat); box-shadow: 0 10px 26px var(--glow); }
.lessons a { display: flex; align-items: baseline; gap: 0.5rem; font: 700 1.05rem var(--ui); text-decoration: none; }
/* Toute la carte est cliquable. */
.lessons a::after { content: ''; position: absolute; inset: 0; }
.lessons .icon { font-size: 1.3rem; transition: rotate 0.2s, scale 0.2s; }
.lessons li:hover .icon { rotate: -12deg; scale: 1.25; }
.lesson-num { flex: none; order: 3; margin-left: auto; color: var(--cat); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.lessons p { margin: 0.4rem 0 0; color: var(--muted); font: 0.88rem/1.5 var(--ui); }

/* ---------- Accueil ---------- */

/* Comme le lecteur, les blocs de l'accueil dépassent la colonne de texte pour occuper la largeur disponible. */
.hero, .page-hero, .stats, .families, .method, .table-wrap, .home .lessons, .category .lessons,
.duo, .checks, .balance, .code, .doc-end, .callout, details { width: min(100cqi, 62rem); }

.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 2.5rem; align-items: center; padding: 0.5rem 0 1rem; }
.hero h1 { margin-top: 0.8rem; font-size: clamp(1.9rem, 3.3vw, 2.7rem); }
.hero-lead { color: var(--muted); font-size: 1.2rem; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1.4rem 0 0; padding: 0; list-style: none; font: 600 0.8rem var(--ui); }
.chips li { display: flex; align-items: center; gap: 0.4rem; margin: 0; padding: 0.2rem 0.7rem; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); }

/* La grille d'icônes : un raccourci vers chaque pattern, teinté par sa famille. */
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.6rem; }
.icon-grid a { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid color-mix(in srgb, var(--cat) 35%, var(--line)); border-radius: var(--radius); background: var(--tint); font-size: 1.5rem; text-decoration: none; transition: scale 0.18s, rotate 0.18s, box-shadow 0.18s; animation: float 5s ease-in-out infinite; animation-delay: calc(var(--i) * -0.45s); }
.icon-grid a:hover { scale: 1.18; rotate: -8deg; box-shadow: 0 8px 22px var(--glow); animation-play-state: paused; }
@keyframes float { 50% { translate: 0 -5px; } }

.doc .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; margin: 1.2rem 0 0; padding: 0; list-style: none; font-family: var(--ui); }
.stats li { margin: 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stats b { display: block; width: fit-content; font-size: 2.2rem; font-weight: 800; line-height: 1.15; }
.stats span { color: var(--muted); font-size: 0.88rem; }

.families, .method { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; padding: 0; list-style: none; font-family: var(--ui); }
.families li { position: relative; margin: 0; padding: 1.1rem 1.2rem; border: 1px solid color-mix(in srgb, var(--cat) 35%, var(--line)); border-radius: var(--radius); background: var(--tint); transition: translate 0.18s, box-shadow 0.18s; }
.families li:hover { translate: 0 -4px; box-shadow: 0 10px 26px var(--glow); }
.families .icon { display: block; font-size: 1.9rem; }
.families a { color: var(--cat); font-size: 1.1rem; font-weight: 700; text-decoration: none; }
.families a::after { content: ''; position: absolute; inset: 0; }
.families small { display: block; color: var(--muted); }
.families p { margin: 0.5rem 0 0; font-size: 0.9rem; line-height: 1.5; }

.method { counter-reset: method; }
.method li { margin: 0; padding: 1rem 1.2rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 0.93rem; line-height: 1.55; counter-increment: method; }
.method li::before { content: counter(method); display: block; width: fit-content; margin-bottom: 0.2rem; background: var(--rainbow); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 2.2rem; font-weight: 800; line-height: 1.15; }

/* ---------- Page 404 ---------- */

.not-found { width: min(100cqi, 62rem); max-width: none; padding-top: 1rem; text-align: center; }
.not-found-code { display: flex; align-items: center; justify-content: center; gap: 0.05em; margin: 0; font: 800 clamp(5.5rem, 20vw, 10rem) / 1 var(--ui); letter-spacing: -0.04em; }
/* La boussole du milieu cherche son chemin. */
.not-found-code .icon { font-size: 0.72em; animation: lost 4s ease-in-out infinite; }
@keyframes lost { 0%, 100% { rotate: -25deg; } 50% { rotate: 25deg; } }
.not-found .hero-lead { max-width: 34rem; margin-inline: auto; }
.not-found .actions { justify-content: center; }
.not-found h2 { border-image: linear-gradient(90deg, transparent, var(--cat), var(--cat-end), transparent) 1; }
.not-found .icon-grid { max-width: 27rem; margin: 1.2rem auto 2rem; }
.not-found .families { text-align: left; }

/* ---------- Pages de pattern ---------- */

.page-hero .doc-meta { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.page-hero .aka { margin-bottom: 0.4rem; }
.doc > .chips { margin: 1rem 0 0; }
.chips .icon { font-size: 0.95rem; }
.chips a { text-decoration: none; }

/* Problème puis solution, l'un sous l'autre : deux cartes, l'avant et l'après. */
.duo { display: grid; gap: 1rem; margin-top: 2rem; }
.duo section { padding: 1.2rem 1.4rem; border: 1px solid var(--line); border-top-width: 3px; border-radius: var(--radius); background: var(--surface); }
.duo section:first-child { border-top-color: var(--behavior-end); }
.duo section:last-child { border-top-color: var(--structure); }
.duo h2 { margin: 0 0 0.5rem; padding: 0; border: 0; font-size: 1.2rem; }
.duo p { margin: 0; }

.doc .callout { padding: 1.1rem 1.4rem; border-radius: var(--radius); background: var(--tint); box-shadow: inset 4px 0 var(--cat); font-size: 1.12rem; font-style: italic; }

.doc .checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.7rem; padding: 0; list-style: none; font: 0.95rem/1.5 var(--ui); }
.checks li { display: flex; gap: 0.65rem; margin: 0; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.checks li::before { content: '✓'; flex: none; display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--grad); color: var(--bg); font-size: 0.8rem; font-weight: 800; }

/* ---------- Pages de famille ---------- */

/* Bandeau aux couleurs de la famille, avec un halo décoratif dans le coin. */
.page-hero { position: relative; display: flex; align-items: center; gap: 1.5rem; padding: 1.6rem 1.8rem; overflow: hidden; border: 1px solid color-mix(in srgb, var(--cat) 35%, var(--line)); border-radius: calc(var(--radius) + 4px); background: var(--tint); }
.page-hero::after { content: ''; position: absolute; top: -5rem; right: -4rem; width: 15rem; height: 15rem; border-radius: 50%; background: var(--grad); opacity: 0.22; filter: blur(14px); }
.page-hero-icon { font-size: 4.2rem; line-height: 1; animation: hello 0.9s ease 0.2s both; }
.page-hero h1 { margin: 0 0 0.3rem; }
.page-hero .hero-lead { margin: 0; }
.doc .cat-intro { margin-top: 1.5rem; }
.category .stats { grid-template-columns: repeat(3, 1fr); }
.category .families { grid-template-columns: repeat(2, 1fr); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-family: var(--ui); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; line-height: 1.5; }
th { padding: 0.7rem 1rem; background: var(--tint); color: var(--cat); font-size: 0.8rem; text-align: left; white-space: nowrap; }
td { padding: 0.7rem 1rem; border-top: 1px solid var(--line); vertical-align: top; }
td:first-child { font-weight: 700; white-space: nowrap; }
td:first-child a { text-decoration: none; }
tbody tr:hover td { background: var(--sunken); }

@container main (max-width: 40rem) {
  .page-hero { flex-direction: column; align-items: flex-start; gap: 0.6rem; padding: 1.2rem; }
  .category .families { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; gap: 1.5rem; }
  .home .stats { grid-template-columns: repeat(2, 1fr); }
  .families, .method { grid-template-columns: 1fr; }
}

.doc-end { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-family: var(--ui); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pager a { padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; transition: translate 0.15s, box-shadow 0.15s, border-color 0.15s; }
.pager a:hover { border-color: var(--cat); translate: 0 -3px; box-shadow: 0 8px 22px var(--glow); }
.pager a[rel='next'] { text-align: right; }
.pager small { display: block; color: var(--muted); }
/* Retour en haut : bouton flottant en bas à droite, visible une fois la page descendue. */
.to-top { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 30; display: grid; place-items: center; width: 2.9rem; height: 2.9rem; border-radius: 50%; background: var(--grad); color: var(--bg); box-shadow: 0 8px 22px var(--glow); transition: opacity 0.2s, translate 0.2s, visibility 0.2s; }
.to-top:hover { translate: 0 -3px; }
.js .to-top:not(.is-visible) { opacity: 0; visibility: hidden; translate: 0 10px; }


/* ---------- Schéma animé ---------- */

/* Cadre à bordure en dégradé : un fond uni dans la zone de contenu, le dégradé sous la bordure. */
.player { padding: 1rem; border: 2px solid transparent; border-radius: calc(var(--radius) + 4px); background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box; box-shadow: 0 10px 30px var(--glow); font-family: var(--ui); }
.player-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.player-bar .icon-only { justify-content: center; width: 2.6rem; height: 2.6rem; padding: 0; color: var(--cat); }
.player-bar .icon-only.primary { width: 3.1rem; height: 3.1rem; color: var(--bg); }
.player-bar .icon-only:hover:not(:disabled) .player-icon { scale: 1.15; }
.player-icon { transition: scale 0.15s, rotate 0.4s; }
#player-reset:hover .player-icon { rotate: -360deg; }
/* Le bouton de lecture porte les deux icônes ; une seule est visible selon son état. */
.icon-pause, .is-playing .icon-play { display: none; }
.is-playing .icon-pause { display: block; }
.icon-compress, .player:fullscreen .icon-expand { display: none; }
.player:fullscreen .icon-compress { display: block; }
.player-bar .icon-only:disabled { opacity: 0.45; cursor: default; translate: none; box-shadow: none; }
.player-speed { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.player-speed select { padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); }

/* Le plan de travail : un papier pointillé, comme une feuille de conception. */
.stage { border: 1px solid var(--line); border-radius: var(--radius); background-color: var(--bg); background-image: radial-gradient(color-mix(in srgb, var(--cat) 30%, var(--line)) 1.2px, transparent 1.2px); background-size: 20px 20px; }
.stage svg { display: block; width: 100%; height: auto; }

.node-body { transition: opacity 0.4s, transform 0.4s; transform-box: fill-box; transform-origin: center; }
.node.is-hidden .node-body { opacity: 0; transform: scale(0.55); }
.node rect { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; transition: stroke-width 0.3s; }
.node text { fill: var(--ink); font: 600 13px var(--ui); }
.node.k-client rect { stroke: var(--structure); fill: color-mix(in srgb, var(--structure) 14%, var(--surface)); }
.node.k-iface rect { stroke: var(--cat); stroke-dasharray: 6 4; }
.node.k-data rect { stroke: var(--behavior-end); fill: color-mix(in srgb, var(--behavior-end) 14%, var(--surface)); }
.node.is-active rect { stroke: var(--cat); stroke-width: 3; stroke-dasharray: none; filter: drop-shadow(0 0 8px var(--glow)); }
.node.is-pulsing .node-body { animation: pulse 0.55s ease; }
@keyframes pulse { 40% { transform: scale(1.14); } }
.trail { stroke: var(--muted); stroke-opacity: 0.4; stroke-width: 1.5; stroke-dasharray: 4 5; }
.message { stroke: var(--cat); stroke-width: 2.4; color: var(--cat); filter: drop-shadow(0 0 5px var(--glow)); }
.message-label rect { fill: var(--cat); }
.message-label text { fill: var(--bg); font: 600 12px var(--mono); }

.player-note { min-height: 3.2em; margin: 0.75rem 0 0; padding: 0.6rem 0.9rem; border-radius: var(--radius-small); background: var(--tint); font-size: 0.95rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; margin: 0.6rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.8rem; }
.legend li { margin: 0; }
.legend li::before { content: ''; display: inline-block; width: 0.9rem; height: 0.65rem; margin-right: 0.4rem; border: 1.5px solid var(--muted); border-radius: 3px; vertical-align: -1px; }
.legend .k-client::before { border-color: var(--structure); }
.legend .k-iface::before { border-color: var(--cat); border-style: dashed; }
.legend .k-data::before { border-color: var(--behavior-end); }

.steps { margin: 1rem 0 0; padding-left: 2rem; font-size: 0.93rem; line-height: 1.5; }

/* Colonne assez large : le schéma à gauche, les étapes à droite, le tout sur un seul écran.
   Le lecteur dépasse alors la colonne de texte et prend toute la largeur disponible.
   La liste des étapes prend la hauteur du schéma et défile à l'intérieur. */
@container main (min-width: 40rem) {
  .js .player { display: grid; grid-template-columns: minmax(0, 1fr) clamp(13rem, 30%, 16rem); gap: 1rem; width: min(100cqi, 62rem); }
  .js .player-steps { position: relative; }
  .js .steps { position: absolute; inset: 0; margin: 0; overflow-y: auto; scrollbar-width: thin; font-size: 0.86rem; }
}
.steps li { margin: 0.1rem 0; padding: 0.25rem 0.6rem; border-radius: var(--radius-small); }
.js .steps li { color: var(--muted); cursor: pointer; }
.js .steps li:hover { color: var(--ink); background: var(--sunken); }
.js .steps li[aria-current] { color: var(--ink); background: var(--tint); }

/* Plein écran : le lecteur occupe tout l'écran et le schéma grandit pour remplir la hauteur. */
.player:fullscreen { width: 100vw; height: 100vh; padding: 1.5rem; overflow: auto; border: 0; border-radius: 0; background: var(--bg); box-shadow: none; }
.player:fullscreen .player-note { font-size: 1.15rem; }
@media (min-width: 46rem) {
  .player:fullscreen { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1.5rem; }
  .player:fullscreen .player-view { display: flex; flex-direction: column; min-height: 0; }
  .player:fullscreen .stage { flex: 1; min-height: 0; overflow: hidden; }
  .player:fullscreen .stage svg { min-width: 0; height: 100%; }
  .player:fullscreen .player-steps { position: relative; }
  .player:fullscreen .steps { position: absolute; inset: 0; margin: 0; overflow-y: auto; scrollbar-width: thin; font-size: 1.05rem; }
}

/* ---------- Exemples de code ---------- */

/* Une fenêtre d'éditeur : onglets de langage, barre de fichier, puis le code avec ses numéros de ligne. */
.code { overflow: hidden; border: 1px solid var(--line); border-radius: calc(var(--radius) + 2px); background: var(--code-bg); box-shadow: 0 10px 30px var(--glow); font-family: var(--ui); }
.tabs { display: flex; gap: 0.3rem; padding: 0.5rem; overflow-x: auto; scrollbar-width: none; background: var(--sunken); }
.tabs [role='tab'] { display: flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.85rem; border: 0; border-radius: var(--pill); background: none; color: var(--muted); font-weight: 600; font-size: 0.88rem; white-space: nowrap; cursor: pointer; transition: color 0.15s, background 0.15s; }
.tabs [role='tab']:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.lang-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; }

.panel + .panel { border-top: 1px solid var(--line); }
.js .panel { display: none; border-top: 0; }
.panel-title { margin: 0; padding: 0.9rem 1rem 0; }
.js .panel-title { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }

.panel-bar { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.8rem 0.55rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }
.window-dots { display: flex; gap: 0.35rem; }
.window-dots i { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--behavior); }
.window-dots i:nth-child(2) { background: var(--behavior-end); }
.window-dots i:nth-child(3) { background: var(--structure); }
.file-name { color: var(--ink); font: 600 0.82rem var(--mono); }
.line-count { margin-right: auto; }
.copy { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); color: var(--ink); font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.copy:hover { border-color: var(--cat); color: var(--cat); }
.copy.is-done { border-color: var(--structure); color: var(--structure); }

pre { display: flex; margin: 0; max-height: 38rem; overflow: auto; scrollbar-width: thin; font: 0.82rem/1.65 var(--mono); tab-size: 4; }
pre code { flex: 1; padding: 1rem 1.2rem 1.2rem 0.9rem; }
/* La colonne des numéros reste collée à gauche quand le code défile horizontalement. */
.gutter { position: sticky; left: 0; flex: none; padding: 1rem 0.8rem 1.2rem 1rem; border-right: 1px solid var(--line); background: var(--code-bg); color: var(--t-com); text-align: right; user-select: none; }
.t-kw { color: var(--t-kw); font-weight: 600; }
.t-str { color: var(--t-str); }
.t-com { color: var(--t-com); font-style: italic; }
.t-num { color: var(--t-num); }
.t-ty { color: var(--t-ty); }
.t-fn { color: var(--t-fn); }
.t-var { color: var(--t-var); }
.t-dec { color: var(--t-dec); }

/* ---------- Écrans étroits ---------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 17.5rem minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .layout { display: block; }
  .menu-btn, .search-btn { display: grid; }
  .topbar { gap: 0.5rem; }
  .balance, .pager { grid-template-columns: 1fr; }

  /* Liens du sommaire assez hauts pour le doigt. */
  .nav a { padding-block: 0.6rem; }

  /* Le schéma garde une taille lisible : il défile horizontalement au lieu de rétrécir. */
  .player { padding: 0.6rem; }
  /* Le mot « Vitesse » est masqué à l'écran pour que la barre tienne sur une ligne. */
  .player-speed span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .stage { overflow-x: auto; }
  .stage svg { min-width: 34rem; }

  /* Avec JavaScript, le sommaire devient un panneau latéral ; sans, il s'affiche sous le contenu. */
  html:not(.js) .layout { display: flex; flex-direction: column; }
  html:not(.js) .sidebar { position: static; order: 1; height: auto; border: 0; border-top: 1px solid var(--line); }
  .js .sidebar { position: fixed; left: 0; z-index: 60; width: min(19rem, 88vw); background: var(--surface); visibility: hidden; translate: -100% 0; transition: translate 0.2s, visibility 0.2s; }
  /* À l'ouverture, la visibilité change tout de suite : le champ de recherche peut recevoir le curseur. */
  .js .nav-open .sidebar { visibility: visible; translate: 0 0; transition: translate 0.2s; }
  .scrim { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 0.45); }
}

/* Très petits écrans : il ne reste que le logo, pour laisser la place aux boutons. */
@media (max-width: 30rem) {
  .topbar .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Généré par build.mjs à partir de LANGS */
html[data-lang="python"] .panel[data-lang="python"],
html[data-lang="typescript"] .panel[data-lang="typescript"],
html[data-lang="java"] .panel[data-lang="java"],
html[data-lang="csharp"] .panel[data-lang="csharp"],
html[data-lang="php"] .panel[data-lang="php"],
html[data-lang="go"] .panel[data-lang="go"]{display:block}
html[data-lang="python"] .tabs [role=tab][data-lang="python"],
html[data-lang="typescript"] .tabs [role=tab][data-lang="typescript"],
html[data-lang="java"] .tabs [role=tab][data-lang="java"],
html[data-lang="csharp"] .tabs [role=tab][data-lang="csharp"],
html[data-lang="php"] .tabs [role=tab][data-lang="php"],
html[data-lang="go"] .tabs [role=tab][data-lang="go"]{color:var(--ink);background:var(--surface);box-shadow:0 2px 8px var(--glow)}
