/* ============================================================
   Modèle conteneur des articles (guides, ressources)
   Chargé après ds.css : il ne touche qu'aux pages qui portent
   .legal / .prose, donc aucune autre page du site n'est affectée.

   Trois règles :
   1. une colonne de lecture étroite et centrée (≈ 68 signes) ;
   2. un rythme vertical explicite (chapeau, paragraphes, listes) ;
   3. des tableaux autorisés à sortir du texte, symétriquement,
      mais jamais du conteneur, et toujours alignés à gauche.

   Les noms de classes des composants sont hachés par CSS Modules :
   d'où les sélecteurs [class*="…"] pour tableWrap / note / caption.
   ============================================================ */

/* ---------- 1. Le conteneur ---------- */
.legal {
  /* 190 (sommaire) + 26 (gouttière) + 824 (texte) = 1040 : le bloc reste
     compact même sur un écran de 1920 px, au lieu de s'étirer. */
  grid-template-columns: 190px minmax(0, 1fr);
  gap: clamp(18px, 1.8vw, 26px);
  align-items: start;
  max-width: 1040px;
  margin-inline: auto;
  padding-block: clamp(24px, 3vw, 40px);
}

.legal .toc {
  font-size: 10px;
  line-height: 2.1;
}

@media (min-width: 901px) {
  .legal .toc {
    position: sticky;
    top: 120px;
  }
}

/* La colonne de lecture prend toute la largeur du couloir : le texte et
   le tableau partagent exactement le même bord gauche et le même bord droit. */
.prose {
  max-width: none;
  min-width: 0;
  margin-inline: 0;
  position: relative;
}

/* ---------- 2. Le rythme du texte ---------- */
.prose p,
.prose li {
  font-size: 17px;
  line-height: 1.7;
  max-width: none;
  margin: 0 0 1.05em;
  color: var(--muted-2);
}

.prose > p:first-of-type {
  font-size: 19px;
  line-height: 1.6;
  margin-bottom: 1.3em;
  color: var(--ink);
}

.prose h2 + p,
.prose h3 + p {
  margin-top: 0;
}

.prose ul,
.prose ol {
  margin: 0 0 1.2em;
  padding-left: 20px;
}

.prose li {
  margin-bottom: 0.5em;
}

.prose strong {
  font-weight: 500;
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}

.prose a:hover {
  text-decoration-color: var(--accent);
}

/* ---------- 2 bis. Moins d'air sur les grands écrans ---------- */
@media (min-width: 1100px) {
  .legal {
    padding-block: 32px;
  }

  .prose h2 {
    margin: 1.9em 0 0.5em;
  }

  .prose h3 {
    margin-top: 1.7em;
  }

  .prose [class*="note"] {
    margin-block: 1.5em;
  }
}

/* ---------- 3. Les tableaux ---------- */
/* Le tableau occupe la colonne entière, comme le texte : plus de saillie,
   donc plus de décalage entre le bord du paragraphe et le bord du tableau. */
.prose [class*="tableWrap"] {
  --bleed: 0px;
  width: 100%;
  margin: 1.5em 0 1.3em;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.prose table {
  width: 100%;
  max-width: none;
  min-width: 0;
  border-collapse: collapse;
  font-size: 15px;
}

/* Tout le contenu du tableau est aligné à gauche, sans exception,
   y compris les colonnes de prix qui étaient en text-align: right. */
.prose table caption,
.prose table th,
.prose table td,
.prose table td.price,
.prose table th.price {
  text-align: left !important;
}

.prose table caption {
  caption-side: top;
  padding: 0 0 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.prose table th,
.prose table td {
  padding: 15px 20px 15px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--line-2);
}

.prose table thead th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.prose table tbody th {
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  width: 1%;
}

.prose table tbody tr:last-child th,
.prose table tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- 4. Mobile : plus de tableau coupé ---------- */
@media (max-width: 760px) {
  /* minmax(0,1fr) et non 1fr : sinon la colonne s'élargit à la largeur
     mini-content du tableau et fait déborder la page. */
  .legal {
    grid-template-columns: minmax(0, 1fr);
  }

  .legal .toc {
    position: static;
    top: auto;
  }

  .prose {
    width: 100%;
    max-width: none;
  }

  .prose p,
  .prose li {
    font-size: 16px;
    line-height: 1.68;
  }

  .prose > p:first-of-type {
    font-size: 17.5px;
  }

  .prose [class*="tableWrap"] {
    --bleed: 0px;
    width: auto;
    max-width: 100%;
    margin-inline: 0;
  }

  .prose table {
    min-width: 0;
    font-size: 14px;
  }

  /* Les tableaux des guides portent un data-label sur chaque cellule : ils se
     lisent en fiches empilées, sans défilement latéral. Les tableaux sans
     libellé (markdown) gardent la première colonne collée au bord. */
  .prose table:not(:has(td[data-label])) {
    min-width: 540px;
  }

  .prose table:has(td[data-label]) {
    display: block;
    border-collapse: separate;
  }

  .prose table:has(td[data-label]) thead {
    display: none;
  }

  .prose table:has(td[data-label]) tbody,
  .prose table:has(td[data-label]) tr,
  .prose table:has(td[data-label]) th,
  .prose table:has(td[data-label]) td {
    display: block;
    width: auto;
    border: 0;
  }

  .prose table:has(td[data-label]) tbody tr {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 10px;
  }

  .prose table:has(td[data-label]) tbody tr:last-child {
    margin-bottom: 0;
  }

  .prose table:has(td[data-label]) th,
  .prose table:has(td[data-label]) td {
    padding: 0;
    white-space: normal;
  }

  .prose table:has(td[data-label]) td {
    margin-top: 9px;
  }

  .prose table:has(td[data-label]) td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted-2);
    margin-bottom: 3px;
  }

  /* La première colonne reste visible pendant le défilement horizontal. */
  .prose table:not(:has(td[data-label])) th:first-child,
  .prose table:not(:has(td[data-label])) td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    padding-right: 16px;
    background: var(--paper, #fff);
  }
}

/* Ancres des pages ressources : l'en-tête est fixe, un titre cliqué dans le
   sommaire doit rester visible sous lui. */
.prose h2[id],
.prose h3[id] {
  scroll-margin-top: 108px;
}
