:root {
  --navy: #1F3A5F;
  --navy-dark: #162b47;
  --gold: #C8962E;
  --gold-dark: #8a6410;
  --bg: #F7F8FA;
  --surface: #ffffff;
  --text: #1E2430;
  --muted: #5b6573;
  --border: #dde2e9;
  --green: #2e7d4f;
  --green-bg: #f1f8f4;
  --def-bg: #e8f0fb;
  --def-border: #5b8fd6;
  --def-label: #1F3A5F;
  --ex-bg: #fff8dc;
  --ex-border: #e0b73a;
  --ex-label: #7a5a00;
  --rem-bg: #eef0f3;
  --rem-border: #9aa3b0;
  --rem-label: #4a5260;
  --radius: 12px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

/* En-tête */
.site-header {
  background: var(--navy);
  border-bottom: 4px solid var(--gold);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  min-height: 64px;
  color: #fff;
  text-decoration: none;
}
.brand svg, .brand .logo { flex: none; width: 44px; height: 44px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1.05rem; }
.brand-text span { font-size: 0.9rem; color: #d6deea; }

/* Barre de navigation */
.site-nav {
  display: flex;
  gap: 4px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 8px 8px;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
}
.site-nav a:hover, .site-nav a:focus { background: rgba(255, 255, 255, 0.15); }

/* Contenu */
main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 72px;
}
.content { min-width: 0; max-width: 760px; }

h1, h2, h3, h4 { line-height: 1.3; margin: 1.6em 0 0.5em; color: var(--navy); }
h1 { font-size: 1.7rem; margin-top: 0.6em; }
h2 { font-size: 1.35rem; border-bottom: 2px solid var(--gold); padding-bottom: 0.2em; scroll-margin-top: 12px; }
h3 { font-size: 1.15rem; }

p, ul, ol { margin: 0.8em 0; }
li { margin: 0.3em 0; }
a { color: #1d5fa8; }

img { max-width: 100%; height: auto; }

/* Fil d'Ariane */
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
}
.breadcrumb li { margin: 0; }
.breadcrumb li + li::before { content: "›"; margin-right: 6px; color: var(--muted); }
.breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--navy);
}
.breadcrumb [aria-current] { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--muted); }

/* Cours / Exercices */
.tabs { display: flex; gap: 8px; margin: 4px 0 8px; }
.tab {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--navy);
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
  background: var(--surface);
}
.tab.current { background: var(--navy); color: #fff; }

/* Table des matières */
.toc {
  margin: 12px 0 8px;
  padding: 4px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--gold);
  border-radius: var(--radius);
}
.toc h2 { border: 0; font-size: 1.05rem; margin: 0.7em 0 0.3em; }
.toc ol { margin: 0; padding-left: 1.4em; }
.toc li { margin: 0; }
.toc a {
  display: inline-block;
  padding: 10px 0;
  min-height: var(--tap);
  color: var(--navy);
  text-decoration: none;
}
.toc a:hover, .toc a:focus { text-decoration: underline; }

/* Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1em 0; }
table { border-collapse: collapse; min-width: 100%; font-size: 0.95rem; background: var(--surface); }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--navy); color: #fff; }

/* Citations : Définition / Exemple / Remarque */
blockquote {
  margin: 1.1em 0;
  padding: 12px 16px;
  background: var(--rem-bg);
  border-left: 5px solid var(--rem-border);
  border-radius: 0 var(--radius) var(--radius) 0;
}
blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }
.note > p:first-child > strong:first-child {
  display: inline-block;
  margin-right: 6px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.7;
}
.note-definition { background: var(--def-bg); border-left-color: var(--def-border); }
.note-definition > p:first-child > strong:first-child { background: var(--def-label); }
.note-exemple { background: var(--ex-bg); border-left-color: var(--ex-border); }
.note-exemple > p:first-child > strong:first-child { background: var(--ex-label); }
.note-remarque { background: var(--rem-bg); border-left-color: var(--rem-border); }
.note-remarque > p:first-child > strong:first-child { background: var(--rem-label); }

code { background: #eceff2; padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
pre { overflow-x: auto; background: #eceff2; padding: 12px; border-radius: 8px; }
pre code { background: none; padding: 0; }

/* Correction des exercices */
details {
  margin: 1em 0;
  border: 1px solid #a9d3b9;
  border-left: 5px solid var(--green);
  border-radius: 10px;
  background: var(--green-bg);
}
summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 16px;
  min-height: var(--tap);
  color: var(--green);
  font-weight: 700;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "▶";
  flex: none;
  font-size: 0.9em;
  transition: transform 0.15s;
}
details[open] > summary::before { transform: rotate(90deg); }
details > :not(summary) { margin-left: 16px; margin-right: 16px; }
details > :last-child { margin-bottom: 14px; }

/* Boutons */
.btn {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 22px;
  min-height: var(--tap);
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  border-radius: 10px;
}
.btn-alt { background: var(--gold); color: #1E2430; }
.btn:hover, .btn:focus { filter: brightness(0.92); }
.btn small { font-weight: 400; font-size: 0.8rem; opacity: 0.85; }
.btn-ghost { background: var(--surface); color: var(--navy); border: 1px solid var(--navy); }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 0.4em 0; }

/* Précédent / Suivant */
.pager { display: flex; flex-direction: column; gap: 10px; margin-top: 40px; }
.pager .next { text-align: right; }

/* Retour en haut */
.to-top {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  min-width: var(--tap);
  justify-content: center;
  padding: 0 14px;
  background: var(--gold);
  color: #1E2430;
  font-weight: 700;
  text-decoration: none;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.to-top span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Accueil */
.hero {
  margin: 12px 0 8px;
  padding: 24px 20px;
  background: linear-gradient(135deg, var(--navy), var(--navy-dark));
  border-bottom: 4px solid var(--gold);
  border-radius: var(--radius);
  color: #fff;
}
.hero h1 { color: #fff; margin: 0 0 0.3em; }
.hero p { margin: 0; color: #e3e9f2; }

.section-title { margin-top: 1.4em; }
.modules { display: grid; gap: 14px; grid-template-columns: 1fr; }
.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
}
.card.soon { border-top-color: var(--border); }
.card h3 { margin: 0; font-size: 1.1rem; }
.card h3 a { color: var(--navy); }
.card-num { font-size: 0.85rem; font-weight: 700; color: var(--gold-dark); text-transform: uppercase; letter-spacing: 0.04em; }
.card-meta { margin: 0 0 6px; color: var(--muted); font-size: 0.95rem; }
.badge {
  display: inline-block;
  padding: 2px 12px;
  background: #e3e7eb;
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}
.badge-ok { background: #dff1e6; color: #1e6b3f; }

.chapters { scroll-margin-top: 12px; }
.chapter {
  margin: 12px 0;
  padding: 4px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chapter h3 { margin: 0.8em 0 0.4em; font-size: 1.05rem; }

/* Page d'entraînement */
[hidden] { display: none !important; }
button.btn { border: 0; font: inherit; font-weight: 700; cursor: pointer; }
button.btn-ghost { border: 1px solid var(--navy); }
.series { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.serie { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 18px; background: var(--surface); border: 2px solid var(--border); border-radius: 10px; font-weight: 600; cursor: pointer; }
.serie:has(input:checked) { border-color: var(--navy); background: var(--def-bg); }
.serie input { width: 20px; height: 20px; }

.exam-title { margin-top: 0.8em; }
.ex { margin: 18px 0; padding: 4px 16px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.ex h2 { font-size: 1.15rem; }
.ex h3 { font-size: 1.05rem; }
.pts { display: inline-block; margin-left: 6px; padding: 0 10px; background: var(--gold); color: #1E2430; border-radius: 999px; font-size: 0.8rem; font-weight: 700; vertical-align: middle; }
.cons { color: var(--muted); font-size: 0.95rem; }
.defs { display: grid; gap: 8px; margin: 8px 0 14px; }
.def { display: flex; gap: 10px; padding: 8px 12px; background: var(--def-bg); border-left: 4px solid var(--def-border); border-radius: 0 8px 8px 0; }
.def b { flex: none; color: var(--navy); }
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
.q { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.q .lab { display: block; margin-bottom: 6px; }
.q select, .q input[type="text"] { width: 100%; min-height: var(--tap); padding: 6px 10px; font: inherit; color: var(--text); background: #fff; border: 1px solid #aab3c0; border-radius: 8px; }
.vf { display: flex; gap: 8px; }
.vf button { flex: 1; min-height: var(--tap); font: inherit; font-weight: 700; color: var(--navy); background: #fff; border: 2px solid var(--navy); border-radius: 8px; cursor: pointer; }
.vf button.on { background: var(--navy); color: #fff; }
.q.ok { background: var(--green-bg); border-color: #a9d3b9; border-left: 5px solid var(--green); }
.q.ko { background: #fdf0ef; border-color: #e8b4b0; border-left: 5px solid #c0392b; }
.q .note { margin-top: 6px; font-size: 0.95rem; }
.q.ok .note { color: var(--green); font-weight: 700; }
.q.ko .note { color: #9b2c20; }
.why { margin-top: 4px; color: var(--text); }
.schema { display: block; margin: 8px 0 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.result { margin: 12px 0; padding: 4px 16px 12px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--gold); border-radius: var(--radius); }
.big-note { margin: 0; font-size: 2.2rem; color: var(--navy); }
table.score { min-width: 0; width: 100%; max-width: 420px; }
table.score td:last-child { text-align: right; white-space: nowrap; }
table.score tr.tot td { font-weight: 700; background: var(--def-bg); }
.legend { font-size: 0.9rem; }
.lg { display: inline-block; padding: 0 10px; border-radius: 999px; margin-right: 6px; }
.lg.ok { background: #dff1e6; color: #1e6b3f; }
.lg.ko { background: #fbe3e0; color: #9b2c20; }
@media (min-width: 700px) { .grid { grid-template-columns: 1fr 1fr; } }
@media print { .site-nav { display: none; } }

/* Pied de page */
.site-footer {
  padding: 18px 16px;
  background: var(--navy);
  color: #d6deea;
  text-align: center;
  font-size: 0.95rem;
}
.site-footer p { margin: 0.1em 0; }

/* Écrans larges */
@media (min-width: 900px) {
  body { font-size: 18px; }
  .tabs { margin-bottom: 0; }
  .layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; align-items: start; }
  .toc { position: sticky; top: 16px; margin-top: 0; }
  .modules { grid-template-columns: repeat(2, 1fr); }
  .pager { flex-direction: row; justify-content: space-between; }
  .pager .btn { max-width: 48%; }
  .hero { padding: 40px 36px; }
  .hero h1 { font-size: 2.1rem; }
}

/* Impression */
@media print {
  body { background: #fff; font-size: 12pt; display: block; }
  .site-header, .breadcrumb, .tabs, .toc, .pager, .to-top, .site-footer { display: none; }
  main { max-width: none; padding: 0; }
  .layout { display: block; }
  .content { max-width: none; }
  details { border-color: #999; background: #fff; }
  details > summary::before { display: none; }
  details > :not(summary) { display: block; }
  img, table, blockquote, details, tr { break-inside: avoid; page-break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  a { color: inherit; text-decoration: none; }
}
