/* ==========================================================================
   Troquizy — Pages juridiques (CGU, confidentialité, mentions légales)
   À charger APRÈS css/styles.css (et après css/rtl.css sur l'hébreu).

   Parti pris : un contrat imprimé, pas une page marketing. Quarante pages de
   texte se lisent avec une justification courte, un interlignage large et des
   numéros d'article suspendus dans la marge — la numérotation est la
   structure du document, elle doit rester visible sans être lue.
   Tout est exprimé en propriétés logiques (inline-start/end) : la version
   hébraïque utilise la même feuille, retournée.
   ========================================================================== */

.legal-page {
  --measure: 68ch;
  --rule: #E9E2DB;
  --legal-header-h: 68px;
  background:
    radial-gradient(1100px 420px at 88% -12%, color-mix(in srgb, var(--blush) 60%, transparent), transparent 70%),
    var(--cream);
  background-attachment: fixed;
}

.legal-skip {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 200;
  background: var(--ink); color: var(--white);
  padding: .7rem 1.2rem; border-radius: 0 0 12px 0;
  font-size: .85rem; font-weight: 600; text-decoration: none;
}
.legal-skip:focus { inset-inline-start: 0; }

/* --------------------------------------------------------------------------
   En-tête : barre fine, le titre du document tient le centre
   -------------------------------------------------------------------------- */
.legal-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule);
}
.legal-header__inner {
  width: min(1180px, 92%); margin-inline: auto;
  height: var(--legal-header-h);
  display: flex; align-items: center; gap: 1.5rem;
}
.legal-header__logo img { display: block; height: 38px; width: auto; }
.legal-header__doc {
  flex: 1; min-width: 0;
  font-family: var(--serif); font-size: 1.02rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-inline-start: 1.5rem;
  border-inline-start: 1px solid var(--rule);
}

/* --------------------------------------------------------------------------
   Gabarit : sommaire collant + document
   -------------------------------------------------------------------------- */
.legal-main {
  width: min(1180px, 92%); margin-inline: auto;
  display: grid; grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
  padding-block: 3.5rem 5rem;
}

.legal-toc { position: sticky; top: calc(var(--legal-header-h) + 2.2rem); }
.legal-toc__switch { position: absolute; }
.legal-toc__handle {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--terracotta);
  padding-bottom: .9rem; border-bottom: 1px solid var(--rule);
}
.legal-toc__handle svg { display: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.legal-toc__panel {
  max-height: calc(100vh - var(--legal-header-h) - 8rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Ascenseur discret : le sommaire ne doit pas rivaliser avec le texte. */
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.legal-toc__panel ol { list-style: none; counter-reset: none; padding: .9rem 0 0; }
.legal-toc__panel a {
  display: block; padding: .42rem 0;
  font-size: .855rem; line-height: 1.45; color: var(--grey); text-decoration: none;
  border-inline-start: 2px solid transparent; padding-inline-start: .9rem;
  transition: color .18s ease, border-color .18s ease;
}
.legal-toc__panel a:hover { color: var(--ink); border-inline-start-color: var(--terracotta-light); }
.legal-toc__panel a.is-current {
  color: var(--terracotta); font-weight: 600; border-inline-start-color: var(--terracotta);
}

/* --------------------------------------------------------------------------
   Le document
   -------------------------------------------------------------------------- */
.legal-doc {
  max-width: var(--measure); font-size: 1rem;
  /* La politique de confidentialité cite ses références en clair : des URL
     de gov.il de 84 caractères, insécables. Sans cette coupure, ce seul mot
     impose sa largeur à toute la colonne et la page déborde sur téléphone —
     constaté dans le navigateur intégré de l'app avant correction. */
  overflow-wrap: anywhere;
}

.legal-doc__head { padding-bottom: 2.4rem; border-bottom: 1px solid var(--rule); margin-bottom: 2.6rem; }
.legal-doc__head .eyebrow { margin-bottom: .9rem; }
.legal-doc h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(1.95rem, 4.4vw, 2.9rem); line-height: 1.14; letter-spacing: -.01em;
}
.legal-doc__version {
  margin-top: 1.3rem;
  font-size: .84rem; font-weight: 600; letter-spacing: .04em;
  color: var(--terracotta);
}

/* Clause de langue prévalente : un encart, pas une alerte. */
.legal-notice {
  margin-top: 1.6rem; padding: 1rem 1.2rem;
  background: color-mix(in srgb, var(--blush) 55%, var(--white));
  border-inline-start: 3px solid var(--terracotta-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .9rem; line-height: 1.6; color: var(--ink);
}

.legal-doc h2 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(1.35rem, 2.6vw, 1.7rem); line-height: 1.2;
  margin: 3.4rem 0 1.1rem;
  scroll-margin-top: calc(var(--legal-header-h) + 1.5rem);
}
/* Filet au-dessus de chaque article : respiration d'un document imprimé. */
.legal-doc h2::before {
  content: ""; display: block;
  width: 46px; height: 2px; background: var(--terracotta);
  margin-bottom: 1.3rem;
}
.legal-doc h2:first-of-type { margin-top: 0; }

.legal-doc h3 {
  font-family: var(--sans); font-weight: 600;
  font-size: 1.02rem; line-height: 1.45; color: var(--ink);
  margin: 2.2rem 0 .7rem;
  scroll-margin-top: calc(var(--legal-header-h) + 1.5rem);
}
.legal-doc h4 {
  font-family: var(--sans); font-weight: 600;
  font-size: .94rem; line-height: 1.45; color: var(--grey);
  margin: 1.6rem 0 .5rem;
  scroll-margin-top: calc(var(--legal-header-h) + 1.5rem);
}

.legal-annex {
  margin-top: 4.5rem; padding-top: 2.6rem;
  border-top: 1px solid var(--rule);
  text-transform: none;
}
.legal-annex::before { display: none; }

.legal-doc p { margin: 0 0 1rem; line-height: 1.78; color: #3B3835; }

/* Liens du document : ceux de l'avocat, repris des annotations du PDF —
   références de lois, adresses de contact. Soulignés, car dans un texte
   juridique la couleur seule ne suffit pas à les distinguer ; le décalage
   du trait les rend lisibles sans hacher les lignes. */
.legal-doc :is(p, li, h2, h3, h4) a {
  color: var(--terracotta);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  text-decoration-color: color-mix(in srgb, var(--terracotta) 45%, transparent);
  transition: text-decoration-color .18s ease, color .18s ease;
}
.legal-doc :is(p, li, h2, h3, h4) a:hover {
  color: var(--terracotta-dark);
  text-decoration-color: currentColor;
}
/* Une référence dont le libellé EST le lien occupe tout l'item : le trait
   sous une ligne entière alourdit, la couleur et la flèche suffisent. */
.legal-list li > span > a:only-child {
  text-decoration: none;
  font-weight: 500;
}
.legal-list li > span > a:only-child::after {
  content: "↗";
  font-size: .8em; margin-inline-start: .3em;
  color: var(--terracotta-light);
}
.legal-list li > span > a:only-child:hover { text-decoration: underline; }

/* Alinéa numéroté : le numéro est suspendu dans la marge. En dessous de la
   largeur qui le permet, il repasse dans le flux (voir requête média). */
.clause {
  display: flex; gap: .75rem;
  scroll-margin-top: calc(var(--legal-header-h) + 1.5rem);
}
.clause__n {
  flex: 0 0 auto; min-width: 3.4rem;
  margin-inline-start: -4.15rem;
  text-align: end;
  font-variant-numeric: tabular-nums;
  font-size: .82rem; font-weight: 600; color: var(--terracotta);
  line-height: 1.78;
  padding-top: .06em;
}

.legal-list { list-style: none; margin: 0 0 1.2rem; padding: 0; }
.legal-list li {
  display: flex; gap: .75rem;
  margin-bottom: .55rem; line-height: 1.78; color: #3B3835;
}
/* Puce simple quand l'item n'a pas de lettre : un tiret demi-cadratin. */
.legal-list li:not(:has(.legal-list__mark))::before {
  content: "–"; flex: 0 0 auto; color: var(--terracotta-light);
}
.legal-list__mark {
  flex: 0 0 auto; min-width: 1.9rem;
  font-variant-numeric: tabular-nums;
  font-size: .86rem; font-weight: 600; color: var(--terracotta);
}

/* --------------------------------------------------------------------------
   Pied du document
   -------------------------------------------------------------------------- */
.legal-doc__foot { margin-top: 4.5rem; padding-top: 2.4rem; border-top: 1px solid var(--rule); }
.legal-doc__support { font-size: .95rem; color: var(--grey); }
.legal-doc__support a { color: var(--terracotta); font-weight: 600; text-decoration: none; }
.legal-doc__support a:hover { text-decoration: underline; }

.legal-doc__others { margin-top: 2rem; display: flex; flex-direction: column; gap: .1rem; }
.legal-doc__others h2 {
  font-family: var(--sans); font-size: .76rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--terracotta);
  margin: 0 0 .9rem;
}
.legal-doc__others h2::before { display: none; }
.legal-doc__others a {
  padding: .6rem 0; border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none; font-size: .95rem; font-weight: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  transition: color .18s ease;
}
.legal-doc__others a::after {
  content: "→"; color: var(--terracotta); font-size: .95rem;
  transition: transform .18s ease;
}
.legal-doc__others a:hover { color: var(--terracotta); }
.legal-doc__others a:hover::after { transform: translateX(3px); }

.legal-doc__back { margin-top: 2.2rem; display: flex; gap: 1.6rem; flex-wrap: wrap; }
.legal-doc__back a { font-size: .9rem; font-weight: 600; color: var(--terracotta); text-decoration: none; }
.legal-doc__back a:hover { text-decoration: underline; }
.legal-doc__rights { margin-top: 1.6rem; font-size: .82rem; color: #8C8783; }

/* --------------------------------------------------------------------------
   Hébreu : la flèche du pied de page et la mirette du sommaire s'inversent
   -------------------------------------------------------------------------- */
html[dir="rtl"] .legal-doc__others a::after { content: "←"; }
html[dir="rtl"] .legal-doc__others a:hover::after { transform: translateX(-3px); }
/* L'hébreu n'a ni capitales ni fort interlettrage. */
html[dir="rtl"] .legal-toc__handle,
html[dir="rtl"] .legal-doc__others h2 { letter-spacing: .04em; text-transform: none; }
/* Interlignage plus large : les points-voyelles et les hampes hébraïques
   demandent de l'air que l'alphabet latin n'exige pas. */
html[dir="rtl"] .legal-doc p,
html[dir="rtl"] .legal-list li { line-height: 1.95; }
html[dir="rtl"] .clause__n { line-height: 1.95; }
html[dir="rtl"] .legal-doc h1 { letter-spacing: 0; line-height: 1.3; }

/* --------------------------------------------------------------------------
   Écrans intermédiaires : le sommaire passe au-dessus, replié
   -------------------------------------------------------------------------- */
@media (max-width: 1000px) {
  .legal-main { grid-template-columns: 1fr; gap: 1.8rem; padding-block: 2.2rem 3.5rem; }
  .legal-doc { max-width: none; }

  .legal-toc { position: static; }
  .legal-toc__handle {
    cursor: pointer;
    padding: .95rem 1.1rem; border: 1px solid var(--rule); border-radius: var(--radius);
    background: var(--white);
  }
  .legal-toc__handle svg { display: block; transition: transform .22s ease; }
  .legal-toc__panel { display: none; max-height: none; }
  .legal-toc__switch:checked ~ .legal-toc .legal-toc__handle svg { transform: rotate(180deg); }
  .legal-toc__switch:checked ~ .legal-toc .legal-toc__panel { display: block; }
  .legal-toc__panel ol { padding: 1rem .4rem 0; }

  /* Numéro d'alinéa ramené dans le flux : plus de marge où le suspendre. */
  .clause__n { margin-inline-start: 0; min-width: 2.9rem; text-align: start; }
}

@media (max-width: 620px) {
  .legal-page { --measure: none; }
  .legal-header__doc { display: none; }
  .legal-header__inner { gap: 1rem; justify-content: space-between; }
  .legal-doc { font-size: .97rem; }
  .clause { gap: .55rem; }
  .clause__n { min-width: 2.6rem; font-size: .78rem; }
}

/* --------------------------------------------------------------------------
   Impression : un document juridique doit pouvoir être imprimé et signé
   -------------------------------------------------------------------------- */
@media print {
  .legal-page { background: var(--white); }
  .legal-header, .legal-toc, .legal-skip,
  .legal-doc__others, .legal-doc__back { display: none; }
  .legal-main { display: block; width: auto; padding: 0; }
  .legal-doc { max-width: none; font-size: 10.5pt; }
  .legal-doc h2 { break-after: avoid; }
  .clause, .legal-list li { break-inside: avoid; }
  .clause__n { margin-inline-start: 0; }
}
