/* ------------------------------------------------------------------
   Global sourcing — particle-engine scene with copy.
   Like the hero, it is a scroll track: the screen stays pinned while
   scrolling assembles the engine (js/sourcing.js → js/sourcing-scene.js)
   and then reveals the copy; scrolling back reverses it.
------------------------------------------------------------------ */
.sourcing {
  --sourcing-track: 130vh;
  --reveal: 1; /* copy reveal 0→1, set from scroll by js/sourcing.js */

  position: relative;
  background: #02050c;
}

.sourcing__sticky {
  position: relative;
  display: flex;
  align-items: center;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: clip;
  isolation: isolate;
}

@media (prefers-reduced-motion: no-preference) {
  .js .sourcing { height: calc(100vh + var(--sourcing-track)); }
  .js .sourcing__sticky { position: sticky; top: 0; }
}
@supports (height: 100svh) {
  @media (prefers-reduced-motion: no-preference) {
    .js .sourcing { height: calc(100svh + var(--sourcing-track)); }
  }
}

.sourcing__scene {
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0;
  transition: opacity 1.2s var(--ease-out);
}
.sourcing.is-ready .sourcing__scene { opacity: 1; }
.sourcing__scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}
/* No WebGL: a still of the engine in the same place. */
.sourcing.is-fallback .sourcing__scene {
  opacity: 0.55;
  background: url("../assets/sourcing/engine.webp") 22% 50% / auto 70% no-repeat;
}

/* Vignette like the original, plus depth on the copy side (right). */
.sourcing__veil {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, var(--color-bg) 0%, transparent 14%, transparent 86%, var(--color-bg) 100%),
    linear-gradient(to left, rgb(2 5 12 / 0.75) 0%, rgb(2 5 12 / 0.35) 34%, transparent 55%),
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.6) 100%);
}

.sourcing__content {
  display: flex;
  justify-content: flex-start; /* RTL: start = right */
}

.sourcing__head {
  display: grid;
  gap: 20px;
  max-width: min(32rem, 42vw);
}
.sourcing__head .eyebrow[dir="ltr"] { text-align: right; }
.sourcing__head .section__title {
  font-size: clamp(34px, 4vw, 60px);
  line-height: 1.25;
  text-wrap: balance;
  text-shadow: 0 0 40px rgb(80 140 255 / 0.25);
}
.sourcing__lead {
  font-size: clamp(16px, 1.25vw, 19px);
  line-height: 2;
  text-wrap: pretty;
  color: rgb(238 241 245 / 0.78);
}

/* Copy reveal — follows the scroll (--reveal), staggered per line, so it
   plays forwards and backwards with the engine. */
@media (prefers-reduced-motion: no-preference) {
  .js .sourcing__head > * {
    --k: clamp(0, calc(var(--reveal) * 1.6 - var(--i) * 0.3), 1);
    opacity: var(--k);
    translate: 0 calc((1 - var(--k)) * 28px);
  }
  .js .sourcing__head > :nth-child(1) { --i: 0; }
  .js .sourcing__head > :nth-child(2) { --i: 1; }
  .js .sourcing__head > :nth-child(3) { --i: 2; }
}

/* Tall screens: the engine sits in the upper half (see the scene), copy below. */
@media (max-aspect-ratio: 11/10) {
  .sourcing__sticky { align-items: flex-end; }
  .sourcing__content {
    justify-content: center;
    padding-bottom: clamp(48px, 9svh, 110px);
  }
  .sourcing__head {
    max-width: 34rem;
    justify-items: center;
    text-align: center;
  }
  .sourcing__head .eyebrow[dir="ltr"] { text-align: center; margin-right: 0; }
  .sourcing__head { gap: 14px; }
  .sourcing__head .section__title { font-size: clamp(28px, 7.4vw, 48px); }
  .sourcing__lead { font-size: 15px; line-height: 1.9; }
  .sourcing__veil {
    background:
      linear-gradient(to bottom, var(--color-bg) 0%, transparent 12%, transparent 45%, rgb(2 5 12 / 0.85) 75%, var(--color-bg) 100%),
      radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.6) 100%);
  }
  .sourcing.is-fallback .sourcing__scene { background-position: 50% 18%; background-size: auto 45%; }
}
