/* ============================================================
   Tuto-CRPE — lessons.css
   Styles des pages de leçons (dossiers lecons-francais/ et
   lecons-maths/ + index lecons-francais.html / lecons-maths.html) :
   tables de synthèse, listes, cartes et groupes de l'index.
   S'appuie sur les variables de base.css.
   ============================================================ */

/* ============================ PROSE (corps de leçon) ============================ */
.prose {
  max-width: 780px;
}
.prose h2 {
  scroll-margin-top: 90px; /* ancrage confort sous l'en-tête fixe */
}
.prose h3 {
  margin-top: 30px;
}
.prose p:last-child {
  margin-bottom: 0;
}
.prose em {
  font-style: italic;
}

/* ---------- Blocs « Pourquoi pas l'autre ? » ---------- */
.alternative {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
}
.alternative h3 {
  font-size: .92rem;
  font-weight: 700;
  color: var(--warn-soft-text);
  margin-bottom: 8px;
}
.alternative p {
  font-size: .93rem;
  margin: 0 0 8px;
}
.alternative:last-child {
  margin-bottom: 0;
}

/* ---------- Bloc « Astuce CRPE » amélioré ---------- */
.callout {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 24px 0;
  font-size: .95rem;
}
.callout p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .alternative {
    padding: 14px 16px;
  }
  /* Tables : scroll horizontal sur mobile */
  .prose table {
    font-size: .85rem;
    display: block;
    overflow-x: auto;
    white-space: normal;
  }
  .prose thead th,
  .prose tbody td {
    padding: 8px 10px;
  }
  /* Prose : largeur réduite sur mobile */
  .prose {
    max-width: 100%;
    padding: 0 4px;
  }
  /* Boutons hero-cta : empiler sur mobile */
  .hero-cta {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-cta .btn {
    justify-content: center;
    width: 100%;
  }
}

/* ============================ TABLES ============================ */
.prose table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  width: 100%;
  margin: 18px 0 26px;
  font-size: .95rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
}
.prose table td:first-child {
  font-weight: 600;
}
.prose thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 11px 16px;
  border-bottom: 2px solid var(--border);
  white-space: normal;
  word-wrap: break-word;
}
.prose thead th:first-child {
  border-top-left-radius: calc(var(--radius) - 1px);
}
.prose thead th:last-child {
  border-top-right-radius: calc(var(--radius) - 1px);
}
.prose tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 120px;
}
.prose tbody tr:nth-child(even) {
  background: var(--surface);
}
.prose tbody tr:last-child td {
  border-bottom: none;
}
.prose tbody tr:last-child td:first-child {
  border-bottom-left-radius: calc(var(--radius) - 1px);
}
.prose tbody tr:last-child td:last-child {
  border-bottom-right-radius: calc(var(--radius) - 1px);
}

/* ============================ CARTES DE L'INDEX DES LEÇONS ============================ */
.lecon-card h3 {
  font-size: 1.02rem;
  line-height: 1.35;
}
.lecon-card p {
  color: var(--muted);
  font-size: .93rem;
}

/* ============================ GROUPES DE L'INDEX DES LEÇONS ============================ */
.lecons-groupe {
  scroll-margin-top: 90px;
}
.lecons-groupe + .lecons-groupe {
  margin-top: 48px;
}
.lecons-groupe > h2 {
  font-size: 1.45rem;
  margin-bottom: 18px;
}
.lecons-groupe > h2 .groupe-count {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 10px;
  vertical-align: middle;
}

/* ============================ BLOC « À RETENIR » ============================ */
.a-retenir {
  background: linear-gradient(135deg, var(--primary-soft) 0%, color-mix(in srgb, var(--primary-soft) 50%, var(--success-soft) 50%) 100%);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
  box-shadow: var(--shadow-sm);
}
.a-retenir::before {
  content: ' À retenir';
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-soft-text);
  margin-bottom: 8px;
}
.a-retenir ul {
  margin: 0;
  padding-left: 20px;
}
.a-retenir li {
  margin-bottom: 6px;
  font-size: .93rem;
}
.a-retenir li:last-child {
  margin-bottom: 0;
}

/* ============================ IMPRESSION ============================ */
@media print {
  .site-header,
  .site-footer,
  .hero-cta,
  .skip-link {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .prose table {
    display: table;
    border-radius: 0;
    max-width: none;
  }
  .prose tbody tr:nth-child(even) {
    background: #f3f4f6;
  }
}
