/* =====================================================================
   Directline — hero motion (v2)
   Loaded after motion.css. Composition, colors, copy and links are the
   approved ones from styles.css; this file only adds layers and motion.

   Transform ownership (nothing writes another layer's property):
     .hero-art            → `scale` `translate` `opacity`  (scroll exit, JS var --exit)
                            `transform` stays with styles.css (responsive scale)
     .art-tilt            → `transform`                     (pointer, JS vars --rx/--ry)
     orbit / cards / note → `transform` stays with styles.css (approved tilt)
                            `scale` `rotate` `translate`     (entrance, then float)
     .orbit-back          → `translate`                     (pointer counter-depth)
     .hero-media__inner   → `translate`                     (scroll parallax)
   ===================================================================== */

/* ---------- Background media: poster + optional video + scrim ------- */
.hero > .container { position: relative; z-index: 1; }
.hero-media {
  position: absolute; inset: 0; z-index: 0; overflow: hidden;
  pointer-events: none; background: var(--deep);
}
.hero-media__inner { position: absolute; inset: -56px 0 0 0; }
/* Footage: Doha West Bay at dusk. Framed so the clean sky sits behind the
   headline and the skyline forms a horizon across the lower third (behind
   the CTAs and the bottom bar). Top-anchored and enlarged, so the cut falls
   in the water, not in the towers. */
.hero-poster, .hero-video {
  position: absolute; left: 0; top: 0; width: 100%; height: 128%;
  object-fit: cover; object-position: 50% 0;
}
.hero-video { opacity: 0; transition: opacity 1200ms var(--ease-out); }
.hero-video.is-playing { opacity: 1; }
/* deep-purple scrim: heaviest only behind the copy column (right), a soft
   veil under the header, and a fade of the water into the bottom bar —
   the skyline stays readable across the centre and left */
.hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(to left, rgb(42 22 77 / .8) 0%, rgb(42 22 77 / .62) 36%, rgb(42 22 77 / .2) 68%, rgb(42 22 77 / .1) 100%),
    linear-gradient(to bottom, rgb(42 22 77 / .6) 0, rgb(42 22 77 / 0) 230px),
    linear-gradient(to top, rgb(42 22 77 / .94) 0, rgb(42 22 77 / .4) 130px, rgb(42 22 77 / 0) 300px),
    radial-gradient(ellipse at 50% 16%, rgb(85 48 131 / .34) 0%, rgb(61 34 105 / .28) 50%, rgb(42 22 77 / .3) 100%);
}
@media (max-width: 800px) {
  .hero-poster, .hero-video { height: 100%; object-position: 46% 70%; }
  .hero-scrim {
    background:
      linear-gradient(to bottom, rgb(42 22 77 / .86) 0%, rgb(42 22 77 / .74) 48%, rgb(42 22 77 / .5) 100%),
      rgb(61 34 105 / .24);
  }
}

/* motion control in the bottom bar */
.hero-bottom-end { display: flex; align-items: center; gap: 22px; }
.motion-toggle {
  display: none; align-items: center; gap: 8px;
  background: none; padding: 6px 0; min-height: 32px;
  font-size: 11px; color: #c9bcd7;
  transition: color var(--motion-fast) var(--ease-ui);
}
.motion-ok .motion-toggle { display: inline-flex; }
.motion-toggle:hover { color: var(--lime); }
.motion-toggle svg { width: 12px; height: 12px; flex: none; }
.motion-toggle .icon-play { display: none; }
.motion-toggle[aria-pressed="true"] .icon-play { display: block; }
.motion-toggle[aria-pressed="true"] .icon-pause { display: none; }

/* ---------- Entrance: ~1.3s total, plays once on load ---------------- */
.hero h1 .h-line { display: inline-block; }

/* header: logo, then nav, then actions — calm fade, usable at once */
.motion-ok .nav-wrap > .brand    { animation: dl-fade 420ms var(--ease-out) both; }
.motion-ok .nav-wrap > nav       { animation: dl-drop 420ms var(--ease-out) 70ms both; }
.motion-ok .nav-wrap > .nav-actions { animation: dl-drop 420ms var(--ease-out) 130ms both; }
@media (max-width: 800px) { .motion-ok .nav-wrap > nav { animation: none; } }
@keyframes dl-drop { from { opacity: 0; translate: 0 -6px; } }

/* headline: line-by-line mask reveal. Each line is one span, so Arabic
   letters stay joined; the clip box is padded so diacritics/descenders
   are never cut once revealed. */
.motion-ok .hero h1 .h-line { animation: dl-mask 720ms var(--ease-out) both; }
.motion-ok .hero h1 .h-line:nth-of-type(1) { animation-delay: 120ms; }
.motion-ok .hero h1 .h-line:nth-of-type(2) { animation-delay: 200ms; }
.motion-ok .hero h1 .h-line:nth-of-type(3) { animation-delay: 280ms; }
@keyframes dl-mask {
  from { clip-path: inset(0 -.3em 100% -.3em); translate: 0 .5em; }
  to   { clip-path: inset(-.4em -.3em -.4em -.3em); translate: 0 0; }
}

.motion-ok .hero-copy > .eyebrow { animation: dl-rise 500ms var(--ease-out) 60ms both; --rise: 8px; }
.motion-ok .hero-copy > p        { animation: dl-rise 600ms var(--ease-out) 380ms both; --rise: 12px; }
.motion-ok .hero-actions         { animation: dl-rise 600ms var(--ease-out) 440ms both; --rise: 12px; }
.motion-ok .hero-foot            { animation: dl-fade 500ms var(--ease-out) 540ms both; }
.motion-ok .hero-bottom          { animation: dl-fade 500ms var(--ease-out) 600ms both; }

/* composition, in parallel with the headline. Choreography follows the
   reference video: (1) the subject — the purple ring — establishes alone,
   (2) the surrounding layers rise from a horizon line in depth order,
   back to front, (3) the small labels/marks land last. */
.project-food, .project-web { animation: none; } /* reference float rewrote `transform` */
.motion-ok .art-grid    { animation: dl-fade 700ms var(--ease-out) both; }
/* beat 1: subject alone */
.motion-ok .orbit-back  { animation: dl-orbit 650ms var(--ease-out) 0ms both; }
/* beat 2: layers rise, back → front */
.motion-ok .project-food {
  animation: dl-horizon 720ms var(--ease-out) 280ms both,
             dl-float-a 9s ease-in-out 1.05s infinite;
}
.motion-ok .orbit-front { animation: dl-rise-up 680ms var(--ease-out) 360ms both; } /* keeps its own clip-path shape */
.motion-ok .project-web {
  animation: dl-horizon 700ms var(--ease-out) 440ms both,
             dl-float-b 11.5s ease-in-out 1.2s infinite;
}
.motion-ok .floating-note {
  animation: dl-horizon 560ms var(--ease-out) 600ms both,
             dl-float-c 7.5s ease-in-out 1.25s infinite;
}
/* beat 3: marks */
.motion-ok .hero-art-label, .motion-ok .art-marker { animation: dl-fade 400ms var(--ease-out) 900ms both; }
.motion-ok .art-spark { animation: dl-spark 440ms var(--ease-out) 860ms both, turn 30s linear 1.3s infinite; }

@keyframes dl-orbit   { from { opacity: 0; scale: .96; rotate: -3deg; } }
/* emerges from behind a horizon: rises while its own box is revealed top-first.
   The open state is padded (-120px) so card shadows are never clipped. */
@keyframes dl-horizon {
  0%   { opacity: 0; translate: 0 64px; clip-path: inset(0 -120px 100% -120px); }
  35%  { opacity: 1; }
  100% { opacity: 1; translate: 0 0;    clip-path: inset(-120px); }
}
@keyframes dl-rise-up {
  0%   { opacity: 0; translate: 0 56px; }
  40%  { opacity: 1; }
  100% { opacity: 1; translate: 0 0; }
}
@keyframes dl-spark       { from { opacity: 0; scale: .6; } }

/* ---------- Continuous: slow, different rhythms, 4–8px --------------- */
.hero { --float: 1; }
@keyframes dl-float-a { 50% { translate: 0 calc(-7px * var(--float)); rotate: calc(1deg * var(--float)); } }
@keyframes dl-float-b { 50% { translate: 0 calc(6px * var(--float));  rotate: calc(-1deg * var(--float)); } }
@keyframes dl-float-c { 50% { translate: 0 calc(-4px * var(--float)); } }
@media (max-width: 800px) { .hero { --float: .6; } }

/* pointer response: desktop fine pointer only (JS adds .tilt-on) */
.hero-art.tilt-on .art-tilt {
  transform: perspective(1100px)
             rotateX(calc(var(--ry, 0) * -2.4deg))
             rotateY(calc(var(--rx, 0) * 2.4deg))
             translate(calc(var(--rx, 0) * 5px), calc(var(--ry, 0) * 5px));
  will-change: transform;
}
.hero-art.tilt-on .orbit-back { translate: calc(var(--rx, 0) * -3px) calc(var(--ry, 0) * -3px); }

/* paused: off-screen, hidden tab, or the visitor pressed the control */
.hero.is-paused :is(.project-food, .project-web, .floating-note, .art-spark),
.motion-paused .hero :is(.project-food, .project-web, .floating-note, .art-spark) {
  animation-play-state: paused;
}

/* ---------- Scroll exit: composition recedes as the next section arrives
   native scroll only; text and CTAs are never touched */
.motion-ok .hero.exit-on .hero-art {
  scale: calc(1 - var(--exit, 0) * .07);
  translate: 0 calc(var(--exit, 0) * 48px);
  opacity: calc(1 - var(--exit, 0) * .55);
}
.motion-ok .hero.exit-on .hero-media__inner { translate: 0 calc(var(--exit, 0) * 56px); }
@media (max-width: 800px) {
  .motion-ok .hero.exit-on .hero-art {
    scale: calc(1 - var(--exit, 0) * .04);
    translate: 0 calc(var(--exit, 0) * 24px);
    opacity: calc(1 - var(--exit, 0) * .35);
  }
}

/* ---------- Reduced motion: static, complete, final states ----------- */
@media (prefers-reduced-motion: reduce) {
  .hero-art .art-tilt { transform: none !important; }
  .hero-art .orbit-back { translate: none !important; }
  .hero-video { display: none; }
}

/* ---------- Fix: composition clipped on phones narrower than 375px ---
   (pre-existing in the reference: up to 50px of the ring and the
   "A DIRECT LINE" label fell off the left edge at 320px). Re-centres the
   already-scaled artwork with a relative offset, so it doesn't touch any
   transform layer. */
@media (max-width: 374px) {
  .hero-art { left: calc((425px - 100vw) / 2); }
}

/* contrast over the brightest footage frame (measured): small hero text
   nudged lighter in the same hue so it stays ≥ 4.5:1 */
.hero-foot { color: #b2a3c1; }
.art-marker { color: #b5a6c8; }

/* ---------- Header as part of the hero ------------------------------
   html.js-hero is set by the inline head script (before first paint, so the
   pull-up causes no layout shift): the hero sits under the sticky header and
   both share the video background. Transparency needs .is-top, which only
   hero.js adds (top of page, menu closed) — if hero.js never runs, the
   header simply stays solid. */
.header { transition: background-color var(--motion-ui) var(--ease-ui), border-color var(--motion-ui) var(--ease-ui), backdrop-filter var(--motion-ui) var(--ease-ui); }
.js-hero .header.is-top {
  background-color: transparent;
  border-bottom-color: rgb(255 255 255 / .07);
  backdrop-filter: none;
}
.js-hero .hero { margin-top: calc(-1 * var(--head-h, 91px)); padding-top: var(--head-h, 91px); }
@media (max-width: 800px) { .js-hero .hero { --head-h: 75px; } }

/* ---------- First screen: the whole hero fits the viewport (desktop) --
   header + copy + composition + bottom bar = 100svh. hero.js sets --fit
   (0.72–1) when the natural content is taller than the space left. */
@media (min-width: 801px) {
  .js-hero .hero { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
  .js-hero .hero-grid {
    flex: 1 0 auto; min-height: 0;
    padding-top: clamp(16px, 4.5svh, 62px); padding-bottom: clamp(16px, 4.5svh, 63px);
  }
  .js-hero .hero-bottom { flex: none; }
  .js-hero .hero-copy, .js-hero .hero-art { zoom: var(--fit, 1); }
}
