/* ============================================================
   Site du cours — reprend l'identité du thème Marp « neurone »
   ============================================================ */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --fg: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --dot: rgba(15, 23, 42, 0.06);
  --accent: #7c3aed;
  --accent-fg: #6d28d9;
  --accent-soft: #f5f3ff;
  --link: #2563eb;
  --grad: linear-gradient(120deg, #7c3aed 0%, #2563eb 55%, #06b6d4 100%);
  --shadow: 0 12px 32px -20px rgba(15, 23, 42, 0.5);
  --shadow-lg: 0 24px 60px -30px rgba(15, 23, 42, 0.55);
  --stage-bg: #e9edf3;

  --c-draft: #b45309;

  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-head: 'Space Grotesk', 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --radius: 16px;
  --container: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1020;
    --surface: #121a30;
    --surface-2: #18213b;
    --fg: #e8edf5;
    --muted: #94a3b8;
    --line: rgba(255, 255, 255, 0.1);
    --dot: rgba(255, 255, 255, 0.05);
    --accent: #a78bfa;
    --accent-fg: #c4b5fd;
    --accent-soft: rgba(167, 139, 250, 0.12);
    --link: #7dd3fc;
    --shadow: 0 12px 32px -18px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
    --stage-bg: #070b16;
    --c-draft: #fbbf24;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0b1020;
  --surface: #121a30;
  --surface-2: #18213b;
  --fg: #e8edf5;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.1);
  --dot: rgba(255, 255, 255, 0.05);
  --accent: #a78bfa;
  --accent-fg: #c4b5fd;
  --accent-soft: rgba(167, 139, 250, 0.12);
  --link: #7dd3fc;
  --shadow: 0 12px 32px -18px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
  --stage-bg: #070b16;
  --c-draft: #fbbf24;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--fg);
  background:
    radial-gradient(circle at 1px 1px, var(--dot) 1.2px, transparent 0) 0 0 / 28px 28px,
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

a { color: var(--link); }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

.icon { width: 1.15em; height: 1.15em; flex: none; }

kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 0.1em 0.45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
}

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

.kicker {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-fg);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}
.tag-draft { color: var(--c-draft); border-color: currentColor; background: transparent; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 15px/1 var(--font-body);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--grad); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-small { font-size: 14px; padding: 8px 14px; border-radius: 10px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-size: 18px;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar::before { content: ''; display: block; height: 3px; background: var(--grad); }

.topbar-inner {
  max-width: var(--container);
  margin-inline: auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg);
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: radial-gradient(circle, #fff 0 5px, transparent 5.5px), var(--grad);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-family: var(--font-head); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 13px; }

.crumb {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  padding-left: 16px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.theme-toggle { margin-left: auto; }

/* ---------- Accueil ---------- */
.hero { padding: 72px 0 48px; position: relative; overflow: hidden; }
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -10% auto auto;
  width: 640px;
  height: 640px;
  background: radial-gradient(closest-side, rgba(124, 58, 237, 0.22), transparent),
              radial-gradient(closest-side at 30% 70%, rgba(6, 182, 212, 0.18), transparent);
  pointer-events: none;
}
.hero h1 {
  font-size: clamp(42px, 7vw, 76px);
  line-height: 1.02;
  margin-bottom: 8px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 0.06em;
}
.hero-sub { font-family: var(--font-head); font-size: clamp(22px, 3vw, 30px); font-weight: 600; margin: 0 0 12px; }
.hero-meta { color: var(--muted); margin: 0 0 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.section { padding-block: 40px; }
.section-title { font-size: 30px; margin-bottom: 24px; }
.section-title::after { content: ''; display: block; width: 56px; height: 4px; margin-top: 10px; border-radius: 4px; background: var(--grad); }

.prose { max-width: 820px; }
.prose h2 { font-size: 26px; margin-top: 1.6em; }
.prose h3 { font-size: 21px; margin-top: 1.4em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose li { margin: 0.25em 0; }
.prose li::marker { color: var(--accent); font-weight: 700; }
.prose strong { color: var(--accent-fg); }
.intro { max-width: var(--container); padding-top: 8px; font-size: 18px; }
.intro > * { max-width: 780px; }

.chapter-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
}
.card::before { content: ''; height: 4px; background: var(--grad); }
.card:not(.is-upcoming):hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-link { display: block; padding: 22px 24px 18px; color: inherit; text-decoration: none; flex: 1; }
.card-num {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  margin-bottom: 14px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card .tag { position: absolute; top: 26px; right: 22px; }
.card h3 { font-size: 22px; margin-bottom: 8px; }
.card p { color: var(--muted); margin: 0 0 14px; font-size: 15.5px; }
.card-actions { display: flex; border-top: 1px solid var(--line); }
.card-actions a {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}
.card-actions a + a { border-left: 1px solid var(--line); }
.card-actions a:hover { background: var(--accent-soft); color: var(--accent-fg); }
.card.is-upcoming { opacity: 0.6; box-shadow: none; border-style: dashed; }
.card.is-upcoming::before { background: var(--line); }
.card.is-upcoming .card-num { background: none; color: var(--muted); }
.card.is-draft { border-color: color-mix(in srgb, var(--c-draft) 45%, var(--line)); }

.meta-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 14px; }
.meta-list li { display: inline-flex; align-items: center; gap: 6px; }

.empty { color: var(--muted); padding: 32px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

.howto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.howto-grid > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.howto-grid h3 { font-size: 17px; margin: 12px 0 6px; }
.howto-grid p { margin: 0; color: var(--muted); font-size: 14.5px; }
.howto-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-fg); font-size: 20px; }

/* ---------- Page chapitre ---------- */
.chapter-head { padding-top: 44px; padding-bottom: 20px; }
.chapter-head h1 { font-size: clamp(32px, 5vw, 52px); }
.lede { font-size: 19px; color: var(--muted); margin: 0 0 16px; max-width: 760px; }

.toolbar {
  position: sticky;
  top: 60px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 10px;
  margin-bottom: 20px;
}
.toolbar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 14.5px/1 var(--font-body);
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--fg); background: var(--surface-2); }
.tab[aria-selected='true'] { background: var(--accent-soft); color: var(--accent-fg); }

/* Menu exporter */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(340px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 30;
}
.menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--fg);
  text-align: left;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.menu-item:hover { background: var(--accent-soft); }
.menu-item .icon { margin-top: 3px; color: var(--accent-fg); }
.menu-item span { display: flex; flex-direction: column; line-height: 1.3; }
.menu-item strong { font-size: 15px; }
.menu-item small { color: var(--muted); font-size: 13px; }

/* ---------- Diapositives (Marp) ---------- */
.slides-view { padding-inline: 24px; }
.slides-view .marpit > svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  background: #fff;
}

.stage-wrap { max-width: var(--container); margin-inline: auto; }
.controls, .progress { display: none; }

/* Mode diaporama */
.slides-view[data-mode='diapo'] .stage-wrap { max-width: 1040px; }
.slides-view[data-mode='diapo'] .marpit > svg { display: none; cursor: pointer; }
.slides-view[data-mode='diapo'] .marpit > svg.is-active { display: block; }
.slides-view[data-mode='diapo'] .controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}
.slides-view[data-mode='diapo'] .progress {
  display: block;
  height: 4px;
  margin: 14px auto 0;
  max-width: 320px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.progress span { display: block; height: 100%; width: 0; background: var(--grad); transition: width 0.25s; }
.counter { font-family: var(--font-mono); font-size: 14px; font-weight: 600; min-width: 84px; text-align: center; color: var(--muted); }
.controls [data-action='fullscreen'] { margin-left: 14px; }

/* Plein écran */
.stage-wrap:fullscreen {
  max-width: none;
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px;
}
.stage-wrap:fullscreen .marpit > svg.is-active {
  height: calc(100vh - 90px);
  width: 100%;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
}
.stage-wrap:fullscreen .controls { margin-top: 10px; opacity: 0.35; transition: opacity 0.2s; }
.stage-wrap:fullscreen .controls:hover { opacity: 1; }
.stage-wrap:fullscreen .icon-btn { background: #111; color: #fff; border-color: #333; }
.stage-wrap:fullscreen .counter { color: #aaa; }
.stage-wrap:fullscreen .progress { position: absolute; left: 0; right: 0; bottom: 0; max-width: none; margin: 0; border-radius: 0; background: #222; }

/* Mode défilement */
.slides-view[data-mode='defilement'] .marpit { display: grid; gap: 32px; max-width: 980px; margin-inline: auto; }

/* Mode vue d'ensemble */
.slides-view[data-mode='apercu'] .marpit {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.slides-view[data-mode='apercu'] .marpit > svg {
  cursor: pointer;
  box-shadow: var(--shadow);
  outline: 2px solid transparent;
  transition: transform 0.15s, outline-color 0.15s;
}
.slides-view[data-mode='apercu'] .marpit > svg:hover,
.slides-view[data-mode='apercu'] .marpit > svg:focus-visible { transform: translateY(-3px); outline-color: var(--accent); }
.slides-view[data-mode='apercu'] .marpit > svg.is-active { outline-color: var(--accent); }

/* ---------- Navigation entre chapitres ---------- */
.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-block: 56px 24px; }
.chapter-nav-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
}
.chapter-nav-link:hover { border-color: var(--accent); }
.chapter-nav-link small { color: var(--muted); }
.chapter-nav-link.next { text-align: right; grid-column: 2; }

/* ---------- Pied de page ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding-block: 24px; color: var(--muted); font-size: 14px; }
.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .container, .topbar-inner { padding-inline: 16px; }
  .slides-view { padding-inline: 16px; }
  .crumb { display: none; }
  .hero { padding: 48px 0 32px; }
  .toolbar { top: 57px; }
  .tab span { display: none; }
  .tab { padding: 10px 12px; }
  .tab[aria-selected='true'] span { display: inline; }
  .menu > summary span { display: none; }
  .menu > summary { padding: 11px 13px; }
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav-link.next { grid-column: auto; }
  .slides-view[data-mode='apercu'] .marpit { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .slides-view .marpit > svg { border-radius: 8px; }
  .slides-view[data-mode='defilement'] .marpit { gap: 16px; }
}

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

/* ---------- Impression (Ctrl+P) : contenu seul ---------- */
@media print {
  .topbar, .toolbar, .chapter-nav, .site-footer, .controls, .progress { display: none !important; }
  body { background: #fff; }
  .doc-desk { background: none; padding: 0; }
  .doc { box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- Documents à télécharger (dossier supports/) ---------- */
.supports { padding-top: 40px; }
.supports-intro { color: var(--muted); margin: -6px 0 18px; }
.support-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.support {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.support:hover, .support:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.support-icon { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-fg); }
.support-text { flex: 1; min-width: 0; }
.support-text strong { display: block; overflow-wrap: anywhere; }
.support-text small { color: var(--muted); }
.support-dl { flex: none; color: var(--muted); }
.support:hover .support-dl { color: var(--accent-fg); }
@media print { .supports { display: none; } }
