/* Rendu du contenu d'un cours : titres, listes, callouts, médias, cartes, formules. */

/* Typographie « document » : mesure étroite (voir #app.reading .content-inner
   dans layout.css), interligne aéré, grands titres en serif. */
.blocks { font-size: clamp(16px, 1.1vw, 17px); line-height: 1.7; }
.blocks h2 { font-family: var(--serif); font-size: clamp(23px, 2.5vw, 28px); margin: 44px 0 12px; letter-spacing: -.012em; font-weight: 600; color: var(--heading); }
.blocks h3 { font-size: clamp(18px, 1.9vw, 20px); margin: 30px 0 10px; letter-spacing: -.008em; font-weight: 700; color: var(--heading); }
.blocks h4 { font-size: clamp(16px, 1.6vw, 17.5px); margin: 24px 0 8px; font-weight: 700; }
.blocks h5 { font-size: 15.5px; margin: 20px 0 6px; font-weight: 700; }
.blocks p { margin: 12px 0; }
.blocks ul, .blocks ol { margin: 12px 0; padding-left: 25px; }
.blocks li { margin: 6px 0; }
.blocks li::marker { color: var(--accent); }
/* Enfants indentés d'un bloc (sous-points d'un paragraphe, d'un titre…). */
.blocks .blk-children { margin-left: 22px; }
/* Séparateur Craft : invisible à la lecture, il découpe les diapositives du
   mode présentation (voir app/ui/presentation.js). */
.blocks hr.slide-break { display: none; }

.blocks a.ext-link, .blocks a.internal-link {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 2px; transition: background .15s, border-color .15s;
}
.blocks a.ext-link:hover, .blocks a.internal-link:hover { border-bottom-color: var(--accent); background: var(--accent-soft); }
.blocks a.internal-link { font-weight: 550; border-bottom-style: dotted; }

/* Renvoi vers un contenu encore non publié : lisible, mais clairement inactif. */
.blocks .link-soon {
  color: var(--text-faint); border-bottom: 1px dotted var(--border); cursor: help;
}
.blocks .link-soon::after {
  content: "à venir"; font-size: .72em; font-weight: 700; letter-spacing: .03em; vertical-align: .12em;
  margin-left: .35em; padding: 1px 6px; border-radius: 20px; background: var(--panel-2); color: var(--text-faint);
}

.blocks code { background: var(--panel-2); border: 1px solid var(--hairline); border-radius: 6px; padding: 1.5px 6px; font-size: .9em; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.blocks pre { background: var(--panel-2); border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 14px 16px; overflow-x: auto; }
.blocks pre code { background: none; border: none; padding: 0; }

.blocks .table-wrap { overflow-x: auto; margin: 18px 0; -webkit-overflow-scrolling: touch; }
.blocks table { border-collapse: collapse; width: 100%; min-width: max-content; font-size: 14px; }
.blocks th, .blocks td { border: 1px solid var(--border); padding: 9px 13px; text-align: left; vertical-align: top; }
.blocks thead th { background: var(--panel-2); font-weight: 700; }
.blocks tbody tr:nth-child(even) { background: color-mix(in srgb, var(--text) 3%, transparent); }
.blocks del { color: var(--text-faint); }

mark, .hl { border-radius: 4px; padding: 0 4px; color: var(--hl-text); box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hl-yellow { background: #fdeea1; } .hl-green { background: #bdefcb; } .hl-mint { background: #aeefda; } .hl-cyan { background: #a7ebf7; }
.hl-blue { background: #c2dbff; } .hl-purple { background: #e4d2ff; } .hl-pink { background: #ffcfe3; } .hl-red { background: #ffd0d0; } .hl-gray { background: #e5e2db; }
.hl-gradient-yellow { background: linear-gradient(120deg, #fdeea1, #ffcf8a); }
.hl-gradient-red { background: linear-gradient(120deg, #ffd0d0, #ffb0bd); }
.hl-gradient-blue { background: linear-gradient(120deg, #c2dbff, #b3bcff); }
.hl-gradient-purple { background: linear-gradient(120deg, #e4d2ff, #f3b8fb); }
.hl-gradient-brown { background: linear-gradient(120deg, #ece6df, #dcc2af); }
mark.search-hit { background: #ffd94d; color: #201f1c; box-shadow: 0 0 0 3px rgba(255, 217, 77, .5); border-radius: 3px; }

.callout { background: var(--heading-soft); border-left: 3px solid var(--heading); border-radius: var(--r-sm); padding: 15px 20px; margin: 20px 0; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
blockquote { border-left: 3px solid var(--border); margin: 18px 0; padding: 4px 20px; color: var(--text-dim); font-style: italic; }
/* (Les séparateurs de Craft ne sont plus affichés — voir render/blocks.js.) */
.checklist { list-style: none; padding-left: 4px; }
.checklist li { display: flex; align-items: baseline; gap: 9px; }
.checklist .cb { flex: none; font-size: 14px; }

/* ============ MÉDIAS ============ */
figure.media { margin: 24px 0; text-align: center; }
figure.media img {
  max-width: 100%; height: auto; border-radius: var(--r-sm); box-shadow: var(--shadow-sm);
  cursor: zoom-in; transition: transform .25s var(--ease); background: var(--panel-2);
}
figure.media img:hover { transform: scale(1.008); }
/* Photos : taille raisonnable. Schémas et dessins : pleine largeur. */
figure.media-photo img { max-width: min(100%, 640px); max-height: 480px; }
/* Mode sombre : les schémas Craft sont à encre foncée sur fond transparent. */
:root[data-theme="dark"] figure.media-schema img { background: #fff; padding: 12px; }
figure.media figcaption { font-size: 13px; color: var(--text-dim); margin-top: 8px; }
/* Place réservée tant que l'image n'est pas arrivée : le texte ne saute pas.
   (Pas de `content-visibility: auto` ici : sur des schémas hauts, il laissait
   de grandes zones vides au défilement rapide.) */
figure.media img.is-loading { min-height: 180px; }

/* ⚠️ Aucune règle ne doit MASQUER une image en échec. Une version précédente
   remplaçait l'image par un cadre « ouvrir dans un onglet » : une défaillance
   passagère du réseau faisait alors disparaître un schéma valide pour toute la
   séance. Un échec se rattrape (voir render/media.js), il ne se camoufle pas.

   Une image qui tarde se SIGNALE, en revanche : le cadre ci-dessous accompagne
   l'image (il ne la remplace pas) et disparaît de lui-même dès qu'elle arrive.
   `display:none` sur une figure est INTERDIT — c'est ce qui faisait disparaître
   les tableaux blancs du cours sur le microscope. */
figure.media.media-attente {
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  padding: 14px 12px 10px;
  background: var(--panel-2);
}
figure.media.media-attente img { min-height: 120px; }
.media-etat {
  font-size: 13px; color: var(--text-dim);
  margin: 10px 0 0; display: flex; flex-wrap: wrap;
  gap: 4px 8px; align-items: center; justify-content: center;
}
.media-etat .media-ouvrir { color: var(--accent); text-decoration: underline; }

/* ============ DIAGRAMMES MERMAID ============ */
/* Composés par render/mermaid.js. Tant que la bibliothèque n'est pas arrivée
   (ou si elle n'arrive jamais), c'est le TEXTE du diagramme qui reste affiché :
   l'information n'est jamais perdue, seule sa mise en forme l'est. */
.mermaid-figure { margin: 26px 0; }
.mermaid-svg { text-align: center; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mermaid-svg svg { max-width: 100%; height: auto; display: inline-block; }
.mermaid-pending {
  background: var(--panel-2); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  padding: 14px 16px; overflow-x: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .88em; color: var(--text-dim); white-space: pre; margin: 0;
}
/* Diagramme que Mermaid n'a pas su lire (syntaxe à corriger dans Craft). */
.mermaid-failed { border-color: var(--red); }
.mermaid-failed::before {
  content: "Ce diagramme n'a pas pu être composé — voici son texte."; display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12.5px; color: var(--red); margin-bottom: 8px; white-space: normal;
}

.math-display { margin: 22px 0; padding: 12px 8px; text-align: center; overflow-x: auto; overflow-y: hidden; }
.math-display .katex { font-size: 1.12em; }
.math-error { display: block; background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: var(--r-xs); white-space: pre-wrap; font-size: 13.5px; }
/* Formule en attente du chargement de KaTeX : on garde le texte source lisible. */
.math-pending { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .95em; color: var(--text-dim); }

.link-card, .yt-card, .file-card {
  display: flex; align-items: center; gap: 14px; margin: 18px 0; text-decoration: none; color: var(--text); overflow: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .2s;
}
.link-card:hover, .yt-card:hover, .file-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.link-card { padding: 15px 18px; }
.link-card .icon { font-size: 22px; flex: none; }
.link-card .lc-title { font-weight: 600; font-size: 15px; }
.link-card .lc-host { font-size: 12.5px; color: var(--text-dim); }
.yt-card { max-width: 560px; }
.yt-thumb { position: relative; flex: none; width: 190px; aspect-ratio: 16/9; background: #14120f; }
.yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.yt-play span {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(221, 54, 44, .95); color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center; padding-left: 4px; box-shadow: 0 3px 12px rgba(0, 0, 0, .3);
  transition: transform .18s var(--ease);
}
.yt-card:hover .yt-play span { transform: scale(1.12); }
.yt-info { padding: 12px 16px 12px 2px; min-width: 0; }
.yt-badge { display: inline-block; background: #dd362c; color: #fff; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 5px; letter-spacing: .04em; margin-bottom: 6px; }
.yt-title { font-weight: 600; font-size: 14.5px; line-height: 1.4; }
.file-card { padding: 14px 18px; max-width: 560px; }
.file-card .icon { font-size: 21px; flex: none; }
.file-card .fc-name { font-weight: 600; font-size: 14.5px; word-break: break-word; }
.file-card .fc-hint { font-size: 12px; color: var(--text-dim); }

/* ============ TOGGLES & CARTES ============ */
details.toggle, details.card-section { margin: 16px 0; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--card); }
details.toggle > summary, details.card-section > summary {
  cursor: pointer; list-style: none; padding: 13px 16px; user-select: none; display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px; transition: background .15s;
}
details.toggle > summary::-webkit-details-marker, details.card-section > summary::-webkit-details-marker { display: none; }
details.toggle > summary:hover, details.card-section > summary:hover { background: var(--panel-2); }
details.toggle > summary .nav-chevron, details.card-section > summary .nav-chevron { color: var(--text-dim); flex: none; }
details[open].toggle > summary, details[open].card-section > summary { border-bottom: 1px solid var(--hairline); }
.toggle-body, .card-body { padding: 8px 18px 15px; }
details.card-section { margin: 22px 0; }
details.card-section > summary { color: var(--heading); }
.card-icon { flex: none; font-size: 19px; }

[id^="b-"] { scroll-margin-top: 20px; }
.blk-flash { animation: blkFlash 1.9s ease-out; border-radius: 8px; }
@keyframes blkFlash {
  0%, 28% { background: var(--accent-soft); box-shadow: 0 0 0 7px var(--accent-soft); }
  100% { background: transparent; box-shadow: 0 0 0 7px transparent; }
}
@keyframes fadeSlide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* (Un cours commun ne porte plus aucun bandeau : le renvoi vers un autre module
   est une mécanique de rédaction, transparente pour l'élève — voir ui/cours.js.) */

/* ============ PAGES SÉANCE / SÉQUENCE / MODULE ============ */
.listing-intro { color: var(--text-dim); font-size: 15px; margin: 0 0 26px; }
.listing-group { margin: 0 0 30px; }
.listing-group h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); font-weight: 700;
  margin: 32px 0 14px; display: flex; align-items: center; gap: 12px;
}
.listing-group h2::after { content: ""; flex: 1 0 24px; height: 1px; background: var(--border); }
/* `.crumb-link` est en `flex: none` (layout.css) pour ne pas être comprimé dans
   le fil d'Ariane. Ici, c'est l'inverse qu'il faut : un titre de séance long
   (« Matériaux des lentilles de contact… ») gardait sa largeur de contenu, la
   page débordait de 200 px sur la droite, et TOUT le sommaire se décalait —
   défilement latéral et titre coupé à gauche. Il doit se réduire et revenir à
   la ligne comme n'importe quel titre. */
.listing-group h2 .crumb-link {
  font: inherit; color: inherit; letter-spacing: inherit;
  flex: 0 1 auto; min-width: 0; white-space: normal; overflow-wrap: break-word;
}
.listing-group h2 .crumb-link:hover { color: var(--accent); }
.listing-list { display: flex; flex-direction: column; gap: 9px; }
.listing-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; font: inherit;
  padding: 14px 18px; border-radius: var(--r); border: 1px solid var(--border); background: var(--card);
  color: var(--text); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s;
}
.listing-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.listing-item .li-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.listing-item .li-title { flex: 1; font-weight: 600; font-size: 15px; min-width: 0; }
.listing-item .li-sub { display: block; font-weight: 400; font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.listing-item .li-arrow { flex: none; color: var(--accent); }
.listing-item.is-soon { cursor: default; background: var(--panel-2); box-shadow: none; color: var(--text-faint); }
.listing-item.is-soon:hover { transform: none; box-shadow: none; border-color: var(--border); }
.listing-item.is-soon .li-num { background: var(--panel); color: var(--text-faint); }
.listing-item.is-soon .li-title { font-weight: 500; }
.listing-item .li-soon {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 3px 10px; border-radius: 20px;
  background: var(--panel); color: var(--text-faint); box-shadow: inset 0 0 0 1px var(--hairline);
}
