:root {
  --bg: #05050f;
  --fg: #f6f4ff;
  --muted: rgba(246, 244, 255, 0.6);
  --subtle: rgba(246, 244, 255, 0.3);
  --cyan: #7cf0ff;
  --violet: #c084ff;
  --magenta: #ff6fd8;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --mx: 50%;
  --my: 50%;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(1200px 700px at 15% 10%, rgba(124, 240, 255, 0.09), transparent 60%),
    radial-gradient(1100px 800px at 85% 95%, rgba(255, 111, 216, 0.08), transparent 60%),
    radial-gradient(900px 600px at 50% 50%, rgba(192, 132, 255, 0.05), transparent 70%),
    var(--bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.55));
}

.cursor-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    420px circle at var(--mx) var(--my),
    rgba(192, 132, 255, 0.18),
    rgba(124, 240, 255, 0.08) 30%,
    transparent 60%
  );
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 3vh, 2.5rem);
  padding: 2rem;
  pointer-events: none;
}

/* ============================================================
   Title
   ============================================================ */
.title {
  position: relative;
  margin: 0;
  font-weight: 800;
  font-size: clamp(2rem, 10.5vw, 8.5rem);
  letter-spacing: -0.04em;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  animation: titleFloat 7s ease-in-out 1.6s infinite;
  will-change: transform;
}

/* When JS splits the title into letters, this class is added and
   the raw text node disappears. Before JS runs we still want the
   raw text to look good, so keep a minimal fallback below. */
.title:not(.split) {
  background: linear-gradient(92deg, var(--cyan), var(--violet) 48%, var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  opacity: 0.85;
}

.letter {
  display: inline-block;
  background: linear-gradient(
    180deg,
    hsl(calc(188 + var(--i, 0) * 10), 92%, 72%) 0%,
    hsl(calc(270 + var(--i, 0) * 6), 84%, 70%) 55%,
    hsl(calc(322 + var(--i, 0) * 3), 92%, 72%) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  opacity: 0;
  transform: translateY(40px) scale(0.7);
  filter: blur(10px);
  animation: letterIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(0.08s + var(--i, 0) * 0.05s);
}

.letter.dot {
  background: radial-gradient(circle, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
}

@keyframes letterIn {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.7);
    filter: blur(10px);
  }
  60% {
    opacity: 1;
    transform: translateY(-4px) scale(1.04);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ============================================================
   Subtitle
   ============================================================ */
.subtitle {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: clamp(0.85rem, 1.3vw + 0.35rem, 1.1rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  opacity: 0;
  animation: fadeSlide 0.7s 1.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  white-space: nowrap;
}

.prompt {
  color: var(--cyan);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(124, 240, 255, 0.5);
}

.subtitle-text { display: inline-flex; }

.sub-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(4px);
  animation: subLetterIn 0.35s cubic-bezier(0.33, 1, 0.68, 1) forwards;
  animation-delay: calc(1.6s + var(--i, 0) * 0.04s);
}

@keyframes subLetterIn {
  to { opacity: 1; transform: translateY(0); }
}

.caret {
  display: inline-block;
  width: 0.5em;
  height: 1em;
  background: var(--cyan);
  margin-left: 0.2em;
  box-shadow: 0 0 8px rgba(124, 240, 255, 0.5);
  opacity: 0;
  animation:
    caretIn 0.3s 2.2s ease-out forwards,
    caretBlink 1.05s 2.5s steps(2, end) infinite;
}

@keyframes caretIn { to { opacity: 1; } }
@keyframes caretBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 1.2rem 1rem calc(1.2rem + var(--safe-b));
  text-align: center;
  opacity: 0;
  animation: fadeSlide 0.9s 2.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
}

.footer p {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  font-style: italic;
  color: var(--subtle);
  letter-spacing: 0.03em;
}

/* ============================================================
   Reduced motion + responsive
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .title { animation: none; }
  .letter {
    animation: letterInReduced 0.25s ease-out forwards;
    animation-delay: calc(var(--i, 0) * 0.02s);
    filter: none;
  }
  .sub-letter { animation-duration: 0.2s; }
  .caret { animation: caretIn 0.2s forwards; }
  .cursor-glow { transition: none; }
}

@keyframes letterInReduced {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .title { letter-spacing: -0.05em; }
  .footer p { font-size: 0.62rem; letter-spacing: 0.02em; }
  .cursor-glow { display: none; }
}
