/* gloop.live: first-impression intro (see js/intro.js).
   Loading screen (particles coalescing into a glowing Gloop) -> title card
   -> lightning flash -> game. Self-contained; reuses gloop.css variables with
   literal fallbacks. Sits below the no-WebGL screens (z 70) and above the HUD. */

.intro {
  --i-bg: #06080b;
  --i-ink: var(--ink, #e8e0d2);
  --i-mute: var(--mute, #8a8278);
  --i-glow: var(--glow, #c4f5c0);
  --i-hot: var(--hot, #e8c07a);
  position: fixed;
  inset: 0;
  z-index: 64;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* viewport-fit=cover: keep content clear of notches / home indicator */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  color: var(--i-ink);
  font-family: var(--font, "IBM Plex Sans", "Segoe UI", sans-serif);
  cursor: progress;
  opacity: 1;
  transition: opacity 0.7s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* opaque night sky while loading; fades away on the title card so the live
   3D land shows through the vignette underneath */
.intro::before,
.intro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.intro::before {
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(196, 245, 192, 0.07), transparent 70%),
    radial-gradient(120% 90% at 50% 20%, #16202b 0%, #0b1017 45%, var(--i-bg) 100%);
  transition: opacity 1.4s ease 0.15s;
}
.intro::after {
  background:
    radial-gradient(75% 65% at 50% 46%, rgba(6, 8, 11, 0.5) 0%, rgba(6, 8, 11, 0.8) 62%, rgba(6, 8, 11, 0.95) 100%);
}
.intro[data-phase="title"]::before,
.intro[data-phase="out"]::before { opacity: 0; }
.intro[data-phase="title"] { cursor: pointer; }
.intro[data-phase="out"] { opacity: 0; pointer-events: none; }
.intro[data-phase="out"].is-quick { transition-duration: 0.3s; }

/* keep the vignette (::after) underneath the particles, status and card */
.intro-sky, .intro-moon, .intro-load { z-index: 1; }

.intro-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* crescent moon, as on the og-image */
.intro-moon {
  position: absolute;
  top: calc(clamp(1.4rem, 9vh, 5rem) + env(safe-area-inset-top, 0px));
  right: calc(clamp(1.4rem, 12vw, 9rem) + env(safe-area-inset-right, 0px));
  width: clamp(28px, 4.2vw, 46px);
  height: clamp(28px, 4.2vw, 46px);
  border-radius: 50%;
  box-shadow: inset calc(clamp(28px, 4.2vw, 46px) * -0.26) calc(clamp(28px, 4.2vw, 46px) * 0.12) 0 0 #d9d1c4;
  filter: drop-shadow(0 0 10px rgba(217, 209, 196, 0.25));
  transform: rotate(-12deg);
  opacity: 0.85;
  pointer-events: none;
}

/* ---- loading status -------------------------------------------------------- */
.intro-load {
  position: absolute;
  left: 50%;
  bottom: calc(clamp(2.2rem, 12vh, 6.5rem) + env(safe-area-inset-bottom, 0px));
  width: min(78vw, 300px);
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  transition: opacity 0.5s ease, transform 0.6s ease;
}
.intro-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--i-mute);
}
.intro-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--i-glow);
  box-shadow: 0 0 10px 2px rgba(196, 245, 192, 0.55);
  animation: intro-pulse 1.3s ease-in-out infinite;
  flex: none;
}
.intro-bar {
  position: relative;
  height: 2px;
  margin: 0.85rem auto 0.7rem;
  border-radius: 2px;
  background: rgba(232, 224, 210, 0.1);
  overflow: hidden;
}
.intro-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p, 6%);
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(196, 245, 192, 0.2), var(--i-glow));
  box-shadow: 0 0 12px rgba(196, 245, 192, 0.7);
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.intro-bar i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: translateX(-100%);
  animation: intro-shimmer 1.4s ease-in-out infinite;
}
.intro-flavour {
  min-height: 1.2em;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: rgba(138, 130, 120, 0.8);
  transition: opacity 0.35s ease;
}
.intro-flavour.is-swap { opacity: 0; }
.intro:not([data-phase="load"]) .intro-load {
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
}

/* ---- title card ------------------------------------------------------------- */
.intro-card {
  position: relative;
  z-index: 2;
  width: min(92vw, 760px);
  padding: 0 0.5rem;
  text-align: center;
  visibility: hidden;
}
.intro[data-phase="title"] .intro-card,
.intro[data-phase="out"] .intro-card { visibility: visible; }
.intro[data-phase="out"] .intro-card {
  transform: scale(1.04);
  filter: blur(3px);
  transition: transform 0.7s ease, filter 0.7s ease;
}

.intro-kicker,
.intro-word span,
.intro-tag > span,
.intro-verbs,
.intro-go,
.intro-hint {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.8s ease;
}
.intro[data-phase="title"] .intro-kicker,
.intro[data-phase="title"] .intro-word span,
.intro[data-phase="title"] .intro-tag > span,
.intro[data-phase="title"] .intro-verbs,
.intro[data-phase="title"] .intro-go,
.intro[data-phase="title"] .intro-hint,
.intro[data-phase="out"] .intro-card * {
  opacity: 1;
  transform: none;
  filter: none;
}

.intro-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 0.4rem;
  font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  font-size: clamp(0.7rem, 2.6vw, 0.85rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--i-mute);
  transition-delay: 0.05s;
}

.intro-word {
  margin: 0;
  font-weight: 700;
  font-size: clamp(4.2rem, 22vw, 11rem);
  line-height: 0.95;
  letter-spacing: 0.035em;
  color: var(--i-ink);
  text-shadow:
    0 0 18px rgba(196, 245, 192, 0.28),
    0 0 60px rgba(196, 245, 192, 0.16);
  white-space: nowrap;
  user-select: none;
}
.intro-word span {
  display: inline-block;
  filter: blur(8px);
  transform: translateY(0.35em) scaleY(0.6);
  transform-origin: 50% 100%;
}
.intro-word span:nth-child(1) { transition-delay: 0.12s; }
.intro-word span:nth-child(2) { transition-delay: 0.2s; }
.intro-word span:nth-child(3) { transition-delay: 0.28s; }
.intro-word span:nth-child(4) { transition-delay: 0.36s; }
.intro-word span:nth-child(5) { transition-delay: 0.44s; }
/* once in, the letters wobble like something not quite solid */
.intro[data-phase="title"].is-settled .intro-word span {
  animation: intro-goo 3.6s ease-in-out infinite;
}
.intro-word span:nth-child(2) { animation-delay: -0.5s; }
.intro-word span:nth-child(3) { animation-delay: -1s; }
.intro-word span:nth-child(4) { animation-delay: -1.5s; }
.intro-word span:nth-child(5) { animation-delay: -2s; }
.intro-word .o { color: var(--i-glow); text-shadow: 0 0 22px rgba(196, 245, 192, 0.55), 0 0 70px rgba(196, 245, 192, 0.3); }

.intro-tag {
  margin: 1rem auto 0;
  font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  font-size: clamp(0.84rem, 3.5vw, 1.12rem);
  line-height: 1.55;
}
.intro-tag > span { display: block; text-wrap: balance; }
.intro-tag .g { color: var(--i-glow); transition-delay: 0.62s; }
.intro-tag .h { color: var(--i-hot); transition-delay: 0.78s; }

.intro-verbs {
  margin: 1.1rem 0 0;
  font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  font-size: clamp(0.62rem, 2.5vw, 0.74rem);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(138, 130, 120, 0.85);
  transition-delay: 0.92s;
}

.intro-go {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin: 1.9rem 0 0;
  padding: 0.85rem 1.6rem 0.85rem 1.75rem;
  border: 1px solid rgba(196, 245, 192, 0.55);
  border-radius: 999px;
  background: rgba(196, 245, 192, 0.08);
  color: var(--i-glow);
  font: 600 0.95rem/1 var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(196, 245, 192, 0.4), inset 0 0 18px rgba(196, 245, 192, 0.08);
  transition-delay: 1.05s;
  transition-property: opacity, transform, background, box-shadow, color;
}
.intro[data-phase="title"].is-settled .intro-go { animation: intro-ring 2.4s ease-out infinite; transition-delay: 0s; }
.intro-go:hover,
.intro-go:focus-visible {
  background: rgba(196, 245, 192, 0.18);
  color: #effff0;
  outline: none;
  box-shadow: 0 0 28px rgba(196, 245, 192, 0.45), inset 0 0 18px rgba(196, 245, 192, 0.15);
}
.intro-go:focus-visible { outline: 1px solid rgba(196, 245, 192, 0.4); outline-offset: 5px; }
.intro-go b { font-weight: 600; transition: transform 0.25s ease; }
.intro-go:hover b { transform: translateX(3px); }

.intro-hint {
  margin: 0.9rem 0 0;
  font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: #aea79d; /* AA contrast on the dark card */
  transition-delay: 1.2s;
}

/* ---- lightning on enter ----------------------------------------------------- */
.intro-flash {
  position: fixed;
  inset: 0;
  z-index: 65;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(120% 90% at 50% 10%, rgba(236, 244, 255, 0.95), rgba(170, 196, 255, 0.55) 45%, rgba(120, 150, 230, 0.15) 100%);
  mix-blend-mode: screen;
}
.intro-flash svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro-flash path {
  fill: none;
  stroke: #f4f8ff;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px #cfe0ff) drop-shadow(0 0 18px #9fbaff);
}
.intro-flash path.fork { stroke-width: 1.2; opacity: 0.8; }
.intro-flash.is-on { animation: intro-flash 0.62s ease-out forwards; }

/* ---- keyframes -------------------------------------------------------------- */
@keyframes intro-pulse {
  0%, 100% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}
@keyframes intro-shimmer {
  to { transform: translateX(100%); }
}
@keyframes intro-goo {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  45% { transform: translateY(-0.03em) scale(0.985, 1.025); }
  70% { transform: translateY(0.012em) scale(1.02, 0.985); }
}
@keyframes intro-ring {
  0% { box-shadow: 0 0 0 0 rgba(196, 245, 192, 0.38), inset 0 0 18px rgba(196, 245, 192, 0.08); }
  70%, 100% { box-shadow: 0 0 0 14px rgba(196, 245, 192, 0), inset 0 0 18px rgba(196, 245, 192, 0.08); }
}
@keyframes intro-flash {
  0% { opacity: 0; }
  8% { opacity: 0.9; }
  18% { opacity: 0.15; }
  28% { opacity: 0.7; }
  100% { opacity: 0; }
}

/* ---- small screens ---------------------------------------------------------- */
@media (max-width: 600px) {
  /* the HUD is dense on phones: dim it harder behind the card */
  .intro::after {
    background: radial-gradient(90% 55% at 50% 48%, rgba(6, 8, 11, 0.7) 0%, rgba(6, 8, 11, 0.88) 70%, rgba(6, 8, 11, 0.96) 100%);
  }
}
@media (max-width: 480px) {
  .intro-go { padding: 0.8rem 1.3rem 0.8rem 1.45rem; font-size: 0.86rem; }
  .intro-tag { max-width: 22em; }
  .intro-verbs { letter-spacing: 0.16em; }
}
@media (max-height: 520px) {
  .intro-word { font-size: clamp(3rem, 16vh, 6rem); }
  .intro-go { margin-top: 1rem; }
  .intro-verbs { display: none; }
}

/* ---- reduced motion: plain fades, no flash, no wobble ----------------------
   .is-rm is set by intro.js from prefers-reduced-motion or GloopLand.reducedMotion() */
.intro.is-rm, .intro.is-rm::before, .intro.is-rm .intro-load,
.intro.is-rm .intro-card *, .intro.is-rm[data-phase="out"] .intro-card {
  transition-duration: 0.2s !important;
  transition-delay: 0s !important;
}
.intro.is-rm .intro-word span, .intro.is-rm .intro-kicker, .intro.is-rm .intro-tag > span,
.intro.is-rm .intro-verbs, .intro.is-rm .intro-go, .intro.is-rm .intro-hint,
.intro.is-rm[data-phase="out"] .intro-card {
  transform: none;
  filter: none;
}
.intro.is-rm .intro-dot, .intro.is-rm .intro-bar i::after,
.intro.is-rm[data-phase="title"].is-settled .intro-word span,
.intro.is-rm[data-phase="title"].is-settled .intro-go { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .intro-flash { display: none; }
}
