/* ---------- Gateway Growth cinematic intro ---------- */
.gg-intro {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--black);
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.8s ease;
}

.gg-intro[data-state="exiting"] { opacity: 0; pointer-events: none; }

.gg-intro::after {
  /* faint vignette so the center reads as the only place light lives */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.55) 100%);
}

.gg-intro-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Scene 1 — the signal. A lone oxblood ember, breathing. */
.gg-intro-signal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--oxblood);
  box-shadow: 0 0 16px 5px var(--oxblood-dim);
  animation: gg-pulse 2.4s ease-in-out infinite;
  opacity: 0;
  transition: opacity 1.1s ease;
}

.gg-intro[data-scene="signal"] .gg-intro-signal,
.gg-intro[data-scene="connection"] .gg-intro-signal,
.gg-intro[data-scene="formation"] .gg-intro-signal {
  opacity: 1;
}

/* the ember holds the center through the gather, then hands off to the mark */
.gg-intro[data-mark-ready] .gg-intro-signal,
.gg-intro[data-scene="gateway"] .gg-intro-signal {
  opacity: 0;
  transition: opacity 0.5s ease;
}

@keyframes gg-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px 3px var(--oxblood-dim); }
  50% { transform: scale(1.7); box-shadow: 0 0 26px 9px var(--oxblood-dim); }
}

/* Scene 3 media fragments — brief signals in the periphery, never a montage */
.gg-intro-fragments {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease;
}

.gg-intro[data-scene="formation"] .gg-intro-fragments { opacity: 1; }
.gg-intro[data-scene="gateway"] .gg-intro-fragments { opacity: 0; }

.gg-fragment {
  position: absolute;
  width: 130px;
  aspect-ratio: 16/10;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(135deg, #1c1516, #08090a);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: gg-fragment-in 2.6s ease forwards;
}

.gg-fragment span {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-dim);
  text-align: center;
  padding: 0 10px;
}

.gg-fragment.f1 { top: 20%; left: 14%; animation-delay: 0.15s; }
.gg-fragment.f2 { top: 60%; left: 72%; animation-delay: 0.5s; }
.gg-fragment.f3 { top: 68%; left: 18%; animation-delay: 0.85s; }
.gg-fragment.f4 { top: 16%; left: 68%; animation-delay: 1.2s; }

@keyframes gg-fragment-in {
  0% { opacity: 0; transform: scale(0.94); }
  20% { opacity: 0.6; transform: scale(1); }
  65% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}

/* Real conversation thumbnails — float faded in the background like a credits reel,
   then converge to center in sync with the particle gather/bloom, as if these
   videos are what's forming the mark. Sits behind the canvas so particles/lines
   render on top of them through the canvas's transparent regions. */
.gg-intro-thumbs {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.gg-intro[data-scene="connection"] .gg-intro-thumbs,
.gg-intro[data-scene="formation"] .gg-intro-thumbs {
  opacity: 1;
}

.gg-intro[data-scene="gateway"] .gg-intro-thumbs {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.gg-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  aspect-ratio: 16/9;
  border-radius: 6px;
  overflow: hidden;
  opacity: var(--op, 0.3);
  transform: translate(-50%, -50%) translate(var(--ox), var(--oy)) rotate(var(--rot, 0deg));
  transition: opacity 1s ease, box-shadow 1s ease;
  transition-delay: var(--delay, 0s);
  filter: grayscale(0.32) contrast(0.95) brightness(0.88);
  box-shadow: 0 0 0 0 transparent;
}

/* soft oxblood glow while floating — ties them to the brand mark that's forming */
.gg-intro[data-scene="connection"] .gg-thumb {
  box-shadow: 0 0 14px 2px var(--oxblood-dim);
}

/* desktop/tablet scatter — wide viewport, plenty of periphery room */
.gg-thumb-1 { --ox: -34vw; --oy: -24vh; }
.gg-thumb-2 { --ox: 32vw;  --oy: -21vh; }
.gg-thumb-3 { --ox: -39vw; --oy: 7vh; }
.gg-thumb-4 { --ox: 37vw;  --oy: 9vh; }
.gg-thumb-5 { --ox: -22vw; --oy: 31vh; }
.gg-thumb-6 { --ox: 24vw;  --oy: 29vh; }

/* converge as the network gathers/blooms into the mark — not a straight shrink to
   center, but a swing inward with a brightening oxblood flash partway, as if each
   video gets swept into the ring before collapsing into it. */
.gg-intro[data-scene="formation"] .gg-thumb {
  animation: gg-thumb-converge 1.15s cubic-bezier(0.55, 0, 0.85, 0.35) forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes gg-thumb-converge {
  0% {
    transform: translate(-50%, -50%) translate(var(--ox), var(--oy)) rotate(var(--rot, 0deg)) scale(1);
    opacity: var(--op, 0.3);
    box-shadow: 0 0 14px 2px var(--oxblood-dim);
  }
  45% {
    transform: translate(-50%, -50%) translate(calc(var(--ox) * 0.32), calc(var(--oy) * 0.32)) rotate(calc(var(--rot, 0deg) + 30deg)) scale(0.55);
    opacity: calc(var(--op, 0.3) * 1.8);
    box-shadow: 0 0 28px 6px var(--oxblood-dim);
  }
  100% {
    transform: translate(-50%, -50%) scale(0.08) rotate(calc(var(--rot, 0deg) + 65deg));
    opacity: 0;
    box-shadow: 0 0 0 0 transparent;
  }
}

.gg-thumb-inner {
  position: absolute;
  inset: 0;
  animation: gg-thumb-drift 3.4s ease-in-out both;
}

.gg-thumb-inner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes gg-thumb-drift {
  0% { transform: translateY(-22px); }
  100% { transform: translateY(18px); }
}

/* The GG mark — grows out of the particle ring, then travels home to the header */
.gg-intro-mark {
  --gg-land-x: 0px;
  --gg-land-y: 0px;
  --gg-land-scale: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 160px;
  height: 160px;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  transition:
    opacity 0.7s ease,
    transform 0.9s cubic-bezier(0.22, 1.35, 0.36, 1); /* slight overshoot as it locks in */
}

.gg-intro[data-mark-ready] .gg-intro-mark {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* departure: land exactly on the real header logo's position and size */
.gg-intro[data-scene="gateway"] .gg-intro-mark {
  transition: transform 0.85s cubic-bezier(0.55, 0, 0.15, 1);
  transform:
    translate(calc(-50% + var(--gg-land-x)), calc(-50% + var(--gg-land-y)))
    scale(var(--gg-land-scale));
}

.gg-intro-mark-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 16px rgba(255,255,255,0.28));
}

.gg-intro-mark-glow {
  position: absolute;
  inset: -35%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--oxblood-dim) 0%, rgba(107,31,31,0) 66%);
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.gg-intro[data-mark-ready] .gg-intro-mark-glow { opacity: 0.45; }
.gg-intro[data-scene="gateway"] .gg-intro-mark-glow { opacity: 0; transition: opacity 0.4s ease; }

/* The line — appears once the mark has formed, clears before it departs */
.gg-intro-reveal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 130px));
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.gg-intro-reveal p {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(13px, 2.2vw, 18px);
  letter-spacing: 0.34em;
  color: var(--off-white);
  margin: 0;
  white-space: nowrap;
  text-transform: uppercase;
  transition: letter-spacing 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.gg-intro[data-mark-ready] .gg-intro-reveal {
  opacity: 1;
  transition: opacity 0.7s ease 0.25s;
}

.gg-intro[data-mark-ready] .gg-intro-reveal p { letter-spacing: 0.16em; }

.gg-intro[data-scene="gateway"] .gg-intro-reveal {
  opacity: 0;
  transition: opacity 0.35s ease;
}

/* skip control — visible and focusable from the first frame */
.gg-intro-skip {
  position: absolute;
  bottom: 28px;
  right: 28px;
  z-index: 2;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.gg-intro-skip:hover,
.gg-intro-skip:focus-visible {
  color: var(--white);
  border-color: var(--gray);
  outline: none;
}

/* homepage behind the intro: held a breath back, settles forward as the mark lands */
.gg-intro-stage {
  transform: scale(0.985);
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.gg-intro-stage.gg-stage-settled { transform: scale(1); }

@media (prefers-reduced-motion: reduce) {
  .gg-intro-stage { transform: none; transition: none; }
}

/* simple-fade fallback (reduced motion / low-end) */
.gg-intro[data-mode="simple"] .gg-intro-canvas,
.gg-intro[data-mode="simple"] .gg-intro-fragments,
.gg-intro[data-mode="simple"] .gg-intro-thumbs,
.gg-intro[data-mode="simple"] .gg-intro-signal { display: none; }

.gg-intro[data-mode="simple"] .gg-intro-mark {
  transition: opacity 0.9s ease;
  transform: translate(-50%, -50%) scale(1);
}

.gg-intro[data-mode="simple"][data-mark-ready] .gg-intro-mark { opacity: 1; }
.gg-intro[data-mode="simple"][data-scene="gateway"] .gg-intro-mark { opacity: 0; }

.gg-intro[data-mode="simple"] .gg-intro-reveal p { letter-spacing: 0.16em; transition: none; }

@media (max-width: 720px) {
  .gg-intro-mark { width: 110px; height: 110px; }
  .gg-intro-reveal { transform: translate(-50%, calc(-50% + 100px)); }
  .gg-fragment { width: 92px; }

  /* tighter scatter so it stays fully on-screen — but kept close to desktop's
     visibility now (was overcorrected to near-invisible on the first pass) */
  .gg-thumb {
    width: 82px;
    opacity: calc(var(--op, 0.3) * 0.95);
    filter: grayscale(0.4) contrast(0.92) brightness(0.78);
  }
  .gg-thumb-1 { --ox: -24vw; --oy: -19vh; }
  .gg-thumb-2 { --ox: 24vw;  --oy: -17vh; }
  .gg-thumb-3 { --ox: -26vw; --oy: 4vh; }
  .gg-thumb-4 { --ox: 26vw;  --oy: 6vh; }
  .gg-thumb-5 { --ox: -16vw; --oy: 24vh; }
  .gg-thumb-6 { --ox: 17vw;  --oy: 23vh; }
}
