/* =============================================================
   Solmateria — QU'EST-CE QUE LE BIPV
   Top: a calm reading moment — title + chapô, full width, at a
   comfortable measure (no video beside). Middle: the unchanged
   two-column scene — the two functions (left) and the panel video
   (right), shown as a CONTAINED, framed media, driven by SCROLL
   (scroll-scrubbing) while the scene is pinned. Bottom: the closing.
   Mobile / reduced-motion / data-saver stack a still + the copy.
   ============================================================= */

.bipv {
  position: relative;
  isolation: isolate;
  --pp: 0; /* scrub progress 0..1 (set by JS) — fades the scroll cue */
  /* Top holds #2e4a6a (matching the constat's new bottom) flat for the first 10%,
     so the constat→BIPV join is flat on both sides — no bright ramp-2 ridge. Then
     down to the BIPV body; the bottom (#324a62) still matches the gamme top. */
  background: linear-gradient(180deg, #2e4a6a 0%, #2e4a6a 10%, #2f4a66 55%, #324a62 100%);
}

/* ---- Reading moment: title + chapô (full width) ------------ */
.bipv__intro {
  padding-top: var(--section-pad);
  margin-bottom: var(--space-8);
}
.bipv__title { font-size: var(--text-3xl); }
.bipv__title .em { color: var(--brand-orange); }
.bipv__chapo {
  max-width: 50rem; /* comfortable reading measure */
  margin-top: var(--space-6);
  display: grid;
  gap: var(--space-4);
}
.bipv__chapo p {
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  line-height: var(--leading-body);
}

/* ---- Closing (full width, below the scene) ----------------- */
.bipv__outro {
  position: static; /* always in normal flow — never under the pinned scene */
  margin-top: var(--space-4);
  padding-bottom: var(--section-pad);
}
.bipv__closing {
  max-width: 44rem;
  margin-inline: auto;
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}
.bipv__closing .spark { color: var(--brand-orange); }

/* ---- The framed media (contained, not full-bleed) ---------- */
.bipv__track { position: relative; }
.bipv__stage { position: relative; }
.bipv__media { margin: 0; width: 100%; }
.bipv__video,
.bipv__fallback {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}
.bipv__video { display: none; } /* shown only while scrubbing */
.bipv.is-scrubbing .bipv__video { display: block; }
.bipv.is-scrubbing .bipv__fallback { display: none; }

/* ---- The two functions ------------------------------------- */
.functions { display: grid; gap: var(--space-6); }
.fn {
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.03);
}
.fn__icon {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.fn__icon svg { width: 26px; height: 26px; }
.fn h3 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
.fn p { color: var(--color-text-muted); font-size: var(--text-base); }

/* Both icons use a solid gradient chip + white glyph — same visual weight,
   good contrast on any background (the previous pale steel-on-steel tint
   for "constructive" was nearly invisible against the section's blue). */
.fn--constructive .fn__icon { background: var(--gradient-cold); color: #fff; }
.fn--energetic {
  border-color: rgba(246, 140, 56, 0.4);
  background: linear-gradient(180deg, rgba(246, 140, 56, 0.12), rgba(238, 96, 67, 0.045));
}
.fn--energetic .fn__icon { background: var(--gradient-warm); color: #fff; }
.fn--energetic h3 { color: var(--brand-orange); }

/* =============================================================
   STATIC / FALLBACK (default, mobile, reduced-motion, no-JS):
   normal flow — the panel-out still on top, the functions below.
   ============================================================= */
.bipv:not(.is-scrubbing) .bipv__stage { padding-inline: var(--gutter); }
.bipv:not(.is-scrubbing) .bipv__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  max-width: 40rem;
  margin-inline: auto;
}
.bipv:not(.is-scrubbing) .bipv__media { order: -1; } /* still on top on mobile */
.bipv:not(.is-scrubbing) .bipv__cue { display: none; }

/* =============================================================
   SCRUB — WIDE (≥861px): pin the two-column scene (functions left,
   contained panel media right), centred with air around it.
   The pin (sticky) is a desktop-only layout choice; it is kept in
   lockstep with the JS `wide` media query in initPanelScrub, which
   maps the scrub over the pinned scroll distance at this width.
   ============================================================= */
@media (min-width: 861px) {
  .bipv.is-scrubbing .bipv__track { height: 156vh; } /* shorter, snappier scrub (~22% less course than 180vh, stage ≈ 74vh so ample margin) */
  .bipv.is-scrubbing .bipv__stage {
    position: sticky;
    top: 0;
    /* Height follows the CONTENT (not a forced 100svh): the pinned scene is
       exactly as tall as the composition needs, so there is no dead space
       below it before the closing line. The scrub JS reads this real height
       (stage.offsetHeight) to map the scroll, so the panel finishes exactly
       as the pin releases. */
    height: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: calc(68px + var(--space-8)) var(--gutter) var(--space-8);
  }
  .bipv.is-scrubbing .bipv__inner {
    display: grid;
    grid-template-columns: 1fr auto; /* functions | contained media */
    align-items: center;
    gap: clamp(2rem, 5vw, 5rem);
    width: 100%;
    max-width: var(--container);
  }
  .bipv.is-scrubbing .functions { max-width: 36rem; }
  .bipv.is-scrubbing .bipv__media {
    width: clamp(16rem, 32vw, 30rem); /* contained + elegant, room around it */
  }
}

/* =============================================================
   SCRUB — NARROW (≤860px): no pin. The video is a contained media
   ON TOP of the two cards, all in normal flow — so nothing can
   overlap the closing. It scrubs inline as it transits the viewport
   (see the non-`wide` branch of onScroll in initPanelScrub). A
   comfortable gap separates the video from the first card.
   ============================================================= */
@media (max-width: 860px) {
  .bipv.is-scrubbing .bipv__stage { padding-inline: var(--gutter); }
  .bipv.is-scrubbing .bipv__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-12); /* comfortable video ↔ first card spacing */
    max-width: 40rem;
    margin-inline: auto;
  }
  .bipv.is-scrubbing .functions { width: 100%; }
  .bipv.is-scrubbing .bipv__media {
    order: -1; /* video ABOVE the two cards */
    width: min(82vw, 22rem);
  }
  .bipv.is-scrubbing .bipv__cue { display: none; }
}

/* Scroll cue — centred under the composition, fades as it progresses. */
.bipv__cue {
  position: absolute;
  left: 50%;
  /* Pushed just below the composition so it no longer overlaps the bottom
     function card (was var(--space-6); the cue's ~20px height was reaching ~12px
     into the card zone). Slightly negative → sits in the breathing space before
     the closing line. ⚠️ Value to confirm visually on a real browser: the cue
     only appears in wide-desktop scrubbing, invisible in the Electron preview. */
  bottom: calc(var(--space-2) * -1);
  z-index: 3;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-subtle);
  opacity: calc(1 - var(--pp) * 3);
  transition: opacity 120ms linear;
}
.bipv__cue svg { width: 16px; height: 16px; }
@media (prefers-reduced-motion: no-preference) {
  .bipv.is-scrubbing .bipv__cue svg {
    animation: bipv-cue-bob 2.2s var(--ease-in-out) infinite;
  }
}
@keyframes bipv-cue-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}
