/* Référentiel de sécurité O27 — feuille de style du rendu HTML.
 *
 * Parti pris : un ouvrage de référence composé, pas une page web. Colonne
 * unique à mesure typographique tenue, filets plutôt que cadres, une seule
 * couleur d'accent, et un état de document lisible avant tout contenu.
 *
 * Aucune ressource distante : ces documents doivent se rendre à l'identique
 * hors ligne et à l'impression, y compris chez un vérificateur.
 */

:root {
  --papier: #f8f6f1;
  --papier-creux: #f1eee7;
  --encre: #1c1a17;
  --encre-attenuee: #5f5a52;
  --filet: #d9d4c9;
  --filet-appuye: #b3aca0;

  --accent: #1f3149;
  --accent-clair: #3d5878;

  --brouillon-teinte: #fbf3dd;
  --brouillon-trait: #a9812a;
  --brouillon-encre: #6a4e11;
  --retrait-teinte: #eeece7;
  --retrait-trait: #6f6a61;
  --retrait-encre: #423e38;
  --supersede-teinte: #f9e9e6;
  --supersede-trait: #9c3626;
  --supersede-encre: #6f2116;
  --incoherence-teinte: #efe9f6;
  --incoherence-trait: #5c3a8c;
  --incoherence-encre: #402765;

  /* Piles système, choisies pour leur caractère plutôt que pour leur ubiquité. */
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "Palatino Linotype",
    Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Gill Sans", "Gill Sans MT", "Segoe UI",
    system-ui, sans-serif;
  --mono: "SF Mono", "IBM Plex Mono", "JetBrains Mono", Menlo, Consolas,
    ui-monospace, monospace;

  --mesure: 38rem;
}

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

html { font-size: 17px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 1.5rem 8rem;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
}

.content { max-width: var(--mesure); margin: 0 auto; }

/* Un état de document se signale par un filet haut sur toute la page, non par
 * une trame qui rend le texte pénible à lire. */
body:has(.banniere_supersede) { border-top: 5px solid var(--supersede-trait); }
body:has(.banniere_incoherence) { border-top: 5px solid var(--incoherence-trait); }

/* --- Titre --- */

h1.title {
  margin: 5rem 0 2.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--filet-appuye);
  font-family: var(--serif);
  font-size: 2.3rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.012em;
  text-wrap: balance;
  color: var(--accent);
}

/* --- Titres de section --- */

h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--encre);
}

/* Org peut lier le titre à lui-même : le lien ne doit pas se voir. */
h1 a, h2 a, h3 a, h4 a {
  color: inherit;
  text-decoration: none;
  border: 0;
}

h2 {
  margin: 3.5rem 0 1.1rem;
  font-size: 1.12rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

section[class^="outline-container"] > h2,
div[class^="outline-container"] > h2 {
  padding-top: 1.1rem;
  border-top: 1px solid var(--filet);
}

h3 {
  margin: 2.4rem 0 0.7rem;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  color: var(--accent);
}

h4 {
  margin: 1.8rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--encre-attenuee);
}

/* --- Texte courant --- */

p { margin: 0 0 1.15rem; }
ul, ol { margin: 0 0 1.15rem; padding-left: 1.4rem; }
li { margin-bottom: 0.35rem; }
li > ul, li > ol { margin-top: 0.35rem; }
ol { font-variant-numeric: oldstyle-nums; }
b, strong { font-weight: 650; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--filet-appuye);
  transition: text-decoration-color 120ms ease, color 120ms ease;
}

a:hover { color: var(--accent-clair); text-decoration-color: currentColor; }

code, kbd, samp, pre {
  font-family: var(--mono);
  font-size: 0.84em;
  font-variant-numeric: tabular-nums lining-nums;
}

code {
  padding: 0.08em 0.32em;
  border-radius: 2px;
  background: var(--papier-creux);
  word-break: break-word;
}

pre {
  overflow-x: auto;
  margin: 0 0 1.4rem;
  padding: 1rem 1.15rem;
  border-left: 2px solid var(--filet-appuye);
  background: var(--papier-creux);
  line-height: 1.5;
}

pre code { padding: 0; background: none; }

blockquote {
  margin: 0 0 1.4rem;
  padding: 0.1rem 0 0.1rem 1.25rem;
  border-left: 2px solid var(--filet-appuye);
  color: var(--encre-attenuee);
  font-style: italic;
}

hr { height: 0; margin: 2.5rem 0; border: 0; border-top: 1px solid var(--filet); }

/* --- Bloc de contrôle documentaire --- */

.controle_documentaire {
  margin: 0 0 3rem;
  padding: 1.5rem 0 0.4rem;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--filet-appuye);
}

.controle_documentaire > p:first-child { margin: 0 0 1.25rem; }

.controle_documentaire > p:first-child b {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.controle_documentaire dl {
  display: grid;
  grid-template-columns: minmax(9rem, 12rem) 1fr;
  gap: 0;
  margin: 0;
  font-size: 0.9rem;
}

.controle_documentaire dt {
  grid-column: 1;
  padding: 0.42rem 1.25rem 0.42rem 0;
  border-top: 1px solid var(--filet);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1.5;
  color: var(--encre-attenuee);
}

.controle_documentaire dd {
  grid-column: 2;
  margin: 0;
  padding: 0.42rem 0;
  border-top: 1px solid var(--filet);
  line-height: 1.5;
  font-variant-numeric: tabular-nums lining-nums;
}

.controle_documentaire dt:first-of-type,
.controle_documentaire dt:first-of-type + dd { border-top: 0; }

.controle_documentaire code {
  padding: 0.05em 0.3em;
  background: rgba(31, 49, 73, 0.07);
}

.controle_documentaire > p:last-child {
  margin: 1.1rem 0 0;
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--encre-attenuee);
}

/* --- Historique des versions ---
 * Appareil critique, pas corps du document : dérivé de l'historique du dépôt,
 * il ferme la page en retrait de corps, sur un fond légèrement creusé. Le
 * filet haut appuyé reprend celui du bloc de contrôle, dont il est le pendant
 * en fin de lecture. */

#outline-container-historique-des-versions {
  margin-top: 4.5rem;
  padding: 0 1.15rem 0.6rem;
  background: var(--papier-creux);
  border-top: 2px solid var(--accent);
}

/* Neutralise le filet de séparation que porte tout titre de section : le bloc
 * a déjà le sien, plus appuyé. */
#outline-container-historique-des-versions > h2 {
  margin: 0;
  padding: 1.3rem 0 0;
  border-top: 0;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.historique_versions { margin-top: 1.1rem; }
.historique_versions table { margin-bottom: 0.9rem; font-size: 0.78rem; }
.historique_versions thead th { border-top: 0; }

/* Hachage, date et auteur tiennent sur une ligne : seul le sujet du commit,
 * de longueur imprévisible, doit absorber la largeur restante. */
.historique_versions td:first-child,
.historique_versions td:nth-child(2),
.historique_versions td:nth-child(3) { white-space: nowrap; }

.historique_versions code {
  padding: 0.05em 0.3em;
  background: rgba(31, 49, 73, 0.07);
}

.historique_versions > p:last-child {
  margin: 0;
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--encre-attenuee);
}

/* --- Bannières d'état --- */

.banniere_brouillon, .banniere_obsolete,
.banniere_supersede, .banniere_incoherence {
  margin: 0 0 1rem;
  padding: 0.85rem 1.1rem;
  border-left: 3px solid;
  font-family: var(--sans);
  font-size: 0.83rem;
  font-weight: 500;
  line-height: 1.5;
}

.banniere_brouillon > p, .banniere_obsolete > p,
.banniere_supersede > p, .banniere_incoherence > p { margin: 0; }

.banniere_brouillon {
  background: var(--brouillon-teinte);
  border-color: var(--brouillon-trait);
  color: var(--brouillon-encre);
}

.banniere_obsolete {
  background: var(--retrait-teinte);
  border-color: var(--retrait-trait);
  color: var(--retrait-encre);
}

.banniere_supersede {
  background: var(--supersede-teinte);
  border-color: var(--supersede-trait);
  color: var(--supersede-encre);
}

.banniere_incoherence {
  background: var(--incoherence-teinte);
  border-color: var(--incoherence-trait);
  color: var(--incoherence-encre);
}

h1.title + div[class^="banniere"] { margin-top: -1rem; }
div[class^="banniere"] + .controle_documentaire { margin-top: 2rem; }

/* --- Table des matières --- */

#table-of-contents { margin: 0 0 3.5rem; }

#table-of-contents h2 {
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: var(--encre-attenuee);
}

#table-of-contents ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.45;
}

#table-of-contents li { margin: 0 0 0.28rem; }

#table-of-contents ul ul {
  margin: 0.28rem 0 0.5rem;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--encre-attenuee);
}

#table-of-contents a {
  text-decoration: none;
  color: var(--encre);
  border-bottom: 1px solid transparent;
}

#table-of-contents a:hover { color: var(--accent); border-bottom-color: var(--filet-appuye); }

/* --- Tableaux --- */

table {
  width: 100%;
  margin: 0 0 1.6rem;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums lining-nums;
}

caption {
  margin-bottom: 0.5rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-style: italic;
  text-align: left;
  color: var(--encre-attenuee);
}

thead th {
  padding: 0.5rem 0.7rem 0.5rem 0;
  border-top: 1px solid var(--filet-appuye);
  border-bottom: 1px solid var(--filet-appuye);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  vertical-align: bottom;
  color: var(--encre-attenuee);
}

tbody td, tbody th {
  padding: 0.5rem 0.7rem 0.5rem 0;
  border-bottom: 1px solid var(--filet);
  text-align: left;
  vertical-align: top;
}

tbody tr:last-child td, tbody tr:last-child th { border-bottom: 1px solid var(--filet-appuye); }
td:last-child, th:last-child { padding-right: 0; }
table code { font-size: 0.92em; background: none; padding: 0; }

/* --- Écran étroit --- */

@media (max-width: 46rem) {
  html { font-size: 16px; }
  body { padding: 0 1.1rem 5rem; }
  h1.title { margin-top: 3rem; font-size: 1.8rem; }
  .controle_documentaire dl { grid-template-columns: 1fr; }
  .controle_documentaire dt { padding-bottom: 0; border-top: 1px solid var(--filet); }
  .controle_documentaire dd { padding-top: 0.15rem; border-top: 0; }
  .controle_documentaire dt:first-of-type + dd { border-top: 0; }
  #outline-container-historique-des-versions { padding-left: 0.85rem; padding-right: 0.85rem; }
  table { display: block; overflow-x: auto; }
}

/* --- Impression ---
 * Ces documents sont imprimés ou exportés en PDF pour un vérificateur. La mise
 * en page imprimée est un livrable, pas une retombée. */

@page { margin: 20mm 18mm 22mm; }

@media print {
  html { font-size: 10.5pt; }

  body {
    padding: 0;
    background: #fff;
    color: #000;
    border-top: 0 !important;
  }

  .content { max-width: none; }
  h1.title { margin-top: 0; font-size: 20pt; color: #000; }
  h2, h3 { break-after: avoid; page-break-after: avoid; color: #000; }
  p, li { orphans: 3; widows: 3; }
  a { color: #000; text-decoration: none; }

  .banniere_brouillon, .banniere_obsolete,
  .banniere_supersede, .banniere_incoherence {
    background: none;
    border: 1pt solid #000;
    border-left-width: 3pt;
    color: #000;
    font-weight: 600;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .controle_documentaire {
    break-inside: avoid;
    page-break-inside: avoid;
    border-top: 1.5pt solid #000;
    border-bottom: 0.5pt solid #000;
  }

  .controle_documentaire > p:first-child b { color: #000; }
  .controle_documentaire dt, .controle_documentaire dd { border-top-color: #ccc; }
  .controle_documentaire code { background: none; }

  /* L'historique peut courir sur plusieurs pages : il ne doit pas être
   * maintenu d'un bloc, seulement démarré sur une page neuve. */
  #outline-container-historique-des-versions {
    margin-top: 0;
    padding: 0;
    background: none;
    border-top: 0;
    break-before: page;
    page-break-before: always;
  }

  #outline-container-historique-des-versions > h2 {
    padding-top: 0;
    color: #000;
  }

  .historique_versions { break-inside: auto; }
  .historique_versions code { background: none; }

  #table-of-contents { break-after: page; page-break-after: always; }
  table { break-inside: auto; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }
  code { background: none; }

  pre, blockquote {
    break-inside: avoid;
    page-break-inside: avoid;
    background: none;
    border-left: 1pt solid #000;
  }
}
