/* ═══════════════════════════════════════════════
   PrépaConcours — Styles pages de modules
═══════════════════════════════════════════════ */

/* ── Breadcrumb ──────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--clr-muted);
  padding-block: 1rem;
}
.breadcrumb a { color: var(--clr-primary); transition: var(--transition); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb__sep { color: var(--clr-border); }

/* ── Module hero ─────────────────────────────── */
.module-hero {
  background: linear-gradient(135deg, var(--clr-primary-dk) 0%, var(--clr-primary) 100%);
  padding-block: 3.5rem;
  position: relative;
  overflow: hidden;
}
.module-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.module-hero__inner {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}
.module-hero__icon {
  font-size: 3.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.module-hero__content { flex: 1; }
.module-hero__tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.8);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 99px;
  padding: .2rem .75rem;
  margin-bottom: .875rem;
}
.module-hero__title {
  font-family: var(--ff-display);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  color: #fff;
  line-height: 1.2;
  margin-bottom: .875rem;
}
.module-hero__desc {
  font-size: 1rem;
  color: rgba(255,255,255,.8);
  line-height: 1.7;
  max-width: 42rem;
  margin-bottom: 1.5rem;
}
.module-hero__meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.module-hero__meta span {
  font-size: .875rem;
  color: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  gap: .35rem;
}

/* ── Module layout ───────────────────────────── */
.module-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 2.5rem;
  align-items: start;
  padding-block: 3rem;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.sidebar-card {
  background: #fff;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.sidebar-card h3 {
  font-size: .875rem;
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--clr-border);
}
.toc-list { display: flex; flex-direction: column; gap: .25rem; }
.toc-list li a {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--clr-muted);
  padding: .35rem .5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.toc-list li a:hover, .toc-list li a.active {
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
}
.toc-list li a .toc-num {
  font-size: .7rem;
  font-weight: 700;
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
  border-radius: 99px;
  padding: .1rem .4rem;
  flex-shrink: 0;
}
/* Regroupement optionnel de chapitres (chapters.group_label) : simple séparateur
   visuel, sans nouveau niveau de hiérarchie (le chapitre reste l'unité de base). */
.toc-list__group {
  font-size: .7rem;
  font-weight: 700;
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: .9rem 0 .3rem;
  padding-top: .6rem;
  border-top: 1px solid var(--clr-border);
}
.toc-list__group:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.chapter-group-header {
  font-size: .95rem;
  font-weight: 700;
  color: var(--clr-primary-dk);
  background: var(--clr-primary-lt);
  border-radius: var(--radius-sm);
  padding: .55rem .9rem;
  margin: 1.5rem 0 .75rem;
}
.chapter-group-header:first-child { margin-top: 0; }

.progress-bar-wrap {
  background: var(--clr-surface);
  border-radius: 99px;
  height: 6px;
  margin-bottom: .5rem;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--clr-primary);
  border-radius: 99px;
  transition: width .6s ease;
}
.progress-label {
  font-size: .75rem;
  color: var(--clr-muted);
}

.modules-nav { display: flex; flex-direction: column; gap: .375rem; }
.modules-nav a {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-size: .8125rem;
  color: var(--clr-muted);
  padding: .5rem .625rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.modules-nav a:hover { color: var(--clr-primary); background: var(--clr-primary-lt); }
.modules-nav a.current {
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
  font-weight: 600;
}
.modules-nav a .nav-icon { font-size: 1.1rem; }

/* ── Chapter accordion ───────────────────────── */
.chapters { display: flex; flex-direction: column; gap: 1rem; }

.chapter {
  background: #fff;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.chapter:hover { box-shadow: var(--shadow-sm); }
.chapter.is-open { box-shadow: var(--shadow-md); }

.chapter__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.chapter__header:hover { background: var(--clr-bg-alt); }
.chapter.is-open .chapter__header { background: var(--clr-primary-lt); border-bottom: 1px solid rgba(29,78,216,.12); }

.chapter__num {
  font-size: .75rem;
  font-weight: 700;
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
  border: 1px solid rgba(29,78,216,.2);
  border-radius: 99px;
  padding: .2rem .6rem;
  flex-shrink: 0;
  min-width: 2.25rem;
  text-align: center;
}
.chapter.is-open .chapter__num {
  background: var(--clr-primary);
  color: #fff;
  border-color: var(--clr-primary);
}
.chapter__title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--clr-text);
  line-height: 1.35;
}
.chapter__meta {
  font-size: .75rem;
  color: var(--clr-muted);
  flex-shrink: 0;
}
.chapter__arrow {
  font-size: .875rem;
  color: var(--clr-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.chapter.is-open .chapter__arrow { transform: rotate(180deg); }

.chapter__body {
  display: none;
  padding: 1.75rem 1.5rem;
  border-top: 1px solid var(--clr-border);
}
.chapter.is-open .chapter__body { display: block; }

/* ══════════════════════════════════════════════
   CHAPTER BODY — prose root
   All chapter content lives inside .chapter__body
   ══════════════════════════════════════════════ */
.chapter__body {
  font-size: .9375rem;
  line-height: 1.85;
  color: #374151;
}

/* ── Headings ─────────────────────────────────
   h3 = section (numbered, colored bar on start)
   h4 = subsection (arrow prefix)
   ─────────────────────────────────────────── */
.chapter__body h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-primary-dk);
  background: var(--clr-primary-lt);
  border-inline-start: 4px solid var(--clr-primary);
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-start-end-radius: .5rem;
  border-end-end-radius: .5rem;
  padding-block: .625rem;
  padding-inline: 1rem;
  padding-inline-start: 1.125rem;
  margin-block: 1.875rem .875rem;
}
.chapter__body h3:first-child { margin-top: 0; }
.chapter-intro + h3,
.chapter-intro + * + h3 { margin-top: 1.25rem; }

.chapter__body h4 {
  font-size: .9375rem;
  font-weight: 700;
  color: #111827;
  margin-block: 1.375rem .5rem;
  display: flex;
  align-items: center;
  gap: .375rem;
}
.chapter__body h4::before {
  content: '▸';
  color: var(--clr-primary);
  font-size: .75rem;
  flex-shrink: 0;
  opacity: .9;
}

/* ── Body text ────────────────────────────────── */
.chapter__body p {
  margin-bottom: .875rem;
}
.chapter__body p:last-child { margin-bottom: 0; }
.chapter__body strong {
  font-weight: 600;
  color: #111827;
}
.chapter__body em {
  color: var(--clr-muted);
  font-style: italic;
}
.chapter__body code {
  font-family: 'Courier New', Consolas, monospace;
  font-size: .875em;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: .3rem;
  padding: .1rem .4rem;
  color: #1e3a8a;
  white-space: nowrap;
}

/* ── Chapter intro box ───────────────────────── */
.chapter-intro {
  background: linear-gradient(135deg, #f0f9ff, var(--clr-primary-lt));
  border: 1px solid rgba(29,78,216,.15);
  border-inline-start: 3px solid var(--clr-primary);
  border-radius: .75rem;
  padding: 1.125rem 1.375rem;
  margin-bottom: 1.5rem;
}
.chapter-intro p {
  font-size: .9375rem;
  color: #1e40af;
  line-height: 1.8;
  margin: 0;
}

/* ── Custom list ─────────────────────────────── */
.content-list {
  list-style: none;
  padding: 0;
  margin-block: .5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.content-list > li {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  line-height: 1.7;
}
.content-list > li::before {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  min-width: 7px;
  background: var(--clr-primary);
  border-radius: 50%;
  margin-top: .55rem;
  opacity: .75;
}

/* Ordered list inside chapter body */
.chapter__body ol {
  padding-inline-start: 1.625rem;
  margin-block: .5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  list-style: decimal;
}
.chapter__body ol > li {
  padding-inline-start: .25rem;
  line-height: 1.7;
}

/* ── Table ───────────────────────────────────── */
.bl-table {
  overflow-x: auto;
  margin-block: .75rem 1.25rem;
  border-radius: .75rem;
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow-sm);
}
.bl-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.bl-table thead tr {
  background: var(--clr-primary);
  color: #fff;
}
.bl-table thead th {
  padding: .7rem 1rem;
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .04em;
  text-align: start;
  border: none;
}
.bl-table tbody tr {
  border-bottom: 1px solid var(--clr-border);
  transition: background var(--transition);
}
.bl-table tbody tr:last-child { border-bottom: none; }
.bl-table tbody tr:nth-child(even) { background: #f8fafc; }
.bl-table tbody tr:hover { background: var(--clr-primary-lt); }
.bl-table tbody td {
  padding: .6rem 1rem;
  color: #374151;
  vertical-align: top;
  line-height: 1.6;
  border-inline-end: 1px solid var(--clr-border);
}
.bl-table tbody td:last-child { border-inline-end: none; }
.bl-table tbody td strong { color: var(--clr-primary-dk); font-weight: 600; }
/* Cell with rowspan: add subtle separator */
.bl-table tbody td[rowspan] {
  background: #f0f9ff;
  font-weight: 600;
  color: var(--clr-primary-dk);
  border-inline-end: 2px solid rgba(29,78,216,.2);
}

/* ── Definition / formula box ────────────────── */
.def-box {
  background: #f0f9ff;
  border: 1px solid #a7f3d0;
  border-inline-start: 4px solid #1d4ed8;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-start-end-radius: .75rem;
  border-end-end-radius: .75rem;
  padding: 1rem 1.375rem;
  margin-block: 1.125rem;
  font-size: .875rem;
  color: #1e3a8a;
  line-height: 1.75;
}
.def-box strong {
  display: block;
  color: #1d4ed8;
  font-weight: 700;
  font-size: .8125rem;
  letter-spacing: .04em;
  margin-bottom: .375rem;
}
.def-box code {
  display: block;
  background: #fff;
  border: 1px solid #a7f3d0;
  border-radius: .4rem;
  padding: .5rem 1rem;
  font-family: 'Courier New', Consolas, monospace;
  font-size: .9em;
  color: #1d4ed8;
  font-weight: 600;
  margin-block: .5rem .25rem;
  white-space: normal;
}
.def-box em {
  color: #6b7280;
  font-style: italic;
  font-size: .8125rem;
  margin-top: .25rem;
  display: block;
}

/* ── Exam tip box ─────────────────────────────── */
.tip-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-inline-start: 4px solid #d97706;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-start-end-radius: .75rem;
  border-end-end-radius: .75rem;
  padding: .875rem 1.375rem;
  margin-block: 1.25rem 0;
  font-size: .875rem;
  color: #78350f;
  line-height: 1.75;
}
.tip-box strong {
  color: #92400e;
  font-weight: 700;
}

/* ── Module sidebar (actual PHP class) ──────── */
.module-sidebar {
  position: sticky;
  top: 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar-widget {
  background: #fff;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}
.video-widget__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: .6rem;
  overflow: hidden;
  background: #000;
}
.video-widget__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-widget__title {
  margin-top: .75rem;
  font-size: .85rem;
  font-weight: 700;
  color: var(--clr-text);
  line-height: 1.5;
}
.video-widget__link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-top: .5rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--clr-primary);
  text-decoration: none;
}
.video-widget__link:hover { text-decoration: underline; }
.sidebar-widget h4 {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: .875rem;
  padding-bottom: .625rem;
  border-bottom: 1px solid var(--clr-border);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.sidebar-widget ul {
  display: flex;
  flex-direction: column;
  gap: .125rem;
  list-style: none;
  padding: 0;
}
.sidebar-widget ul li {
  font-size: .8125rem;
  color: var(--clr-muted);
  padding: .3rem .5rem;
  border-radius: .375rem;
}
.toc-list { gap: .1rem; }
.toc-list li a {
  display: block;
  text-align: start;
  font-size: .8125rem;
  color: var(--clr-muted);
  padding: .4rem .625rem;
  border-radius: .375rem;
  transition: var(--transition);
  line-height: 1.4;
}
.toc-list li a:hover,
.toc-list li a.active {
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
}

/* Concept clé avec indice (infobulle au survol / focus) */
.sidebar-widget li.kw-hint {
  cursor: help;
  position: relative;
  padding-inline-start: 1.1rem;
  text-decoration: underline dotted var(--clr-primary);
  text-underline-offset: 3px;
  transition: var(--transition);
}
.sidebar-widget li.kw-hint::before {
  content: 'ⓘ';
  position: absolute;
  inset-inline-start: 0;
  color: var(--clr-primary);
  font-size: .8em;
  opacity: .8;
}
.sidebar-widget li.kw-hint:hover,
.sidebar-widget li.kw-hint:focus {
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
  border-radius: .375rem;
  outline: none;
}

/* ═══════════════════════════════════════════════
   CONTENT COMPONENTS (used inside .chapter__body)
   grid-2 · card-concept · steps-inline · exam-tip · ex-ar
   ═══════════════════════════════════════════════ */

/* ── Two-column concept grid ─────────────────── */
.chapter__body .grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-block: 1rem 1.25rem;
}
@media (max-width: 640px) {
  .chapter__body .grid-2 { grid-template-columns: 1fr; }
}

/* ── Concept card ────────────────────────────── */
.chapter__body .card-concept {
  background: #fff;
  border: 1px solid var(--clr-border);
  border-top: 3px solid var(--clr-primary);
  border-radius: .75rem;
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.chapter__body .card-concept:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.chapter__body .card-concept h4 {
  margin-top: 0;
  margin-bottom: .5rem;
  font-size: .9375rem;
  color: var(--clr-primary-dk);
}
.chapter__body .card-concept h4::before { content: none; }
.chapter__body .card-concept p:last-child,
.chapter__body .card-concept ul:last-child { margin-bottom: 0; }
.chapter__body .card-concept ul {
  margin-block: .25rem 0;
  padding-inline-start: 1.1rem;
}
.chapter__body .card-concept li { line-height: 1.6; }

/* ── Inline numbered steps ───────────────────── */
.chapter__body .steps-inline {
  display: flex;
  flex-direction: column;
  gap: .625rem;
  margin-block: 1rem 1.25rem;
}
.chapter__body .step-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--clr-bg-alt, #f8fafc);
  border: 1px solid var(--clr-border);
  border-radius: .625rem;
  padding: .75rem .875rem;
  line-height: 1.65;
}
.chapter__body .step-badge {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-primary);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  border-radius: 50%;
}

/* ── Exam tip (inline span-icon variant) ─────── */
.chapter__body .exam-tip {
  display: block;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-inline-start: 4px solid #d97706;
  border-radius: .75rem;
  padding: .875rem 1.25rem;
  margin-block: 1.25rem .25rem;
  font-size: .875rem;
  color: #78350f;
  line-height: 1.75;
}
.chapter__body .exam-tip strong { color: #92400e; font-weight: 700; }

/* ── Application / inspector note ────────────── */
.chapter__body .ex-ar {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-inline-start: 4px solid #16a34a;
  border-radius: .75rem;
  padding: .875rem 1.25rem;
  margin-block: 1.125rem .25rem;
  font-size: .875rem;
  color: #14532d;
  line-height: 1.75;
}
.chapter__body .ex-ar strong { color: #166534; font-weight: 700; }

/* Legacy plain <table class="bl-table"> (no wrapper div) */
.chapter__body table.bl-table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  margin-block: .75rem 1.25rem;
  border: 1px solid var(--clr-border);
  border-radius: .75rem;
  overflow: hidden;
}
.chapter__body table.bl-table thead tr { background: var(--clr-primary); color: #fff; }
.chapter__body table.bl-table th { padding: .7rem 1rem; text-align: start; font-weight: 600; }
.chapter__body table.bl-table td {
  padding: .6rem 1rem;
  border-top: 1px solid var(--clr-border);
  vertical-align: top;
  line-height: 1.6;
}
.chapter__body table.bl-table tbody tr:nth-child(even) { background: #f8fafc; }

/* ── Objectives ──────────────────────────────── */
.objectives {
  background: var(--clr-primary-lt);
  border: 1px solid rgba(29,78,216,.15);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-bottom: 2rem;
}
.objectives h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.objectives ul {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  list-style: none;
  padding: 0;
}
.objectives li {
  font-size: .9375rem;
  color: #1e3a8a;
  display: flex;
  gap: .625rem;
  align-items: flex-start;
}
.objectives li::before {
  content: '✓';
  color: var(--clr-primary);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: .1rem;
}

/* ── Module CTA ──────────────────────────────── */
.module-cta {
  background: linear-gradient(135deg, var(--clr-primary-dk) 0%, var(--clr-primary) 100%);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  color: #fff;
  margin-top: 2rem;
}
.module-cta h3 {
  font-family: var(--ff-display);
  font-size: 1.375rem;
  margin-bottom: .5rem;
}
.module-cta p {
  color: rgba(255,255,255,.8);
  font-size: .9375rem;
  margin-bottom: 1.25rem;
}
.module-cta .btn--white:hover { background: var(--clr-primary-lt); }

/* ── Module navigation (prev/next) ───────────── */
.module-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 2rem;
  border-top: 1px solid var(--clr-border);
  margin-top: 2rem;
}
.pager-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  transition: var(--transition);
  max-width: 48%;
  flex: 1;
}
.pager-link--next { justify-content: flex-end; text-align: right; }
.pager-link:hover { border-color: var(--clr-primary); box-shadow: var(--shadow-sm); }
.pager-link__label { font-size: .75rem; color: var(--clr-muted); margin-bottom: .2rem; }
.pager-link__title { font-size: .9375rem; font-weight: 600; color: var(--clr-text); }
.pager-arrow { font-size: 1.25rem; color: var(--clr-primary); flex-shrink: 0; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 900px) {
  .module-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; }
}
@media (max-width: 600px) {
  .module-hero__inner { flex-direction: column; gap: 1rem; }
  .module-pager { flex-direction: column; }
  .pager-link { max-width: 100%; }
}


/* ── Reading progress enhancements ───────────── */
.chapter.is-read .chapter__header {
  border-inline-start: 4px solid #16a34a;
}
.chapter.is-read .chapter__header::after {
  content: '✓';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  font-size: .8rem;
  font-weight: 800;
  margin-inline-start: .5rem;
}
/* button reset — chapter header is now a <button> */
button.chapter__header {
  border: none;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  width: 100%;
  text-align: start;
  box-sizing: border-box;
}
.chapter__header:focus-visible,
.toc-list a:focus-visible {
  outline: 3px solid rgba(29,78,216,.35);
  outline-offset: 3px;
}
@media (max-width: 600px) {
  .chapter__header { gap: .75rem; }
  .chapter__meta { font-size: .75rem; }
  .chapter__body table { display: block; overflow-x: auto; white-space: nowrap; }
}


/* ── Academy theme module refinements ────────── */
.sidebar-card,
.chapter,
.module-cta,
.objectives,
.pager-link {
  box-shadow: var(--shadow-sm);
}
.chapter {
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(220,231,226,.92);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.chapter + .chapter { margin-top: 1rem; }
.chapter__header {
  background: linear-gradient(135deg, #ffffff, #f4f8ff);
  transition: background .18s ease, color .18s ease;
}
.chapter.is-open .chapter__header {
  background: linear-gradient(135deg, var(--clr-primary-lt), #fff7ed);
  color: var(--clr-heading);
}
.chapter__body {
  background: #fff;
}
.chapter__body h3,
.chapter__body h4 {
  color: var(--clr-heading);
}
.chapter__body h4::before { color: var(--clr-accent); }
.chapter__body table.bl-table {
  border-color: var(--clr-border);
  box-shadow: var(--shadow-sm);
}
.chapter__body table.bl-table thead tr {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-dk));
}
.chapter__body table.bl-table tbody tr:nth-child(even) { background: #f8fbff; }
.toc-list li a {
  border-radius: .55rem;
  color: var(--clr-muted);
}
.toc-list li a.active {
  background: var(--clr-primary-lt);
  color: var(--clr-primary-dk);
  font-weight: 800;
}
.progress-bar {
  background: #eef6ff;
}
.modules-nav a:hover {
  background: var(--clr-primary-lt);
  color: var(--clr-primary-dk);
}
.key-term {
  background: linear-gradient(135deg, #fff, #f8fbff);
  border-color: var(--clr-border);
}
.key-term__word { color: var(--clr-primary-dk); }
.callout {
  background: #f8fbff;
  border-color: var(--clr-primary);
}
.callout--warn {
  background: #fff7ed;
  border-color: var(--clr-accent);
}
.callout--tip {
  background: #ecfdf5;
  border-color: #16a34a;
}


/* Module action buttons */
.module-actions {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  margin-top: 2rem;
}
.module-actions__quiz {
  display: grid;
  justify-items: center;
  gap: .8rem;
}
.module-actions__title {
  color: var(--clr-text);
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}
.module-actions__levels,
.module-actions__return {
  display: flex;
  justify-content: center;
  gap: .75rem;
  flex-wrap: wrap;
  width: 100%;
}
.module-actions__btn {
  justify-content: center;
  min-width: 12.5rem;
  max-width: 100%;
  min-height: 4.5rem;
  text-align: center;
}

@media (max-width: 480px) {
  .module-actions__levels,
  .module-actions__return {
    align-items: stretch;
    flex-direction: column;
  }
  .module-actions__btn {
    width: 100%;
    min-width: 0;
  }
}


/* Contrast audit fixes: lesson content in dark mode */
html[data-theme="dark"] .chapter__body,
html[data-theme="dark"] .chapter__body .lesson-block {
  background:#172033 !important;
  color:#eaf2ff !important;
}
html[data-theme="dark"] .chapter__body p,
html[data-theme="dark"] .chapter__body li,
html[data-theme="dark"] .chapter__body td,
html[data-theme="dark"] .chapter__body .note-box,
html[data-theme="dark"] .chapter__body .lesson-block p,
html[data-theme="dark"] .chapter__body .lesson-block li {
  color:#dbe7ff !important;
}
html[data-theme="dark"] .chapter__body h3,
html[data-theme="dark"] .chapter__body h4,
html[data-theme="dark"] .chapter__body strong {
  color:#f8fbff !important;
}
html[data-theme="dark"] .chapter__body .note-box,
html[data-theme="dark"] .chapter__body .callout,
html[data-theme="dark"] .chapter__body .card-concept {
  background:#0f172a !important;
  border-color:rgba(96,165,250,.28) !important;
}
html[data-theme="dark"] .toc-list a,
html[data-theme="dark"] .sidebar-widget,
html[data-theme="dark"] .sidebar-card {
  background:#172033 !important;
  color:#cbd5e1 !important;
  border-color:rgba(96,165,250,.26) !important;
}
html[data-theme="dark"] .toc-list a.active {
  background:rgba(96,165,250,.18) !important;
  color:#f8fbff !important;
}
html[data-theme="dark"] .sidebar-widget h4,
html[data-theme="dark"] .sidebar-card h3 {
  color:#f8fbff !important;
}


html[data-theme="dark"] .objectives,
html[data-theme="dark"] .chapter-intro,
html[data-theme="dark"] .def-box,
html[data-theme="dark"] .chapter__body code {
  background:#0f172a !important;
  color:#dbeafe !important;
  border-color:rgba(96,165,250,.30) !important;
}
html[data-theme="dark"] .objectives h3,
html[data-theme="dark"] .objectives li,
html[data-theme="dark"] .chapter-intro li,
html[data-theme="dark"] .chapter-intro p,
html[data-theme="dark"] .def-box,
html[data-theme="dark"] .def-box strong,
html[data-theme="dark"] .toc-list li,
html[data-theme="dark"] .toc-list li a,
html[data-theme="dark"] .toc-list li a .toc-num {
  color:#eaf2ff !important;
}
html[data-theme="dark"] .toc-list li a.active,
html[data-theme="dark"] .toc-list li a:hover {
  background:rgba(37,99,235,.24) !important;
  color:#ffffff !important;
  border-color:rgba(147,197,253,.40) !important;
}

/* ── Dark mode : tableaux bl-table ──────────────────────── */
html[data-theme="dark"] .bl-table {
  border-color: rgba(96,165,250,.22) !important;
}
html[data-theme="dark"] .bl-table tbody td,
html[data-theme="dark"] .chapter__body table.bl-table td {
  color: #dbe7ff !important;
  border-color: rgba(96,165,250,.15) !important;
}
html[data-theme="dark"] .bl-table tbody td strong,
html[data-theme="dark"] .chapter__body table.bl-table td strong {
  color: #bfdbfe !important;
}
html[data-theme="dark"] .bl-table tbody tr:nth-child(even),
html[data-theme="dark"] .chapter__body table.bl-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,.05) !important;
}
html[data-theme="dark"] .bl-table tbody tr:hover,
html[data-theme="dark"] .chapter__body table.bl-table tbody tr:hover {
  background: rgba(96,165,250,.12) !important;
}
html[data-theme="dark"] .bl-table tbody td[rowspan],
html[data-theme="dark"] .chapter__body table.bl-table td[rowspan] {
  background: rgba(37,99,235,.15) !important;
  color: #93c5fd !important;
  border-color: rgba(96,165,250,.3) !important;
}
html[data-theme="dark"] .exam-tip {
  background: #0f172a !important;
  color: #dbeafe !important;
  border-color: rgba(96,165,250,.3) !important;
}
html[data-theme="dark"] .tip-box {
  background: rgba(180,83,9,.12) !important;
  border-color: rgba(251,191,36,.3) !important;
  color: #fcd34d !important;
}
html[data-theme="dark"] .tip-box strong { color: #fde68a !important; }
html[data-theme="dark"] .chapter__body .ex-ar {
  background: rgba(22,163,74,.10) !important;
  border-color: rgba(74,222,128,.25) !important;
  color: #bbf7d0 !important;
}
html[data-theme="dark"] .chapter__body .ex-ar strong { color: #86efac !important; }


/* Mobile overflow guard for lesson pages */
@media (max-width: 600px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .module-page,
  .module-layout,
  .main-content,
  .chapters,
  .chapter,
  .chapter__header,
  .chapter__body,
  .objectives,
  .sidebar-card,
  .sidebar-widget {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .chapter,
  .objectives {
    width: 100%;
  }
  .chapter__title,
  .chapter__meta,
  .chapter__body,
  .chapter__body * {
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .chapter__body code {
    white-space: normal;
  }
  .header .nav > div[style*="display:flex"] {
    min-width: 0;
    margin-inline-start: auto;
  }
  .header .nav__portal,
  .header .theme-toggle {
    display: none !important;
  }
}

/* ════════════════════════════════════════════════
   CONTENT SAFETY — données larges (toutes largeurs)
   127 chapitres contiennent des <table> ; on garantit
   qu'aucun tableau / média ne casse la mise en page.
   ════════════════════════════════════════════════ */
/* Tableaux bruts (non enveloppés dans .bl-table) : défilent au lieu de déborder */
.chapter__body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* On préserve le comportement du wrapper .bl-table (lui défile déjà) */
.bl-table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  contain: inline-size;
}
.bl-table table {
  display: table;
  overflow: visible;
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.bl-table th,
.bl-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
/* Médias jamais plus larges que le conteneur */
.chapter__body img,
.chapter__body video,
.chapter__body iframe,
.chapter__body svg {
  max-width: 100%;
  height: auto;
}
/* Figures (schémas SVG) : même traitement que .bl-table — défilent au lieu
   de déborder, et ne forcent jamais le conteneur (grid/flex) à s'élargir */
.chapter__body figure {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  contain: inline-size;
}
/* Longues chaînes (URL, mots) ne forcent pas un débordement horizontal */
.chapter__body { overflow-wrap: anywhere; }
.chapter__body pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
}

/* ═══════════════════════════════════════════════
   MODAL IFRAME — ressources interactives (pop-up)
   ═══════════════════════════════════════════════ */
.iframe-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0px, 3vw, 32px);
}
.iframe-modal[hidden] { display: none; }
.iframe-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.iframe-modal__panel {
  position: relative;
  width: min(1200px, 96vw);
  height: min(92vh, 100%);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .32);
  animation: iframeModalIn .22s ease;
}
@keyframes iframeModalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.iframe-modal__bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .75rem;
  background: var(--clr-primary);
  color: #fff;
  flex-shrink: 0;
}
.iframe-modal__title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iframe-modal__btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease;
}
.iframe-modal__btn:hover { background: rgba(255, 255, 255, .34); }
.iframe-modal__body { flex: 1; min-height: 0; background: #fff; }
.iframe-modal__frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
@media (max-width: 640px) {
  .iframe-modal { padding: 0; }
  .iframe-modal__panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
}
