/* ------------------------------------------------------------------
   Engine hero — scroll-scrubbed engine film.

   Without JS (or with reduced motion) this is a plain 100vh hero with
   a static frame. With JS (html.js, set inline in <head> so it applies
   before first paint) the section becomes a scroll track and
   engine-hero.js drives the film and the [data-reveal] groups.
------------------------------------------------------------------ */
.engine-hero {
  /* Film placement — engine-hero.js mirrors this geometry exactly.
     Side by side: the frame is cover-sized and anchored so the engine's
     leading edge (--engine-edge, a fraction of the frame width) lands at
     --engine-start of the stage width, whatever the viewport ratio.
     Stacked (--engine-start: 0): plain cover, positioned by --engine-focus. */
  --engine-edge: 0.38;
  --engine-start: 0.42;
  --engine-focus: 1;
  --engine-track: 320vh;

  position: relative;
  background: var(--color-bg);
}

.engine-hero__sticky {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  isolation: isolate;
}

/* ---------- Film ---------------------------------------------------- */
.engine-hero__stage {
  position: absolute;
  inset: 0;
  z-index: -2;
  container-type: size;
}

.engine-hero__poster,
.engine-hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.engine-hero__poster {
  object-fit: cover;
  /* 177.38cqh = stage height × frame aspect (1600 / 902) */
  object-position:
    calc(100% + max(0px, (1 - var(--engine-edge)) * max(100cqw, 177.38cqh) - (1 - var(--engine-start)) * 100cqw))
    50%;
}

/* The canvas paints the exact same geometry as the poster, so it can sit
   on top and become visible the moment its first frame is drawn — no
   cross-fade, no flash. */
.engine-hero__canvas { visibility: hidden; }
.engine-hero__canvas.is-live { visibility: visible; }

/* Left-side atmosphere for the copy + a bottom fade into the next
   section. Two soft gradients, no visible edges. */
.engine-hero__shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to top, var(--color-bg) 0%, rgb(0 3 11 / 0.7) 9%, rgb(0 3 11 / 0) 26%),
    linear-gradient(to right,
      rgb(0 3 11 / 0.86) 0%,
      rgb(0 3 11 / 0.5) 26%,
      rgb(0 3 11 / 0.16) 44%,
      rgb(0 3 11 / 0) 58%);
}

/* ---------- Copy ---------------------------------------------------- */
.engine-hero__content {
  position: absolute;
  top: 50%;
  left: var(--gutter);
  width: max-content;
  max-width: min(46vw, 700px);
  translate: 0 -46%;
  text-align: start;
}

.engine-hero__headline,
.engine-hero__details,
.engine-hero__statement,
.engine-hero__cue { will-change: opacity, transform; }

.engine-hero__eyebrow {
  margin-bottom: clamp(24px, 2.6vw, 36px);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--color-gold);
}
/* The eyebrow is LTR inside an RTL column: keep it on the column's start
   (right) edge and cancel the trailing tracking so the edge aligns. */
.engine-hero__eyebrow[dir="ltr"] {
  text-align: right;
  margin-right: -0.34em;
}

.engine-hero__title {
  display: grid;
  font-size: clamp(52px, 5vw, 92px);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
}
.engine-hero__title-line { white-space: nowrap; }
.engine-hero__title-line--accent {
  font-weight: 200;
  color: var(--color-gold-soft);
}

.engine-hero__details {
  margin-top: clamp(28px, 3vw, 44px);
}
.engine-hero__lead {
  max-width: min(440px, 34vw);
  margin-bottom: 36px;
  font-size: clamp(16px, 1.15vw, 18px);
  font-weight: 400;
  line-height: 1.95;
  color: rgb(238 241 245 / 0.74);
}

/* Closing statement — takes the headline's place once the copy has cleared. */
.engine-hero__statement {
  position: absolute;
  left: var(--gutter);
  top: 50%;
  translate: 0 -50%;
  font-size: clamp(30px, 3.4vw, 56px);
  font-weight: 300;
  line-height: 1.25;
  text-shadow: 0 2px 28px rgb(0 3 11 / 0.75);
  opacity: 0;
}
.engine-hero__statement span { color: var(--color-gold-soft); }

/* ---------- Scroll cue ---------------------------------------------- */
.engine-hero__cue {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  display: none;
  justify-items: center;
  gap: 14px;
  translate: -50% 0;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.engine-hero__cue span { margin-right: -0.4em; }
.engine-hero__cue i {
  position: relative;
  width: 1px;
  height: 44px;
  overflow: hidden;
  background: var(--color-line);
}
.engine-hero__cue i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent, var(--color-gold) 50%, transparent);
  translate: 0 -100%;
  animation: engine-cue 2.6s var(--ease-out) 1.6s infinite;
}

@keyframes engine-cue {
  0%   { translate: 0 -100%; }
  70%, 100% { translate: 0 100%; }
}

/* ---------- Intro -------------------------------------------------------
   Runs on the children so it never fights the scroll timeline, which
   drives the [data-reveal] wrappers. */
.engine-hero__eyebrow,
.engine-hero__title-line {
  animation: engine-rise 1.4s var(--ease-out) both;
}
.engine-hero__title-line:nth-child(1) { animation-delay: 0.12s; }
.engine-hero__title-line:nth-child(2) { animation-delay: 0.26s; }

@keyframes engine-rise {
  from { opacity: 0; translate: 0 24px; filter: blur(6px); }
  to   { opacity: 1; translate: 0 0;    filter: blur(0); }
}

@media (prefers-reduced-motion: no-preference) {
  .js .engine-hero { height: var(--engine-track); }
  .js .engine-hero__sticky { position: sticky; top: 0; }
  .js .engine-hero__cue { display: grid; }
  /* Revealed by the scroll timeline; hidden before JS runs so it can't flash. */
  .js .engine-hero__details { opacity: 0; }
}

/* Keyboard users must always be able to see the CTA they've focused. */
.engine-hero__details:focus-within {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
}

/* ---------- Stacked layout (phones, portrait tablets) ------------------
   Copy on top, engine in the lower part of the frame, faded in from the
   background. */
@media (max-aspect-ratio: 1/1) {
  .engine-hero {
    --engine-start: 0;
    --engine-focus: 0.66;
    --engine-track: 230vh;
  }

  .engine-hero__poster { object-position: calc(var(--engine-focus) * 100%) 50%; }

  .engine-hero__stage {
    top: 40%;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 30%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 30%);
  }

  .engine-hero__shade {
    background: linear-gradient(to top, var(--color-bg) 0%, rgb(0 3 11 / 0) 18%);
  }

  .engine-hero__content {
    top: calc(var(--header-h) + clamp(20px, 5svh, 64px));
    left: var(--gutter);
    right: var(--gutter);
    width: auto;
    max-width: none;
    translate: none;
  }

  .engine-hero__title { font-size: clamp(40px, 10.4vw, 76px); }
  .engine-hero__details { margin-top: 22px; }
  .engine-hero__lead {
    margin-bottom: 26px;
    font-size: 15px;
    line-height: 1.9;
  }

  .engine-hero__statement {
    top: calc(var(--header-h) + clamp(20px, 5svh, 64px));
    translate: none;
    font-size: clamp(24px, 7vw, 40px);
  }
}

@media (max-aspect-ratio: 1/1) and (max-width: 767.98px) {
  .engine-hero__lead { max-width: 34ch; }
  .engine-hero__details .button { min-height: 48px; padding: 0 22px; }
}

/* Short landscape screens (phones on their side). */
@media (min-aspect-ratio: 1/1) and (max-height: 560px) {
  .engine-hero { --engine-start: 0.5; }
  .engine-hero__sticky { min-height: 0; }
  .engine-hero__content { top: calc(50% + var(--header-h) / 2); }
  .engine-hero__eyebrow { margin-bottom: 14px; font-size: 10px; }
  .engine-hero__title { font-size: clamp(34px, 8.5vh, 52px); }
  .engine-hero__details { margin-top: 14px; }
  .engine-hero__lead { max-width: 36vw; margin-bottom: 16px; font-size: 14px; line-height: 1.8; }
  .engine-hero__statement { font-size: 26px; top: calc(50% + var(--header-h) / 2); }
}

/* ---------- Reduced motion ---------------------------------------------
   JS doesn't scrub: the hero stays a single composed frame (the poster). */
@media (prefers-reduced-motion: reduce) {
  .engine-hero__eyebrow,
  .engine-hero__title-line,
  .engine-hero__cue i::after { animation: none; }
}
