/*
 * Pages légales (/politiques/…) : confidentialité, conditions d'utilisation, mentions légales, cookies.
 * Utilise uniquement les tokens et composants du design system (static/css/ds/). Préfixe : lg-
 */

.lg__wrap {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-6);
}

/* --- Barre de lecture (navigateurs qui savent lier une animation au défilement) --- */
.lg-progress { display: none; }

@supports (animation-timeline: scroll()) {
  .lg-progress {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--ds-z-toast);
    height: 3px;
    background: var(--ds-primary);
    transform-origin: 0 50%;
    transform: scaleX(0);
    animation: lg-progress linear both;
    animation-timeline: scroll(root);
    pointer-events: none;
  }

  @keyframes lg-progress {
    to { transform: scaleX(1); }
  }
}

/* --- Introduction ---------------------------------------------- */
.lg-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(26px, 5vw, 56px) clamp(22px, 5vw, 56px);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-sm);
}

.lg-hero::before,
.lg-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.lg-hero::before {
  width: 360px;
  height: 360px;
  right: -130px;
  top: -170px;
  background: var(--ds-primary-soft);
}

.lg-hero::after {
  width: 200px;
  height: 200px;
  right: 110px;
  bottom: -150px;
  background: var(--ds-accent-soft);
}

.lg-hero > * {
  position: relative;
  z-index: 1;
}

.lg-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  margin: 0 0 var(--ds-space-4);
  padding: 6px 14px;
  border-radius: var(--ds-radius-badge);
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
  font-size: var(--ds-text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lg-title {
  max-width: 18em;
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: clamp(1.7rem, 4.6vw, 2.8rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ds-text);
}

.lg-lead {
  max-width: 40em;
  margin: var(--ds-space-4) 0 0;
  font-size: var(--ds-text-lg);
  line-height: 1.6;
  color: var(--ds-text-2);
}

.lg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-2) var(--ds-space-5);
  margin-top: var(--ds-space-6);
  font-size: var(--ds-text-sm);
  color: var(--ds-text-2);
}

.lg-meta__item {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
}

.lg-meta__item .cb-icon { color: var(--ds-primary-text); }

.lg-meta__btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--ds-border-strong);
  text-underline-offset: 3px;
}

.lg-meta__btn:hover { color: var(--ds-text); }

/* --- Les quatre documents ------------------------------------- */
.lg-docs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ds-space-3);
}

.ds-shell a.lg-doc {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  min-height: 64px;
  padding: var(--ds-space-3) var(--ds-space-4);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  color: var(--ds-text);
  font-weight: 600;
  font-size: var(--ds-text-sm);
  line-height: 1.3;
  text-decoration: none;
  transition: border-color var(--ds-duration) var(--ds-ease), background-color var(--ds-duration) var(--ds-ease), transform var(--ds-duration) var(--ds-ease);
}

.ds-shell a.lg-doc:hover {
  border-color: var(--ds-border-strong);
  transform: translateY(-1px);
}

.ds-shell a.lg-doc.is-current {
  border-color: var(--ds-primary);
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
}

.lg-doc__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: var(--ds-radius-sm);
  background: var(--ds-surface-2);
  color: var(--ds-primary-text);
  font-size: 21px;
}

.lg-doc.is-current .lg-doc__icon {
  background: var(--ds-primary);
  color: var(--ds-on-primary);
}

/* --- L'essentiel ------------------------------------------------ */
.lg-essential {
  padding: clamp(20px, 3.5vw, 32px);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-accent-soft);
}

.lg-essential__title {
  margin: 0 0 var(--ds-space-4);
  font-family: var(--ds-font-display);
  font-size: var(--ds-text-lg);
  font-weight: 600;
  color: var(--ds-text);
}

.lg-essential__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ds-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lg-essential__item {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  font-size: var(--ds-text-sm);
  line-height: 1.5;
  color: var(--ds-text-2);
}

.lg-essential__item strong { color: var(--ds-text); }

.lg-essential__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--ds-radius-sm);
  background: var(--ds-accent-soft);
  color: var(--ds-accent-text);
  font-size: 20px;
}

.lg-essential__note {
  margin: var(--ds-space-4) 0 0;
  font-size: var(--ds-text-xs);
  color: var(--ds-text-2);
}

/* --- Sommaire + texte ------------------------------------------- */
.lg-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: var(--ds-space-6);
  align-items: start;
}

.lg-aside {
  position: sticky;
  top: calc(var(--cbh-h, 60px) + var(--ds-space-4));
  max-height: calc(100vh - var(--cbh-h, 60px) - var(--ds-space-8));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.lg-toc {
  padding: var(--ds-space-4);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
}

.lg-toc__head {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: var(--ds-space-1) var(--ds-space-2) var(--ds-space-3);
  font-size: var(--ds-text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-text-2);
  list-style: none;
  cursor: default;
}

.lg-toc__head::-webkit-details-marker { display: none; }

.lg-toc__caret { display: none; margin-left: auto; transition: transform var(--ds-duration) var(--ds-ease); }

.lg-toc__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ds-shell a.lg-toc__link {
  display: flex;
  align-items: baseline;
  gap: var(--ds-space-3);
  padding: 7px var(--ds-space-2);
  border-radius: var(--ds-radius-sm);
  color: var(--ds-text-2);
  font-size: var(--ds-text-sm);
  line-height: 1.4;
  text-decoration: none;
  transition: background-color var(--ds-duration) var(--ds-ease), color var(--ds-duration) var(--ds-ease);
}

.ds-shell a.lg-toc__link:hover {
  background: var(--ds-surface-hover);
  color: var(--ds-text);
}

.ds-shell a.lg-toc__link.is-active {
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
  font-weight: 600;
}

.lg-toc__num {
  flex: none;
  min-width: 1.4em;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ds-text-3);
}

.lg-toc__link.is-active .lg-toc__num { color: inherit; }

/* --- Le document ------------------------------------------------ */
.lg-doc-body {
  counter-reset: lg-sec;
  min-width: 0;
  padding: clamp(22px, 4.5vw, 52px);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-sm);
  color: var(--ds-text-2);
  line-height: 1.75;
}

.lg-sec {
  counter-increment: lg-sec;
  scroll-margin-top: calc(var(--cbh-h, 60px) + var(--ds-space-5));
}

.lg-sec + .lg-sec {
  margin-top: var(--ds-space-10);
  padding-top: var(--ds-space-10);
  border-top: 1px solid var(--ds-border);
}

.lg-sec h2 {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  margin: 0 0 var(--ds-space-4);
  font-family: var(--ds-font-display);
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ds-text);
}

.lg-sec h2::before {
  content: counter(lg-sec);
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--ds-radius-sm);
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-sm);
  font-weight: 700;
}

.lg-sec h3 {
  margin: var(--ds-space-6) 0 var(--ds-space-2);
  font-size: var(--ds-text-base);
  font-weight: 600;
  line-height: 1.4;
  color: var(--ds-text);
}

.lg-sec p {
  margin: 0 0 var(--ds-space-3);
}

.lg-sec p:last-child { margin-bottom: 0; }

.lg-sec strong { color: var(--ds-text); font-weight: 600; }

.lg-sec a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.lg-sec code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--ds-surface-2);
  color: var(--ds-text);
  font-size: 0.88em;
}

.lg-sec ul:not([class]) {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
  margin: 0 0 var(--ds-space-3);
  padding: 0;
  list-style: none;
}

.lg-sec ul:not([class]) > li {
  position: relative;
  padding-left: 22px;
}

.lg-sec ul:not([class]) > li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.72em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ds-primary);
}

/* Encadrés (information, mise en garde) */
.lg-note {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-3);
  margin: var(--ds-space-5) 0;
  padding: var(--ds-space-4) var(--ds-space-5);
  border-radius: var(--ds-radius-md);
  background: var(--ds-primary-soft);
  color: var(--ds-text);
  line-height: 1.6;
}

.lg-note > .cb-icon {
  margin-top: 3px;
  font-size: 22px;
  color: var(--ds-primary-text);
}

.lg-note > div p + p { margin-top: var(--ds-space-2); }

.lg-note--warn { background: var(--ds-warning-soft); }
.lg-note--warn > .cb-icon { color: var(--ds-warning); }

.lg-note:last-child { margin-bottom: 0; }

/* Blocs empilés (catégories de données) */
.lg-cols {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
  margin-top: var(--ds-space-4);
}

.lg-box {
  padding: var(--ds-space-5);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-2);
  font-size: var(--ds-text-sm);
  line-height: 1.6;
}

.lg-sec .lg-box h3 { margin-top: 0; }
.lg-sec .lg-box ul:not([class]) { margin-bottom: 0; }

/* Droits RGPD */
.lg-rights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--ds-space-3);
  margin: var(--ds-space-4) 0;
  padding: 0;
  list-style: none;
}

.lg-rights li {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
  padding: var(--ds-space-4);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  font-size: var(--ds-text-sm);
  line-height: 1.5;
}

/* Fiches (éditeur, hébergeur) */
.lg-facts {
  margin: var(--ds-space-4) 0 0;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  overflow: hidden;
}

.lg-facts > div {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: var(--ds-space-4);
  padding: var(--ds-space-3) var(--ds-space-5);
}

.lg-facts > div + div { border-top: 1px solid var(--ds-border); }

.lg-facts dt {
  font-size: var(--ds-text-sm);
  font-weight: 600;
  color: var(--ds-text-3);
}

.lg-facts dd {
  margin: 0;
  color: var(--ds-text);
  overflow-wrap: anywhere;
}

/* Tableau des cookies */
.lg-table-wrap {
  margin: var(--ds-space-2) 0 var(--ds-space-4);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  overflow-x: auto;
}

.lg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ds-text-sm);
  line-height: 1.5;
}

.lg-table th,
.lg-table td {
  padding: var(--ds-space-3) var(--ds-space-4);
  text-align: left;
  vertical-align: top;
}

.lg-table thead th {
  background: var(--ds-surface-2);
  font-size: var(--ds-text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ds-text-3);
}

.lg-table tbody tr + tr { border-top: 1px solid var(--ds-border); }
.lg-table tbody th { font-weight: 600; color: var(--ds-text); }
.lg-table td:last-child { white-space: nowrap; }

.lg-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--ds-radius-badge);
  background: var(--ds-accent-soft);
  color: var(--ds-accent-text);
  font-size: var(--ds-text-xs);
  font-weight: 600;
}

.lg-tag--on { background: var(--ds-success-soft); color: var(--ds-text); }
.lg-tag--muted { background: var(--ds-surface-2); color: var(--ds-text-2); }

/* Gestion du consentement (page cookies) */
.lg-consent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-4) var(--ds-space-6);
  margin: 0 0 var(--ds-space-5);
  padding: var(--ds-space-5);
  border-radius: var(--ds-radius-md);
  background: var(--ds-primary-soft);
}

.lg-sec .lg-consent h3 { margin: 0 0 var(--ds-space-1); }
.lg-consent p { color: var(--ds-text-2); }
.lg-consent .ds-btn { flex: none; text-decoration: none; }

/* Contact en bas du document */
.lg-contact {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--ds-space-4);
  align-items: center;
  margin-top: var(--ds-space-10);
  padding: var(--ds-space-5);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-2);
}

.lg-contact__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--ds-radius-sm);
  background: var(--ds-surface);
  color: var(--ds-primary-text);
  font-size: 24px;
}

.lg-contact__title {
  margin: 0;
  font-size: var(--ds-text-base);
  font-weight: 600;
  color: var(--ds-text);
}

.lg-contact__text {
  margin: 2px 0 0;
  font-size: var(--ds-text-sm);
  color: var(--ds-text-2);
}

.lg-contact__actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-2);
}

/* Retour en haut */
.ds-shell a.lg-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: var(--ds-z-sticky);
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
  color: var(--ds-text);
  font-size: 20px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--ds-duration) var(--ds-ease), transform var(--ds-duration) var(--ds-ease), visibility 0s linear var(--ds-duration);
}

.ds-shell a.lg-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

/* --- Tablette et mobile ----------------------------------------- */
@media (max-width: 959px) {
  .lg-layout { grid-template-columns: minmax(0, 1fr); }

  .lg-aside {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .lg-toc { padding: var(--ds-space-3) var(--ds-space-4); }
  .lg-toc__head { padding: var(--ds-space-2) var(--ds-space-1); cursor: pointer; font-size: var(--ds-text-sm); }
  .lg-toc[open] .lg-toc__head { padding-bottom: var(--ds-space-3); }
  .lg-toc__caret { display: inline-block; }
  .lg-toc[open] .lg-toc__caret { transform: rotate(180deg); }
}

@media (max-width: 720px) {
  .lg-docs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ds-space-2); }
  .ds-shell a.lg-doc { min-height: 56px; padding: var(--ds-space-2) var(--ds-space-3); }
  .lg-doc__icon { width: 34px; height: 34px; font-size: 19px; }

  .lg-essential__list { grid-template-columns: minmax(0, 1fr); }

  .lg-facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }

  .lg-consent { flex-direction: column; align-items: stretch; }
  .lg-consent .ds-btn { width: 100%; }

  .lg-contact__actions .ds-btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-shell a.lg-doc,
  .ds-shell a.lg-top { transition: none; }
}

/* --- Impression : le texte seul ------------------------------------ */
@media print {
  .cbh, .cbf, .lg-progress, .lg-docs, .lg-aside, .lg-top, .lg-meta__btn, .lg-contact__actions, .lg-consent .ds-btn { display: none !important; }
  body { padding-top: 0 !important; }
  .ds-shell { padding: 0; background: #fff; }
  .lg-hero, .lg-doc-body, .lg-essential { border: 0; box-shadow: none; padding: 0; background: none; }
  .lg-hero::before, .lg-hero::after { display: none; }
  .lg-layout { display: block; }
  .lg-sec { break-inside: auto; }
  .lg-sec h2, .lg-sec h3 { break-after: avoid; }
  .lg-sec a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}
