/* ==========================================================================
   E-NETT — version moderne : pages légales (mentions légales, confidentialité, conditions générales)
   Même texte que le site classique (mêmes articles, mêmes données {{ … }}) ; seule la mise en forme change.
   - Grand écran (≥ 900 px) : sommaire collant à gauche, texte à droite. L’entrée de l’article en cours passe
     en couleur du texte et le trait vert descend le long du sommaire au fil de la lecture (js/pages/legal.js).
   - Petit écran : barre « Sommaire » collée sous l’en-tête (article en cours + trait de progression) ; la liste
     s’ouvre par-dessus le texte. Sans JavaScript : sommaire ouvert, en tête du texte, rien n’est collé.
   Le vert ne sert qu’au trait (progression, article en cours) ; la typographie vient de .prose (components.css).
   ========================================================================== */

.legal__grid { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(40px, 6vw, 112px); }
.legal-body { min-width: 0; }

/* ---------- Sommaire ---------- */
.legal-toc { min-width: 0; }
.legal-toc__summary { list-style: none; color: var(--fg); }
.legal-toc__summary::-webkit-details-marker { display: none; }
.legal-toc__label { flex: none; font-family: var(--f-mono); font-size: 12px; line-height: 1.4; letter-spacing: .08em; text-transform: uppercase; }
.legal-toc__panel { position: relative; }
.legal-toc__list a {
  display: flex; align-items: baseline; gap: 12px;
  font-size: 15px; line-height: 1.35; color: var(--muted); text-decoration: none;
  transition: color .3s;
}
.legal-toc__list a:hover { color: var(--fg); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.legal-toc__list a[aria-current] { color: var(--fg); }
.legal-toc__n {
  flex: none; width: 2.6em;
  font-family: var(--f-mono); font-size: 11.5px; line-height: 1.5; letter-spacing: .04em; font-variant-numeric: tabular-nums;
  color: var(--muted); transition: color .3s;
}
.legal-toc--art .legal-toc__n { width: 5.4em; }
.legal-toc__list a[aria-current] .legal-toc__n { color: var(--fg); }

@media (min-width: 900px) {
  .legal-toc__box {
    position: sticky; top: calc(var(--header-h) + 32px);
    max-width: 23rem; max-height: calc(100vh - var(--header-h) - 64px); overflow-y: auto; overscroll-behavior: contain;
    padding: 0 6px 6px 0; /* le contour de focus des liens n’est pas rogné */
    scrollbar-width: thin;
  }
  .legal-toc__summary { display: block; padding-bottom: 14px; border-bottom: 1px solid var(--fg); cursor: default; }
  .legal-toc__current, .legal-toc__plus, .legal-toc__bar { display: none; }
  .legal-toc__panel { margin-top: 10px; padding-left: 22px; }
  /* Rail du sommaire : filet fin, et le trait vert qui avance avec la lecture (scaleY posé par le script) */
  .legal-toc__track { position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--line); }
  .legal-toc__fill {
    position: absolute; left: -1px; top: 0; width: 3px; height: 100%;
    background: var(--vert); transform: scaleY(0); transform-origin: 50% 0;
  }
  .legal-toc__list a { padding: 7px 0; }
}

@media (max-width: 899px) {
  .legal__grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .legal-toc { margin-inline: calc(-1 * var(--gutter)); }
  /* Avec JavaScript : barre collée sous l’en-tête (repliée par le script en ligne avant le premier affichage) */
  html.js .legal-toc { position: sticky; top: var(--header-h); z-index: 20; }
  .legal-toc__box { background: var(--bg); }
  .legal-toc__summary {
    position: relative; display: flex; align-items: center; gap: 14px;
    min-height: 52px; padding: 0 var(--gutter);
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .legal-toc__label { color: var(--muted); }
  .legal-toc__current { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; font-weight: 600; font-stretch: 104%; }
  .legal-toc__cn { margin-right: .6em; font-family: var(--f-mono); font-size: 11.5px; font-weight: 400; letter-spacing: .04em; color: var(--muted); }
  .legal-toc__plus { position: relative; flex: none; width: 14px; height: 14px; margin-left: auto; }
  .legal-toc__plus::before, .legal-toc__plus::after {
    content: ""; position: absolute; left: 0; top: 6px; width: 14px; height: 2px; background: currentColor;
    transition: transform .35s var(--ease-out);
  }
  .legal-toc__plus::after { transform: rotate(90deg); }
  .legal-toc__box[open] .legal-toc__plus::before { transform: rotate(45deg); }
  .legal-toc__box[open] .legal-toc__plus::after { transform: rotate(135deg); }
  .legal-toc__bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; overflow: hidden; }
  .legal-toc__bar-fill { display: block; height: 100%; background: var(--vert); transform: scaleX(0); transform-origin: 0 50%; }
  html:not(.js) .legal-toc__bar { display: none; }
  .legal-toc__track { display: none; }
  .legal-toc__panel { padding: 4px var(--gutter) 12px; border-bottom: 1px solid var(--line); }
  /* Liste ouverte : par-dessus le texte (la page ne bouge pas), défilement propre si elle dépasse l’écran */
  html.js .legal-toc__panel {
    position: absolute; left: 0; right: 0; top: 100%;
    max-height: calc(100vh - var(--header-h) - 76px); max-height: calc(100dvh - var(--header-h) - 76px);
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--bg); box-shadow: 0 28px 40px -24px rgba(5, 28, 49, .35);
  }
  .legal-toc__list li + li { border-top: 1px solid var(--line-soft); }
  .legal-toc__list a { min-height: 48px; padding: 13px 0; }
  /* Ancre : le titre s’arrête sous la barre du sommaire */
  html.js .legal-doc .prose h2 { scroll-margin-top: 56px; }
}

/* ---------- Texte ---------- */
.legal-doc .prose { max-width: none; }
.legal-doc .prose > * { max-width: 40rem; }
.legal-doc .prose > .table-wrap { max-width: none; }
.legal-doc .prose h2 { position: relative; margin-top: clamp(48px, 5vw, 72px); padding-top: 22px; }
.legal-doc .prose h2:first-child { margin-top: 0; }
/* L’article en cours : un court trait vert sur son filet (js/pages/legal.js) */
.legal-doc .prose h2::before {
  content: ""; position: absolute; left: 0; top: -2px; width: 56px; height: 3px;
  background: var(--vert); transform: scaleX(0); transform-origin: 0 50%;
  transition: transform .8s var(--ease-out);
}
.legal-doc .prose h2.is-current::before { transform: scaleX(1); }
.legal-n {
  display: block; margin-bottom: 12px;
  font-family: var(--f-mono); font-size: 12px; line-height: 1.4; font-weight: 400; font-stretch: 100%;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.legal-doc .prose address { padding: 2px 0 2px 18px; border-left: 1px solid var(--fg); overflow-wrap: anywhere; }
.legal-doc .prose a { overflow-wrap: anywhere; }
.legal-doc .prose h3 { margin-top: 2em; }
.legal-doc .table-wrap { margin-top: 1.6em; }
.legal-doc .table-wrap + * { margin-top: 1.4em; }

/* Fiche d’identité (mentions légales) */
.legal-dl { border-top: 1px solid var(--fg); }
.legal-dl > div { display: grid; grid-template-columns: minmax(0, 10.5rem) minmax(0, 1fr); gap: 2px 24px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.legal-dl dt { padding-top: .32em; font-family: var(--f-mono); font-size: 11.5px; line-height: 1.5; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.legal-dl dd { overflow-wrap: anywhere; }
@media (max-width: 599px) {
  .legal-dl > div { grid-template-columns: minmax(0, 1fr); }
  .legal-dl dt { padding-top: 0; }
}

/* Tableau des usages (confidentialité) : cellules longues */
.legal-table th span, .legal-table td span { overflow-wrap: anywhere; }
.legal-table tbody th { min-width: 11rem; }
@media (max-width: 640px) { .legal-table tbody th { min-width: 0; } }

/* L’essentiel (conditions générales) */
.legal-essentiel { margin-bottom: clamp(56px, 6vw, 88px); }
.legal-essentiel .kicker { margin-bottom: 18px; }
.legal-facts { border-top-color: var(--fg); }
.legal-facts dd { color: var(--fg); }
@media (min-width: 1200px) { .legal-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 599px) { .legal-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; } .legal-facts dd { font-size: 15px; } }

/* Annexe : formulaire type de rétractation (feuille imprimable) */
.legal-form {
  padding: clamp(22px, 3vw, 36px);
  background: var(--field-bg); border: 1px solid var(--line); border-top: 3px solid var(--fg);
}
.legal-form > * + * { margin-top: 14px; }
.legal-form__note { font-size: 14px; line-height: 1.5; color: var(--muted); }
.legal-form__field { padding-bottom: 30px; border-bottom: 1px dotted var(--field-line); }

/* Autres documents légaux */
.legal-also {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(20px, 3vw, 40px);
  max-width: 52rem; margin-top: clamp(64px, 8vw, 112px); border-top: 1px solid var(--fg);
}
.legal-also .link-arrow {
  justify-content: space-between; gap: 20px; padding: 20px 0 22px;
  border-bottom: 1px solid var(--line); font-size: clamp(1.0625rem, 1rem + .3vw, 1.25rem); line-height: 1.25;
}
@media (max-width: 599px) { .legal-also { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Impression : le texte seul, en noir sur blanc ---------- */
@media print {
  .legal-toc, .legal-also, .page-hero .breadcrumb, .footer { display: none !important; }
  .page-hero[data-theme] { --fg: #000; --muted: #333; --line: #bbb; padding: 0 0 12px !important; }
  .legal-doc { --fg: #000; --muted: #333; --line: #bbb; --field-bg: transparent; --field-line: #555; }
  .legal__grid { display: block; }
  .legal-doc .prose > * { max-width: none; }
  .legal-doc .prose h2::before { display: none; }
  .legal-doc .prose h2 { break-after: avoid; }
  .legal-form { break-inside: avoid; }
}
