/* ==========================================================================
   Groupe Tertio — pages légales (mentions légales, confidentialité, CGU) et 404
   Thème sombre par défaut (version officielle du site) ; thème clair via
   <html data-theme="light">, posé par js/theme-init.js avant l'affichage.
   Aucune ressource externe : polices servies par vendor/fonts/fonts.css.
   ========================================================================== */

/* ---------- Jetons de couleur : thème sombre (par défaut) ---------- */
:root {
  color-scheme: dark;
  --bg: #050714;
  --bg-glow: rgba(227, 6, 19, 0.10);
  --surface: rgba(255, 255, 255, 0.035);
  --surface-solid: #0E101C;               /* --surface posée sur --bg (opaque) */
  --surface-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.22);
  --ink: #F4F5FB;                         /* texte principal */
  --ink-2: #A4A9C8;                       /* texte secondaire */
  --ink-3: #7D839F;                       /* texte atténué (minimum autorisé) */
  --accent: #FF3548;                      /* rouge d'accent pour le texte */
  --btn-bg: linear-gradient(135deg, #C20612 0%, #E30613 100%);
  --btn-bg-hover: linear-gradient(135deg, #A60510 0%, #C20612 100%);
  --btn-ink: #FFFFFF;
  --focus: #FFB800;
  --todo-bg: rgba(255, 184, 0, 0.14);
  --todo-border: rgba(255, 184, 0, 0.70);
  --scroll-shadow: rgba(0, 0, 0, 0.60);
  --sb-thumb: rgba(244, 245, 251, 0.32);
  --sb-thumb-hover: rgba(244, 245, 251, 0.55);
  --sb-track: rgba(255, 255, 255, 0.05);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --gutter: 16px;
  --measure: 760px;                       /* colonne de lecture */
  --wide: 1040px;                         /* en-tête, pied de page, grands tableaux */
  --radius: 16px;
}

/* ---------- Jetons de couleur : thème clair ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F2EDE0;
  --bg-glow: rgba(194, 6, 18, 0.06);
  --surface: rgba(255, 253, 247, 0.55);
  --surface-solid: #F9F6ED;
  --surface-strong: rgba(28, 22, 16, 0.06);
  --border: rgba(28, 22, 16, 0.10);
  --border-strong: rgba(28, 22, 16, 0.24);
  --ink: #1A1612;
  --ink-2: #5A5046;
  --ink-3: #5A5046;
  --accent: #C20612;
  --focus: #1A1612;
  --todo-bg: rgba(255, 184, 0, 0.30);
  --todo-border: rgba(122, 82, 0, 0.75);
  --scroll-shadow: rgba(26, 22, 18, 0.20);
  --sb-thumb: rgba(26, 22, 18, 0.32);
  --sb-thumb-hover: rgba(26, 22, 18, 0.55);
  --sb-track: rgba(28, 22, 16, 0.05);
}

@media (min-width: 600px) {
  :root { --gutter: 24px; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--bg);
}

/* Barre de défilement native, toujours visible et stylée comme sur le site */
@supports (-moz-appearance: none) {
  html { scrollbar-width: auto; scrollbar-color: var(--sb-thumb) var(--sb-track); }
}
html::-webkit-scrollbar { width: 14px; }
html::-webkit-scrollbar-track { background: var(--sb-track); }
html::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 100px; border: 3px solid var(--bg); }
html::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 90% 60% at 10% -10%, var(--bg-glow), transparent 70%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.125rem;            /* 18 px */
  line-height: 1.65;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

img, svg { display: block; max-width: 100%; }

p, ul, ol, dl { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.4em; }
li { margin-bottom: 0.45em; }
li::marker { color: var(--ink-2); }
strong { font-weight: 700; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }

abbr[title] { text-decoration: none; border-bottom: 1px dotted currentColor; cursor: help; }

/* ---------- Focus visible et accessibilité ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}
main:focus { outline: none; }

.skip-link {
  position: absolute;
  top: -200px;
  left: var(--gutter);
  z-index: 100;
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Éléments qui n'ont de sens qu'avec JavaScript (la classe « js » est posée par theme-init.js) */
html:not(.js) .js-only { display: none !important; }

/* ---------- En-tête ---------- */
.site-header {
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 20px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}

.brand { display: inline-flex; border-radius: 8px; }
.brand img { height: 72px; width: auto; }
.brand .logo-light { display: none; }
:root[data-theme="light"] .brand .logo-dark { display: none; }
:root[data-theme="light"] .brand .logo-light { display: block; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px 0 14px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.0625rem;           /* 17 px */
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.pill:hover { border-color: var(--ink-2); text-decoration: none; }
.pill svg { width: 18px; height: 18px; flex-shrink: 0; }

.theme-toggle .icon-moon,
.theme-toggle .label-to-dark { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun,
:root[data-theme="light"] .theme-toggle .label-to-light { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .label-to-dark { display: inline; }

@media (max-width: 599.98px) {
  .brand img { height: 60px; }
}
/* Petits écrans : bouton de thème réduit à son icône (nom accessible porté par aria-label), comme sur le site */
@media (max-width: 419.98px) {
  .theme-toggle { width: 44px; padding: 0; justify-content: center; }
  .theme-toggle .label-to-light,
  :root[data-theme="light"] .theme-toggle .label-to-dark { display: none; }
}
@media (max-width: 359.98px) {
  .brand img { height: 52px; }
}

/* ---------- Contenu principal ---------- */
main {
  flex: 1 0 auto;
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 32px var(--gutter) 72px;
}

.page-intro { margin-bottom: 2.5rem; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 0.75rem;
  color: var(--ink-2);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #E30613;
  box-shadow: 0 0 12px rgba(255, 53, 72, 0.7);
}

h1, h2, h3 { color: var(--ink); text-wrap: balance; }

h1 {
  margin: 0 0 0.45em;
  font-size: clamp(2.25rem, 1.5rem + 3.6vw, 3.75rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.serif {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--accent);
}

h2 {
  margin: 3rem 0 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: clamp(1.5rem, 1.25rem + 1vw, 1.875rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  scroll-margin-top: 16px;
}

h3 {
  margin: 2rem 0 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  scroll-margin-top: 16px;
}

.lead { color: var(--ink-2); font-size: 1.25rem; line-height: 1.55; max-width: 44em; }

.updated { color: var(--ink-2); font-size: 1.0625rem; margin: 0; }
.updated time { color: var(--ink); font-weight: 600; }

/* Sommaire */
.toc {
  margin: 0 0 1rem;
  padding: 1.25rem 1.5rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.toc h2 {
  margin: 0 0 0.6rem;
  padding: 0;
  border: 0;
  color: var(--ink-2);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.toc ol { margin: 0 0 0.75rem; padding-left: 1.6em; }
.toc li { margin-bottom: 0.35em; }
.toc a { color: var(--ink); text-decoration-color: var(--border-strong); }
.toc a:hover { color: var(--accent); text-decoration-color: currentColor; }

/* Encadré « L'essentiel » */
.summary {
  margin: 2rem 0 0;
  padding: 1.25rem 1.5rem 0.25rem;
  border: 1px solid var(--border);
  border-left: 4px solid #E30613;
  border-radius: var(--radius);
  background: var(--surface);
}
.summary h2 { margin: 0 0 0.6rem; padding: 0; border: 0; font-size: 1.375rem; }

/* Listes de faits (éditeur, hébergeur…) */
.facts {
  margin: 0 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.facts > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.15rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
}
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--ink-2); font-weight: 600; font-size: 1.0625rem; }
.facts dd { margin: 0; }
@media (min-width: 640px) {
  .facts > div { grid-template-columns: 13.5rem minmax(0, 1fr); gap: 1.5rem; }
}

/* Mention à compléter par le client */
.todo {
  padding: 0.05em 0.35em;
  border: 1px dashed var(--todo-border);
  border-radius: 6px;
  background: var(--todo-bg);
  color: var(--ink);
  font-weight: 600;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---------- Tableaux ---------- */
.table-title { margin: 1.75rem 0 0.5rem; font-weight: 700; color: var(--ink); }
.table-hint { display: none; margin: 0 0 0.5rem; color: var(--ink-3); font-size: 1.0625rem; }

.table-wrap {
  margin: 0 0 1.75rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Ombres de défilement : visibles seulement quand du contenu est masqué */
  background:
    linear-gradient(to right, var(--surface-solid) 30%, rgba(0, 0, 0, 0)) left center / 48px 100% no-repeat local,
    linear-gradient(to left, var(--surface-solid) 30%, rgba(0, 0, 0, 0)) right center / 48px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), rgba(0, 0, 0, 0)) left center / 16px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), rgba(0, 0, 0, 0)) right center / 16px 100% no-repeat scroll,
    var(--surface-solid);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.0625rem;           /* 17 px */
  line-height: 1.55;
}
th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child > * { border-bottom: 0; }
thead th {
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}
tbody th { color: var(--ink); font-weight: 700; min-width: 11rem; }
tbody th .detail { display: block; margin-top: 0.3rem; color: var(--ink-2); font-weight: 400; }
td { color: var(--ink); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
  padding: 0.05em 0.35em;
  border-radius: 5px;
  background: var(--surface-strong);
  color: var(--ink);
  white-space: nowrap;
}

/* Les grands tableaux débordent de la colonne de lecture sur écran large */
@media (min-width: 900px) {
  .breakout {
    width: min(var(--wide), calc(100vw - 64px));
    margin-left: calc((100% - min(var(--wide), calc(100vw - 64px))) / 2);
  }
}

/* Sous 600 px : défilement horizontal propre, avec indication */
@media (max-width: 599.98px) {
  .table-hint { display: block; }
  .table-wrap table { min-width: 40rem; }
  .table-wrap table.compact { min-width: 34rem; }
}

/* ---------- Boutons et zone d'état ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0.7rem 1.4rem;
  border: 0;
  border-radius: 100px;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--btn-bg); color: var(--btn-ink); }
.btn-primary:hover { background: var(--btn-bg-hover); text-decoration: none; }
a.btn-primary, a.btn-primary:visited { color: var(--btn-ink); }

.pref-reset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1.5rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.status { margin: 0; color: var(--ink); font-weight: 600; min-height: 1.65em; }

.back-top { margin-top: 3rem; }

/* ---------- 404 ---------- */
.code-404 {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(5rem, 3rem + 12vw, 10rem);
  line-height: 0.9;
  color: var(--accent);
}
.link-list { list-style: none; padding: 0; }
.link-list li { margin-bottom: 0.6em; }

/* ---------- Pied de page ---------- */
.site-footer {
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 28px var(--gutter) 36px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  font-size: 1.0625rem;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 0; margin: 0; padding: 0; list-style: none; }
.footer-links li { margin: 0; }
.footer-links li + li::before {
  content: "·";
  content: "·" / "";
  margin: 0 0.6rem;
  color: var(--ink-3);
}
.footer-links a { color: var(--ink-2); text-decoration-color: var(--border-strong); }
.footer-links a:hover { color: var(--ink); text-decoration-color: currentColor; }
.footer-links a[aria-current="page"] { color: var(--ink); font-weight: 700; text-decoration: none; }
.copyright { margin: 0; color: var(--ink-3); }
@media (max-width: 599.98px) {
  .footer-links { gap: 8px 20px; }
  .footer-links li + li::before { display: none; }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Contrastes élevés (Windows) ---------- */
@media (forced-colors: active) {
  .pill, .btn, .toc, .facts, .table-wrap, .pref-reset, .summary { border: 1px solid CanvasText; }
  .todo { border-color: Highlight; }
  :focus-visible { outline-color: Highlight; }
  .eyebrow::before { forced-color-adjust: none; }
}

/* ---------- Impression ---------- */
@media print {
  :root, :root[data-theme="light"] {
    color-scheme: light;
    --bg: #FFFFFF;
    --surface: transparent;
    --surface-solid: #FFFFFF;
    --surface-strong: #EEEEEE;
    --border: #999999;
    --border-strong: #666666;
    --ink: #000000;
    --ink-2: #222222;
    --ink-3: #333333;
    --accent: #000000;
    --todo-bg: #FFFFFF;
    --todo-border: #000000;
  }
  @page { margin: 18mm 16mm; }
  html, body { background: #FFFFFF !important; color: #000000; }
  body { display: block; font-size: 11pt; line-height: 1.5; }
  .skip-link, .header-actions, .toc, .table-hint, .pref-reset, .back-top, .site-footer nav { display: none !important; }
  .brand .logo-dark { display: none !important; }
  .brand .logo-light { display: block !important; height: 40px; }
  .site-header, main, .site-footer { max-width: none; padding-left: 0; padding-right: 0; }
  main { padding-top: 8pt; padding-bottom: 8pt; }
  h1 { font-size: 24pt; }
  h2 { font-size: 15pt; margin-top: 18pt; padding-top: 10pt; break-after: avoid; page-break-after: avoid; }
  h3 { font-size: 12.5pt; break-after: avoid; page-break-after: avoid; }
  a { color: #000000; text-decoration: underline; }
  a[href^="http"]:not(.url)::after { content: " (" attr(href) ")"; font-size: 90%; }
  .breakout { width: auto; margin-left: 0; }
  .table-wrap { overflow: visible; background: none; border: 1px solid #999999; }
  .table-wrap table { min-width: 0 !important; }
  table { font-size: 9.5pt; }
  thead { display: table-header-group; }
  tr, .facts > div, li { break-inside: avoid; page-break-inside: avoid; }
  .facts > div { grid-template-columns: 38mm minmax(0, 1fr); gap: 6mm; padding: 5pt 8pt; }
  .eyebrow::before { display: none; }
}
