/* Legal pages — Solber Conseil (V4)
   - Mobile-first, WCAG 2.2 AA, Perf, iOS-friendly (SE/6)
   - BEM (.legal__*) ; dépend des tokens globaux si présents
   - Couvre Mentions légales & Politique de confidentialité
*/

/* ========= Base & conteneur ========= */
.legal{
  padding-block: var(--space-8, 2rem);
  color: var(--gc-fg, #0f172a);
  background: var(--gc-bg, #ffffff);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.legal .container{
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2rem);
}

/* ========= En-tête ========= */
.legal__header{ margin-bottom: var(--space-6, 1.5rem); }
.legal__intro{
  color: var(--gc-muted, #6b7280);
  max-width: 75ch;
}

/* ========= Sections & titres ========= */
.legal__section{ margin-block: var(--space-6, 1.5rem); }
.legal__section > h2,
.legal h2{
  margin: 0 0 var(--space-3, .75rem);
  font-family: var(--gc-font-serif, "Playfair Display", Georgia, serif);
  font-size: var(--fs-600, 1.25rem);
  line-height: 1.25;
}
.legal h3{
  margin: var(--space-4, 1rem) 0 var(--space-2, .5rem);
  font-size: clamp(1.05rem, .4vw + 1rem, 1.15rem);
}

/* ========= Cartes ========= */
.legal__card{
  border: 1px solid var(--gc-border, #e5e7eb);
  background: var(--gc-surface, #ffffff);
  border-radius: var(--gc-radius, 16px);
  padding: var(--space-4, 1rem);
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
  /* Perf: utile si de longs blocs, évite de peindre off-screen */
  content-visibility: auto;
  contain-intrinsic-size: 600px;
}

/* ========= Blocs identité / adresse ========= */
.legal__org{ font-weight: 600; margin: 0 0 .25rem; }
.legal__address{ white-space: pre-line; margin: .25rem 0 .5rem; }

/* ========= Definition lists ========= */
.legal__dl{
  display: grid;
  gap: .25rem .75rem;
  grid-template-columns: 1fr 2fr;
}
.legal__dl dt{ color: var(--gc-muted, #6b7280); }
.legal__dl dd{ margin: 0; }

/* ========= Listes, texte long ========= */
.legal__ul{ margin: 0; padding-left: 1.1rem; }
.legal__ul li{ margin: 0 0 .35rem; }

.legal p, .legal li, .legal dd, .legal td{
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  max-width: 80ch;
}

/* ========= Liens & cibles tactiles ========= */
.legal a{
  color: var(--gc-link, #0ea5e9);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: .06em;
  border-radius: .5rem; /* pour un focus net visuel */
}
@media (hover:hover){
  .legal a:hover{ text-decoration-thickness: .12em; }
}
.legal a:focus-visible{
  outline: 2px solid var(--gc-focus, #0ea5e9);
  outline-offset: 2px;
}

/* Liens d’actions groupés (ex: PDF, contact) */
.legal__links{
  display: flex; flex-wrap: wrap; gap: .75rem;
  list-style: none; padding: 0; margin: 0;
}
.legal__links a{
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .5rem .75rem; /* iOS/Apple HIG 44px */
  -webkit-tap-highlight-color: rgba(0,0,0,.1);
  touch-action: manipulation;
}

/* ========= Tableaux, médias & code ========= */
.legal table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--gc-border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
}
.legal th, .legal td{
  text-align: left;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--gc-border, #e5e7eb);
}
.legal tr:last-child td{ border-bottom: 0; }
.legal thead th{
  background: var(--gc-subtle, #f8fafc);
  font-weight: 600;
}

/* Médias : ne débordent jamais */
.legal img, .legal video, .legal svg{
  display: block; max-width: 100%; height: auto;
}

/* Blocs citation & code */
.legal blockquote{
  margin: var(--space-4,1rem) 0;
  padding: .75rem 1rem;
  border-inline-start: 3px solid var(--gc-border, #e5e7eb);
  background: var(--gc-subtle, #f8fafc);
  border-radius: 8px;
}
.legal code, .legal pre{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95em;
}
.legal pre{
  background: var(--gc-subtle, #f8fafc);
  border: 1px solid var(--gc-border, #e5e7eb);
  border-radius: 10px;
  padding: .75rem 1rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========= Pied de section ========= */
.legal__footer{ margin-top: var(--space-8, 2rem); }

/* ========= Visually hidden util ========= */
.sr-only{
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ========= Responsive ========= */
@media (min-width: 980px){
  .legal__dl{ grid-template-columns: 220px 1fr; }
}

/* ========= iOS friendliness ========= */
@supports (padding: max(0px)){
  .legal{
    padding-left:  max(var(--space-8,2rem), env(safe-area-inset-left));
    padding-right: max(var(--space-8,2rem), env(safe-area-inset-right));
  }
}

/* Form controls anti-zoom iOS si présents dans la page */
.legal input, .legal select, .legal textarea, .legal button{
  font-size: 16px; /* évite le zoom auto iOS */
  -webkit-appearance: none; appearance: none;
}

/* Scrolling inertiel iOS pour tableaux longs */
.legal .scroll-area{ overflow: auto; -webkit-overflow-scrolling: touch; }

/* Focus visible accessible */
.legal :focus-visible{
  outline: 2px solid var(--gc-focus, #0ea5e9);
  outline-offset: 2px; border-radius: .5rem;
}

/* ========= Petits écrans iPhone SE/6 (~≤360px) ========= */
@media (max-width: 360px){
  .legal{ padding-block: var(--space-6, 1.5rem); }
  .legal__card{ padding: var(--space-4, 1rem); }
  .legal__dl{ grid-template-columns: 1fr; }
  .legal__links{ gap: .5rem; }
  .legal__links a{ width: 100%; justify-content: center; }
  /* Héros/offcanvas éventuels dans ces pages */
  .full-viewport, .hero, .offcanvas{
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS 12–15 */
  }
  /* Footer légal page : respecte safe-area bas */
  .site-footer .footer-bottom{
    padding-bottom: calc(var(--space-4, 1rem) + env(safe-area-inset-bottom));
  }
}

/* ========= Motion safety ========= */
@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ========= Contraste & forced colors ========= */
@media (prefers-contrast: more){
  .legal a{ text-decoration-thickness: .14em; }
}
@media (forced-colors: active){
  .legal{ background: Canvas; color: CanvasText; }
  .legal a{ color: LinkText; }
  .legal table{ border-color: GrayText; }
}

/* ========= Dark mode léger (si activé globalement) ========= */
@media (prefers-color-scheme: dark){
  .legal{
    color: var(--gc-fg-dark, #e5e7eb);
    background: var(--gc-bg-dark, #0b1220);
  }
  .legal__card{
    background: var(--gc-surface-dark, #0f172a);
    border-color: rgba(255,255,255,.08);
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
  }
  .legal thead th{ background: rgba(255,255,255,.06); }
  .legal blockquote, .legal pre{
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.08);
  }
}

/* ========= Impression ========= */
@media print{
  .site-header, .site-footer, .back-to-top{ display: none !important; }
  .legal{ color: #000; background: #fff; }
  .legal a{ color: #000; text-decoration: underline; }
  .legal__card{ box-shadow: none; border-color: #000; }
}
