/* ==========================================================
   Webcabulaire — feuille de style globale
   Les variables (tokens) en haut pilotent tout le design.
   ========================================================== */
:root {
  --bg: #fbf8f3;
  --bg-2: #f3eee5;
  --surface: #ffffff;
  --ink: #1b1a22;
  --muted: #6a6676;
  --line: #e7e0d4;
  --brand: #5b3df5;
  --brand-2: #7c63ff;
  --brand-soft: #ece8ff;
  --on-brand: #ffffff;

  --html: #ff6b3d;
  --html-soft: #ffe9e1;
  --css: #2f7cf6;
  --css-soft: #e3eeff;
  --js: #e6a800;
  --js-soft: #fff3cc;
  --ok: #1f9d63;
  --danger: #e5484d;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(27, 26, 34, .06), 0 2px 8px rgba(27, 26, 34, .05);
  --shadow: 0 10px 30px rgba(27, 26, 34, .10);
  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 68px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121118;
  --bg-2: #1a1923;
  --surface: #1e1d28;
  --ink: #f1eff7;
  --muted: #a29fb2;
  --line: #2f2d3c;
  --brand: #8b78ff;
  --brand-2: #a597ff;
  --brand-soft: #2a2548;
  --on-brand: #121118;
  --html-soft: #3a2218;
  --css-soft: #17263f;
  --js-soft: #3a2f0c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.65;
  background: var(--bg); color: var(--ink);
  transition: background-color .3s, color .3s;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { line-height: 1.1; letter-spacing: -.02em; margin: 0 0 .5em; font-weight: 750; }
h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
code, kbd, pre { font-family: var(--mono); font-size: .88em; }
:not(pre) > code { background: var(--bg-2); border: 1px solid var(--line); padding: .1em .4em; border-radius: 6px; }
kbd { background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px; padding: .05em .45em; border-radius: 6px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--brand); color: var(--on-brand); padding: 10px 16px; border-radius: 10px; z-index: 999; transition: top .2s; }
.skip-link:focus { top: 12px; }

/* ---------- Mise en page ---------- */
.container { width: min(1140px, 100% - 40px); margin-inline: auto; }
.section { padding: clamp(56px, 8vw, 104px) 0; }
.section.alt { background: var(--bg-2); }
.eyebrow { display: inline-flex; gap: .5em; align-items: center; font-family: var(--mono); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--brand); font-weight: 600; margin-bottom: 14px; }
.lead { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--muted); max-width: 62ch; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stack > * + * { margin-top: 1em; }
.center { text-align: center; margin-inline: auto; }
.section-head { max-width: 720px; margin-bottom: 40px; }
.section-head.center .lead { margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .25s, box-shadow .25s;
}
.site-header.scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 24px rgba(27,26,34,.05); }
.site-header .container { height: 100%; display: flex; align-items: center; gap: 24px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; letter-spacing: -.03em; color: var(--ink); text-decoration: none; }
.logo-mark { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; width: 28px; height: 28px; }
.logo-mark i { border-radius: 4px; }
.logo-mark i:nth-child(1) { background: var(--html); }
.logo-mark i:nth-child(2) { background: var(--css); }
.logo-mark i:nth-child(3) { background: var(--js); }
.logo-mark i:nth-child(n+4) { background: var(--ink); opacity: .12; }
.logo-mark i:nth-child(5) { background: var(--brand); opacity: 1; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 550; font-size: .95rem; padding: 8px 12px; border-radius: 999px; transition: color .2s, background .2s; }
.nav a:hover { color: var(--ink); background: var(--bg-2); }
.nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.icon-btn { width: 42px; height: 42px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: grid; place-items: center; transition: transform .2s, background .2s; font-size: 1.1rem; }
.icon-btn:hover { transform: translateY(-1px); background: var(--bg-2); }
.burger { display: none; }
.scroll-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--html), var(--css), var(--js)); z-index: 100; }

@media (max-width: 1040px) {
  .burger { display: grid; margin-left: auto; }
  .nav { position: fixed; inset: var(--header-h) 0 auto 0; flex-direction: column; align-items: stretch; background: var(--bg); padding: 12px 20px 24px; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); transform: translateY(-12px); opacity: 0; visibility: hidden; transition: .25s; margin: 0; }
  .nav.open { transform: none; opacity: 1; visibility: visible; }
  .nav a { padding: 14px 12px; font-size: 1.05rem; }
  .nav .icon-btn { align-self: flex-start; margin-top: 8px; }
}

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .55em; font: inherit; font-weight: 650; font-size: 1rem; padding: .8em 1.35em; border-radius: 999px; border: 2px solid transparent; cursor: pointer; text-decoration: none; transition: transform .18s, box-shadow .18s, background .18s, color .18s, border-color .18s; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 40%, transparent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px color-mix(in srgb, var(--brand) 50%, transparent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { font-size: .88rem; padding: .5em 1em; }

/* ---------- Cartes, puces, couches ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); }
.pill { display: inline-flex; align-items: center; gap: .4em; font-size: .78rem; font-weight: 650; padding: .2em .7em; border-radius: 999px; background: var(--bg-2); color: var(--muted); border: 1px solid var(--line); font-family: var(--mono); }
.l-html { --c: var(--html); --cs: var(--html-soft); }
.l-css { --c: var(--css); --cs: var(--css-soft); }
.l-js { --c: var(--js); --cs: var(--js-soft); }
.layer-tag { display: inline-flex; align-items: center; gap: .4em; font-family: var(--mono); font-size: .76rem; font-weight: 700; padding: .2em .65em; border-radius: 6px; background: var(--cs); color: var(--c); letter-spacing: .02em; }
:root[data-theme="light"] .l-js .layer-tag, :root:not([data-theme]) .l-js .layer-tag { color: #8a6500; }
.layer-tag::before { content: ""; width: .5em; height: .5em; border-radius: 50%; background: var(--c); }
.layer-card { border-top: 5px solid var(--c); }

/* ---------- Blocs de code ---------- */
.codebox { background: #17161d; color: #e9e7f3; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid #2b2937; }
.codebox-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: #1f1e27; border-bottom: 1px solid #2b2937; flex-wrap: wrap; }
.codebox-tab { font: 600 .78rem var(--mono); color: #a9a6ba; background: transparent; border: 0; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.codebox-tab:hover { color: #fff; }
.codebox-tab[aria-selected="true"] { background: #2d2b3b; color: #fff; }
.codebox-tab[data-lang="html"][aria-selected="true"] { box-shadow: inset 0 -2px var(--html); }
.codebox-tab[data-lang="css"][aria-selected="true"] { box-shadow: inset 0 -2px var(--css); }
.codebox-tab[data-lang="js"][aria-selected="true"] { box-shadow: inset 0 -2px var(--js); }
.codebox .copy { margin-left: auto; font: 600 .75rem var(--mono); color: #a9a6ba; background: transparent; border: 1px solid #353347; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.codebox .copy:hover { color: #fff; border-color: #6a6685; }
.codebox pre { margin: 0; padding: 16px 18px; overflow: auto; font-size: .84rem; line-height: 1.65; tab-size: 2; max-height: 420px; }
.tk-tag { color: #ff8c6b; } .tk-attr { color: #ffd479; } .tk-str { color: #9be29b; }
.tk-com { color: #7c7a8f; font-style: italic; } .tk-kw { color: #c3a6ff; } .tk-num { color: #7cc4ff; }
.tk-fn { color: #7cc4ff; } .tk-prop { color: #7cc4ff; } .tk-sel { color: #ffb86b; } .tk-at { color: #c3a6ff; }

/* ---------- Encadrés ---------- */
.callout { display: flex; gap: 14px; padding: 18px 20px; border-radius: var(--radius-sm); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.callout .ico { font-size: 1.3rem; line-height: 1.4; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn { background: var(--js-soft); border-color: color-mix(in srgb, var(--js) 40%, transparent); }
.callout.ok { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #d9d6e6; padding: 56px 0 32px; margin-top: 0; }
:root[data-theme="dark"] .site-footer { background: #0b0a10; }
.site-footer a { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 32px; }
.footer-grid h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: #8f8ca3; font-family: var(--mono); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer-grid a { text-decoration: none; opacity: .9; }
.footer-grid a:hover { text-decoration: underline; }
.footer-bottom { margin-top: 36px; padding-top: 20px; border-top: 1px solid #2c2a3a; font-size: .85rem; color: #8f8ca3; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.site-footer .logo { color: #fff; }

/* ---------- Apparition au scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Toast global (copie, etc.) ---------- */
.sys-toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: .92rem; opacity: 0; pointer-events: none; transition: .3s; z-index: 200; box-shadow: var(--shadow); }
.sys-toast.show { opacity: 1; transform: translate(-50%, 0); }

.to-top { position: fixed; right: 20px; bottom: 20px; z-index: 60; opacity: 0; transform: translateY(16px); pointer-events: none; transition: .3s; background: var(--brand); color: var(--on-brand); border: 0; box-shadow: var(--shadow); }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }

@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  body { font-size: 16.5px; }
}
@media (min-width: 861px) and (max-width: 1060px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

.btn-lg { font-size: 1.1rem; padding: .9em 1.7em; }
.btn-light { background: #fff; color: #1b1a22; }

/* Évite tout défilement horizontal parasite (les éléments inclinés ou en grille) */
body { overflow-x: clip; }
.grid > *, .layers-grid > *, .dom-lab > *, .box-lab > *, .flex-lab > *, .evt-lab > *, .pagemap > *, .gen-body > *, .sb > *, .hero-grid > * { min-width: 0; }
