:root {
  --bg: var(--craie-paper, #f7f4ed);
  --panel: #fffefa;
  --ink: var(--craie-ink, #273e35);
  --muted: #4d6571;
  --line: #ccd7d5;
  --accent: var(--craie-accent, #365e4e);
  --accent-soft: #e8eee5;
  --lime: var(--craie-sage, #dfe7dc);
  --red: #d63a3a;
  --black: #23272f;
  --ok: #27734f;
  --warn: #526a42;
}

* {
  box-sizing: border-box;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body, "Atkinson Hyperlegible Next", system-ui, sans-serif);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

::selection { background: var(--lime); color: var(--ink); }

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

.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link:focus {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 12px 18px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
}

main:focus { outline: none; }

h1, h2, h3, .brand .name {
  font-family: var(--font-display, "Bricolage Grotesque", sans-serif);
}

/* ---------- En-tête ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand .logo {
  width: 28px;
  height: 28px;
}

.brand .name {
  font-weight: 800;
  font-size: 24px;
}

.brand .tag {
  color: var(--muted);
  font-size: 14px;
  margin-left: 4px;
}

@media (max-width: 700px) {
  .brand .tag {
    display: none;
  }
}

.cta-small {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 9px 14px;
  min-height: 44px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.lang {
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 9px 12px;
  min-height: 44px;
  border-radius: 8px;
}

/* ---------- Mise en page ---------- */
.wrap {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
  align-items: start;
}

@media (max-width: 860px) {
  .wrap {
    grid-template-columns: minmax(0, 1fr);
  }
}

.topics {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}

@media (max-width: 860px) {
  .topics {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.topics a {
  text-decoration: none;
  color: var(--ink);
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 14px;
}

.topics a:hover {
  background: var(--accent-soft);
}

.topics a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Article ---------- */
.article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 36px 36px;
  min-width: 0;
}

@media (max-width: 600px) {
  .article {
    padding: 20px 18px 28px;
  }
}

.article h1 {
  font-size: 36px;
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.article .lead {
  font-size: 18px;
  color: var(--muted);
  margin-top: 0;
}

.article h2 {
  font-size: 22px;
  margin: 34px 0 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.article h3 {
  font-size: 17px;
  margin: 22px 0 6px;
}

.article p,
.article li {
  max-width: 72ch;
}

.article ul,
.article ol {
  padding-left: 22px;
}

.article li {
  margin: 4px 0;
}

.article code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

.article pre {
  background: var(--ink);
  color: var(--bg);
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.5;
}

.article pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.article table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

.article th,
.article td {
  border: 1px solid var(--line);
  padding: 6px 12px;
  text-align: left;
}

.article th {
  background: var(--bg);
}

.article figure {
  margin: 18px 0;
  text-align: center;
}

.article figure svg {
  max-width: 100%;
  height: auto;
}

.article figcaption {
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
}

.note,
.pitfall {
  border-radius: 12px;
  padding: 12px 16px;
  margin: 16px 0;
}

.note {
  background: var(--accent-soft);
}

.pitfall {
  background: #f0f6d9;
}

.note p,
.pitfall p {
  margin: 4px 0;
}

.r {
  color: var(--red);
  font-weight: 700;
}

.k {
  color: var(--black);
  font-weight: 700;
}

/* ---------- Encadré « Pratique » ---------- */
.practice {
  margin-top: 36px;
  background: var(--lime);
  border-radius: 12px;
  padding: 18px 22px;
}

.practice h2 {
  border: 0;
  margin: 0 0 4px;
  padding: 0;
  font-size: 20px;
}

.practice-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn-practice {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
}

.btn-practice:hover {
  background: #294b3c;
}

/* ---------- Index ---------- */
.topic-grid {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.topic-card {
  display: block;
  border-top: 1px solid var(--line);
  padding: 20px 0;
  text-decoration: none;
  color: var(--ink);
  transition: color 0.15s;
}

.topic-card:hover {
  color: var(--accent);
}

.topic-card:hover h2 { text-decoration: underline; text-underline-offset: 0.2em; }

.topic-card h2 {
  font-size: 22px;
  margin: 0 0 6px;
  border: 0;
  padding: 0;
  color: var(--accent);
}

.topic-card p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Pied de page ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  padding: 10px 16px 30px;
  color: var(--muted);
  font-size: 13px;
}

.policy {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.policy-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.policy .article h1 { font-size: 32px; }
.policy .muted { color: var(--muted); font-size: 14px; }
.policy .article h2 { font-size: 23px; }

@media (max-width: 600px) {
  .site-header { padding: 16px; gap: 12px; }
  .article h1 { font-size: 29px; overflow-wrap: anywhere; }
  .cta-small { margin-left: 0; }
  .policy .article h1 { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
