/* =============================================================
   Solmateria — LE CONSTAT
   Narrative beat 1: dormant. The resource is wasted; light passes
   uncaptured. Palette stays in the blues, calm and a touch
   frustrating. One warm note only at the very end (the bascule).
   ============================================================= */

.constat {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: var(--section-pad) 0;
  /* Holds ramp-1 at the very top (flat join with the hero seam → no ridge), dips
     to the dormant cold middle, then lightens to a mid steel. The bottom lands on
     #2e4a6a (a slightly deeper steel than ramp-2) so it matches the BIPV body
     luminance — the old bright ramp-2 overshoot at the constat→BIPV seam is gone,
     the join is monotonic. Still cold steel: temperature untouched. */
  background: linear-gradient(180deg,
    var(--ramp-1) 0%,
    var(--ramp-1) 12%,
    #243a53 55%,
    #2e4a6a 100%);
}

/* =============================================================
   BACKGROUND — two switchable versions.
   Default (no body class) = Version A: worked cold gradient + rays.
   body.constat-photo       = Version B: parallax photo + slate overlay.
   ============================================================= */

/* ---- Version A: worked cold/dormant glow ------------------- */
/* A soft dormant light (top-right, an echo of the hero's cool sun) and a
   deeper pool bottom-left — gives the flat gradient depth without a photo. */
.constat__glow {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(58% 48% at 82% 6%, rgba(126, 162, 202, 0.20) 0%, transparent 60%),
    radial-gradient(72% 60% at 10% 102%, rgba(41, 65, 101, 0.34) 0%, transparent 66%);
}

/* faint light rays crossing the section — present but uncaptured */
.constat__rays {
  position: absolute;
  inset: -10% -10% auto -10%;
  height: 130%;
  z-index: -1;
  background: repeating-linear-gradient(
    104deg,
    transparent 0,
    transparent 58px,
    rgba(176, 202, 228, 0.055) 58px,
    rgba(176, 202, 228, 0.055) 61px
  );
  -webkit-mask-image: radial-gradient(120% 70% at 30% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(120% 70% at 30% 0%, #000 0%, transparent 72%);
}
/* very slow drift — light slipping by, never captured */
@media (prefers-reduced-motion: no-preference) {
  body:not(.constat-photo) .constat__rays {
    animation: constat-rays-drift 28s linear infinite;
  }
}
@keyframes constat-rays-drift {
  from { background-position: 0 0; }
  to   { background-position: 124px 0; }
}

/* ---- Version B: full-bleed photo + parallax + slate overlay - */
/* Both layers are hidden until body.constat-photo is set. The photo is
   over-tall (top/bottom headroom) so the JS parallax can shift it without
   exposing an edge; overflow:hidden on .constat clips any overscan. */
.constat__photo,
.constat__photo-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}
.constat__photo {
  top: -14%;
  height: 128%;
  z-index: -2;
  background: #18263a url("../assets/img/constat-bg.png") center / cover no-repeat;
  /* settle the warm sunset toward the cold/dormant temperature of the section */
  filter: saturate(0.9) contrast(1.02) brightness(0.95);
  will-change: transform;
}
.constat__photo-overlay {
  z-index: -1;
  /* Layered to (a) keep every bit of content legible, (b) cool the photo into
     the section's blue temperature, (c) melt the top/bottom seams into the
     surrounding ramp colours. Tame the bright sun corner, darken under the
     left-hand copy, and keep the title/bascule edges dark. */
  background:
    radial-gradient(85% 65% at 86% 15%, rgba(13, 21, 32, 0.48) 0%, transparent 72%),
    linear-gradient(0deg, rgba(33, 56, 83, 0.32), rgba(33, 56, 83, 0.32)),
    linear-gradient(90deg, rgba(13, 21, 32, 0.76) 0%, rgba(13, 21, 32, 0.46) 52%, rgba(13, 21, 32, 0.56) 100%),
    linear-gradient(180deg, var(--ramp-1) 0%, rgba(13, 21, 32, 0.34) 15%, rgba(13, 21, 32, 0.30) 70%, var(--ramp-2) 100%);
}

/* ---- The switch ------------------------------------------- */
body.constat-photo .constat__glow,
body.constat-photo .constat__rays { display: none; }
body.constat-photo .constat__photo,
body.constat-photo .constat__photo-overlay { display: block; }

.constat__head { max-width: 46rem; margin-bottom: var(--space-16); }
.constat__title { font-size: var(--text-3xl); margin-top: var(--space-4); }

/* ---- Beat A: the wasted resource --------------------------- */
.constat__resource {
  display: grid;
  gap: var(--space-12);
  align-items: center;
  margin-bottom: var(--space-24);
}
.constat__lede { font-size: var(--text-lg); color: var(--color-text-muted); }
.constat__lede .waste {
  color: var(--color-text);
  font-style: italic;
  border-bottom: 1px solid var(--color-border-strong);
  padding-bottom: 1px;
}

/* big animated counter */
.stat { position: relative; }
.stat__num {
  display: block;
  font-size: clamp(3.6rem, 2.2rem + 6vw, 6rem);
  font-weight: var(--weight-bold);
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.stat__num .unit {
  font-size: 0.42em;
  font-weight: var(--weight-semibold);
  color: var(--brand-steel);
  margin-left: 0.15em;
  letter-spacing: 0;
}
.stat__label {
  margin-top: var(--space-3);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 22rem;
}
.stat__rule {
  width: 64px; height: 3px; margin-top: var(--space-6);
  background: var(--gradient-cold);
  border-radius: var(--radius-pill);
}

/* ---- Beat B: the climbing bill ----------------------------- */
.constat__tariff {
  display: grid;
  gap: var(--space-12);
  align-items: center;
}
.constat__tariff-copy h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
}
.constat__tariff-copy p { color: var(--color-text-muted); font-size: var(--text-lg); }
.constat__tariff-copy .trend {
  display: inline-block;
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* chart */
.chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.chart__grid line { stroke: rgba(180, 197, 216, 0.14); stroke-width: 1; }
.chart__axis { stroke: var(--color-border-strong); stroke-width: 1.5; }
.chart__axis-label {
  fill: var(--color-text-subtle);
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: var(--weight-medium);
}
.chart__area { fill: url(#tariffArea); opacity: 0; }
.chart__line {
  fill: none;
  stroke: #8DB0D6;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.chart__peak { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0.5); }
.chart__peak-dot { fill: var(--brand-orange-red); }
.chart__peak-ring { fill: none; stroke: var(--brand-orange-red); stroke-width: 2; opacity: 0.4; }
.chart__badge {
  fill: var(--brand-orange-red);
  font-size: 22px;
  font-weight: var(--weight-bold);
  font-family: var(--font-sans);
  opacity: 0;
}

/* draw-on-reveal (one-shot, driven by the shared reveal observer) */
[data-reveal].is-visible .chart__line {
  transition: stroke-dashoffset 1.7s var(--ease-out) 0.15s;
  stroke-dashoffset: 0;
}
[data-reveal].is-visible .chart__area {
  transition: opacity 0.9s ease 0.7s;
  opacity: 1;
}
[data-reveal].is-visible .chart__peak {
  transition: opacity 0.4s ease 1.5s, transform 0.6s var(--ease-out) 1.5s;
  opacity: 1;
  transform: scale(1);
}
[data-reveal].is-visible .chart__badge {
  transition: opacity 0.5s ease 1.7s;
  opacity: 1;
}

/* ---- The bascule: opens toward the solution ---------------- */
.constat__bascule {
  position: relative;
  max-width: 40rem;
  margin: var(--space-24) auto 0;
  padding-top: var(--space-12);
  text-align: center;
  border-top: 1px solid var(--color-border);
}
.constat__bascule p {
  margin: 0 auto;
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}
.constat__bascule .spark { color: var(--brand-orange); } /* first warmth creeping in */
.constat__bascule-cue {
  display: inline-flex;
  margin-top: var(--space-8);
  color: var(--brand-orange);
}
.constat__bascule-cue svg { width: 22px; height: 22px; }

/* ---- Desktop ----------------------------------------------- */
@media (min-width: 820px) {
  .constat__resource { grid-template-columns: 1.1fr 0.9fr; gap: var(--space-16); }
  .constat__tariff { grid-template-columns: 0.95fr 1.05fr; gap: var(--space-16); }
  .constat__tariff-copy { order: 0; }
}
