:root {
  --ink: #1c2430;
  --muted: #5c6775;
  --line: #d5dbe3;
  --paper: #f4f1ea;
  --card: #fffcf7;
  --blue: #1d4e89;
  --blue-soft: #e7f0fa;
  --red: #9c2f2f;
  --red-soft: #f8ecec;
  --ok: #1f6b45;
  --ok-soft: #e5f5ec;
  --shadow: 0 18px 50px rgba(40, 32, 18, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #efe6d4 0%, transparent 55%),
    var(--paper);
  font-family: Outfit, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }

.wrap { width: min(980px, calc(100% - 32px)); margin: 0 auto; }
header.top { padding: 28px 0 8px; }
.kicker {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
}
h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 680;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
h2 {
  margin: 0 0 6px;
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
  letter-spacing: -0.02em;
}
h3 { margin: 0 0 8px; font-size: 18px; }
.lede { max-width: 68ch; margin: 12px 0 0; color: var(--muted); font-size: 17px; }
.note { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.back {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  color: var(--blue);
}

.matieres {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 22px 0 36px;
}
.matiere {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 132px;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.matiere:hover { border-color: var(--blue); }
.matiere strong { font-family: Fraunces, Georgia, serif; font-size: 22px; letter-spacing: -0.02em; }
.matiere span { color: var(--muted); font-size: 14px; }
.matiere em {
  margin-top: auto;
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.matiere.plein em { color: var(--ok); }
.matiere.vide em { color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}
.toolbar button, .jump a {
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink);
}
.toolbar button[aria-pressed="true"] {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

section { margin: 18px 0 26px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.timeline time { font-weight: 700; color: var(--blue); }
.timeline p { margin: 0; }

.defs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.def { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; }
.def h3 { color: var(--red); font-size: 16px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 8px 0 16px; }
.stat { background: var(--blue-soft); border-radius: 14px; padding: 14px; }
.stat strong {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-size: 24px;
  letter-spacing: -0.03em;
}
.stat span { color: var(--muted); font-size: 13px; }

.bullets { margin: 0; padding-left: 18px; }
.bullets li { margin: 8px 0; }
.figure { margin: 12px 0 0; }
.figure figcaption { margin-top: 8px; color: var(--muted); font-size: 13px; }
.tag {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  padding: 3px 8px;
}

.vue-complet, .vue-synthese, .vue-extra { display: none; }
body[data-vue="complet"] .vue-complet,
body[data-vue="synthese"] .vue-synthese,
body[data-vue="extra"] .vue-extra { display: block; }

.vue-extra .card { border-color: #c9b98f; background: #fffaf0; }
.vue-extra .tag { color: #7a5a12; background: #f5ebd3; }
.avertissement {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f5ebd3;
  color: #5a4410;
  font-size: 14px;
}
.badge-extra {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7a5a12;
  background: #f5ebd3;
  border-radius: 999px;
  padding: 2px 7px;
  vertical-align: middle;
}
.rouge { color: var(--red); font-weight: 650; }

.quiz-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.quiz-actions button {
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  background: var(--blue);
  color: white;
  border: 1px solid var(--blue);
  border-radius: 999px;
  padding: 8px 14px;
}
.quiz-actions label { font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }

.choices { display: grid; gap: 8px; }
.choices button {
  text-align: left;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}
.choices button:disabled { cursor: default; }
.choices button.good { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.choices button.bad { background: #fbeaea; border-color: #8d2b2b; color: #8d2b2b; }
.why { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.q { border-top: 1px solid var(--line); padding: 16px 0 8px; }
.q h3 { font-size: 16px; }
#score { font-weight: 700; color: var(--blue); }
.quiz-head { display: flex; justify-content: space-between; gap: 12px; align-items: end; }
.quiz-actions button.secondaire { background: #fff; color: var(--blue); }
.quiz-actions button.ok { background: var(--ok); border-color: var(--ok); }
.quiz-actions button.revoir { background: #fff; color: #8d2b2b; border-color: #8d2b2b; }

.quiz-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 14px; }
.quiz-modes label {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.quiz-modes label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.quiz-modes input { grid-row: span 2; margin: 0; }
.quiz-modes span { font-size: 13px; color: var(--muted); }

/* Jauge fixe en bas de l'écran : progression + série, toujours visibles pendant le quiz. */
.jauge {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.06);
}
.jauge-inner { width: min(980px, calc(100% - 32px)); margin: 0 auto; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
.jauge-barre { grid-column: 1 / -1; display: flex; height: 12px; border-radius: 999px; background: #e9e4d8; overflow: hidden; }
.jauge-ok { background: linear-gradient(90deg, #3e9a6a, var(--ok)); transition: width 0.4s ease; }
.jauge-mauvais { background: #f1c7c7; transition: width 0.4s ease; }
.jauge-texte { grid-column: 1 / -1; margin: 6px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jauge-texte strong { color: var(--ok); font-size: 14px; }
.serie { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 4px 0 0; font-size: 13px; color: var(--muted); min-width: 0; }
.serie-mascotte { font-size: 24px; line-height: 1; transition: transform 0.3s ease; flex: none; }
.serie-flammes { font-size: 14px; letter-spacing: -2px; flex: none; }
.serie-texte { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.serie-record { margin-left: auto; flex: none; font-size: 12px; font-weight: 700; color: #7a5a12; background: #f5ebd3; border-radius: 999px; padding: 2px 8px; }
body[data-page="quiz"] .wrap { padding-bottom: calc(var(--jauge-h, 0px) + 16px); }
.serie.palier .serie-mascotte { animation: saut 0.9s ease; }
@keyframes saut { 0% { transform: scale(1); } 30% { transform: scale(1.6) rotate(-10deg); } 60% { transform: scale(1.3) rotate(8deg); } 100% { transform: scale(1); } }
.consigne-cartes { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.carte {
  margin-top: 12px;
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, #fff 0%, var(--blue-soft) 100%);
}
.carte-progression { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--blue); }
.carte h3 { font-size: 19px; margin: 0 0 10px; }
.carte-reponse { margin: 12px 0 4px; padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid #c8dfd2; }
.bonne { margin: 0; font-weight: 650; color: var(--ok); }
.bonne.explication { font-weight: 450; color: var(--ink); line-height: 1.55; font-size: 15px; }
.bonne.explication mark { background: #fff1b8; color: inherit; padding: 0 3px; border-radius: 4px; font-weight: 650; }
.carte-reponse .why, .bilan .why { margin-top: 6px; }
.carte-actions {
  position: sticky;
  bottom: calc(var(--jauge-h, 0px) + 6px);
  z-index: 5;
  margin: 12px -10px -6px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.05);
}
.carte-actions button { flex: 1 1 140px; padding: 12px 14px; font-size: 15px; }
.carte { scroll-margin-top: calc(var(--barre-h, 56px) + 10px); }

.a-revoir { margin-top: 16px; padding: 10px 14px; border-radius: 14px; background: #fffaf0; border: 1px solid #c9b98f; }
.a-revoir summary { cursor: pointer; font-weight: 700; color: #7a5a12; }
.a-revoir ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.a-revoir li { padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.a-revoir li strong { display: block; font-size: 15px; }
.a-revoir li .bonne { margin-top: 4px; }
.bilan { margin-top: 20px; padding: 16px 18px; border-radius: 16px; background: #fffaf0; border: 1px solid #c9b98f; }
.bilan h3 { margin: 0 0 6px; font-size: 18px; }
.bilan > p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.bilan ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bilan li { padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.bilan li strong { display: block; font-size: 15px; }
.bilan li .bonne { margin-top: 4px; }
.a-faire { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; background: #fffaf0; border: 1px solid #c9b98f; font-size: 14px; }
.a-faire summary { cursor: pointer; font-weight: 650; color: #7a5a12; }
.a-faire p { margin: 8px 0 0; color: var(--muted); }
.suite-quiz .bouton + .bouton { margin-left: 8px; }
.suite-quiz .bouton.secondaire { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.lien-cours { display: inline-block; margin-top: 8px; font-size: 14px; font-weight: 650; color: var(--blue); }

footer { padding: 8px 0 40px; color: var(--muted); font-size: 13px; }

.barre {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(244, 241, 234, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.barre-ligne {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0;
}
.barre-ligne + .barre-ligne { border-top: 1px solid var(--line); padding: 6px 0; }
.barre-accueil {
  flex: none;
  font-family: Fraunces, Georgia, serif;
  font-size: 18px;
  font-weight: 680;
  text-decoration: none;
  color: var(--red);
}
.barre-puces {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.barre-puces::-webkit-scrollbar { display: none; }
.barre-menu {
  display: none;
  margin-left: auto;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 999px;
  color: white;
  padding: 6px 12px;
}
.puce {
  flex: none;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 11px;
}
.puce[aria-current="page"] { background: var(--blue); border-color: var(--blue); color: white; }
.puce-reussir { border-color: var(--ok); color: var(--ok); }
.puce-reussir[aria-current="page"] { background: var(--ok); border-color: var(--ok); color: white; }
.puce-quiz { border-color: #c9b98f; background: #fffaf0; color: #7a5a12; }
.puce-quiz[aria-current="page"] { background: #7a5a12; border-color: #7a5a12; color: white; }
.toolbar.barre-vues { margin: 0; gap: 6px; flex-wrap: nowrap; }
.barre-vues button, .barre-sommaire { padding: 5px 12px; font-size: 13px; }
.barre-sommaire {
  margin-left: auto;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
}
.barre-sommaire[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: white; }
.sommaire {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto 10px;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.sommaire ol { list-style: none; margin: 0; padding: 6px; }
.sommaire a {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
}
.sommaire a:hover, .sommaire a:focus { background: var(--blue-soft); }
.sommaire li:first-child a { color: var(--muted); font-size: 13px; }
.card, section, .card h2 { scroll-margin-top: calc(var(--barre-h, 100px) + 12px); }

.suite-quiz { border-color: #c9b98f; background: #fffaf0; }
.bouton {
  display: inline-block;
  margin-top: 6px;
  font-weight: 650;
  text-decoration: none;
  background: var(--blue);
  color: white;
  border-radius: 999px;
  padding: 10px 18px;
}
.entree-quiz { display: block; text-decoration: none; border-color: #c9b98f; background: #fffaf0; }
.entree-quiz:hover { border-color: #7a5a12; }
.entree-quiz .tag { color: #7a5a12; background: #f5ebd3; }
.choix-matieres { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.choix-matieres button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
}
.choix-matieres button span { font-size: 13px; color: var(--muted); }
.choix-matieres button[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: white; }
.choix-matieres button[aria-pressed="true"] span { color: #dbe7f5; }
.rappel {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--blue-soft);
  font-size: 14px;
}
.rappel a { font-weight: 650; color: var(--blue); }
.badge-matiere {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  padding: 2px 7px;
  vertical-align: middle;
}
.entree-reussir { display: block; text-decoration: none; border-color: #a8cbb8; background: var(--ok-soft); }
.entree-reussir:hover { border-color: var(--ok); }
.entree-reussir .tag { color: var(--ok); background: white; }
.methode-cle { border-color: #a8cbb8; background: linear-gradient(145deg, #fff 0%, var(--ok-soft) 100%); }
.etapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.etapes div { display: flex; flex-direction: column; gap: 5px; padding: 14px; border-radius: 14px; background: white; border: 1px solid #c8dfd2; }
.etapes strong { color: var(--ok); }
.etapes span { color: var(--muted); font-size: 14px; }
.recompense { margin: 0; font-weight: 650; color: var(--ok); }
.exemple { margin-top: 16px; padding: 14px; border-left: 4px solid var(--blue); border-radius: 0 12px 12px 0; background: var(--blue-soft); }
.exemple p { margin: 5px 0; }
.attendu { padding: 12px 14px; border-radius: 12px; background: var(--ok-soft); color: #174f35; }
.gagne { margin-top: 10px !important; padding-top: 10px; border-top: 1px solid #bed0e5; color: var(--blue); }
.checklist ul { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.checklist li { position: relative; padding: 10px 12px 10px 42px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.checklist li::before { content: "✓"; position: absolute; left: 14px; top: 8px; color: var(--ok); font-size: 20px; font-weight: 700; }

@media (max-width: 720px) {
  .timeline li, .defs, .stats { grid-template-columns: 1fr; }
  .quiz-head { flex-direction: column; align-items: start; }
  .barre-ligne { width: calc(100% - 20px); }
  .barre-menu { display: inline-block; }
  .barre-puces {
    display: none;
    position: absolute;
    top: 100%;
    left: 10px;
    right: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    overflow: visible;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
  }
  .barre.menu-ouvert .barre-puces { display: flex; }
  .puce { font-size: 14px; padding: 8px 14px; }
  .barre-sommaire, .barre-vues button { padding: 6px 11px; }
  .etapes { grid-template-columns: 1fr; }
  .barre-accueil { font-size: 16px; }
  header.top { padding-top: 18px; }
}
