/* ==========================================================================
   Institut Xenia — feuille de style unique (écran + impression)
   Couleurs et polices : tout est déclaré dans :root, une ligne par valeur.
   ========================================================================== */

:root {
  /* Couleur (valeurs provisoires de la spec, section 4) */
  --bg:          #FBFAF7;
  --ink:         #16181D;
  --gray:        #5F6672;   /* texte secondaire, 5,9:1 sur --bg */
  --rule:        #E3E1DC;   /* filets */
  --rule-strong: #C9C5BD;
  --accent:      #17456B;   /* bleu encre, usage parcimonieux */
  --accent-soft: #C3D2DF;   /* aplats de figure uniquement */
  --wip:         #8A4B00;   /* marqueurs « en chantier », jamais publiés */
  --wip-bg:      #FFF4E0;

  /* Typographie : deux familles au total */
  --serif: "Source Serif 4", "Source Serif Pro", "Iowan Old Style", Charter, Georgia, serif;
  --sans:  Inter, "Helvetica Neue", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  /* Mesures */
  --measure: 44rem;         /* colonne de texte, ~700 px */
  --figure:  47.5rem;       /* figures, 760 px */
  --toc:     15rem;
  --header-h: 3.5rem;
  --gutter: 1.5rem;
}

/* ---------- Base ---------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;       /* 19 px */
  line-height: 1.65;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-kerning: normal;
  hyphens: auto;
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 1040px) {
  body { font-size: 1.25rem; } /* 20 px */
}

[id] { scroll-margin-top: calc(var(--header-h) + 1.5rem); }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3, h4 {
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.2;
  font-variant-numeric: lining-nums;
  hyphens: manual;
  text-wrap: balance;
}

p, li { text-wrap: pretty; }

strong { font-weight: 650; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Métadonnées : sans-serif, petit corps, interlettrage ouvert, gris soutenu */
.meta, .kicker {
  font-family: var(--sans);
  font-size: .8125rem;
  letter-spacing: .04em;
  color: var(--gray);
  line-height: 1.5;
  font-variant-numeric: lining-nums;
}
.kicker {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Lien d'évitement --------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: .9375rem;
  border: 2px solid var(--accent);
}
.skip-link:focus { top: .5rem; }

/* ---------- En-tête ------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}
.site-header__inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}
.wordmark__mark {
  flex: none;
  width: 1.625rem;
  height: 1.625rem;
}
.wordmark__mark rect { fill: var(--accent); }
.wordmark__mark path { fill: var(--bg); }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.5rem;
}
.site-nav a {
  display: inline-block;
  padding: .35rem 0;
  font-size: .9375rem;
  color: var(--gray);
  text-decoration: none;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.menu-toggle { display: none; }

/* Menu mobile : actif seulement si le JS est là (classe .js sur <html>) */
@media (max-width: 719px) {
  .js .menu-toggle {
    display: inline-block;
    font: inherit;
    font-size: .9375rem;
    color: var(--ink);
    background: none;
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    padding: .3rem .75rem;
    cursor: pointer;
  }
  .js .site-nav { display: none; flex-basis: 100%; padding-bottom: .75rem; }
  .js .site-nav.is-open { display: block; }
  .js .site-nav ul { flex-direction: column; gap: 0; }
  .js .site-nav a { padding: .55rem 0; }
}

/* ---------- Pied de page -------------------------------------------------- */

.site-footer {
  margin-top: 6rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .875rem;
  color: var(--gray);
}
.site-footer__inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 2rem var(--gutter) 3rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--gray); }
.site-footer a:hover { color: var(--ink); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }

/* ---------- Pages simples (résumé, sources, FAQ, institut…) --------------- */

.page {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 4rem var(--gutter) 0;
}
.page-head { margin-bottom: 3rem; }
.page-head h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -.015em;
  margin: .5rem 0 1rem;
}
.page-head .lede {
  font-size: 1.25em;
  line-height: 1.45;
  color: var(--ink);
  margin: 0;
  font-style: italic;
}
.page h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 3.5rem 0 1rem;
  letter-spacing: -.01em;
}
.page h3 {
  font-size: 1.125rem;
  font-weight: 650;
  margin: 2.25rem 0 .75rem;
}

/* ---------- Couverture de la note ---------------------------------------- */

.cover {
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--rule);
}
.cover__inner {
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: 4rem var(--gutter);
}
.cover__title {
  font-size: clamp(2.5rem, 7.5vw, 5.25rem);
  font-weight: 750;
  letter-spacing: -.03em;
  line-height: 1.02;
  margin: 1.25rem 0 1.5rem;
  max-width: 14ch;
}
.cover__subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.25rem, 2.6vw, 1.625rem);
  line-height: 1.4;
  max-width: 34ch;
  margin: 0 0 3rem;
}
.cover__authors {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 550;
  margin: 0 0 .5rem;
  max-width: 44rem;
}
.cover__links {
  margin: 2.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 2rem;
  font-family: var(--sans);
  font-size: .9375rem;
}

/* ---------- Mise en page de la note : sommaire + article ------------------ */

.note-layout {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}
@media (min-width: 1040px) {
  .note-layout {
    max-width: 76rem;
    display: grid;
    grid-template-columns: var(--toc) minmax(0, var(--measure));
    column-gap: clamp(3rem, 6vw, 6rem);
    justify-content: center;
  }
}

/* Sommaire collant à trois états : à lire (gris), en cours (accent), lu (encre) */
.toc {
  font-family: var(--sans);
  font-size: .875rem;
  line-height: 1.4;
  margin: 2.5rem 0 0;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .75rem 1rem;
}
.toc > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  padding: .25rem 0;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc > nav > ol { counter-reset: toc-part; margin-top: .75rem; }
.toc > nav > ol > li { counter-increment: toc-part; margin: 0 0 .9rem; }
.toc a {
  position: relative;
  display: block;
  padding: .15rem 0 .15rem .9rem;
  color: var(--gray);
  text-decoration: none;
}
.toc a:hover { color: var(--ink); text-decoration: underline; }
.toc .toc-part > a { font-weight: 600; }
.toc .toc-part > a::before {
  content: counter(toc-part, decimal-leading-zero);
  display: inline-block;
  width: 1.9rem;
  font-variant-numeric: tabular-nums lining-nums;
}
.toc li li a { padding-left: 2.8rem; font-size: .8125rem; }
.toc a[data-state="read"] { color: var(--ink); }
.toc a[data-state="current"] { color: var(--accent); }
.toc a[data-state="current"]::after {
  content: "";
  position: absolute;
  left: 0; top: .3rem; bottom: .3rem;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}

@media (min-width: 1040px) {
  .toc {
    position: sticky;
    top: calc(var(--header-h) + 2.5rem);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 4rem);
    overflow-y: auto;
    margin-top: 5rem;
    border: 0;
    padding: 0;
  }
  .toc > summary { display: none; }
  .toc > nav > ol { margin-top: 0; }
}

/* ---------- Corps de la note --------------------------------------------- */

.note { counter-reset: part figure; padding-top: 3rem; }

.note > section { counter-increment: part; }

.note h2 {
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 750;
  letter-spacing: -.02em;
  margin: 5rem 0 1.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--ink);
}
/* Numérotation des parties : générée, jamais saisie */
.note h2::before {
  content: "Partie " counter(part, decimal-leading-zero);
  display: block;
  margin-bottom: .75rem;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.note h3 {
  font-size: 1.3125rem;
  font-weight: 650;
  letter-spacing: -.01em;
  margin: 3.5rem 0 1rem;
}
.note h4 {
  font-size: 1.0625rem;
  font-weight: 650;
  margin: 2rem 0 .5rem;
}
.note ul, .note ol, .page ul, .page ol { padding-left: 1.25em; }
.note li, .page li { margin: .4em 0; }
.note li::marker, .page li::marker { color: var(--gray); }

/* ---------- Composants éditoriaux (spec, section 7) ---------------------- */

/* Étiquette commune des encadrés */
.label {
  display: block;
  margin: 0 0 .5rem;
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gray);
}

/* Encadré d'exemple : un cadre, se détache du flux */
.example {
  margin: 2.5rem 0;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  font-size: .95em;
}
.example h4 { margin: 0 0 .75rem; font-size: 1.125rem; }
.example > :last-child { margin-bottom: 0; }

/* Encadré d'analogie : un filet, pas un cadre */
.analogy {
  margin: 2.25rem 0;
  padding: 1rem 0 .25rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.analogy h4 { margin: 0 0 .5rem; }

/* Citation en exergue : une seule dans la note */
.pullquote {
  margin: 3rem 0;
  padding: 0 0 0 1.5rem;
  border-left: 3px solid var(--accent);
}
.pullquote p {
  margin: 0;
  font-size: 1.5em;
  line-height: 1.35;
  font-style: italic;
}
.pullquote footer {
  margin-top: .75rem;
  font-family: var(--sans);
  font-size: .8125rem;
  color: var(--gray);
}

/* Chiffre mis en avant : traitement typographique, pas un encadré */
.stat {
  margin: 2.25rem 0;
  display: grid;
  gap: .25rem;
}
.stat__figure {
  font-family: var(--sans);
  font-size: clamp(2.25rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}
.stat__text {
  font-family: var(--sans);
  font-size: .9375rem;
  line-height: 1.45;
  color: var(--gray);
  max-width: 34rem;
}

/* Note de lecture : filet gris à gauche, corps réduit */
.reading-note {
  margin: 2rem 0;
  padding: .25rem 0 .25rem 1.25rem;
  border-left: 3px solid var(--rule-strong);
  font-size: .875em;
  color: var(--ink);
}
.reading-note > :last-child { margin-bottom: 0; }

/* Question laissée ouverte */
.open-question {
  margin: 2.5rem 0;
  padding: 0 0 0 1.25rem;
  border-left: 3px solid var(--ink);
}
.open-question p:not(.label) {
  font-style: italic;
  font-size: 1.125em;
  line-height: 1.45;
  margin: 0;
}
.open-question .label { color: var(--accent); }

/* Figures : numérotation automatique, peuvent déborder à 760 px */
.figure {
  counter-increment: figure;
  margin: 3rem 0;
}
@media (min-width: 800px) {
  .figure { margin-left: calc((var(--measure) - var(--figure)) / 2); margin-right: calc((var(--measure) - var(--figure)) / 2); }
}
.figure__scroll { overflow-x: auto; }
.figure svg { display: block; width: 100%; min-width: 36rem; height: auto; }
.figure figcaption {
  margin-top: .75rem;
  font-family: var(--sans);
  font-size: .875rem;
  line-height: 1.5;
  color: var(--gray);
}
.figure figcaption::before {
  content: "Figure " counter(figure) ". ";
  font-weight: 650;
  color: var(--ink);
}
.figure .source { display: block; margin-top: .25rem; }
/* Petit écran : la figure garde une taille lisible et défile horizontalement,
   de bord à bord, avec une indication pour le lecteur. */
@media (max-width: 639px) {
  .figure__scroll { margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
  .figure figcaption::after {
    content: "Faites glisser la figure pour la voir en entier.";
    display: block;
    margin-top: .25rem;
    font-style: italic;
  }
}

/* Couleurs des figures SVG incorporées : héritent des variables du site */
.figure svg .ink    { fill: var(--ink); }
.figure svg .gray   { fill: var(--gray); }
.figure svg .accent { fill: var(--accent); }
.figure svg .s-ink  { stroke: var(--ink); fill: none; }
.figure svg .s-acc  { stroke: var(--accent); fill: none; }
.figure svg .s-rule { stroke: var(--rule-strong); fill: none; }
.figure svg .s-hair { stroke: var(--rule); fill: none; }
.figure svg .f-soft  { fill: var(--accent-soft); }
.figure svg .f-paper { fill: var(--bg); }
.figure svg text { font-family: var(--sans); }
.figure svg .kick { font-size: 11.5px; font-weight: 600; letter-spacing: .12em; }
.figure svg .h    { font-size: 16px; font-weight: 600; }
.figure svg .sh   { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; }
.figure svg .lb   { font-size: 12.5px; }
.figure svg .bx   { font-size: 14px; font-weight: 600; }
.figure svg .an   { font-size: 13.5px; }
.figure svg .b    { font-weight: 600; }

/* Tableaux */
.table-wrap { overflow-x: auto; margin: 2rem 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: .875rem;
  line-height: 1.45;
  font-variant-numeric: lining-nums;
  hyphens: manual;
}
caption {
  text-align: left;
  font-weight: 650;
  padding-bottom: .75rem;
  color: var(--ink);
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: .6rem .75rem .6rem 0;
  border-bottom: 1px solid var(--rule);
}
thead th { border-bottom: 1px solid var(--ink); font-weight: 650; }
tbody th { font-weight: 600; }

/* Marqueur de travail : visible en brouillon, bloqué au déploiement */
.wip {
  margin: 1.5rem 0;
  padding: .75rem 1rem;
  background: var(--wip-bg);
  border-left: 3px solid var(--wip);
  font-family: var(--sans);
  font-size: .875rem;
  line-height: 1.5;
  color: #4A2A00;
}
.wip::before {
  content: "En chantier";
  display: block;
  margin-bottom: .25rem;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--wip);
}
.wip > :last-child { margin-bottom: 0; }
.wip p { margin: 0 0 .5rem; }
span.wip { display: inline; margin: 0; padding: .05rem .35rem; border-left: 0; }
span.wip::before { display: none; }

/* Pied de note */
.note-end {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--ink);
  font-family: var(--sans);
  font-size: .9375rem;
  line-height: 1.55;
}
.note-end p { margin: 0 0 .75rem; }

/* Bloc « Pour citer » */
.cite {
  margin: 2.5rem 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: .875rem;
  line-height: 1.55;
}
.cite p { margin: 0 0 .5rem; }
.cite > :last-child { margin-bottom: 0; }

/* Résumé : les points clés */
.keypoints {
  margin: 0 0 3rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: .9375rem;
  line-height: 1.5;
}
.keypoints h2 { margin: 0 0 1rem; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gray); }
.keypoints ol { margin: 0; padding-left: 1.25rem; }
.keypoints li { margin: .5rem 0; }

.cta {
  margin: 3rem 0 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
}

/* FAQ : accordéons natifs */
.faq details {
  border-bottom: 1px solid var(--rule);
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 2rem 1rem 0;
  position: relative;
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: .25rem;
  top: .9rem;
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--gray);
}
.faq details[open] > summary::after { content: "−"; }
.faq details > :not(summary) { margin-top: 0; }
.faq .answer { padding: 0 0 1.25rem; }
.faq .answer > :last-child { margin-bottom: 0; }

/* Membres */
.members { list-style: none; padding: 0 !important; margin: 1.5rem 0; }
.members li {
  padding: .9rem 0;
  border-bottom: 1px solid var(--rule);
  margin: 0 !important;
  font-family: var(--sans);
  font-size: .9375rem;
}
.members .name { font-weight: 650; display: block; }
.members .role { color: var(--gray); }

/* Notes de bas de page (annexe de sources uniquement) */
.footnotes {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: .875rem;
  line-height: 1.55;
}
.footnotes ol { padding-left: 1.5rem; }
sup a { text-decoration: none; font-family: var(--sans); font-size: .75em; padding: 0 .1em; }

/* ==========================================================================
   Impression
   ========================================================================== */
@media print {
  @page { margin: 22mm 20mm 24mm; }

  :root { --bg: #fff; }
  body { font-size: 11pt; line-height: 1.5; background: #fff; }

  .site-header, .site-footer, .skip-link, .toc, .cover__links, .menu-toggle, .no-print { display: none !important; }

  .cover { min-height: 0; border: 0; page-break-after: always; break-after: page; }
  .cover__inner { padding: 30mm 0 0; }

  .note-layout, .page { display: block; max-width: none; padding: 0; }
  .note { padding: 0; }

  h1, h2, h3, h4 { break-after: avoid; page-break-after: avoid; }
  .note h2 { margin-top: 2.5rem; }
  p, li { orphans: 3; widows: 3; }
  .figure, .example, .pullquote, .stat, table, .cite { break-inside: avoid; page-break-inside: avoid; }
  .figure { margin-left: 0; margin-right: 0; }
  .figure svg { min-width: 0; }

  a { color: var(--ink); text-decoration: none; }
  /* URLs des liens externes en clair */
  .note a[href^="http"]::after, .page a[href^="http"]::after {
    content: " <" attr(href) ">";
    font-family: var(--sans);
    font-size: .8em;
    color: var(--gray);
    word-break: break-all;
  }
  .faq details > .answer { display: block; }
  .faq summary::after { content: none; }

  .wip { border: 1px dashed var(--wip); background: none; }
}
