/* --------------------------------------------------------------------
   Topologie — Feuille de style commune aux leçons
   Inspiration : Tufte (typographie lisible, marges généreuses).
   -------------------------------------------------------------------- */

:root {
  --text: #1a1a1a;
  --muted: #6a6a6a;
  --paper: #fffff8;
  --accent: #7a1f1f;
  --accent-soft: #f4e8e8;
  --rule: #d8d4c8;
  --code-bg: #f5f1e6;
  --def-bg: #f0f6ff;
  --def-border: #4a6fa5;
  --thm-bg: #fff8e1;
  --thm-border: #b58900;
  --proof-bg: #f2f7ee;
  --proof-border: #6b8e4e;
  --quiz-bg: #faf5ff;
  --quiz-border: #7c4d9f;
  --warn-bg: #fdecea;
  --warn-border: #b03a2e;
}

html { font-size: 17px; }

body {
  max-width: 720px;
  margin: 3rem auto 6rem;
  padding: 0 1.25rem;
  color: var(--text);
  background: var(--paper);
  font-family: "et-book", Georgia, "Times New Roman", serif;
  line-height: 1.55;
  font-feature-settings: "onum";
}

/* --- Titres --------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  line-height: 1.25;
  color: #111;
}

h1 { font-size: 1.9rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.35rem; margin: 2.4rem 0 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--rule); }
h3 { font-size: 1.1rem; margin: 1.6rem 0 0.4rem; }

.subtitle {
  color: var(--muted);
  font-style: italic;
  margin: 0 0 2rem;
  font-size: 0.95rem;
}

.crumbs {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}
.crumbs a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.crumbs a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Paragraphes & inline ------------------------------------------ */

p { margin: 0.7rem 0; }
strong { color: #000; }
em { color: #2a2a2a; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
a:hover { background: var(--accent-soft); }

code {
  background: var(--code-bg);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

blockquote {
  margin: 1.2rem 0 1.2rem 0.5rem;
  padding: 0.2rem 1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

/* --- Blocs mathématiques ------------------------------------------- */

.box {
  margin: 1.4rem 0;
  padding: 0.9rem 1.1rem;
  border-left: 4px solid;
  border-radius: 0 4px 4px 0;
}

.box .label {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.def   { background: var(--def-bg);   border-color: var(--def-border); }
.def .label   { color: var(--def-border); }

.thm   { background: var(--thm-bg);   border-color: var(--thm-border); }
.thm .label   { color: var(--thm-border); }

.proof { background: var(--proof-bg); border-color: var(--proof-border); }
.proof .label { color: var(--proof-border); }

.warn  { background: var(--warn-bg);  border-color: var(--warn-border); }
.warn .label  { color: var(--warn-border); }

.example {
  background: #fbfbf4;
  border-color: var(--muted);
}
.example .label { color: var(--muted); }

/* --- Quiz cards (recall practice) ---------------------------------- */

.quiz {
  margin: 1.4rem 0;
  padding: 1rem 1.1rem;
  background: var(--quiz-bg);
  border-left: 4px solid var(--quiz-border);
  border-radius: 0 4px 4px 0;
}
.quiz .label {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--quiz-border);
  margin-bottom: 0.35rem;
}
.quiz .q { font-weight: 500; margin: 0.3rem 0 0.5rem; }

.quiz details {
  margin-top: 0.4rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255,255,255,0.5);
  border-radius: 3px;
  cursor: pointer;
}
.quiz details summary {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.85rem;
  color: var(--quiz-border);
  font-weight: 600;
  list-style: none;
}
.quiz details summary::before {
  content: "▶ ";
  font-size: 0.7em;
  display: inline-block;
  transition: transform 0.15s;
}
.quiz details[open] summary::before {
  transform: rotate(90deg);
}
.quiz details[open] {
  background: rgba(255,255,255,0.9);
}
.quiz details .answer { margin-top: 0.5rem; }

/* --- Étapes de preuve numérotées ----------------------------------- */

.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
  margin: 1rem 0;
}
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0.6rem 0 0.6rem 2.5rem;
  border-bottom: 1px dashed var(--rule);
}
.steps > li:last-child { border-bottom: none; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--proof-border);
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps .move {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--proof-border);
  font-weight: 700;
  margin-bottom: 0.15rem;
}

/* --- Pied de leçon (asking followups, primary source) -------------- */

.footer {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
  color: var(--muted);
}
.footer .primary-source {
  background: var(--accent-soft);
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  margin-bottom: 0.8rem;
  color: var(--text);
}
.footer .followup {
  font-style: italic;
}

/* --- Navigation leçon précédente / suivante ------------------------ */

.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 1.2rem 0 2rem;
  padding: 0.7rem 0.2rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.88rem;
}

.lesson-nav a,
.lesson-nav .disabled {
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: none;
  transition: background 0.15s;
  display: inline-block;
  max-width: 48%;
}

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

.lesson-nav .prev {
  text-align: left;
}

.lesson-nav .next {
  text-align: right;
  margin-left: auto;
}

.lesson-nav .disabled {
  color: var(--rule);
  cursor: default;
  font-style: italic;
}

.lesson-nav-bottom {
  margin-top: 3rem;
  margin-bottom: 0.5rem;
}

/* --- Impression ---------------------------------------------------- */

@media print {
  body { max-width: none; margin: 0; padding: 1cm; background: white; }
  h2 { page-break-after: avoid; }
  .box, .quiz, .steps > li { page-break-inside: avoid; }
  a { color: var(--text); border-bottom: none; }
  .footer .followup { display: none; }
}

/* --- MathJax : légèrement plus grand & aéré ------------------------ */

mjx-container { font-size: 1.02em; }
