/* Words and controls over the 3D welcome. The palace and sky live in world/. */
#magical-welcome {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.mw {
  --pink: #f4a9c6;
  --lav: #b9a3f0;
  --plum: #24143d;
  --gold: #ffd76a;
  --cream: #fff5e6;
  --soft: cubic-bezier(0.4, 0, 0.2, 1);
  --land: cubic-bezier(0.05, 0.7, 0.1, 1);
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding:
    max(1.6rem, env(safe-area-inset-top))
    1.2rem
    max(1.4rem, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--cream);
  font-family: Figtree, system-ui, sans-serif;
  background:
    radial-gradient(120% 42% at 50% 0%, rgba(18, 8, 36, 0.55), transparent 70%),
    radial-gradient(120% 34% at 50% 100%, rgba(18, 8, 36, 0.6), transparent 72%);
}

.mw-copy { margin-top: 0.2rem; }
.mw-copy__kicker {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.15rem, 3.6vw, 1.85rem);
  letter-spacing: 0.01em;
  color: var(--pink);
  text-shadow: 0 0 18px rgba(244, 169, 198, 0.5), 0 1px 2px rgba(18, 8, 36, 0.6);
}
.mw-copy__hello {
  margin: 0.1rem 0 0;
  font-family: "Great Vibes", "Cormorant Garamond", cursive;
  font-weight: 400;
  font-size: clamp(2.6rem, 10vw, 5.6rem);
  line-height: 1.15;
  padding: 0 0.3em;
  color: var(--cream);
  text-shadow: 0 0 26px rgba(255, 215, 106, 0.55), 0 2px 3px rgba(18, 8, 36, 0.55);
}

.mw-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: min(100%, 21rem);
  pointer-events: auto;
}
.mw-voice { display: flex; gap: 0.6rem; }
.mw-voice audio { display: none; }
.mw-voice[hidden],
.mw-enter[hidden],
.mw-gate[hidden] { display: none; }

.mw-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.mw-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
}
.mw-gate__q {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.05rem, 3.4vw, 1.35rem);
  line-height: 1.35;
  color: var(--cream);
  text-shadow: 0 2px 12px rgba(18, 8, 36, 0.65);
}
.mw-gate__field { display: block; width: 100%; }
.mw-gate input {
  width: 100%;
  min-height: 52px;
  padding: 0.75rem 1.1rem;
  border: 1px solid rgba(255, 215, 106, 0.45);
  border-radius: 999px;
  background: rgba(36, 20, 61, 0.62);
  color: var(--cream);
  font: 500 1rem/1.2 Figtree, system-ui, sans-serif;
  text-align: center;
  outline: none;
}
.mw-gate input::placeholder { color: rgba(255, 245, 230, 0.45); }
.mw-gate input:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 215, 106, 0.28);
}
.mw-gate__hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--pink);
  text-shadow: 0 1px 8px rgba(18, 8, 36, 0.6);
}
.mw-icon {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 245, 230, 0.32);
  background: rgba(36, 20, 61, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--cream);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background-color 0.12s var(--soft), transform 0.12s var(--soft);
}
.mw-icon:hover { background: rgba(36, 20, 61, 0.75); }
.mw-icon:active { transform: scale(0.94); }
.mw-icon[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.mw-icon:focus-visible,
.mw-enter:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.mw-enter {
  appearance: none;
  border: 0;
  cursor: pointer;
  min-height: 52px;
  padding: 0.9rem 1.4rem;
  width: 100%;
  border-radius: 999px;
  font: 600 1.02rem/1 Figtree, sans-serif;
  color: var(--plum);
  background: linear-gradient(180deg, #ffeeb4, #ffd76a 60%, #f4b94e);
  box-shadow: 0 0 0 1px rgba(255, 215, 106, 0.45), 0 12px 30px rgba(255, 190, 90, 0.3);
  transition: transform 0.15s var(--soft), box-shadow 0.15s var(--soft);
  touch-action: manipulation;
}
.mw-enter:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(255, 215, 106, 0.6), 0 16px 36px rgba(255, 190, 90, 0.42); }
.mw-enter:active,
.mw-enter.is-pressed { transform: scale(0.97); }

/* Entrance: held until the 3D world is ready, then one sequence */
.mw-copy__kicker,
.mw-actions { opacity: 0; transform: translateY(14px); }
.mw-copy__hello { clip-path: inset(-20% 100% -20% 0); }
body.is-ready .mw-copy__kicker { animation: mw-rise 0.7s var(--land) 1.1s both; }
body.is-ready .mw-copy__hello { animation: mw-write 1.3s cubic-bezier(0.45, 0, 0.25, 1) 1.6s both; }
body.is-ready .mw-actions { animation: mw-rise 0.6s var(--land) 2.6s both; }

@keyframes mw-rise { to { opacity: 1; transform: none; } }
@keyframes mw-write {
  from { clip-path: inset(-20% 100% -20% 0); filter: blur(3px); }
  to { clip-path: inset(-20% -5% -20% 0); filter: blur(0); }
}

/* Leaving: words lift away fast so the flight has the screen */
body.mw-leaving .mw-copy,
body.mw-leaving .mw-actions {
  animation: mw-leave 0.38s cubic-bezier(0.3, 0, 1, 1) forwards;
}
body.mw-leaving .mw { background: transparent; transition: background 0.4s; }
body.mw-leaving .mw-actions { pointer-events: none; }
@keyframes mw-leave { to { opacity: 0; transform: translateY(-18px); } }

@media (max-width: 720px) {
  .mw-copy__hello { font-size: clamp(2.5rem, 13vw, 3.6rem); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .mw { padding-top: 0.8rem; padding-bottom: 0.8rem; }
  .mw-copy__hello { font-size: 2.6rem; }
  .mw-actions { flex-direction: row; width: auto; }
  .mw-enter { width: auto; }
  .mw-actions:has(.mw-gate:not([hidden])) {
    flex-direction: column;
    width: min(92vw, 22rem);
  }
  .mw-gate .mw-enter { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .mw-copy__kicker,
  .mw-actions,
  body.is-ready .mw-copy__kicker,
  body.is-ready .mw-actions { animation: none; opacity: 1; transform: none; }
  .mw-copy__hello,
  body.is-ready .mw-copy__hello { animation: none; clip-path: none; }
  body.mw-leaving .mw-copy,
  body.mw-leaving .mw-actions { animation: none; opacity: 0; transition: opacity 0.2s linear; }
}
