:root {
  --ink: #ffffff;
  --sky-top: #2f62a8;
  --sky-low: #bcd3e4;
  --water: #3f7198;
  --deep: #173a57;
  --first: #7b9eca;
}
/* Without WebGL the page stays a still picture: sky, horizon, water. */
body[data-state="fallback"] {
  background: linear-gradient(to bottom,
    var(--sky-top) 0%, var(--sky-low) 54%, var(--water) 55%, var(--deep) 100%);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100dvh; overflow: hidden;
  overscroll-behavior: none; touch-action: none;
}
html { background: var(--first); }
body {
  /* First paint: one calm colour with the words on it; the scene fades in behind them. */
  background: var(--first);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  -webkit-font-smoothing: antialiased;
}
#scene {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; transition: opacity 1.8s cubic-bezier(.4, 0, .2, 1);
}
body.ready #scene { opacity: 1; }
body[data-state="fallback"] #scene { display: none; }

/* The words begin in the middle of the view. */
#words {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center;
  padding: 0 1.5rem 22vh; text-align: center; pointer-events: none;
  text-shadow: 0 1px 2px rgba(12, 40, 70, 0.28), 0 0 28px rgba(12, 40, 70, 0.42);
}
#name {
  margin: 0; font-weight: 400; font-size: clamp(2rem, 1.3rem + 3.4vw, 4.25rem);
  letter-spacing: 0.2em; text-indent: 0.2em; line-height: 1.1;
  opacity: 0; transform: translateY(6px); transition: opacity 2.2s ease, transform 2.6s cubic-bezier(.2, .6, .2, 1);
}
#line {
  margin: 0.9rem 0 0; font-size: clamp(0.95rem, 0.85rem + 0.45vw, 1.3rem);
  font-style: italic; letter-spacing: 0.03em;
  opacity: 0; transition: opacity 2.2s ease 0.6s;
}
body[data-state="arriving"] #name, body[data-state="shore"] #name, body[data-state="invite"] #name, body[data-state="fallback"] #name { opacity: 1; transform: none; }
body[data-state="arriving"] #line, body[data-state="shore"] #line, body[data-state="invite"] #line, body[data-state="fallback"] #line { opacity: 0.92; }
/* On takeoff they lift away... */
body[data-state="flight"] #name, body[data-state="flight"] #line {
  opacity: 0; transform: translateY(-14px); transition: opacity 1.3s ease, transform 1.6s ease-in;
}
/* ...and the name alone returns, small, in the corner. */
#mark {
  position: fixed; margin: 0; pointer-events: none;
  right: max(1.6rem, env(safe-area-inset-right)); bottom: max(1.4rem, env(safe-area-inset-bottom));
  font-size: clamp(0.8rem, 0.76rem + 0.2vw, 0.95rem); letter-spacing: 0.22em;
  text-shadow: 0 1px 2px rgba(12, 40, 70, 0.3), 0 0 16px rgba(12, 40, 70, 0.45);
  opacity: 0; transition: opacity 0.6s ease;
}
body[data-state="flight"] #mark { opacity: 0.85; transition: opacity 2.4s ease 2.2s; }

#invite {
  position: fixed; left: 50%; bottom: max(2.25rem, env(safe-area-inset-bottom));
  width: 44px; height: 44px; margin-left: -22px; padding: 0;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; color: var(--ink); cursor: pointer;
  filter: drop-shadow(0 0 8px rgba(12, 40, 70, 0.5));
  opacity: 0; visibility: hidden; transition: opacity 1.6s ease, visibility 0s linear 1.6s;
}
body[data-state="invite"] #invite { opacity: 0.85; visibility: visible; transition-delay: 0s; }
#invite svg { animation: drift 3.2s ease-in-out infinite; }
#invite.pulse svg { animation: drift 3.2s ease-in-out infinite, pulse 1.4s ease-out 1; }
#invite:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
@keyframes drift { 0%, 100% { transform: translateY(2px); } 50% { transform: translateY(-4px); } }
@keyframes pulse { 0% { opacity: 1; } 35% { opacity: 0.25; } 100% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  #invite svg, #invite.pulse svg { animation: none; }
  #name, body[data-state="flight"] #name, body[data-state="flight"] #line { transform: none; }
}

/* The words are there from the first paint, coming up gently rather than with the scene. */
@keyframes appear { from { opacity: 0; } }
body[data-state="arriving"] #name { animation: appear 1.2s ease both; }
body[data-state="arriving"] #line { animation: appear 1.2s ease 0.3s both; }
