/* ============================================================
   engine.css — "A Full Marketing Engine"
   Pinned, scroll-driven multi-layer parallax (GSAP ScrollTrigger)
   Motion inspiration: Osmo "Parallax Image Layers", Codrops 3DStackMotion
   ============================================================ */

.engine {
  --eng-navy: #050f2a;
  --eng-navy-2: #07193E;
  --eng-blue: #2563EB;
  --eng-sky: #4B92FF;
  --eng-ice: #d8eafc;
  position: relative;
  background: var(--eng-navy);
  color: #fff;
  padding: 0 !important;
  overflow: clip;
  isolation: isolate;
  font-family: 'Poppins', sans-serif;
}

/* The pinned viewport */
.engine__pin {
  position: relative;
  height: 100svh;
  min-height: 600px;
  overflow: hidden;
}

/* ---------- Layer 0: background glow + dot grid ---------- */
.engine__bg {
  position: absolute; inset: -20% 0;
  background:
    radial-gradient(60% 50% at 70% 40%, rgba(37,99,235,.45), transparent 70%),
    radial-gradient(40% 40% at 20% 80%, rgba(75,146,255,.25), transparent 70%),
    linear-gradient(180deg, #06143a 0%, var(--eng-navy) 60%, #030a1d 100%);
  will-change: transform;
}
.engine__grid {
  position: absolute; inset: -30% 0;
  background-image: radial-gradient(rgba(216,234,252,.14) 1px, transparent 1.4px);
  background-size: 34px 34px;
  mask-image: radial-gradient(70% 70% at 50% 50%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(70% 70% at 50% 50%, #000 30%, transparent 100%);
  will-change: transform;
}
.engine__floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 28%;
  background: linear-gradient(180deg, transparent, rgba(37,99,235,.18) 60%, rgba(37,99,235,.28));
  filter: blur(20px);
  pointer-events: none;
}

/* ---------- Header ---------- */
.engine__head {
  position: absolute; top: clamp(72px, 10vh, 110px); left: 0; right: 0;
  text-align: center; z-index: 5; padding: 0 24px;
}
.engine__eyebrow {
  display: inline-block; font-size: .72rem; letter-spacing: .26em; text-transform: uppercase;
  color: rgba(216,234,252,.6); font-weight: 600; margin-bottom: 10px;
}
.engine__head h2 {
  color: #fff; font-size: clamp(1.8rem, 3.6vw, 2.9rem); letter-spacing: -.03em; line-height: 1.05; margin: 0;
}
.engine__head p { color: rgba(216,234,252,.65); margin: 10px auto 0; max-width: 520px; font-size: clamp(.9rem, 1.3vw, 1.02rem); }

/* ---------- Stage: illustrations stacked in Z ---------- */
.engine__stage {
  position: absolute; inset: 0; z-index: 2;
  display: grid; grid-template-columns: 1.15fr .85fr; align-items: center;
  max-width: 1240px; margin: 0 auto; padding: 170px 24px 70px;
}
.engine__scene {
  position: relative; contain: layout paint; height: min(58vh, 560px); perspective: 1400px; transform-style: preserve-3d;
}
.engine__visual {
  position: absolute; inset: 0; margin: 0; display: grid; place-items: center;
  transform-style: preserve-3d; will-change: transform, opacity; opacity: 0;
  pointer-events: none;
}
.engine__visual img {
  width: 100%; height: 100%; object-fit: contain;
  -webkit-mask-image: radial-gradient(closest-side, #000 58%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 58%, transparent 100%);
}
.engine__visual.is-active { pointer-events: auto; }
/* only the current and neighbouring illustrations are composited — big perf win on phones */
.engine:not(.is-static) .engine__visual:not(.is-near) { visibility: hidden; }

/* ---------- Floating foreground chips (fast parallax layer) ---------- */
.engine__float { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.chip {
  position: absolute; display: grid; place-items: center;
  width: var(--s, 64px); height: var(--s, 64px);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(255,255,255,.18), rgba(255,255,255,.04));
  border: 1px solid rgba(216,234,252,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 24px 50px rgba(0,0,0,.45), 0 0 40px rgba(37,99,235,.25);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #e8f1ff; will-change: transform;
  transform: rotate(var(--r, 0deg));
}
.chip svg { width: 46%; height: 46%; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chip--solid { background: linear-gradient(145deg, #4B92FF, #2563EB); border-color: rgba(255,255,255,.35); color: #fff; }
.orb {
  position: absolute; border-radius: 50%; will-change: transform;
  width: var(--s, 180px); height: var(--s, 180px);
  background: radial-gradient(circle at 35% 30%, rgba(216,234,252,.55), rgba(37,99,235,.25) 45%, transparent 70%);
  filter: blur(6px); opacity: .7;
}

/* ---------- Copy: one service at a time ---------- */
.engine__copy { position: relative; z-index: 4; min-height: 300px; }
.engine__service {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  opacity: 0; visibility: hidden; will-change: transform, opacity;
}
.engine__service.is-active { visibility: visible; }
.engine__num {
  font-size: .78rem; letter-spacing: .22em; color: var(--eng-sky); font-weight: 700; margin-bottom: 14px;
}
.engine__num::before { content: ''; display: inline-block; width: 28px; height: 1px; background: var(--eng-sky); vertical-align: middle; margin-right: 10px; }
.engine__service h3 {
  color: #fff; font-size: clamp(1.7rem, 3.3vw, 2.7rem); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 16px; font-weight: 700;
}
.engine__service p { color: rgba(216,234,252,.72); font-size: clamp(.98rem, 1.4vw, 1.12rem); line-height: 1.7; max-width: 440px; margin: 0 0 24px; }
.engine__service .learn {
  display: inline-flex; align-items: center; gap: 8px; color: #fff; font-weight: 600;
  padding: 12px 20px; border-radius: 999px; border: 1px solid rgba(216,234,252,.35);
  background: rgba(255,255,255,.06); transition: background .3s, border-color .3s, transform .3s;
}
.engine__service .learn:hover { background: var(--eng-blue); border-color: var(--eng-blue); transform: translateX(4px); }

/* ---------- Progress ---------- */
.engine__progress {
  position: absolute; left: 50%; bottom: clamp(22px, 4vh, 40px); transform: translateX(-50%);
  z-index: 6; display: flex; align-items: center; gap: 18px; color: rgba(216,234,252,.6);
  font-size: .78rem; letter-spacing: .18em; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.engine__dots { display: flex; gap: 8px; }
.engine__dots i { width: 26px; height: 2px; background: rgba(216,234,252,.25); border-radius: 2px; transition: background .3s, width .3s; }
.engine__dots i.on { background: #fff; width: 40px; }
.engine__hint { position: absolute; right: clamp(16px, 3vw, 40px); bottom: clamp(22px, 4vh, 40px); z-index: 6; color: rgba(216,234,252,.45); font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; writing-mode: vertical-rl; }

/* ---------- Static fallback (reduced motion / no GSAP) ---------- */
.engine.is-static .engine__pin { height: auto; min-height: 0; overflow: visible; padding: 90px 0 70px; }
.engine.is-static .engine__bg, .engine.is-static .engine__grid { inset: 0; }
.engine.is-static .engine__head { position: static; margin-bottom: 48px; }
.engine.is-static .engine__stage { position: static; display: block; }
.engine.is-static .engine__scene { height: auto; perspective: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 40px 32px; }
.engine.is-static .engine__visual { position: relative; inset: auto; opacity: 1; transform: none !important; display: block; }
.engine.is-static .engine__visual img { aspect-ratio: 4/3; height: auto; mask-image: none; -webkit-mask-image: none; border-radius: 18px; }
.engine.is-static .engine__visual figcaption { display: block; }
.engine.is-static .engine__float, .engine.is-static .engine__progress, .engine.is-static .engine__hint, .engine.is-static .engine__copy { display: none; }
.engine__visual figcaption { display: none; margin-top: 18px; }
.engine__visual figcaption h3 { color: #fff; font-size: 1.3rem; margin: 0 0 8px; }
.engine__visual figcaption p { color: rgba(216,234,252,.7); margin: 0 0 12px; }
.engine__visual figcaption .learn { color: var(--eng-sky); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .engine .chip, .engine .orb, .engine__visual, .engine__service, .engine__bg, .engine__grid { transform: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .engine__stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; align-content: center; gap: 0; padding-top: 150px; padding-bottom: 90px; }
  .engine__scene { height: min(42vh, 380px); }
  .engine__copy { min-height: 240px; text-align: center; }
  .engine__service { align-items: center; }
  .engine__service p { max-width: 520px; }
  .engine__hint { display: none; }
  .chip { --s: 46px; border-radius: 14px; }
  .orb { display: none; }
  /* keep chips in the image half so they never sit over the copy */
  .engine__float { top: 150px; bottom: 46%; }
  .chip:nth-child(n+7) { display: none; }
  .engine__dots i { width: 18px; } .engine__dots i.on { width: 28px; }
}
@media (max-width: 560px) {
  .engine__head { top: 64px; }
  .engine__stage { padding-top: 140px; padding-bottom: 80px; }
  .engine__scene { height: min(36vh, 300px); }
  .engine__copy { min-height: 230px; }
  .engine__service h3 { font-size: 1.5rem; }
  .engine__service p { font-size: .95rem; margin-bottom: 18px; }
  .chip:nth-child(n+6) { display: none; }
  .engine.is-static .engine__scene { grid-template-columns: 1fr; }
}
