/* =========================================================
   Intro gate
   Requires base.css, layout.css, sequence.css

   The markup ships with [hidden]; intro.js removes it only when the gate
   should actually run. Without JS the visitor never sees this layer.
   ========================================================= */

.intro[hidden] {
  display: none;
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(var(--surface-rgb), 1) 0%, rgba(var(--surface-rgb), 0) 58%),
    radial-gradient(circle at 78% 8%, rgba(49, 130, 246, 0.14), transparent 40%),
    radial-gradient(circle at 14% 84%, rgba(34, 211, 238, 0.1), transparent 38%),
    var(--page-bg);
}

body.intro-active {
  overflow: hidden;
}

/* The hero cube is held back so the intro cube can land on it. */
body.intro-active .scrollstage .hero-visual {
  opacity: 0;
}

/* ---------------------------------------------------------
   Backdrop: receding perspective grid
   --------------------------------------------------------- */
.intro-grid {
  position: absolute;
  inset: 0;
  overflow: hidden;
  perspective: 700px;
  pointer-events: none;
}

.intro-grid::before {
  content: "";
  position: absolute;
  right: -60%;
  bottom: -24%;
  left: -60%;
  height: 130%;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.1) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: rotateX(74deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 62%);
  mask-image: linear-gradient(to top, #000 0%, transparent 62%);
  transition:
    transform 900ms var(--ease),
    opacity 640ms var(--ease);
}

.intro.is-leaving .intro-grid::before {
  transform: rotateX(74deg) translateY(-34%) scale(1.35);
  opacity: 0;
}

/* ---------------------------------------------------------
   Light burst on enter
   --------------------------------------------------------- */
.intro-burst {
  position: absolute;
  top: 44%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
  background: radial-gradient(
    circle,
    rgba(120, 180, 255, 0.5),
    rgba(34, 211, 238, 0.22) 42%,
    transparent 70%
  );
}

.intro.is-leaving .intro-burst {
  animation: intro-burst 820ms var(--ease) forwards;
}

@keyframes intro-burst {
  0% {
    opacity: 0.85;
    transform: scale(0);
  }
  100% {
    opacity: 0;
    transform: scale(170);
  }
}

/* ---------------------------------------------------------
   Content
   --------------------------------------------------------- */
.intro-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-inline: var(--gutter);
}

.intro-cube {
  position: relative;
  width: min(420px, 56vw);
  aspect-ratio: 1 / 1;
  margin-bottom: clamp(8px, 2vw, 24px);
  will-change: transform;
}

.intro-cube img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: icon-float 6.5s ease-in-out infinite;
}

.intro-cube::before {
  content: "";
  position: absolute;
  inset: -10%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 46%,
    rgba(49, 130, 246, 0.26),
    rgba(34, 211, 238, 0.1) 46%,
    transparent 68%
  );
}

.intro-orbit {
  position: absolute;
  inset: 2%;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 50%;
  transition: transform 420ms var(--ease), border-color 420ms var(--ease);
}

.intro-orbit:nth-of-type(2) {
  inset: 15%;
  border-color: rgba(34, 211, 238, 0.2);
}

.intro-name {
  font-size: clamp(30px, 4.6vw, 44px);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.intro-role {
  margin-top: var(--space-2);
  color: var(--text-secondary);
  font-size: clamp(15px, 1.6vw, 18px);
  font-weight: 550;
}

.intro-enter {
  margin-top: clamp(24px, 3vw, 36px);
}

/* Orbits respond to the button, tying the two together. */
.intro-inner:has(.intro-enter:hover) .intro-orbit {
  transform: scale(1.06);
  border-color: rgba(37, 99, 235, 0.3);
}

.intro-hint {
  margin-top: var(--space-5);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ---------------------------------------------------------
   Stray-click feedback
   Only the button and Escape enter. A click anywhere else answers
   with a ripple and points at the button, so it never reads as dead.
   --------------------------------------------------------- */
.intro-ripple {
  position: absolute;
  z-index: 3;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle,
    rgba(49, 130, 246, 0.34),
    rgba(34, 211, 238, 0.16) 45%,
    transparent 70%
  );
  animation: intro-ripple 620ms var(--ease) forwards;
}

@keyframes intro-ripple {
  0% {
    opacity: 0.9;
    transform: scale(0.4);
  }
  100% {
    opacity: 0;
    transform: scale(16);
  }
}

.intro-enter.is-nudged {
  animation: intro-nudge 520ms var(--ease);
}

@keyframes intro-nudge {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.24);
  }
  38% {
    transform: translateY(-4px) scale(1.035);
    box-shadow: 0 20px 44px rgba(37, 99, 235, 0.36);
  }
}

/* ---------------------------------------------------------
   Exit
   --------------------------------------------------------- */
.intro.is-leaving .intro-name,
.intro.is-leaving .intro-role,
.intro.is-leaving .intro-enter,
.intro.is-leaving .intro-hint,
.intro.is-leaving .intro-orbit {
  opacity: 0;
  transition: opacity 260ms ease;
}

.intro.is-leaving {
  background: transparent;
  transition: background 620ms ease 180ms;
}

@media (max-width: 767px) {
  .intro-cube {
    width: min(300px, 66vw);
  }
}
