/* ==========================================================================
   FEUILLE DE STYLE UNIQUE — HTML, EPUB et PDF imprimé (KDP)
   Modifiez ce fichier puis relancez « make ».
   Sections : 1 Réglages · 2 Polices · 3 Texte · 4 Titres · 5 Citations
              6 Médias · 7 Pages de début · 8 Table des matières
              9 Écran · 10 Impression (format du livre, marges, en-têtes)
   ========================================================================== */

/* 1. RÉGLAGES --------------------------------------------------------------
   Couleurs et polices à changer ici. (Le format de page est en section 10.) */
:root {
  --police-texte: "EB Garamond", Georgia, serif;
  --police-titres: "EB Garamond", Georgia, serif;
  --couleur-texte: #1b1b1b;
  --couleur-accent: #7a2e1d;
  --couleur-discret: #666;
  --interligne: 1.45;
}

/* 2. POLICES (fichiers dans fonts/, licence SIL OFL) ---------------------- */
@font-face { font-family: "EB Garamond"; font-weight: 400; font-style: normal;
  src: url("../fonts/eb-garamond-latin-400-normal.woff") format("woff"); }
@font-face { font-family: "EB Garamond"; font-weight: 400; font-style: italic;
  src: url("../fonts/eb-garamond-latin-400-italic.woff") format("woff"); }
@font-face { font-family: "EB Garamond"; font-weight: 700; font-style: normal;
  src: url("../fonts/eb-garamond-latin-700-normal.woff") format("woff"); }
@font-face { font-family: "EB Garamond"; font-weight: 700; font-style: italic;
  src: url("../fonts/eb-garamond-latin-700-italic.woff") format("woff"); }

@font-face { font-family: "Amiri"; font-weight: 400; font-style: normal;
  src: url("../fonts/amiri-arabic-400-normal.woff") format("woff"); }
@font-face { font-family: "Amiri"; font-weight: 700; font-style: normal;
  src: url("../fonts/amiri-arabic-700-normal.woff") format("woff"); }

/* 3. TEXTE COURANT -------------------------------------------------------- */
html { font-size: 112.5%; }
body {
  font-family: var(--police-texte);
  color: var(--couleur-texte);
  line-height: var(--interligne);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  font-kerning: normal;
}
p { margin: 0; text-indent: 1.4em; orphans: 2; widows: 2; }
/* Pas de retrait après un titre, une citation, une liste ou un média */
h1 + p, h2 + p, h3 + p, blockquote + p, ul + p, ol + p,
figure + p, .media + p, p.first { text-indent: 0; }
a { color: inherit; text-decoration: none; border-bottom: 1px solid #bbb; }
em, i { font-style: italic; }
strong, b { font-weight: 700; }
code { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.8em; }
ul, ol { margin: 0.8em 0; padding-left: 1.6em; }
li > p { text-indent: 0; }
img { max-width: 100%; height: auto; }
hr { border: none; text-align: center; margin: 1.5em 0; }
hr::after { content: "* * *"; letter-spacing: 0.5em; }

/* Notes de bas de page / de fin */
.footnotes { font-size: 0.85em; }
.footnotes hr { display: none; }
.footnotes p { text-indent: 0; }
a.footnote-ref { border: none; vertical-align: super; font-size: 0.7em; }
a.footnote-back { border: none; }

/* Figures et légendes */
figure { margin: 1.2em 0; text-align: center; break-inside: avoid; }
figcaption { font-size: 0.85em; font-style: italic; color: var(--couleur-discret);
  margin-top: 0.4em; text-indent: 0; }

/* 4. TITRES --------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--police-titres);
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  hyphens: manual;
  break-after: avoid;
}
h1 { font-size: 2em; margin: 0 0 1.2em; }
h2 { font-size: 1.35em; margin: 1.8em 0 0.6em; color: var(--couleur-accent); }
h3 { font-size: 1.1em; margin: 1.4em 0 0.4em; font-style: italic; }

/* Numérotation automatique « Chapitre N » (le numéro est calculé par le build) */
section.chapter > h1[data-chapitre]::before {
  content: "Chapitre " attr(data-chapitre);
  display: block;
  font-size: 0.5em;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--couleur-accent);
  margin-bottom: 0.5em;
}

/* 5. CITATIONS ------------------------------------------------------------ */
blockquote {
  margin: 1.2em 0 1.2em 1.5em;
  padding: 0 0 0 1em;
  border-left: 2px solid var(--couleur-accent);
  font-size: 0.95em;
  text-align: left;
  break-inside: avoid;
}
blockquote p { text-indent: 0; margin: 0 0 0.5em; }
blockquote .attribution { text-align: right; font-size: 0.9em;
  color: var(--couleur-discret); font-style: italic; }
blockquote .attribution p { margin: 0; }
/* Épigraphe : citation placée juste sous le titre d'un chapitre */
h1 + blockquote {
  border-left: none; margin: -0.4em 0 2em 25%; padding: 0;
  font-style: italic; font-size: 0.95em;
}
h1 + blockquote .attribution { font-style: normal; }

/* Texte arabe (versets) : de droite à gauche, police Amiri */
.ar { font-family: "Amiri", serif; font-style: normal; }
.verse-ar { direction: rtl; text-align: right; font-family: "Amiri", serif;
  font-size: 1.35em; line-height: 1.9; margin: 0.6em 0 0.1em; hyphens: none; font-style: normal; font-weight: 400; }
.verse-ar p { text-indent: 0; margin: 0; }
blockquote .verse-ar { margin-top: 0.8em; }

/* TABLEAUX ---------------------------------------------------------------
   Modèle par défaut : style « livre » (filets horizontaux).
   Pour un autre modèle, écrire <table role="zebra"> dans le DocBook.
   Modèles : zebra · grille · compact · comparatif · glossaire · financier · fiche
   (ils se combinent : role="zebra compact"). */
table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 0.9em;
  font-variant-numeric: tabular-nums; text-align: left; hyphens: manual; }
caption { caption-side: top; text-align: left; font-weight: 700; font-size: 0.95em;
  color: var(--couleur-accent); margin-bottom: 0.5em; text-indent: 0; }
thead th { border-top: 1.5pt solid var(--couleur-texte); border-bottom: 0.75pt solid var(--couleur-texte);
  padding: 0.35em 0.5em; vertical-align: bottom; font-weight: 700; }
tbody td { padding: 0.22em 0.5em; border-bottom: 0.25pt solid #cfcfcf; vertical-align: top; }
table:not([class*="tbl-"]) tbody tr:last-child td {
  border-top: 0.75pt solid var(--couleur-texte); border-bottom: 1.5pt solid var(--couleur-texte); }
tr { break-inside: avoid; }
thead { display: table-header-group; }

/* zebra : lignes alternées, pour les longs tableaux */
table.tbl-zebra tbody td { border-bottom: none; }
table.tbl-zebra tbody tr:nth-child(even) td { background: #efece5; }
table.tbl-zebra tbody tr:last-child td { border-bottom: 1.5pt solid var(--couleur-texte); }

/* grille : quadrillage complet, pour les plannings et les matrices */
table.tbl-grille th, table.tbl-grille td { border: 0.5pt solid #777; padding: 0.3em 0.5em; }
table.tbl-grille thead th { background: #e8e2d6; }
table.tbl-grille tbody td:first-child { font-weight: 700; background: #f4f1ea; }

/* compact : petits caractères pour beaucoup de colonnes */
table.tbl-compact { font-size: 0.78em; }
table.tbl-compact thead th { padding: 0.25em 0.35em; }
table.tbl-compact tbody td { padding: 0.15em 0.35em; }
table.tbl-compact tbody tr:last-child td { border-bottom: 1.5pt solid var(--couleur-texte); }

/* comparatif : colonnes centrées avec ✓, pour comparer des options */
table.tbl-comparatif thead th:not(:first-child),
table.tbl-comparatif tbody td:not(:first-child) { text-align: center; }
table.tbl-comparatif tbody td:first-child { font-weight: 700; }
table.tbl-comparatif tbody tr:last-child td { border-bottom: 1.5pt solid var(--couleur-texte); }

/* glossaire : terme + définition, sans en-tête marqué */
table.tbl-glossaire thead th { border-top: none; border-bottom: 0.75pt solid var(--couleur-texte);
  color: var(--couleur-discret); font-weight: 400; font-style: italic; }
table.tbl-glossaire tbody td { border-bottom: 0.25pt dotted #999; padding: 0.35em 0.5em; }
table.tbl-glossaire tbody td:first-child { font-weight: 700; color: var(--couleur-accent);
  width: 28%; white-space: nowrap; }
table.tbl-glossaire tbody tr:last-child td { border-bottom: 0.75pt solid var(--couleur-texte); }

/* financier : chiffres alignés, dernière ligne = total mis en valeur */
table.tbl-financier tbody tr:last-child td { background: #efe8d8; font-weight: 700;
  border-top: 1pt solid var(--couleur-texte); border-bottom: 1.5pt double var(--couleur-texte); }

/* fiche : colonne de gauche = rubrique (fiche technique, description) */
table.tbl-fiche thead th { border: none; border-bottom: 1.5pt solid var(--couleur-accent);
  color: var(--couleur-accent); }
table.tbl-fiche tbody td { padding: 0.3em 0.6em; border-bottom: 0.25pt solid #cfcfcf; }
table.tbl-fiche tbody td:first-child { width: 34%; font-weight: 700; background: #f4f1ea; }
table.tbl-fiche tbody tr:last-child td { border-bottom: 1.5pt solid var(--couleur-accent); }

/* ENCADRÉS (remarque, astuce, important, attention, prudence) -------------
   Icônes : images/icones/*.svg (sources) et *.png (utilisés par le livre).
   Pour changer les couleurs d'un type, modifier --adm (trait + titre) et
   --adm-fond (fond) ci-dessous. Les libellés se règlent dans metadata.yaml. */
.admonition {
  --adm: #1d6fb8; --adm-fond: #eaf2fb;
  margin: 1.3em 0; padding: 0.7em 1em 0.55em;
  border-left: 4pt solid var(--adm); background: var(--adm-fond);
  border-radius: 0 4pt 4pt 0; font-size: 0.95em;
  text-align: left; hyphens: manual; break-inside: avoid;
}
.adm-note      { --adm: #1d6fb8; --adm-fond: #eaf2fb; }
.adm-tip       { --adm: #2b8a3e; --adm-fond: #e9f5ec; }
.adm-important { --adm: #b07808; --adm-fond: #fbf3dd; }
.adm-warning   { --adm: #d9480f; --adm-fond: #fdeee4; }
.adm-caution   { --adm: #b91c1c; --adm-fond: #fbe9e9; }
.adm-head { margin: 0 0 0.35em; font-family: var(--police-titres); font-weight: 700;
  font-size: 0.85em; letter-spacing: 0.1em; text-transform: uppercase; color: var(--adm);
  text-indent: 0; break-after: avoid; }
.adm-head img.adm-icon { width: 2em; height: 2em; vertical-align: middle; margin: 0 0.35em 0 0;
  display: inline; }
.adm-title { font-weight: 700; margin: 0 0 0.3em; text-indent: 0; }
.adm-title p { text-indent: 0; margin: 0; }
.admonition p { text-indent: 0; margin: 0 0 0.45em; }
.admonition ul, .admonition ol { margin: 0.3em 0 0.5em; }
.admonition > :last-child { margin-bottom: 0; }

/* Blocs de code (<programlisting>, <screen>) */
pre { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.78em; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; hyphens: none;
  background: #f1eee6; border-radius: 3pt; padding: 0.6em 0.8em; margin: 1em 0; break-inside: avoid; }
pre code { font-size: 1em; }

/* 6. MÉDIAS AUDIO / VIDÉO ------------------------------------------------- */
.media { margin: 1.2em 0; text-indent: 0; text-align: center; }
.media audio { width: 100%; max-width: 32em; }
.media video { width: 100%; height: auto; }
.video-embed { position: relative; width: 100%; padding-top: 56.25%; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-link p { text-indent: 0; text-align: center; }
.media-link a { border-bottom: 1px solid var(--couleur-accent); color: var(--couleur-accent); }
/* Version imprimée : QR code + adresse */
.media-print { text-align: left; hyphens: manual; overflow: hidden;
  border: 1px solid #aaa; padding: 0.6em 0.8em; break-inside: avoid; }
.media-print img.qr { float: left; width: 2.4cm; height: 2.4cm; margin: 0 0.9em 0 0; }
.media-print .media-label { display: block; font-style: italic; padding-top: 0.4cm; }
.media-print .media-label::before { content: "▶ "; font-style: normal; color: var(--couleur-accent); }
.media-print .media-url { display: block; font-size: 0.7em; word-break: break-all;
  color: var(--couleur-discret); margin-top: 0.3em; }

/* 7. PAGES DE DÉBUT ------------------------------------------------------- */
#title-block-header { text-align: center; margin: 22vh 0 0; }
#title-block-header img.cover { display: block; width: 100%; height: auto; margin: 0 auto 2.5em; }
#title-block-header .title { font-size: 2.6em; margin: 0 0 0.3em; text-align: center; }
#title-block-header .subtitle { font-size: 1.3em; font-style: italic; text-indent: 0; text-align: center; }
#title-block-header .author { font-size: 1.2em; margin-top: 3em; text-indent: 0; text-align: center;
  letter-spacing: 0.1em; text-transform: uppercase; }
#title-block-header .publisher { margin-top: 2em; text-indent: 0; text-align: center; color: var(--couleur-discret); }
#copyright-page { font-size: 0.8em; text-align: left; margin-top: 3em; color: var(--couleur-discret); }
#copyright-page p { text-indent: 0; margin: 0 0 0.8em; }

/* 8. TABLE DES MATIÈRES --------------------------------------------------- */
#TOC { margin: 0 0 2em; }
#TOC h2 { margin-top: 0; color: var(--couleur-texte); font-size: 1.6em; }
#TOC ul { list-style: none; padding-left: 0; margin: 0; text-align: left; }
#TOC ul ul { padding-left: 1.4em; font-size: 0.92em; }
#TOC li { margin: 0.25em 0; }
#TOC a { border: none; }

/* Navigation entre les pages du livre HTML (précédent / sommaire / suivant) */
.pager { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-family: var(--police-titres); font-size: 0.95rem; text-align: left; hyphens: manual; }
.pager > span { flex: 1; }
.pager .pager-sommaire { text-align: center; flex: 0 0 auto; }
.pager .pager-suiv { text-align: right; }
.pager a { border: none; color: var(--couleur-accent); }
.pager a:hover { text-decoration: underline; }
.pager-haut { padding: 0 0 0.8rem; border-bottom: 1px solid #ddd; margin-bottom: 2rem; }
.pager-bas { padding: 0.8rem 0 0; border-top: 1px solid #ddd; margin-top: 3rem; }

/* 9. ÉCRAN (navigateur) --------------------------------------------------- */
@media screen {
  body { max-width: 38em; margin: 0 auto; padding: 2rem 1.2rem 5rem; background: #fdfcf9; }
  section.level1 { margin-top: 4rem; }
  section.level1 + section.level1 { border-top: 1px solid #ddd; padding-top: 3rem; }
  body.page-chapitre section.level1 { margin-top: 0; }
  #title-block-header { margin: 12vh 0 4rem; }
  #copyright-page { margin-bottom: 3rem; }
  a:hover { color: var(--couleur-accent); }
}

/* 10. IMPRESSION — PDF Amazon KDP (aussi pris en compte par « Imprimer »)
   Format 6 × 9 po (15,24 × 22,86 cm). Marge intérieure (reliure) selon le
   nombre de pages KDP : 24-150 p. 0,375 po · 151-300 p. 0,5 po ·
   301-500 p. 0,625 po · 501-700 p. 0,75 po. Ici : 0,75 po (sûr jusqu'à 700 p.). */
@media print {
  @page {
    size: 6in 9in;
    margin: 0.75in 0.625in 0.8in 0.75in;
  }
  @page :left  { margin-left: 0.625in; margin-right: 0.75in;
    @top-left { content: counter(page); font: 9pt var(--police-texte); }
    @top-center { content: string(titre-livre); font: italic 9pt var(--police-texte); } }
  @page :right { margin-left: 0.75in; margin-right: 0.625in;
    @top-right { content: counter(page); font: 9pt var(--police-texte); }
    @top-center { content: string(titre-chap, first-except); font: italic 9pt var(--police-texte); } }
  @page nue { @top-left { content: none; } @top-center { content: none; } @top-right { content: none; } }
  @page :blank { @top-left { content: none; } @top-center { content: none; } @top-right { content: none; } }

  html { font-size: 11pt; }
  body { background: none; padding: 0; max-width: none; }
  #title-block-header .title { string-set: titre-livre content(); }
  section.level1 > h1 { string-set: titre-chap content(); }

  /* Pages sans en-tête : titre, copyright, table des matières */
  #title-block-header { page: nue; margin: 0; break-after: page; }
  #title-block-header img.cover { margin: 0 0 14% 0; }
  #title-block-header .title { font-size: 2.3em; }
  #copyright-page { page: nue; break-after: page; margin-top: 55%; }
  #TOC { page: nue; break-after: right; }

  /* Chaque chapitre commence sur une page de droite */
  section.level1 { break-before: right; margin: 0; }
  section.level1 > h1 { margin-top: 18%; }

  /* Vraies notes de bas de page (le filtre les produit pour le PDF) */
  @page { @footnote { margin-top: 0.8em; padding-top: 0.3em; border-top: 0.5pt solid #444; } }
  .fn { float: footnote; font-size: 0.82em; line-height: 1.3; text-indent: 0; text-align: left; }
  .fn::footnote-call { content: counter(footnote); font-size: 0.7em; vertical-align: super; line-height: 0; }
  .fn::footnote-marker { content: counter(footnote) ". "; }

  /* Table des matières avec numéros de page */
  #TOC a::after { content: leader(".") target-counter(attr(href), page); }

  nav.pager { display: none; }
  a { border: none; }
  /* Les liens ordinaires s'impriment avec leur adresse en note discrète */
  .media, figure { break-inside: avoid; }
  table { break-inside: avoid; }
  caption { break-after: avoid; }
  section.level2:has(> table) { break-inside: avoid; }
  blockquote { break-inside: auto; }
  .verse-ar { break-after: avoid; }
  section.level1 { counter-reset: footnote; }
  h2, h3 { break-after: avoid; }
}
