/* ============================================================
   CHAPITRES — structure, intro, animation de chute des titres,
   topics (sous-thèmes au sein d'un chapitre), variantes de blocks.
============================================================ */

.chapter {
  position: relative;
  border-top: 1px solid var(--line);
}

/* En-tête sticky qui reste visible pendant le scroll du chapitre */
.chapter__sticky {
  position: sticky;
  top: 58px; /* sous la nav principale */
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  pointer-events: none;
}
.chapter__sticky-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chapter__sticky-tag {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--bleu);
  position: relative;
  padding-left: 18px;
}
.chapter__sticky-tag::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rouge);
}

/* Intro de chapitre (grand titre + lede) */
.chapter__intro {
  position: relative;
  padding: 20vh 0 12vh;
  overflow: hidden;
  isolation: isolate;
}
.chapter__intro .container {
  position: relative;
  z-index: 2;
}
.chapter__title {
  position: relative;
  font-size: clamp(56px, 9vw, 128px);
  line-height: 0.98;
  letter-spacing: -0.04em;
  font-weight: 800;
  margin: 0 0 44px;
  color: var(--bleu);
}
.chapter__electricity {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ====== Animation de chute des grands titres ======
   Chaque mot est wrappé en .word > .word__inner par js/chapter-titles.js.
   .word agit comme un masque (overflow:hidden).
   .word__inner tombe d'en haut avec décélération forte.
================================================= */
.chapter__title .word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  /* léger padding bas pour ne pas couper les jambages (g, ç, p...) */
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
}
.chapter__title .word__inner {
  display: inline-block;
  transform: translateY(-130%);
  opacity: 0;
  will-change: transform, opacity;
}
.chapter__title.is-in .word__inner {
  animation:
    chapter-drop 1.05s cubic-bezier(0.16, 1, 0.3, 1) forwards,
    chapter-fade 0.5s ease-out forwards;
}

@keyframes chapter-drop {
  0%   { transform: translateY(-115%); }
  100% { transform: translateY(0); }
}

@keyframes chapter-fade {
  0%   { opacity: 0; }
  35%  { opacity: 1; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .chapter__title .word__inner {
    transform: none;
    opacity: 1;
    animation: none !important;
  }

  .chapter__electricity {
    display: none;
  }
}
.chapter__lede {
  font-size: clamp(19px, 1.9vw, 24px);
  max-width: 720px;
  color: var(--ink-2);
  line-height: 1.45;
  margin: 0;
}
.chapter__lede strong { color: var(--ink); font-weight: 600; }

/* ============ TOPICS (sous-thèmes au sein d'un chapitre) ============ */
.topic__icon {
  flex: none;
  display: inline-flex;
  align-self: center;
  width: 28px;
  height: 28px;
  color: var(--rouge);
}
.topic__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.topic__check {
  --check-color: var(--bleu);
  --check-mark-color: #fff;
  position: relative;
  flex: none;
  align-self: center;
  display: inline-flex;
  width: 30px;
  height: 30px;
  color: var(--check-color);
}
.topic__check::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid currentColor;
  border-radius: 11px;
  opacity: 0;
  transform: scale(0.74);
  pointer-events: none;
}
.topic__check svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.topic__check-box {
  fill: transparent;
  stroke: currentColor;
  stroke-width: 2.4;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.92);
}
.topic__check-mark {
  fill: none;
  stroke: var(--check-mark-color);
  stroke-width: 3.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
}
.topic.is-checked .topic__check::after {
  animation: topic-check-pulse 0.72s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.topic.is-checked .topic__check-box {
  fill: currentColor;
  animation: topic-check-box 0.58s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.topic.is-checked .topic__check-mark {
  animation: topic-check-mark 0.62s cubic-bezier(0.16, 1, 0.3, 1) 0.16s both;
}
@keyframes topic-check-pulse {
  0% { opacity: 0; transform: scale(0.72); }
  22% { opacity: 0.42; }
  100% { opacity: 0; transform: scale(1.34); }
}
@keyframes topic-check-box {
  0% { fill: transparent; transform: scale(0.9); }
  54% { fill: currentColor; transform: scale(1.16); }
  100% { fill: currentColor; transform: scale(1); }
}
@keyframes topic-check-mark {
  0% { stroke-dashoffset: 18; }
  100% { stroke-dashoffset: 0; }
}

.topic {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin: 0 0 36px;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--line);
}
.topic__num {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--rouge);
  letter-spacing: 0;
}
.topic__label {
  position: relative;
  display: inline-block;
  max-width: 100%;
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.2;
}
.has-quoi-topic-rush #quoi .topic:not(.topic--heat):not(.topic--power) .topic__label,
.has-quoi-topic-rush #quoi .topic:not(.topic--heat):not(.topic--power) .topic__icon {
  opacity: 0;
  transform: translate3d(-112vw, 0, 0) skewX(-15deg) scaleX(1.22);
  transform-origin: left center;
  will-change: transform, opacity;
}
.has-quoi-topic-rush #quoi .topic:not(.topic--heat):not(.topic--power).is-rushed .topic__label {
  animation: quoi-topic-rush 0.9s cubic-bezier(0.13, 0.86, 0.18, 1) both;
}
.has-quoi-topic-rush #quoi .topic:not(.topic--heat):not(.topic--power).is-rushed .topic__icon {
  animation: quoi-topic-rush 0.9s cubic-bezier(0.13, 0.86, 0.18, 1) 0.1s both;
}
.topic--heat {
  --heat-glow: rgba(225, 0, 15, 0.13);
  gap: 16px;
}
.topic--heat .topic__icon {
  position: relative;
  width: 40px;
  height: 32px;
  overflow: visible;
}
.topic--heat .topic__icon svg {
  position: relative;
  z-index: 1;
  overflow: visible;
  transform: translateY(-2px);
}
.topic--heat .topic__icon::before,
.topic--heat .topic__icon::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 18px;
  width: 112px;
  height: 44px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 12% 54%, rgba(225, 0, 15, 0.22), transparent 42%),
    radial-gradient(ellipse at 34% 36%, rgba(255, 232, 0, 0.24), transparent 46%),
    radial-gradient(ellipse at 58% 60%, rgba(225, 0, 15, 0.14), transparent 48%),
    radial-gradient(ellipse at 82% 46%, rgba(255, 232, 0, 0.12), transparent 48%);
  filter: blur(9px);
  opacity: 0;
  transform: translateX(-20px) scale(0.38, 0.58);
  transform-origin: left center;
  pointer-events: none;
}
.topic--heat .topic__icon::after {
  top: 3px;
  left: 28px;
  width: 92px;
  height: 30px;
  background:
    radial-gradient(ellipse at 22% 50%, var(--heat-glow), transparent 50%),
    radial-gradient(ellipse at 62% 50%, rgba(255, 232, 0, 0.13), transparent 54%);
  filter: blur(12px);
}
.topic--heat .topic__label {
  z-index: 2;
}
.has-quoi-topic-rush #quoi .topic--heat .topic__label {
  opacity: 0;
  transform: translate3d(10px, 0, 0);
  will-change: transform, opacity;
}
.has-quoi-topic-rush #quoi .topic--heat .topic__icon {
  opacity: 0;
  transform: translate3d(-8px, 0, 0) scale(0.94);
  transform-origin: left center;
  will-change: transform, opacity;
}
.has-quoi-topic-rush #quoi .topic--heat.is-rushed .topic__label {
  animation: heat-topic-rise 0.78s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}
.has-quoi-topic-rush #quoi .topic--heat.is-rushed .topic__icon {
  animation: heat-topic-rise-icon 0.86s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.has-quoi-topic-rush #quoi .topic--heat.is-rushed .topic__icon::before {
  animation: heat-topic-glow 1.15s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both;
}
.has-quoi-topic-rush #quoi .topic--heat.is-rushed .topic__icon::after {
  animation: heat-topic-glow 1.24s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}
.heat-pump-icon__unit,
.heat-pump-icon__fan-ring,
.heat-pump-icon__grille {
  stroke-width: 2.2;
}
.heat-pump-icon__fan-blade,
.heat-pump-icon__foot {
  stroke-width: 1.75;
}
@keyframes quoi-topic-rush {
  0% {
    opacity: 0;
    transform: translate3d(-112vw, 0, 0) skewX(-15deg) scaleX(1.22);
  }
  52% {
    opacity: 1;
    transform: translate3d(-16px, 0, 0) skewX(-6deg) scaleX(1.07);
  }
  66% {
    opacity: 1;
    transform: translate3d(4px, 0, 0) skewX(2deg) scaleX(0.98);
  }
  82% {
    opacity: 1;
    transform: translate3d(0, 0, 0) skewX(0deg) scaleX(1);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) skewX(0deg) scaleX(1);
  }
}
@keyframes heat-topic-rise {
  0% { opacity: 0; transform: translate3d(10px, 0, 0); }
  58% { opacity: 1; transform: translate3d(-1px, 0, 0); }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes heat-topic-rise-icon {
  0% { opacity: 0; transform: translate3d(-8px, 0, 0) scale(0.94); }
  58% { opacity: 1; transform: translate3d(1px, 0, 0) scale(1.03); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes heat-topic-glow {
  0% { opacity: 0; transform: translateX(-20px) scale(0.38, 0.58); }
  34% { opacity: 0.78; }
  100% { opacity: 0; transform: translateX(36px) scale(1.18, 1); }
}
.topic--power {
  position: relative;
  gap: 16px;
  overflow: visible;
  isolation: isolate;
}
.topic--power::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 58px;
  top: 3px;
  width: min(420px, calc(100% - 58px));
  height: 34px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 44% 50%, rgba(255, 255, 255, 0.98), transparent 12%),
    linear-gradient(90deg, transparent 0%, rgba(18, 18, 255, 0.04) 18%, rgba(18, 18, 255, 0.8) 46%, rgba(0, 0, 145, 0.18) 60%, transparent 76%);
  filter: blur(5px);
  opacity: 0;
  transform: translateX(-36px) scaleX(0.1);
  transform-origin: left center;
  pointer-events: none;
}
.topic--power .topic__icon {
  position: relative;
  z-index: 2;
  width: 50px;
  height: 32px;
  color: var(--rouge);
  overflow: visible;
}
.topic--power .topic__icon::before {
  content: "";
  position: absolute;
  inset: -10px -12px -8px -8px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 72% 50%, rgba(18, 18, 255, 0.26), transparent 48%),
    radial-gradient(ellipse at 42% 56%, rgba(225, 0, 15, 0.15), transparent 52%);
  filter: blur(10px);
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}
.topic--power .topic__icon svg {
  position: relative;
  z-index: 1;
  overflow: visible;
}
.power-icon__cable {
  stroke: var(--bleu);
  stroke-width: 2.45;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.power-icon__plug,
.power-icon__pin,
.power-icon__connector {
  stroke: var(--bleu);
}
.power-icon__connector {
  stroke-width: 2.45;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.power-icon__pin {
  fill: var(--bleu);
}
.power-icon__factory,
.power-icon__window {
  stroke: currentColor;
}
.power-icon__spark {
  stroke: var(--jaune);
  opacity: 0;
}
.has-quoi-topic-rush #quoi .topic--power .topic__label {
  z-index: 2;
  color: var(--ink);
}
.power-letter {
  display: inline-block;
  color: inherit;
  will-change: color, text-shadow, filter;
}
.power-letter--space {
  width: 0.28em;
}
.has-quoi-topic-rush #quoi .topic--power.is-rushed::before {
  animation: power-shockwave 1.05s cubic-bezier(0.08, 0.9, 0.12, 1) 0.58s both;
}
.has-quoi-topic-rush #quoi .topic--power.is-rushed .power-letter:not(.power-letter--space) {
  animation: power-letter-neon 0.46s cubic-bezier(0.12, 0.92, 0.12, 1) both;
  animation-delay: calc(0.62s + var(--i) * 0.035s);
}
.has-quoi-topic-rush #quoi .topic--power.is-rushed .topic__icon::before {
  animation: power-glow-pulse 0.72s cubic-bezier(0.16, 1, 0.3, 1) 0.56s both;
}
.has-quoi-topic-rush #quoi .topic--power.is-rushed .power-icon__cable {
  animation: power-cable-draw 0.74s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.has-quoi-topic-rush #quoi .topic--power.is-rushed .power-icon__connector {
  animation: power-connector-draw 0.24s cubic-bezier(0.16, 1, 0.3, 1) 0.52s both;
}
.has-quoi-topic-rush #quoi .topic--power.is-rushed .power-icon__spark {
  animation: power-spark 0.42s steps(1, end) 0.66s both;
}
@keyframes power-cable-draw {
  0% { stroke-dashoffset: 1; filter: none; }
  62% { filter: drop-shadow(0 0 4px rgba(18, 18, 255, 0.48)); }
  100% { stroke-dashoffset: 0; filter: drop-shadow(0 0 2px rgba(18, 18, 255, 0.24)); }
}
@keyframes power-connector-draw {
  0% { stroke-dashoffset: 1; filter: none; }
  100% { stroke-dashoffset: 0; filter: drop-shadow(0 0 4px rgba(18, 18, 255, 0.42)); }
}
@keyframes power-glow-pulse {
  0% { opacity: 0; transform: scale(0.78); }
  36% { opacity: 0.82; transform: scale(1.06); }
  100% { opacity: 0; transform: scale(1.24); }
}
@keyframes power-spark {
  0%, 34%, 58%, 100% { opacity: 0; }
  18%, 44% { opacity: 1; }
}
@keyframes power-shockwave {
  0% { opacity: 0; transform: translateX(-36px) scaleX(0.1); }
  14% { opacity: 0.72; }
  100% { opacity: 0; transform: translateX(100%) scaleX(0.16); }
}
@keyframes power-letter-neon {
  0%, 100% {
    color: var(--ink);
    filter: none;
    text-shadow: none;
  }
  24% {
    color: #1212ff;
    filter: brightness(1.45);
    text-shadow:
      0 0 6px rgba(18, 18, 255, 0.6),
      0 0 16px rgba(18, 18, 255, 0.34);
  }
  52% {
    color: #000091;
    filter: brightness(1.18);
    text-shadow: 0 0 10px rgba(18, 18, 255, 0.28);
  }
}
.has-topic-checks #pourquoi .topic__label {
  opacity: 0.46;
  clip-path: inset(0 100% 0 0);
  transform: translateY(3px);
}
.has-topic-checks #pourquoi .topic.is-checked .topic__label {
  animation:
    topic-label-write 0.82s steps(28, end) 0.12s both,
    topic-label-rise 0.52s cubic-bezier(0.16, 1, 0.3, 1) 0.12s both;
}
@keyframes topic-label-write {
  0% { clip-path: inset(0 100% 0 0); opacity: 0.46; }
  100% { clip-path: inset(0 0 0 0); opacity: 1; }
}
@keyframes topic-label-rise {
  0% { transform: translateY(3px); }
  100% { transform: translateY(0); }
}
.topic--invert .topic__check {
  --check-color: #2e3aff;
  --check-mark-color: #fff;
}
.topic--invert .topic__num { color: var(--jaune); }
.topic--invert .topic__label { color: #fff; }
.block--dark .topic { border-bottom-color: rgba(255, 255, 255, 0.12); }

.topic__title {
  font-size: clamp(34px, 4.4vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0 0 36px;
  color: var(--bleu);
}
.topic__title--invert { color: #fff; }

.topic__text {
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 26px;
}
.topic__text--invert { color: #c9c9d4; }
.topic__text strong { color: var(--ink); font-weight: 600; }
.block--dark .topic__text strong { color: #fff; }

/* ============ BLOCKS ============ */
.block {
  padding: 11vh 0;
}
[data-scroll-flag] {
  scroll-margin-top: 70px;
}
.block--soft { background: var(--bg-soft); }
.block--accent { background: var(--bg-accent); }
.block--dark {
  background: var(--bg-dark);
  color: #f4f4f8;
}

@media (max-width: 1080px) {
  [data-scroll-flag] {
    scroll-margin-top: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .topic.is-checked .topic__check::after,
  .topic.is-checked .topic__check-box,
  .topic.is-checked .topic__check-mark,
  .has-topic-checks #pourquoi .topic.is-checked .topic__label {
    animation: none;
  }

  .topic.is-checked .topic__check-box {
    fill: currentColor;
    transform: none;
  }

  .topic.is-checked .topic__check-mark {
    stroke-dashoffset: 0;
  }

  .has-topic-checks #pourquoi .topic__label {
    opacity: 1;
    clip-path: none;
    transform: none;
  }

  .has-quoi-topic-rush #quoi .topic__label,
  .has-quoi-topic-rush #quoi .topic__icon,
  .has-quoi-topic-rush #quoi .topic.is-rushed .topic__label,
  .has-quoi-topic-rush #quoi .topic.is-rushed .topic__icon {
    opacity: 1;
    transform: none;
    clip-path: none;
    text-shadow: none;
    animation: none;
  }

  .has-quoi-topic-rush #quoi .topic--heat .topic__icon::before,
  .has-quoi-topic-rush #quoi .topic--heat .topic__icon::after,
  .has-quoi-topic-rush #quoi .topic--heat.is-rushed .topic__icon::before,
  .has-quoi-topic-rush #quoi .topic--heat.is-rushed .topic__icon::after {
    opacity: 0;
    transform: none;
    animation: none;
  }

  .has-quoi-topic-rush #quoi .topic--power .topic__icon::before,
  .has-quoi-topic-rush #quoi .topic--power.is-rushed .topic__icon::before,
  .has-quoi-topic-rush #quoi .topic--power::before,
  .has-quoi-topic-rush #quoi .topic--power.is-rushed::before {
    opacity: 0;
    transform: none;
    animation: none;
  }

  .has-quoi-topic-rush #quoi .topic--power.is-rushed .power-letter {
    color: inherit;
    filter: none;
    text-shadow: none;
    animation: none;
  }

  .power-icon__cable,
  .power-icon__connector {
    stroke-dashoffset: 0;
    filter: none;
  }

  .power-icon__spark {
    opacity: 0;
  }
}

.block__kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rouge);
  margin: 0 0 24px;
}
.block__kicker--invert { color: var(--jaune); }

.block__title {
  font-size: clamp(34px, 4.4vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0 0 36px;
  color: var(--bleu);
}
.block__title--invert { color: #fff; }

.block__text {
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 26px;
}
.block__text--invert { color: #c9c9d4; }
.block__text strong { color: var(--ink); font-weight: 600; }
.block--dark .block__text strong { color: #fff; }

.block__copy {
  max-width: var(--narrow);
}

.caption {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 26px;
  font-style: italic;
}
.block--dark .caption { color: #8a8aa3; }
