/* ==========================================================================
   Histoire Pacifique — variante ClimaNova (scrollytelling cinématique)
   ========================================================================== */

:root {
  --ink: #f2f6fa;
  --ink-muted: #adbfd4;
  --bg-deep: #0a1018;
  --bg-mid: #0f1824;
  --bg-soft: #121c2a;
  --surface: rgba(8, 14, 24, 0.72);
  --surface-solid: #141e2c;
  --line: rgba(148, 176, 196, 0.16);
  --line-soft: rgba(148, 176, 196, 0.08);
  --sst: #f0a06a;
  --sea: #5ec8d8;
  --people: #e8c86a;
  --giec: #8ec4dc;
  --accent: #5ec8d8;
  --chart-muted: #b8c8d8;
  --chart-muted-future: #8a9cb0;
  --focus-ring: #7ee8f8;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  --dive-depth: 0;
}

body.clima-page {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #020810;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* Image abyssale — pan vertical synchronisé au scroll */
#dive-bg-image {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #020810;
}

#dive-bg-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  min-height: 100vh;
  display: block;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.hero-glass-media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  will-change: transform;
}

.hero-glass-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

body.clima-page::before {
  content: none;
}

body.clima-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: calc(0.12 - var(--dive-depth, 0) * 0.08);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* Plongée — voile léger pour lisibilité du texte (l'image porte la descente) */
#dive-surface-light {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 90% 40% at 50% 0%, rgba(255, 255, 255, 0.06) 0%, transparent 55%);
  opacity: calc(0.55 - var(--dive-depth, 0) * 0.55);
}

#dive-veil {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(2, 8, 16, calc(0.08 + var(--dive-depth, 0) * 0.12)) 0%,
    rgba(0, 4, 10, calc(0.15 + var(--dive-depth, 0) * 0.25)) 100%
  );
}

#dive-veil::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 6, 14, calc(var(--dive-depth, 0) * 0.28));
}

#dive-vignette {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  box-shadow: inset 0 0 calc(60px + var(--dive-depth, 0) * 80px) rgba(0, 2, 8, calc(0.25 + var(--dive-depth, 0) * 0.35));
}

#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, rgba(240, 160, 106, 0.75), rgba(94, 200, 216, 0.9));
  z-index: 60;
  transition: width 0.1s linear;
}

#fable-root {
  position: relative;
  z-index: 2;
}

#bubble-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

#bubble-layer canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Hero ---------- */

.cn-hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: transparent;
}

.cn-hero__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(100% + 20rem);
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(2, 6, 12, 0.62) 0%,
    rgba(2, 8, 16, 0.7) 38%,
    rgba(2, 8, 16, 0.58) 58%,
    rgba(0, 4, 10, 0.38) 78%,
    rgba(0, 4, 10, 0.16) 92%,
    rgba(0, 4, 10, 0) 100%
  );
  pointer-events: none;
}

.cn-hero__overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 92% 58% at 50% 36%,
    rgba(0, 0, 0, 0.42) 0%,
    rgba(0, 0, 0, 0.22) 42%,
    rgba(0, 0, 0, 0.08) 62%,
    transparent 78%
  );
}

.cn-hero__inner {
  position: relative;
  z-index: 2;
  max-width: 920px;
  padding: 4rem 1.5rem 5rem;
  text-align: center;
}

.cn-hero__kicker {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
  font-weight: 600;
}

.cn-hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 700;
  line-height: 1.08;
  margin: 0 0 1.25rem;
  letter-spacing: -0.02em;
}

.cn-hero h1 em {
  font-style: normal;
  color: var(--sea);
}

.cn-hero__sub {
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  color: var(--ink-muted);
  max-width: 640px;
  margin: 0 auto 2.5rem;
}

.cn-hero__figures {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  max-width: 720px;
  margin: 0 auto 2.5rem;
}

.cn-hero__figure {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.85rem 0.5rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.cn-hero__figure strong {
  display: block;
  font-size: 1.35rem;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.cn-hero__figure span {
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.35;
}

.cn-hero__cue {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  animation: cn-bounce 2.4s ease-in-out infinite;
}

@keyframes cn-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(6px); opacity: 1; }
}

/* ---------- Chapter head ---------- */

.chapter-head {
  position: relative;
  z-index: 2;
  max-width: 720px;
  padding: 4rem 1.5rem 2rem;
  margin: 0 auto;
}

.cn-hero + .chapter-head .chapter-num,
.cn-hero + .chapter-head h2,
.cn-hero + .chapter-head p {
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.65);
}

.chapter-num {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.chapter-head h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  margin: 0 0 0.75rem;
  line-height: 1.15;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}

.chapter-head .chapter-lead {
  color: var(--ink-muted);
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
}

.chapter-head .chapter-note {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  opacity: 0.82;
}

.chapter-head p:not(.chapter-num):not(.chapter-lead):not(.chapter-note) {
  color: var(--ink-muted);
  margin: 0;
  font-size: 1rem;
}

.chapter-bridge {
  position: relative;
  z-index: 2;
  max-width: 560px;
  margin: 0 auto;
  padding: 2rem 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.98rem;
  font-style: italic;
  line-height: 1.55;
  color: var(--accent-soft, var(--ink-muted));
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

.giec-attribution {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

/* ---------- Clima block (60/40 sticky) ---------- */

.cn-block {
  display: grid;
  grid-template-columns: 60fr 40fr;
  gap: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.cn-block--reverse {
  grid-template-columns: 40fr 60fr;
}

.cn-block--reverse .cn-block__steps {
  order: 2;
}

.cn-block--reverse .cn-block__panel {
  order: 1;
}

.cn-block__steps {
  padding-right: 2rem;
}

.cn-block--reverse .cn-block__steps {
  padding-right: 0;
  padding-left: 2rem;
}

.cn-block__panel {
  position: relative;
}

.cn-block__panel-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding: 2rem 0;
  gap: 1.25rem;
}

.cn-ocean-loop {
  position: relative;
  width: 100%;
  height: min(42vh, 360px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 20px 50px rgba(0, 0, 0, 0.22);
  will-change: transform;
}

.cn-ocean-loop canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.cn-ocean-loop.cn-sea-rise {
  height: min(52vh, 480px);
  background: transparent;
  overflow: hidden;
}

.cn-ocean-loop.cn-sea-rise canvas,
.cn-ocean-loop.cn-sea-heat canvas,
.cn-ocean-loop.cn-population-rise canvas {
  background: transparent;
}

.cn-ocean-loop.cn-sea-heat {
  height: min(52vh, 480px);
  background: transparent;
  overflow: hidden;
}

.cn-ocean-loop.cn-population-rise {
  height: min(52vh, 480px);
  background: transparent;
  overflow: hidden;
}

.cn-metric {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.cn-metric__label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.cn-metric__year {
  font-size: 0.85rem;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

.cn-metric__value {
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  margin: 0;
  font-variant-numeric: tabular-nums;
  padding-left: 0.65rem;
  border-left: 4px solid transparent;
}

.cn-metric__value--sst {
  color: var(--sst);
  border-left-color: var(--sst);
}

.cn-metric__value--sea {
  color: var(--sea);
  border-left-color: var(--sea);
}

.cn-metric__value--dens {
  color: var(--people);
  border-left-color: var(--people);
}

.cn-metric__unit {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin: 0.35rem 0 0;
}

.cn-metric__source {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin: 0.75rem 0 0;
  line-height: 1.45;
}

/* Steps */

.cn-block .step {
  min-height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 0;
  opacity: 0.58;
  transition: opacity 0.5s ease;
}

.cn-block .step.active {
  opacity: 1;
}

.cn-block .step h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  margin: 0 0 0.85rem;
  line-height: 1.2;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

.cn-block .step p {
  color: var(--ink-muted);
  margin: 0;
  font-size: 1.02rem;
  max-width: 36rem;
}

.cn-block .step-figure {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  background: rgba(94, 200, 216, 0.1);
}

/* ---------- GIEC ---------- */

.giec-section {
  background: rgba(4, 10, 18, calc(0.45 + var(--dive-depth, 0) * 0.25));
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 4rem 1.5rem;
  backdrop-filter: blur(10px);
}

.giec-section .panel-section {
  max-width: 820px;
  margin: 0 auto;
}

.giec-badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--giec);
  border: 1px solid rgba(142, 196, 220, 0.22);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  margin-bottom: 1rem;
  background: rgba(142, 196, 220, 0.04);
}

.giec-section h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 1.5rem;
}

.giec-quote {
  border-left: 3px solid var(--giec);
  margin: 0 0 1.25rem;
  padding: 0.5rem 0 0.5rem 1.25rem;
  color: var(--ink-muted);
  font-size: 1.02rem;
}

.giec-section h4 {
  margin: 2rem 0 1rem;
  font-size: 1.1rem;
}

.giec-contrib {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.contrib-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 1rem;
}

.contrib-card strong {
  display: block;
  font-size: 1.4rem;
  color: var(--giec);
  margin-bottom: 0.35rem;
}

.contrib-card span {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.panel-note {
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin: 1.25rem 0 0;
}

.giec-links a {
  color: var(--giec);
  margin-right: 1rem;
}

/* ---------- Finale ---------- */

.finale {
  max-width: 960px;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
}

.finale-intro {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 2.5rem;
}

.finale-outro {
  max-width: 640px;
  margin: 3rem auto 0;
  text-align: left;
}

.finale-outro h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 0.85rem;
  line-height: 1.15;
  text-align: center;
}

.finale-outro-lead,
.finale-outro-body {
  color: var(--ink-muted);
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  line-height: 1.65;
}

.finale-outro-close {
  color: var(--ink);
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  font-style: italic;
}

.finale-lead + .finale-lead {
  margin-top: 0.85rem;
}

.finale h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 0.85rem;
  line-height: 1.15;
}

.finale-lead {
  color: var(--ink-muted);
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.6;
}

.finale-chart-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 1.5rem 1.5rem 1.25rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.finale-chart-head {
  margin: 0;
  padding: 0;
}

.finale-chart-title {
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  margin: 0 0 0.4rem;
  line-height: 1.25;
  font-weight: 600;
}

.finale-chart-desc {
  margin: 0 0 1rem;
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 42rem;
}

.finale-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin: 0;
}

.finale-chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.3;
}

.finale-chart-legend__swatch {
  flex-shrink: 0;
  width: 1.75rem;
  height: 0.65rem;
  border-radius: 2px;
}

.finale-chart-legend__swatch--line {
  background: var(--sea);
  height: 3px;
  border-radius: 999px;
  align-self: center;
}

.finale-chart-legend__swatch--hatch {
  background: repeating-linear-gradient(
    135deg,
    rgba(94, 200, 216, 0.35) 0 2px,
    rgba(94, 200, 216, 0.08) 2px 6px
  );
  border: 1px solid rgba(94, 200, 216, 0.35);
}

.finale-chart-plot {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
}

.finale-chart-plot svg {
  width: 100%;
  height: auto;
  display: block;
}

.finale-chart-insight {
  margin: 1.25rem 0 0;
  padding: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.55;
}

.finale-chart-card .graphic-source {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.sources-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  border-top: 1px solid var(--line-soft);
}

.sources-footer h3 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.sources-method,
.sources-limits {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 52ch;
}

.sources-footer ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.sources-footer li {
  margin-bottom: 0.35rem;
}

/* ---------- SVG chart styles (finale) ---------- */

.annot { font-size: 13px; fill: var(--chart-muted); }
.annot--y { font-size: 12px; }
.annot--future { fill: var(--chart-muted-future); font-size: 12px; }
.axis-title { font-size: 13px; fill: var(--ink); font-weight: 600; }
.tick-mark { stroke: rgba(184, 200, 216, 0.45); stroke-width: 1; }
.gridline { stroke: rgba(140, 170, 200, 0.18); stroke-width: 1; }
.zero-line { stroke: rgba(184, 200, 216, 0.55); stroke-width: 1.5; stroke-dasharray: 5 4; }
.zero-label { font-size: 12px; fill: var(--chart-muted); font-weight: 600; }
.series-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.series-line--observed { stroke: var(--sea); }
.annot-line { stroke: rgba(184, 200, 216, 0.55); stroke-width: 1.5; stroke-dasharray: 4 4; }
.annot-line--end { stroke: rgba(232, 200, 106, 0.75); stroke-width: 2; stroke-dasharray: none; }
.future-zone { fill: url(#future-grad); }
.future-label { font-size: 13px; fill: var(--ink-muted); font-weight: 500; }
.chart-callout-bg { fill: rgba(8, 14, 24, 0.82); stroke: rgba(184, 200, 216, 0.2); stroke-width: 1; }
.chart-callout { font-size: 13px; fill: var(--ink); font-weight: 600; }
.chart-callout-sub { font-size: 11px; fill: var(--chart-muted); }

.fable-tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: rgba(14, 22, 34, 0.92);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  opacity: 0;
  transition: opacity 0.15s;
  backdrop-filter: blur(10px);
}

.fable-tooltip.visible { opacity: 1; }
.fable-tooltip .tt-label { color: var(--ink-muted); font-size: 0.78rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cn-hero__cue { animation: none; }
  #progress-bar { transition: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .cn-block,
  .cn-block--reverse {
    grid-template-columns: 1fr;
    padding: 0 1rem 3rem;
  }

  .cn-block__steps,
  .cn-block--reverse .cn-block__steps {
    order: 2;
    padding: 0;
  }

  .cn-block__panel,
  .cn-block--reverse .cn-block__panel {
    order: 1;
  }

  .cn-block__panel-inner {
    position: relative;
    height: auto;
    min-height: auto;
    padding: 1rem 0 2rem;
  }

  .cn-ocean-loop {
    height: 220px;
  }

  .cn-ocean-loop.cn-sea-rise,
  .cn-ocean-loop.cn-sea-heat,
  .cn-ocean-loop.cn-population-rise {
    height: 260px;
  }

  .cn-block .step {
    min-height: 60vh;
  }

  .cn-hero__figures {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Language switch (FR / EN) */
.lang-switch {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 70;
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(8, 14, 24, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.lang-switch__btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
  color: var(--ink-muted);
  background: transparent;
  transition: color 0.2s ease, background 0.2s ease;
}

.lang-switch__btn:hover {
  color: var(--ink);
}

.lang-switch__btn--active,
.lang-switch__btn[aria-pressed="true"] {
  color: var(--bg-deep);
  background: var(--accent);
}

@media (max-width: 640px) {
  .lang-switch {
    top: 0.65rem;
    right: 0.65rem;
  }
}
