/* ---------------------------------------------------------------------------
   course.css — feuille de style unique du cours.
   Aucune dépendance. Thème clair et sombre pilotés par des variables CSS.
   --------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* Palette Material 3, alignée sur l'identité Flutter. */
  --md-sys-color-primary: #0b57d0;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d3e3fd;
  --md-sys-color-on-primary-container: #041e49;
  --md-sys-color-secondary-container: #e8def8;
  --md-sys-color-tertiary-container: #fde8d0;

  --surface: #fdfcfd;
  --surface-raised: #ffffff;
  --surface-sunken: #f4f6f9;
  --surface-hover: #eef1f6;
  --border: #dfe3ea;
  --border-strong: #c3c9d4;

  --text: #1a1c20;
  --text-muted: #5a6270;
  --text-faint: #838b99;

  --success: #146c2e;
  --success-bg: #e3f4e6;
  --danger: #b3261e;
  --danger-bg: #fce8e6;
  --warning: #8a5000;
  --warning-bg: #fdf1d9;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.16);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --header-h: 60px;
  --sidebar-w: 292px;
  --prose-w: 46rem;

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
    Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;

  --md-sys-color-primary: #a8c7fa;
  --md-sys-color-on-primary: #062e6f;
  --md-sys-color-primary-container: #0842a0;
  --md-sys-color-on-primary-container: #d3e3fd;
  --md-sys-color-secondary-container: #4a4458;
  --md-sys-color-tertiary-container: #6b5339;

  --surface: #0e1116;
  --surface-raised: #161a21;
  --surface-sunken: #12151b;
  --surface-hover: #1d222b;
  --border: #262c36;
  --border-strong: #3a424f;

  --text: #e3e6ec;
  --text-muted: #a2abba;
  --text-faint: #737d8c;

  --success: #7ddb8f;
  --success-bg: #10321b;
  --danger: #f2b8b5;
  --danger-bg: #3a1512;
  --warning: #f5c26b;
  --warning-bg: #3a2a0d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* --- Réinitialisation minimale ------------------------------------------- */

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--md-sys-color-primary);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
  top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- En-tête ------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.site-header__logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #42a5f5, #0b57d0);
  color: #fff;
  font-size: 17px;
  flex-shrink: 0;
}

.site-header__sep {
  color: var(--text-faint);
}

.site-header__chapter {
  color: var(--text-muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-header__spacer {
  flex: 1;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  margin-left: 6px;
  line-height: 1;
}

.menu-btn {
  display: none;
}

@media (max-width: 1023px) {
  .menu-btn {
    display: inline-grid;
  }
  .site-header__chapter {
    display: none;
  }
}

/* --- Structure : barre latérale + contenu -------------------------------- */

.layout {
  display: flex;
  align-items: flex-start;
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  flex-shrink: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 12px 64px 20px;
  border-right: 1px solid var(--border);
  background: var(--surface-sunken);
}

.sidebar__progress {
  padding: 0 12px 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar__progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sidebar__progress-head strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #42a5f5, var(--md-sys-color-primary));
  transition: width 0.4s ease;
}

.sidebar__module {
  margin-bottom: 18px;
}

.sidebar__module-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 12px;
  margin: 0 0 6px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s;
}

.sidebar__link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar__link[aria-current="page"] {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 600;
}

.sidebar__check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--text-faint);
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
}

.sidebar__check.is-done {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.sidebar__link.is-done .sidebar__label {
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}

.sidebar__time {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    z-index: 35;
    width: min(86vw, var(--sidebar-w));
    transform: translateX(-102%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: var(--header-h) 0 0;
    z-index: 34;
    background: rgba(0, 0, 0, 0.45);
  }
}

/* --- Zone de contenu ----------------------------------------------------- */

.content {
  flex: 1;
  min-width: 0;
  padding: 36px 28px 96px;
}

.prose {
  max-width: var(--prose-w);
  margin: 0 auto;
}

.prose > h2,
.prose > h3 {
  scroll-margin-top: calc(var(--header-h) + 16px);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.prose h2 {
  margin: 52px 0 16px;
  padding-top: 20px;
  font-size: 1.6rem;
  border-top: 1px solid var(--border);
}

.prose > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.prose h3 {
  margin: 32px 0 10px;
  font-size: 1.18rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.1em;
}

.prose li {
  margin-bottom: 0.4em;
}

.prose li > ul,
.prose li > ol {
  margin-top: 0.4em;
}

.prose img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* --- En-tête de chapitre ------------------------------------------------- */

.page-head {
  margin-bottom: 34px;
}

.page-head__eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
  margin-bottom: 10px;
}

.page-head h1 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.page-head__summary {
  font-size: 1.08rem;
  color: var(--text-muted);
  margin: 0 0 18px;
  max-width: 42rem;
}

.page-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.page-head__meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* --- Cartes d’information (objectifs, à retenir, pièges) ---------------- */

.card {
  padding: 20px 22px;
  margin: 26px 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.card > :last-child {
  margin-bottom: 0;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card__body > :first-child {
  margin-top: 0;
}

.card--objectives {
  background: var(--md-sys-color-primary-container);
  border-color: transparent;
  color: var(--md-sys-color-on-primary-container);
}

.card--objectives .card__title {
  color: inherit;
}

.card--objectives ul {
  margin-bottom: 0;
  padding-left: 1.1em;
}

.card--takeaway {
  border-left: 4px solid var(--success);
  background: var(--success-bg);
}

.card--takeaway .card__title {
  color: var(--success);
}

.card--trap {
  border-left: 4px solid var(--danger);
  background: var(--danger-bg);
}

.card--trap .card__title {
  color: var(--danger);
}

.card--note {
  border-left: 4px solid var(--md-sys-color-primary);
  background: var(--surface-sunken);
}

.card--note .card__title {
  color: var(--md-sys-color-primary);
}

.card--tip {
  border-left: 4px solid var(--warning);
  background: var(--warning-bg);
}

.card--tip .card__title {
  color: var(--warning);
}

/* --- Bloc de code -------------------------------------------------------- */

.code-block {
  position: relative;
  margin: 20px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  overflow: hidden;
}

.code-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px 7px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}

.code-block__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.code-block pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.65;
  tab-size: 2;
}

.code-block pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: var(--text);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.copy-btn.is-copied {
  color: var(--success);
  border-color: var(--success);
}

/* Coloration syntaxique : repli silencieux si highlight.js est absent. */
.hljs-comment,
.hljs-quote {
  color: var(--text-faint);
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-type {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

.hljs-string,
.hljs-meta .hljs-string {
  color: #0a7d4e;
}

[data-theme="dark"] .hljs-string,
[data-theme="dark"] .hljs-meta .hljs-string {
  color: #7ddb8f;
}

.hljs-number,
.hljs-symbol {
  color: #a5450b;
}

[data-theme="dark"] .hljs-number,
[data-theme="dark"] .hljs-symbol {
  color: #f5c26b;
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: #6a3ab8;
}

[data-theme="dark"] .hljs-title,
[data-theme="dark"] .hljs-title.function_,
[data-theme="dark"] .hljs-section {
  color: #c9a6ff;
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable {
  color: #b3261e;
}

[data-theme="dark"] .hljs-attr,
[data-theme="dark"] .hljs-attribute,
[data-theme="dark"] .hljs-variable,
[data-theme="dark"] .hljs-template-variable {
  color: #f2b8b5;
}

.hljs-built_in,
.hljs-name {
  color: #00658f;
}

[data-theme="dark"] .hljs-built_in,
[data-theme="dark"] .hljs-name {
  color: #7ec8e3;
}

.hljs-meta,
.hljs-params {
  color: var(--text-muted);
}

/* --- Tableaux ------------------------------------------------------------ */

.table-wrap {
  margin: 22px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  font-weight: 650;
  background: var(--surface-hover);
  color: var(--text);
  white-space: nowrap;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

tbody tr:hover {
  background: var(--surface-hover);
}

/* --- Éléments en ligne --------------------------------------------------- */

code {
  padding: 0.12em 0.36em;
  border-radius: 4px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.87em;
  color: var(--text);
  overflow-wrap: break-word;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 0.8em;
  line-height: 1.5;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.button:hover {
  filter: brightness(1.08);
}

.button:active {
  transform: translateY(1px);
}

.button--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.button--ghost:hover {
  background: var(--surface-hover);
  filter: none;
}

.button--done {
  background: var(--success);
  color: #fff;
}

/* --- Quiz ---------------------------------------------------------------- */

.quiz {
  margin: 30px 0;
  padding: 24px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.quiz__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.quiz__title {
  font-size: 1.08rem;
  font-weight: 650;
  margin: 0;
}

.quiz__score {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.quiz__question {
  margin: 22px 0 10px;
  font-weight: 600;
  line-height: 1.5;
}

.quiz__question .quiz__num {
  color: var(--md-sys-color-primary);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

.quiz__options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
  margin-inline: 0;
}

.quiz__option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}

.quiz__option:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.quiz__option input {
  margin: 4px 0 0;
  accent-color: var(--md-sys-color-primary);
  flex-shrink: 0;
}

.quiz__option:has(input:checked) {
  border-color: var(--md-sys-color-primary);
}

.quiz__option.is-correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.quiz__option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.quiz__feedback {
  display: none;
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  border-left: 3px solid var(--border-strong);
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.quiz__feedback.is-visible {
  display: block;
}

.quiz__feedback.is-correct {
  border-left-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.quiz__feedback.is-wrong {
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.quiz__result {
  display: none;
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.quiz__result.is-visible {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.quiz__result-text {
  font-weight: 600;
}

/* --- Exercices (details) ------------------------------------------------- */

.exercise {
  margin: 26px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  overflow: hidden;
}

.exercise__head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 20px;
  background: var(--md-sys-color-tertiary-container);
  color: #4a3400;
  font-weight: 650;
  font-size: 0.98rem;
}

[data-theme="dark"] .exercise__head {
  color: #ffe2b0;
}

.exercise__body {
  padding: 6px 22px 20px;
}

.exercise__body > :first-child {
  margin-top: 16px;
}

details.solution {
  margin: 16px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  overflow: hidden;
}

details.solution > summary {
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--md-sys-color-primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details.solution > summary::-webkit-details-marker {
  display: none;
}

details.solution > summary::before {
  content: "▸";
  transition: transform 0.15s;
  display: inline-block;
}

details.solution[open] > summary::before {
  transform: rotate(90deg);
}

details.solution[open] > summary {
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.solution__content {
  padding: 0 16px 4px;
}

.solution__content > :last-child {
  margin-bottom: 0;
}

.hint {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* --- Éditeur DartPad (chargé à la demande) ------------------------------ */

.playground {
  margin: 26px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  overflow: hidden;
}

.playground__head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
}

.playground__title {
  font-weight: 650;
  font-size: 0.95rem;
  margin: 0;
}

.playground__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.playground__facade {
  padding: 30px 24px;
  text-align: center;
  color: var(--text-muted);
}

.playground__facade p {
  margin: 0 0 16px;
  font-size: 0.92rem;
  max-width: 34rem;
  margin-inline: auto;
}

.playground__facade .button {
  margin-right: 8px;
}

.playground__note {
  font-size: 0.8rem;
  margin-top: 14px;
  color: var(--text-faint);
}

.playground__frame {
  display: none;
  width: 100%;
  height: 620px;
  border: 0;
  background: #fff;
}

.playground.is-loaded .playground__facade {
  display: none;
}

.playground.is-loaded .playground__frame {
  display: block;
}

.playground.is-error .playground__facade {
  display: block;
  border: 1px dashed var(--danger);
}

/* --- Sommaire du chapitre ------------------------------------------------ */

.toc {
  margin: 0 0 34px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  font-size: 0.92rem;
}

.toc__title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 8px;
}

.toc ol {
  margin: 0;
  padding-left: 1.2em;
}

.toc li {
  margin-bottom: 4px;
}

.toc a {
  text-decoration: none;
  color: var(--text-muted);
}

.toc a:hover {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
}

/* --- Pied de page et navigation de chapitre ------------------------------ */

.chapter-nav {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 52px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.chapter-nav__link {
  flex: 1;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

.chapter-nav__link:hover {
  border-color: var(--md-sys-color-primary);
  transform: translateY(-1px);
}

.chapter-nav__link--next {
  text-align: right;
}

.chapter-nav__dir {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.chapter-nav__title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--md-sys-color-primary);
}

.done-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 34px;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.done-bar__text {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.done-bar__spacer {
  flex: 1;
}

@media (max-width: 640px) {
  .chapter-nav {
    flex-direction: column;
  }
  .chapter-nav__link--next {
    text-align: left;
  }
}

.site-footer {
  padding: 26px 28px 40px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: 0.86rem;
  color: var(--text-muted);
  text-align: center;
}

/* --- Modale de recherche ------------------------------------------------- */

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  background: rgba(10, 14, 20, 0.5);
  backdrop-filter: blur(2px);
}

.search-modal.is-open {
  display: flex;
}

.search-modal__box {
  width: min(640px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.search-modal__input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.search-modal__input {
  flex: 1;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1.02rem;
  color: var(--text);
  outline: none;
}

.search-modal__input::placeholder {
  color: var(--text-faint);
}

.search-modal__results {
  overflow-y: auto;
  padding: 6px;
  margin: 0;
  list-style: none;
}

.search-result {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}

.search-result:hover,
.search-result.is-active {
  background: var(--surface-hover);
}

.search-result__title {
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
}

.search-result__title mark {
  background: var(--md-sys-color-tertiary-container);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.search-result__path {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search-modal__empty {
  padding: 26px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.search-modal__footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: 0.76rem;
  color: var(--text-faint);
  display: flex;
  gap: 16px;
}

/* --- Page d’accueil ------------------------------------------------------ */

.hero {
  padding: 64px 24px 56px;
  text-align: center;
  background:
    radial-gradient(1000px 380px at 50% -80px, var(--md-sys-color-primary-container), transparent),
    var(--surface);
  border-bottom: 1px solid var(--border);
}

.hero__inner {
  max-width: 46rem;
  margin: 0 auto;
}

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 6vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.hero p {
  margin: 0 auto 28px;
  max-width: 38rem;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.hero__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero__stats {
  display: flex;
  gap: 34px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.hero__stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero__stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.home {
  max-width: 62rem;
  margin: 0 auto;
  padding: 44px 24px 90px;
}

.home h2 {
  margin: 52px 0 8px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.home h2:first-child {
  margin-top: 0;
}

.home__lead {
  color: var(--text-muted);
  margin-bottom: 26px;
  max-width: 44rem;
}

.module-card {
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.module-card__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 20px 24px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}

.module-card__num {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
}

.module-card__title {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: -0.015em;
}

.module-card__blurb {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.93rem;
  width: 100%;
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 24px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.chapter-row:last-child {
  border-bottom: 0;
}

.chapter-row:hover {
  background: var(--surface-hover);
}

.chapter-row__index {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chapter-row.is-done .chapter-row__index {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.chapter-row__text {
  flex: 1;
  min-width: 0;
}

.chapter-row__title {
  display: block;
  font-weight: 600;
}

.chapter-row__summary {
  display: block;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.chapter-row__time {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin: 22px 0;
}

.tile {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.tile h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.tile p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.tile__icon {
  font-size: 1.4rem;
  margin-bottom: 8px;
  display: block;
}

.checklist {
  list-style: none;
  padding: 0;
}

.checklist li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 8px;
}

.checklist li::before {
  content: "▢";
  position: absolute;
  left: 0;
  color: var(--md-sys-color-primary);
}

/* --- Accessibilité : mouvement réduit ------------------------------------ */

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

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

@media print {
  .site-header,
  .sidebar,
  .chapter-nav,
  .done-bar,
  .quiz,
  .playground,
  .search-modal,
  .site-footer {
    display: none !important;
  }
  .content {
    padding: 0;
  }
  body {
    font-size: 12pt;
  }
}
