/* XEL — the arrival (first-visit cinematic overlay).
   sits just under the boot veil, above everything else, briefly.
   passive: pointer-events exist solely so a click can skip it — and they
   are surrendered the moment the iris opens, so the live page (and xel's
   greeting bubble) is clickable while the last line bows out. */

.xi {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-boot) - 1);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.45s ease;
  font-family: var(--font-display);
  -webkit-user-select: none;
  user-select: none;
}

.xi.xi-on { opacity: 1; }

/* the graceful exit — skip or natural end, same fade */
.xi.xi-out {
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

/* iris open = the page is back. clicks pass through; the overlay is now
   scenery, not a wall. (Escape/space still skip via the window listener.) */
.xi.xi-iris {
  pointer-events: none;
  cursor: default;
}

/* ------------------------------------------------ the void (backdrop) */

.xi-back {
  position: absolute;
  inset: 0;
  background: #040210; /* a shade past --bg-deep. the spare room. */
}

/* ------------------------------------------------ stars: three, faint */

.xi-star {
  position: absolute;
  border-radius: 50%;
  background: var(--ink-dim);
  opacity: 0.18;
  animation: xi-twinkle 3.4s ease-in-out infinite alternate;
  transition: opacity 0.6s ease;
}

.xi.xi-iris .xi-star { opacity: 0; }

@keyframes xi-twinkle {
  from { opacity: 0.1; transform: scale(0.85); }
  to   { opacity: 0.32; transform: scale(1.15); }
}

/* ------------------------------------------------ the speck */

/* macro position: JS drives --sx/--sy, the transform transition does the travel */
.xi-speck {
  position: fixed;
  left: 0;
  top: 0;
  opacity: 0;
  transform: translate3d(var(--sx, -12vmax), var(--sy, -12vmax), 0);
  transition: transform 1s cubic-bezier(0.3, 0.75, 0.35, 1), opacity 0.5s ease;
  will-change: transform, opacity;
}

.xi.xi-p2 .xi-speck { opacity: 1; }

/* settling: shorter, smoother, more certain. almost like it understands momentum. */
.xi.xi-settle .xi-speck {
  transition: transform 0.6s var(--ease-smooth), opacity 0.5s ease;
}

/* the handoff: fade out exactly over the real canvas speck */
.xi.xi-iris .xi-speck {
  opacity: 0;
  transition: transform 0.6s var(--ease-smooth), opacity 0.55s ease 0.1s;
}

/* wobble layer — it does not fully understand momentum yet */
.xi-speck-wob {
  animation: xi-wobble 2.7s ease-in-out infinite;
}

.xi.xi-settle .xi-speck-wob {
  animation: xi-wobble-soft 3.6s ease-in-out infinite;
}

@keyframes xi-wobble {
  0%   { transform: translate(0, 0) rotate(0deg); }
  17%  { transform: translate(9px, -7px) rotate(4deg); }
  36%  { transform: translate(-8px, 5px) rotate(-5deg); }
  54%  { transform: translate(6px, 9px) rotate(2deg); }
  77%  { transform: translate(-9px, -6px) rotate(-3deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes xi-wobble-soft {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(3px, -2px); }
  66%  { transform: translate(-2px, 2px); }
  100% { transform: translate(0, 0); }
}

/* the glowing dot itself; --xi-glow is sized from the live #xel-stage rect */
.xi-speck-core {
  width: var(--xi-glow, 44px);
  height: var(--xi-glow, 44px);
  margin-left: calc(var(--xi-glow, 44px) / -2);
  margin-top: calc(var(--xi-glow, 44px) / -2);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #ffffff 0 11%,
    var(--seafoam) 24%,
    rgba(92, 225, 255, 0.45) 46%,
    rgba(92, 225, 255, 0) 70%
  );
  animation: xi-breathe 1.9s ease-in-out infinite;
}

@keyframes xi-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

/* ------------------------------------------------ the lines */

.xi-line {
  position: absolute;
  left: 50%;
  bottom: 26%;
  transform: translate(-50%, 10px);
  max-width: min(82vw, 34rem);
  margin: 0;
  text-align: center;
  font-size: clamp(1.05rem, 2.6vw, 1.45rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 0 0 18px rgba(125, 249, 224, 0.25);
  opacity: 0;
  transition: opacity 0.55s ease, transform 0.55s var(--ease-smooth);
}

.xi-line.xi-line-show {
  opacity: 0.92;
  transform: translate(-50%, 0);
}

.xi-line.xi-line-small {
  font-size: clamp(0.85rem, 1.9vw, 1.05rem);
  color: var(--ink-dim);
  letter-spacing: 0.06em;
}

/* ------------------------------------------------ reduced-motion card */

.xi.xi-rm .xi-star { animation: none; opacity: 0.22; }

.xi-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: min(84vw, 32rem);
  padding: 1.6rem 2rem;
  text-align: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
}

.xi-card-line {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.3rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.xi-card-line-small {
  margin-top: 0.9rem;
  font-size: clamp(0.8rem, 1.8vw, 0.95rem);
  color: var(--ink-dim);
  letter-spacing: 0.06em;
}

/* belt and braces: even if JS ever ran the cinematic under reduced motion,
   the keyframes go still. opacity fades stay — function, not fireworks. */
@media (prefers-reduced-motion: reduce) {
  .xi-star,
  .xi-speck-wob,
  .xi-speck-core {
    animation: none;
  }
  .xi-speck {
    transition: opacity 0.6s ease;
  }
  .xi-line {
    transition: opacity 0.55s ease;
    transform: translate(-50%, 0);
  }
}

/* ------------------------------------------------ crawlable homepage context */

.xel-seo-intro {
  width: min(94vw, 760px);
  padding: 0.65rem 1rem 0.75rem;
  text-align: center;
  background: rgba(22, 13, 52, 0.52);
  border: 1px solid rgba(157, 123, 255, 0.24);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 28px rgba(5, 2, 20, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.xel-seo-intro h1 {
  color: var(--ink);
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  line-height: 1.2;
  letter-spacing: 0.025em;
}

.xel-seo-intro p {
  max-width: 680px;
  margin: 0.22rem auto 0;
  color: var(--ink-dim);
  font-size: 0.84rem;
  line-height: 1.4;
}

.xel-seo-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.85rem;
  margin-top: 0.38rem;
  font-family: var(--font-display);
  font-size: 0.76rem;
}

.xel-seo-links a {
  color: var(--seafoam);
  border-bottom: 1px dotted rgba(125, 249, 224, 0.45);
}

.xel-seo-links a:hover {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

@media (max-width: 640px) {
  .xel-seo-intro {
    padding: 0.55rem 0.75rem 0.65rem;
  }

  .xel-seo-intro p {
    font-size: 0.78rem;
  }

  .xel-seo-links {
    gap: 0.2rem 0.7rem;
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xel-seo-links a {
    transition: none;
  }
}
