/* =====================================================================
   Layout — conteneurs, navigation de progression, coquilles de section
   ===================================================================== */

.wrap {
  width: min(100% - 2 * var(--gutter), var(--maxw));
  margin-inline: auto;
}
.wrap--narrow { max-width: 900px; }

/* Sommaire ouvert : les chapitres lui cèdent la marge droite plutôt que de passer dessous ;
   ils restent centrés tant que la marge naturelle suffit. Réservée dès le premier rendu. */
:root { --sommaire-w: 256px; }
@media (width > 1100px) {
  :root:not(.nav-closed) { --nav-space: calc(var(--sommaire-w) + 16px); }
}
:is(.section, footer.site) > .wrap {
  --wrap-w: min(var(--maxw), 100% - 2 * var(--gutter), 100% - var(--gutter) - var(--nav-space, 0px));
  width: var(--wrap-w);
  margin-left: min((100% - var(--wrap-w)) / 2, max(var(--gutter), 100% - var(--wrap-w) - var(--nav-space, 0px)));
}

/* ---- Sommaire : panneau latéral en câble sondé, ouvert par défaut, touche M ---- */
.chapter-nav {
  --rail: 64px;          /* colonne du câble et des connecteurs */
  --head-h: 46px;
  --source-h: 54px;
  --pad-top: 8px;
  --row: clamp(50px, 7dvh, 80px);
  --sub-row: clamp(34px, 4.2dvh, 46px);
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 60;
  width: var(--sommaire-w);
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 16px 0 0 16px;
  background: color-mix(in srgb, var(--charcoal-2) 84%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .35);
  color: var(--ink);
  visibility: hidden;
  transform: translate(calc(100% + 24px), -50%);
  transition: transform .45s var(--ease-out), visibility 0s linear .45s;
}
.chapter-nav::-webkit-scrollbar { display: none; }
.chapter-nav.is-visible { visibility: visible; transform: translate(0, -50%); transition-delay: 0s; }
.chapter-nav ol { list-style: none; }
.chapter-nav__body { position: relative; padding: var(--pad-top) 0 20px 16px; }
.chapter-nav__head { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail); align-items: center; height: var(--head-h); }
.chapter-nav__title { display: flex; align-items: center; gap: .6rem; font: 600 .6875rem/1 var(--font-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--faint); }
.chapter-nav__title kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: inset 0 -2px 0 rgba(255, 255, 255, .08);
  font: 700 .6875rem/1 var(--font-mono); letter-spacing: 0; color: var(--ink-soft);
}
@media (pointer: coarse) { .chapter-nav__title kbd { display: none; } }
.chapter-nav__close {
  justify-self: center; display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--ink-soft); cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}
.chapter-nav__close:hover { color: #fff; border-color: var(--neon); background: var(--neon-soft); }
.chapter-nav__close:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.chapter-nav__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chapter-nav__cable {
  position: absolute;
  top: calc(var(--pad-top) + var(--head-h) + var(--source-h) / 2);
  bottom: 20px;
  right: calc(var(--rail) / 2 - 2px);
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #1a1d21, #454a51 45%, #1a1d21);
}
.chapter-nav__lit {
  position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 45%, transparent), var(--neon));
  box-shadow: 0 0 10px var(--neon-glow);
  transform: scaleY(0); transform-origin: 50% 0;
}
.chapter-nav__pulse, .chapter-nav__echo, .chapter-nav__ring { position: absolute; top: 0; left: 50%; border-radius: 50%; pointer-events: none; }
.chapter-nav__pulse {
  width: 12px; height: 12px; margin: -6px 0 0 -6px;
  background: radial-gradient(circle, #fff 0 30%, var(--neon-2) 60%, var(--neon));
  box-shadow: 0 0 0 3px rgba(255, 51, 35, .22), 0 0 18px 5px var(--neon-glow);
}
.chapter-nav__echo { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; background: #fff; box-shadow: 0 0 10px 3px var(--neon-glow); opacity: 0; }
.chapter-nav__ring { width: 48px; height: 48px; margin: -24px 0 0 -24px; border: 1.5px solid var(--neon); opacity: 0; }

.chapter-nav__source,
.chapter-nav__chapters > li > a,
.chapter-nav__subchapters a {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 30px auto minmax(20px, 1fr) var(--rail);
  grid-template-areas: "num lbl lead node";
  align-items: center;
  border-radius: 8px;
  color: inherit;
}
.chapter-nav__source::after,
.chapter-nav__chapters > li > a::after,
.chapter-nav__subchapters a::after {   /* dérivation, du titre jusqu'à l'axe du câble */
  content: ""; grid-area: 1 / 3 / 2 / 5;
  height: 1px; margin: 0 calc(var(--rail) / 2) 0 10px;
  background: var(--line);
  transition: background-color var(--dur), box-shadow var(--dur);
}
.chapter-nav a:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.chapter-nav__node {
  grid-area: node; justify-self: center;
  position: relative; z-index: 1;
  display: block; width: 48px; height: 48px; overflow: hidden;
  border-radius: 50%;
  background: var(--charcoal-2);
  box-shadow: 0 0 0 1.5px var(--line-strong), 0 2px 10px rgba(0, 0, 0, .55);
  transform: scale(.75);
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur);
}
.chapter-nav__node img { width: 100%; height: 100%; object-fit: cover; opacity: .5; filter: saturate(.55); transition: opacity var(--dur), filter var(--dur); }

.chapter-nav__source { min-height: var(--source-h); grid-template-areas: "lbl lbl lead node"; }
.chapter-nav__source > .lbl { grid-area: lbl; font: 600 .6875rem/1 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--faint); transition: color var(--dur); }
.chapter-nav__source .chapter-nav__node { display: grid; place-items: center; width: 40px; height: 32px; overflow: visible; border-radius: 8px; transform: none; }
.chapter-nav__source svg { width: 24px; height: 18px; fill: none; stroke: var(--ink-soft); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.chapter-nav__source polyline { stroke: var(--neon); }
.chapter-nav__source:hover > .lbl { color: #fff; }

.chapter-nav__chapters > li > a { min-height: var(--row); }
.chapter-nav__chapters > li > a > .num { grid-area: num; font: 700 .75rem/1 var(--font-mono); letter-spacing: .04em; font-variant-numeric: tabular-nums; color: var(--faint); transition: color var(--dur); }
.chapter-nav__chapters > li > a > .lbl { grid-area: lbl; font: 400 .75rem/1.3 var(--font-display); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); transition: color var(--dur); }
.chapter-nav__card {
  display: none; grid-area: 2 / 1 / 3 / 4;
  width: calc(100% - 12px); height: auto; margin: 2px 0 14px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 40%, transparent), 0 12px 28px rgba(0, 0, 0, .5);
}
.chapter-nav__chapters > li > a.is-reached > .num { color: var(--muted); }
.chapter-nav__chapters > li > a.is-reached > .lbl { color: var(--ink-soft); }
.chapter-nav__chapters > li > a.is-reached::after { background: color-mix(in srgb, var(--neon) 55%, transparent); }
.chapter-nav__chapters > li > a.is-reached .chapter-nav__node { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--neon) 70%, transparent), 0 2px 10px rgba(0, 0, 0, .55); }
.chapter-nav__chapters > li > a:is(.is-reached, :hover) .chapter-nav__node img { opacity: .9; filter: none; }
.chapter-nav__chapters > li > a:is(.is-active, :hover) > .lbl { color: #fff; }
.chapter-nav__chapters > li > a.is-active > .num { color: var(--neon); }
.chapter-nav__chapters > li > a.is-active::after { background: var(--neon); box-shadow: 0 0 6px var(--neon-glow); }
.chapter-nav__chapters > li > a.is-active .chapter-nav__node { transform: none; box-shadow: 0 0 0 2px var(--neon), 0 0 18px 3px var(--neon-glow); }
.chapter-nav__chapters > li > a.is-active .chapter-nav__node img { opacity: 1; }
.chapter-nav__chapters > li > a.is-active .chapter-nav__card { display: block; }

.chapter-nav__subchapters { margin-bottom: 10px; }
.chapter-nav__subchapters a { min-height: var(--sub-row); padding: 4px 0; }
.chapter-nav__subchapters a > .num { grid-area: num; font: 600 .75rem/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--faint); transition: color var(--dur); }
.chapter-nav__subchapters a > .lbl { grid-area: lbl; font-size: .8125rem; line-height: 1.35; color: var(--muted); transition: color var(--dur); }
.chapter-nav__subchapters a:not(:has(.num)) > .lbl { grid-column: 1 / 3; }
.chapter-nav__subchapters a::before {   /* jonction en T sur le câble */
  content: ""; grid-area: node; justify-self: center; position: relative; z-index: 1;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--charcoal-3); box-shadow: 0 0 0 1.5px var(--line-strong);
  transition: background-color var(--dur), box-shadow var(--dur);
}
.chapter-nav__subchapters a:hover > .lbl { color: #fff; }
.chapter-nav__subchapters a.is-passed > .lbl { color: var(--ink-soft); }
.chapter-nav__subchapters a.is-passed::after { background: color-mix(in srgb, var(--neon) 55%, transparent); }
.chapter-nav__subchapters a.is-passed::before { background: var(--neon); box-shadow: 0 0 0 1.5px var(--neon); }
.chapter-nav__subchapters a.is-active > :is(.num, .lbl) { color: var(--neon); }
.chapter-nav__subchapters a.is-active::after { background: var(--neon); box-shadow: 0 0 6px var(--neon-glow); }
.chapter-nav__subchapters a.is-active::before { box-shadow: 0 0 0 1.5px var(--neon), 0 0 10px 2px var(--neon-glow); }
.chapter-nav-toggle {
  position: fixed; top: 50%; right: 0; z-index: 61;
  display: grid; justify-items: center; gap: 8px;
  width: 48px; padding: 14px 0 12px;
  border: 1px solid var(--line-strong); border-right: 0; border-radius: 14px 0 0 14px;
  background: color-mix(in srgb, var(--charcoal-2) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--ink-soft); cursor: pointer;
  transform: translateY(-50%);
  transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}
.chapter-nav-toggle[hidden] { display: none; }
.chapter-nav-toggle svg { width: 24px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.chapter-nav-toggle svg polyline { stroke: var(--neon); }
.chapter-nav-toggle__num { font: 700 .75rem/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--neon); }
.chapter-nav-toggle__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chapter-nav-toggle:hover { color: #fff; border-color: var(--neon); background-color: color-mix(in srgb, var(--neon) 16%, var(--charcoal-2)); }
.chapter-nav-toggle:focus-visible { outline: 2px solid var(--neon); outline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) {
  .chapter-nav__subchapters:not([hidden]), .chapter-nav a.is-active .chapter-nav__card { animation: chapter-sub-enter .35s var(--ease-out); }
  @keyframes chapter-sub-enter { from { opacity: 0; } }
}
@media (max-width: 1100px) {
  .chapter-nav {
    top: auto; bottom: 4.75rem; right: 1rem;
    width: min(320px, calc(100vw - 2rem)); max-height: calc(100dvh - 6rem);
    border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
    background: var(--charcoal-2); opacity: 0; transform: translateY(6px);
    transition: opacity .3s var(--ease-out), transform .3s var(--ease-out), visibility 0s linear .3s;
  }
  .chapter-nav.is-visible { opacity: 1; transform: none; }
  .chapter-nav-toggle {
    top: auto; bottom: 1rem; right: 1rem;
    display: flex; align-items: center; gap: .55rem;
    width: auto; min-height: 44px; padding: .6rem 1rem;
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--charcoal-2); color: var(--ink); transform: none;
    font: 600 .875rem/1.4 var(--font-body);
  }
  .chapter-nav-toggle[aria-expanded="true"] { border-color: var(--neon); }
  .chapter-nav-toggle__num { display: none; }
  .chapter-nav-toggle__label { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .chapter-nav__chapters > li > a, .chapter-nav__subchapters a { min-height: 44px; }
  .chapter-nav__subchapters a > .lbl { font-size: .875rem; }
}

/* ---- Barre de progression supérieure ---- */
.scroll-progress {
  position: fixed; top: 0; left: 0;
  height: 3px; width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--petrol), var(--signal));
  z-index: 70;
}

/* ---- En-tête minimal (marque) ---- */
.brandbar {
  position: fixed; top: 0; left: 0;
  width: 100%; z-index: 55;
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(0.8rem, 1.5vw, 1.4rem) var(--gutter);
  pointer-events: none;
}
.brandbar .mark {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--on-dark-soft);
  transition: color var(--dur);
}
.brandbar.on-light .mark { color: var(--muted); }
.brandbar .mark b { color: inherit; font-weight: 700; }

/* ---- Coquille de section ---- */
.section {
  position: relative;
  padding-block: var(--space-section);
}
.section--dark {
  background: var(--bg-navy);
  color: var(--on-dark);
}
.section--dark h1, .section--dark h2, .section--dark h3 { color: #fff; }
.section--dark .lead { color: var(--on-dark-soft); }

/* En-tête de chapitre */
.chapter-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
  margin-bottom: clamp(2.5rem, 5vw, 4.5rem);
}
.chapter-head .index {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--petrol);
  letter-spacing: 0;
}
.chapter-head h2 { font-size: var(--t-h1); }
.chapter-head .lead { max-width: 60ch; }
#parcours .chapter-head .lead { max-width: none; }

/* Filigrane 3D en fond d'intro de chapitre */
.section > .wrap { position: relative; z-index: 1; }
.chapter-fg {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 0;
  width: min(72%, 960px);
  height: clamp(460px, 66vh, 820px);
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: top right;
  background-size: cover;
  opacity: 0.75;
  mix-blend-mode: screen;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 46%), linear-gradient(to bottom, #000 62%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent 0, #000 46%), linear-gradient(to bottom, #000 62%, transparent 100%);
  mask-composite: intersect;
}
#surveillance .chapter-fg { background-image: url('../assets/filigrane/02-surveillance.jpg'); }
#parcours .chapter-fg { background-image: url('../assets/filigrane/01-parcours.jpg'); }
#pronostic .chapter-fg { background-image: url('../assets/filigrane/03-pronostic.jpg'); }
#incendie .chapter-fg { background-image: url('../assets/filigrane/04-incendie.jpg'); }
#perspectives .chapter-fg { background-image: url('../assets/filigrane/05-perspectives.jpg'); }
@media (max-width: 720px) {
  .chapter-fg { width: 100%; height: 360px; opacity: 0.5; }
}

/* Grille éditoriale à deux colonnes */
.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.75rem, 4vw, 4rem);
  align-items: start;
}
@media (min-width: 900px) {
  .split { grid-template-columns: 1.05fr 0.95fr; }
  .split--sticky > .split__aside { position: sticky; top: 14vh; }
}

/* Figure encadrée */
figure.plate {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
figure.plate img { width: 100%; }
figure.plate figcaption {
  font-size: var(--t-small);
  color: var(--muted);
  padding: 0.75rem 1rem 0.95rem;
  border-top: 1px solid var(--line);
  line-height: 1.45;
}
figure.plate figcaption b { color: var(--ink-soft); }

footer.site {
  background: var(--bg-abyss);
  color: var(--on-dark-soft);
  padding-block: clamp(3rem, 6vw, 5rem);
}
