/* ============================================================
   Versions web des documents PDF (/documents/{slug}).
   Lecture : en-tête de page (h1, téléchargement, sommaire), puis le texte
   mis en forme (intertitres, listes, tableaux, encadrés, paroles).
   Les composants doc-* plus bas servent aux versions automatiques des PDF
   envoyés depuis le tableau de bord. Une teinte = une classe doc-c-*.
   ============================================================ */

.document-tete__barre {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--e-1) var(--e-3);
  margin-top: var(--e-2);
}

.document-tete__barre p {
  margin: 0;
  color: var(--encre-douce);
}

.document-tete__meta {
  font-weight: 400;
}

.section.document-page {
  padding-top: var(--e-2);
}

.document-page__retour {
  margin-top: var(--e-4);
}

/* ----- Texte du document ----- */
.doc {
  max-width: 48rem;
}

.doc > :first-child {
  margin-top: 0;
}

.doc h2 {
  margin: var(--e-4) 0 var(--e-2);
  padding-top: var(--e-3);
  border-top: 1px solid var(--trait);
  font-size: clamp(1.45rem, 1.25rem + 0.9vw, 1.9rem);
  scroll-margin-top: calc(var(--entete-h) + var(--e-2));
}

.doc > h2:first-child {
  padding-top: 0;
  border-top: 0;
}

.doc h3 {
  margin: var(--e-3) 0 var(--e-1);
  font-size: var(--t-1);
}

.doc h4 {
  margin: var(--e-3) 0 var(--e-1);
  font-size: var(--t-0);
  color: var(--encre);
}

.doc p,
.doc li,
.doc dd {
  max-width: var(--mesure);
}

.doc p {
  margin: 0 0 var(--e-2);
}

.doc ul:not([class]),
.doc ol:not([class]) {
  margin: 0 0 var(--e-2);
  padding-left: 1.4rem;
}

.doc li + li {
  margin-top: var(--e-1);
}

.doc li > ul,
.doc li > ol {
  margin: var(--e-1) 0 0;
}

.doc li::marker {
  color: var(--orange-texte);
  font-weight: 800;
}

.doc dl {
  margin: 0 0 var(--e-2);
}

.doc dt {
  font-weight: 800;
  color: var(--marron);
}

.doc dd {
  margin: 0 0 var(--e-2);
}

/* Chapeau : sous-titre ou introduction du document */
.doc .doc-chapo {
  font-size: var(--t-1);
  line-height: 1.5;
  color: var(--encre);
}

/* Encadré du PDF (conseil, à retenir, contact) */
.doc-encadre {
  margin: var(--e-3) 0;
  padding: var(--e-3);
  border-radius: var(--rayon);
  background: var(--jaune-clair);
}

.doc-encadre > :first-child {
  margin-top: 0;
}

.doc-encadre > :last-child {
  margin-bottom: 0;
}

.doc-encadre h2,
.doc-encadre h3 {
  padding-top: 0;
  border-top: 0;
}

/* Citation du PDF */
.doc blockquote {
  margin: var(--e-3) 0;
  padding: var(--e-1) 0 var(--e-1) var(--e-3);
  border-left: 4px solid var(--jaune);
  font-size: var(--t-1);
  line-height: 1.5;
  color: var(--marron);
}

.doc blockquote p:last-child {
  margin-bottom: 0;
}

/* Auteur d'une citation ou d'un témoignage */
.doc blockquote footer {
  margin-top: var(--e-1);
  font-size: 1rem;
  font-weight: 700;
  color: var(--encre-douce);
}

/* Paroles d'enfants : une réplique par bulle */
.doc-paroles {
  display: flex;
  flex-direction: column;
  gap: var(--e-1);
  margin: 0 0 var(--e-3);
  padding: 0;
  list-style: none;
}

.doc .doc-paroles li {
  max-width: var(--mesure);
  margin: 0;
  padding: var(--e-1) var(--e-2);
  border-radius: 4px var(--rayon-champ) var(--rayon-champ) var(--rayon-champ);
  background: var(--creme);
  box-shadow: inset 4px 0 0 var(--jaune);
}

/* Mention de fin (auteur, date, licence) */
.doc .doc-mention {
  margin-top: var(--e-4);
  padding-top: var(--e-2);
  border-top: 1px solid var(--trait);
  font-size: 1rem;
  color: var(--encre-douce);
}

/* Tableaux : en-tête teinté, lignes séparées, défilement horizontal sur mobile */
.table-scroll {
  max-width: 100%;
  margin: var(--e-2) 0 var(--e-3);
  background:
    linear-gradient(to right, var(--blanc) 30%, transparent) left / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--blanc) 30%, transparent) right / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--marron) 22%, transparent), transparent) left / 0.9rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--marron) 22%, transparent), transparent) right / 0.9rem 100% no-repeat scroll;
  overflow-x: auto;
}

.table-scroll:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.doc table:not([class]) {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

/* Quatre colonnes ou plus : largeur minimale, la zone défile sur petit écran */
.doc table:not([class]):has(tr > :nth-child(4)) {
  min-width: 40rem;
}

.doc table:not([class]) caption {
  margin-bottom: var(--e-1);
  font-weight: 800;
  color: var(--marron);
  text-align: left;
}

.doc table:not([class]) :is(th, td) {
  padding: var(--e-1) var(--e-2);
  border-bottom: 1px solid var(--trait);
  text-align: left;
  vertical-align: top;
}

.doc table:not([class]) thead th {
  color: var(--marron);
  background: var(--jaune-clair);
}

.doc table:not([class]) tbody th {
  font-weight: 700;
}

.doc table:not([class]) td.nombre,
.doc table:not([class]) th.nombre {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ----- Versions automatiques : une page du PDF = une feuille ----- */
.doc-page + .doc-page {
  margin-top: var(--space-6);
}

.doc-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: clamp(var(--space-4), 3vw, var(--space-7));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.doc-page > * {
  margin: 0;
}

.doc-page__num {
  align-self: flex-end;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

/* En-tête de document : logo + titre */
.doc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
}

.doc-head__logo {
  flex: none;
  width: clamp(5rem, 18vw, 9rem);
  height: auto;
}

.doc-head__text {
  flex: 1 1 16rem;
  min-width: 0;
}

.doc-head h1 {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
}

.doc-head__sub {
  margin-top: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 700;
}

/* Bandeau ou encadré de couleur */
.doc-band,
.doc-box {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
}

.doc-band {
  font-weight: 700;
}

.doc-box > * + * {
  margin-top: var(--space-2);
}

/* Colonnes du PDF : côte à côte sur grand écran, empilées sur mobile */
.doc-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-5);
}

.doc-cols > * > * + * {
  margin-top: var(--space-3);
}

/* Champs d'un formulaire papier : intitulé coloré, case vide à remplir */
.doc-fields {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 var(--space-1);
}

.doc-fields th {
  width: 40%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
}

.doc-fields td {
  min-height: 2.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface);
}

.doc-fields caption {
  margin-bottom: var(--space-2);
  font-weight: 700;
  text-align: left;
}

/* Cases à cocher d'un formulaire papier */
.doc-checks {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0;
  list-style: none;
}

.doc-checks li {
  position: relative;
  padding-left: 2rem;
}

/* La case est dessinée à part : le contenu de l'option (texte, gras, picto) reste en ligne */
.doc-checks li::before {
  content: "";
  position: absolute;
  top: 0.2em;
  left: 0;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.doc-checks img {
  display: inline-block;
  width: auto;
  height: 1.75rem;
  margin-right: var(--space-2);
  vertical-align: middle;
}

/* Ligne à compléter (« Fait à … le … ») */
.doc-blank {
  display: inline-block;
  min-width: 8rem;
  border-bottom: 1px solid var(--line-strong);
}

/* Tableaux de données du PDF */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.doc-table caption {
  margin-bottom: var(--space-2);
  font-weight: 700;
  text-align: left;
}

.doc-table th,
.doc-table td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  text-align: left;
  vertical-align: top;
}

/* Images du PDF (logo, photo, carte, schéma) */
.doc-figure {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.doc-figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.doc-figure figcaption {
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.doc-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-5);
  padding: 0;
  list-style: none;
}

.doc-logos img {
  width: auto;
  max-width: 9rem;
  max-height: 3.5rem;
  object-fit: contain;
}

.doc ul:not([class]) {
  list-style: disc;
}

.doc ol:not([class]) {
  list-style: decimal;
}

/* Teintes : fond et texte associés (tokens --doc-*) */
.doc-c-orange {
  color: var(--doc-orange-ink);
  background: var(--doc-orange);
}

.doc-c-jaune {
  color: var(--doc-jaune-ink);
  background: var(--doc-jaune);
}

.doc-c-vert {
  color: var(--doc-vert-ink);
  background: var(--doc-vert);
}

.doc-c-turquoise {
  color: var(--doc-turquoise-ink);
  background: var(--doc-turquoise);
}

.doc-c-marine {
  color: var(--doc-marine-ink);
  background: var(--doc-marine);
}

.doc-c-bleu {
  color: var(--doc-bleu-ink);
  background: var(--doc-bleu);
}

.doc-c-rouge {
  color: var(--doc-rouge-ink);
  background: var(--doc-rouge);
}

.doc-c-rose {
  color: var(--doc-rose-ink);
  background: var(--doc-rose);
}

.doc-c-violet {
  color: var(--doc-violet-ink);
  background: var(--doc-violet);
}

.doc-c-orange-clair {
  color: var(--doc-orange-clair-ink);
  background: var(--doc-orange-clair);
}

.doc-c-vert-clair {
  color: var(--doc-vert-clair-ink);
  background: var(--doc-vert-clair);
}

.doc-c-bleu-clair {
  color: var(--doc-bleu-clair-ink);
  background: var(--doc-bleu-clair);
}

.doc-c-rose-clair {
  color: var(--doc-rose-clair-ink);
  background: var(--doc-rose-clair);
}

.doc-c-jaune-clair {
  color: var(--doc-jaune-clair-ink);
  background: var(--doc-jaune-clair);
}

.doc-c-gris {
  color: var(--doc-gris-ink);
  background: var(--doc-gris);
}

/* Lien dans un bloc coloré : même couleur que son texte, souligné */
[class*="doc-c-"] a {
  color: inherit;
  text-decoration: underline;
}

/* Titres et texte en gras d'un bloc coloré : couleur du bloc (les titres du site ont la leur) */
[class*="doc-c-"] :is(h1, h2, h3, h4, strong, em) {
  color: inherit;
}

/* Adresses web longues écrites en clair : elles passent à la ligne au lieu d'élargir la page */
.doc a {
  overflow-wrap: anywhere;
}
