:root {
  --bg: #080808;
  --bg-surface: #111111;
  --bg-hover: #1f1f1f;
  --text: #ffffff;
  --text-muted: #e9e9e9;
  --text-secondary: #888888;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-dim: rgba(245, 158, 11, 0.12);
  --border: #222222;
  --border-accent: rgba(245, 158, 11, 0.3);
  --radius: 8px;
  --transition: 0.18s ease;

  /* Polices : Google Fonts, chargées par les <link> du <head> de chaque page.
     Pour passer aux polices système (aucun appel à Google), remplacer par :
       --font-ui:      'Helvetica Neue', Helvetica, Arial, sans-serif;
       --font-text:    Georgia, 'Times New Roman', Times, serif;
       --font-mono:    ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
       --font-display: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif-condensed, 'Helvetica Neue', Helvetica, Arial, sans-serif;
     et supprimer les <link> Google Fonts des pages. */
  --font-ui: 'DM Sans', sans-serif;
  --font-text: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --font-display: 'Bebas Neue', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: env(safe-area-inset-bottom);
}

/* Grain léger */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

header, main, footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}

/* ── EN-TÊTE ── */
header {
  padding: 48px 0 28px;
  border-bottom: 1px solid var(--border);
}

/* Petite ligne d'étiquette (ou fil d'Ariane) au-dessus du titre */
header p:first-child,
main > p:first-child {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

header p:first-child a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--border-accent);
}

header p:first-child a:hover { color: var(--accent-hover); }

header p:first-child a:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 3px;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(52px, 17vw, 128px);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

h1 mark {
  background: none;
  color: var(--accent);
}

h1 + p {
  margin-top: 16px;
  max-width: 34rem;
  font-size: 15px;
  font-weight: 300;
  color: var(--text-muted);
}

/* Ligne de chiffres clés sous l'introduction */
header h1 + p + p {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

header h1 + p + p strong {
  font-weight: 500;
  color: var(--accent);
}

/* ── SECTIONS ── */
main {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 12px;
}

section + section,
main > nav + section { margin-top: 28px; }

h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── TEXTE COURANT (mentions légales, présentation, articles) ── */
main section > p,
main article > p,
main aside p,
main figcaption p {
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-muted);
}

main section > p { max-width: 34rem; }

main section > p + p { margin-top: 12px; }

main strong {
  font-weight: 600;
  color: var(--text);
}

main section > h3,
main article > h3 {
  margin-top: 24px;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: var(--text);
}

main section > p a,
main section > ul a,
main article a,
main aside a,
main figcaption a {
  color: var(--accent);
  text-underline-offset: 3px;
}

main section > p a:hover,
main section > ul a:hover,
main article a:hover,
main aside a:hover,
main figcaption a:hover { color: var(--accent-hover); }

main section > p a:focus-visible,
main section > ul a:focus-visible,
main article a:focus-visible,
main aside a:focus-visible,
main figcaption a:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 3px;
}

/* ── ARTICLE LONG : titres, rythme vertical ── */
main article > * + * { margin-top: 14px; }

main article > h2 {
  display: block;
  margin-top: 44px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
  overflow-wrap: anywhere;
}

main article > h2::after { content: none; }

main article > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

main article > h3 { margin-top: 28px; }

main article > h2 + *,
main article > h3 + * { margin-top: 12px; }

main > aside:first-child + article { margin-top: 28px; }
main > article + aside { margin-top: 44px; }
main > aside + section { margin-top: 28px; }

/* ── LISTES (puces ambre) ── */
main article ul,
main aside ul,
main section > ul {
  list-style: none;
  display: grid;
  gap: 6px;
}

main article li,
main aside li,
main section > ul > li {
  position: relative;
  padding-left: 18px;
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-muted);
}

main article li::before,
main aside li::before,
main section > ul > li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Liste de sources : plus discrète */
main section > ul > li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ── ENCADRÉS (<aside>) ── */
main aside {
  padding: 16px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* « En bref » : premier élément de la page */
main > aside:first-child { border-left: 3px solid var(--accent); }

main aside h2 { margin-bottom: 10px; }

main aside p + p,
main aside p + ul { margin-top: 10px; }

/* Mouvements à risque / signes d'alerte : encadré dans l'article */
main article aside {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.25);
  border-left: 3px solid #ef4444;
}

main article aside strong { color: #f87171; }

/* ── FIGURE (schéma + légende) ── */
main figure {
  display: grid;
  gap: 20px;
  align-items: center;
  padding: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

main figure svg {
  width: 100%;
  max-width: 180px;
  height: auto;
  justify-self: center;
}

main figcaption p {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
}

main figcaption ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 14px;
}

main figcaption li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-secondary);
}

main figcaption li::before { content: none; }

main figcaption li svg {
  width: 8px;
  height: 8px;
  max-width: none;
  flex-shrink: 0;
  justify-self: auto;
}

/* ── TABLEAUX ── */
main table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.55;
}

main th {
  padding: 10px 14px;
  text-align: left;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

main td {
  padding: 12px 14px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

main td:first-child {
  width: 24%;
  font-weight: 500;
  color: var(--text);
}

main tbody tr:last-child td { border-bottom: none; }

main td strong {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ── LIENS EN GROS BOUTONS (liste de liens dans un <nav>) ── */
nav ul {
  list-style: none;
  display: grid;
  gap: 10px;
  counter-reset: entree;
}

nav li { display: grid; counter-increment: entree; }

main nav a {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 16px;
  align-items: center;
  min-height: 84px;
  padding: 16px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition),
              transform var(--transition), box-shadow var(--transition);
}

main nav a::before {
  content: counter(entree, decimal-leading-zero);
  grid-row: 1 / 3;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

main nav a::after {
  content: '→';
  grid-row: 1 / 3;
  grid-column: 3;
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--accent);
  transition: transform var(--transition);
}

main nav a h3 {
  grid-column: 2;
  grid-row: 1;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.04em;
}

main nav a p {
  grid-column: 2;
  grid-row: 2;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
  color: var(--text-secondary);
}

main nav a:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.12);
}

main nav a:hover::after { transform: translateX(4px); }

main nav a:active { transform: translateY(0); }

main nav a:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 3px;
}

/* Une liste d'un seul lien = le bouton principal, plein (guide, retour, application) */
main nav li:only-child a {
  grid-template-columns: 1fr auto;
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

main nav li:only-child a::before { content: none; }

main nav li:only-child a h3,
main nav li:only-child a p { grid-column: 1; }

main nav li:only-child a::after { grid-column: 2; color: #000; }

main nav li:only-child a p { color: rgba(0, 0, 0, 0.72); }

main nav li:only-child a:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
}

/* ── PAGE D'ERREUR : un gros titre au centre ── */
main:has(> h1) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

main > h1 {
  font-size: clamp(140px, 46vw, 300px);
  line-height: 0.85;
  letter-spacing: 0.02em;
}

main > h1 mark {
  display: inline-block;
  transform-origin: 50% 60%;
  animation: bascule 2.6s ease-in-out infinite;
}

@keyframes bascule {
  0%, 100% { transform: rotate(-9deg); }
  50%      { transform: rotate(9deg) translateY(-4%); }
}

main > h1 + p { margin-left: auto; margin-right: auto; }

main:has(> h1) > nav {
  width: 100%;
  max-width: 24rem;
  margin-top: 32px;
}

/* ── PIED DE PAGE ── */
footer {
  margin-top: 28px;
  padding: 16px 0 28px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--text-secondary);
}

footer a:hover { color: var(--text); border-color: var(--text); }

footer a:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 3px;
}

/* ── GRANDS ÉCRANS ── */
@media (min-width: 600px) {
  body { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
  header { padding: 72px 0 36px; }

  main figure { grid-template-columns: 180px 1fr; gap: 28px; }

  main nav ul { grid-template-columns: 1fr 1fr; }
  main nav li:only-child { grid-column: 1 / -1; }

  main nav li:not(:only-child) a { grid-template-columns: 1fr auto; grid-template-rows: auto auto 1fr; align-content: start; align-items: start; min-height: 140px; }
  main nav li:not(:only-child) a::before { grid-row: 1; grid-column: 1; align-self: start; }
  main nav li:not(:only-child) a::after { grid-row: 1; grid-column: 2; align-self: start; }
  main nav li:not(:only-child) a h3 { grid-column: 1 / 3; grid-row: 2; align-self: end; margin-top: 18px; font-size: 34px; }
  main nav li:not(:only-child) a p { grid-column: 1 / 3; grid-row: 3; }
}

/* ── PETITS ÉCRANS : tableaux empilés (une ligne = un bloc) ── */
@media (max-width: 599px) {
  main table, main tbody, main tr, main td { display: block; }

  main thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  main tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  main tbody tr:last-child { border-bottom: none; }

  main td { padding: 3px 0; border: none; width: auto; }

  main td:first-child {
    width: auto;
    padding-bottom: 6px;
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: 0.04em;
    color: var(--text);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
