/* splash.css — sign-in animation (15-Oct)
   Shown by js/splash.js from the moment sign-in succeeds until the start page
   is ready: the wordmark sweeps in, signal rings pulse out from the logo's
   head (devices checking in), and three steps tick off underneath. The same
   overlay is resumed by index.html, so the hand-off between the two pages is
   seamless. Reduced motion: still logo, steps only. */

.splash {
  --splash-bg: #06201d;   /* deep brand teal (#58b8a8 family) */
  --splash-teal: #7fd3c4;   /* brand teal, lifted to read on the teal backdrop */
  --splash-text: rgba(240, 244, 243, 0.9);
  --splash-dim: rgba(240, 244, 243, 0.42);
  position: fixed; inset: 0; z-index: 5000;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(ellipse 60% 45% at 50% 46%, rgba(88, 184, 168, 0.20), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 46%, transparent 55%, rgba(2, 14, 12, 0.55) 100%),
    var(--splash-bg);
  color: var(--splash-text);
  font-family: 'DM Sans', -apple-system, 'Segoe UI', sans-serif;
  opacity: 1; transition: opacity 420ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.splash.is-leaving { opacity: 0; transform: scale(1.03); pointer-events: none; }
.splash-inner { display: grid; justify-items: center; gap: 34px; width: min(360px, 82vw); }

/* the logo and its signal rings */
.splash-mark { position: relative; width: 100%; aspect-ratio: 512 / 160; }
.splash-logo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  clip-path: inset(0 100% 0 0); animation: splash-reveal 900ms cubic-bezier(0.2, 0.8, 0.2, 1) 120ms forwards;
}
.splash-sweep {
  position: absolute; inset: -10% -6%; pointer-events: none; overflow: hidden;
  -webkit-mask: url('../logo-white.png') center / 88% no-repeat; mask: url('../logo-white.png') center / 88% no-repeat;
}
.splash-sweep::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 30%; left: -40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: splash-sweep 1100ms ease-in-out 1000ms forwards;
}
/* centred on the head (right-hand side of the wordmark) */
.splash-rings { position: absolute; left: 84%; top: 46%; width: 0; height: 0; }
.splash-ring {
  position: absolute; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 50%;
  border: 1.5px solid var(--splash-teal); opacity: 0;
  animation: splash-ring 2400ms cubic-bezier(0.2, 0.7, 0.3, 1) infinite;
}
.splash-ring:nth-child(2) { animation-delay: 800ms; }
.splash-ring:nth-child(3) { animation-delay: 1600ms; }
.splash-node {
  position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--splash-teal); opacity: 0;
  animation: splash-node 2400ms ease-out infinite;
}

/* the steps */
.splash-steps { list-style: none; margin: 0; padding: 0 0 8px; display: grid; gap: 10px; min-width: 220px; }
.splash-steps li {
  display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--splash-dim);
  opacity: 0.45; transform: translateY(4px);
  transition: opacity 300ms ease, transform 300ms ease, color 300ms ease;
}
.splash-steps li.is-active, .splash-steps li.is-done { opacity: 1; transform: none; }
.splash-steps li.is-active { color: var(--splash-text); }
.splash-steps li.is-done { color: var(--splash-dim); }
.splash-tick { position: relative; width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid currentColor; }
.splash-steps li.is-active .splash-tick {
  border-color: rgba(88, 184, 168, 0.25); border-top-color: var(--splash-teal); animation: splash-spin 800ms linear infinite;
}
.splash-steps li.is-done .splash-tick { border-color: var(--splash-teal); background: var(--splash-teal); }
.splash-steps li.is-done .splash-tick::after {
  content: ''; position: absolute; left: 4.5px; top: 1.5px; width: 3.5px; height: 7px;
  border: solid var(--splash-bg); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg);
}

/* resumed on the app page: the logo is already there */
.splash.is-resumed .splash-logo { clip-path: none; animation: none; }
.splash.is-resumed .splash-sweep { display: none; }

@keyframes splash-reveal { to { clip-path: inset(0 0 0 0); } }
@keyframes splash-sweep { to { left: 120%; } }
@keyframes splash-ring {
  0% { transform: scale(0.25); opacity: 0; }
  15% { opacity: 0.55; }
  100% { transform: scale(2.6); opacity: 0; }
}
@keyframes splash-node { 0%, 30% { opacity: 0; } 45% { opacity: 1; } 100% { opacity: 0; } }
@keyframes splash-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .splash, .splash-steps li { transition: none; }
  .splash-logo { clip-path: none; animation: none; }
  .splash-sweep, .splash-rings { display: none; }
  .splash-steps li.is-active .splash-tick { animation: none; border-color: var(--splash-teal); }
}

/* background (js/splash-bg.js): device mesh on a canvas + a faint dot grid */
.splash-bg, .splash-grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.splash-grid {
  background-image: radial-gradient(rgba(143, 224, 209, 0.18) 1px, transparent 1.2px);
  background-size: 26px 26px; background-position: center;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  opacity: 0.55;
}
.splash-inner { position: relative; z-index: 1; }

/* leaving: jump to light speed into the platform (js/splash.js hide).
   CSS animations, so they keep running while the start page renders;
   --warp must match WARP_MS in splash.js. */
.splash { --warp: 950ms; }
.splash-glow, .splash-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; will-change: opacity, transform; }
.splash-glow {
  background: radial-gradient(circle at 50% 46%, rgba(210, 250, 242, 0.55) 0%, rgba(88, 184, 168, 0.18) 28%, transparent 60%);
  transform: scale(0.4);
}
.splash-flash {
  z-index: 2;
  background: radial-gradient(circle at 50% 46%, #ffffff 0%, rgba(205, 248, 240, 0.95) 22%, rgba(88, 184, 168, 0.75) 55%, rgba(6, 32, 29, 0.9) 100%);
}
.splash.is-warping .splash-glow { animation: splash-warp-glow var(--warp) cubic-bezier(0.5, 0, 0.9, 0.4) forwards; }
.splash.is-warping .splash-flash { animation: splash-warp-flash calc(var(--warp) + 180ms) linear forwards; }
.splash.is-warping .splash-steps { opacity: 0; transform: translateY(6px); transition: opacity 220ms ease, transform 220ms ease; }
.splash.is-warping .splash-rings, .splash.is-warping .splash-grid { opacity: 0; transition: opacity 260ms ease; }
.splash.is-warping .splash-logo {
  clip-path: none; will-change: transform, opacity, filter;
  animation: splash-warp-logo var(--warp) cubic-bezier(0.55, 0, 0.9, 0.35) forwards;
}
@keyframes splash-warp-logo {
  0%   { transform: scale(1); opacity: 1; filter: blur(0); }
  60%  { opacity: 0.9; }
  100% { transform: scale(3.2); opacity: 0; filter: blur(8px); }
}
@keyframes splash-warp-glow { to { opacity: 1; transform: scale(1.7); } }
@keyframes splash-warp-flash { 0%, 85% { opacity: 0; } 100% { opacity: 1; } }
.splash.is-leaving { transition-duration: 380ms; }

/* arrived: the app page picking up at the sign-in page's flash (js/splash.js
   resume). The flash settles into a soft glow while the start page loads,
   then the whole overlay dissolves into the platform (is-leaving). */
.splash.is-arrived .splash-inner, .splash.is-arrived .splash-grid, .splash.is-arrived .splash-bg { display: none; }
.splash.is-arrived .splash-flash { opacity: 1; animation: splash-settle 700ms cubic-bezier(0.2, 0.8, 0.2, 1) 60ms forwards; }
@keyframes splash-settle { to { opacity: 0.32; } }
.splash.is-arrived.is-leaving { transition-duration: 520ms; }
/* before the overlay exists (index.html <head> → html.splash-pending), the
   page itself paints the flash, so there is no dark frame in between */
html.splash-pending, html.splash-pending body {
  background: radial-gradient(circle at 50% 46%, #ffffff 0%, rgba(205, 248, 240, 0.95) 22%, rgba(88, 184, 168, 0.75) 55%, rgba(6, 32, 29, 0.9) 100%), #06201d !important;
}

/* arriving: signing out plays the jump backwards (Splash.signOut) */
.splash.is-arriving { animation: splash-arrive-in 220ms ease-out both; }
.splash.is-arriving .splash-rings, .splash.is-arriving .splash-sweep, .splash.is-arriving .splash-steps { display: none; }
.splash.is-arriving .splash-grid { opacity: 0; animation: splash-arrive-in 500ms ease var(--warp) forwards; }
.splash.is-arriving .splash-glow { animation: splash-warp-glow var(--warp) cubic-bezier(0.5, 0, 0.9, 0.4) reverse both; }
.splash.is-arriving .splash-logo {
  clip-path: none; will-change: transform, opacity, filter;
  animation: splash-arrive-logo var(--warp) cubic-bezier(0.1, 0.65, 0.45, 1) both;
}
@keyframes splash-arrive-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes splash-arrive-logo {
  0%   { transform: scale(3.2); opacity: 0; filter: blur(8px); }
  40%  { opacity: 0.9; }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}

@media (prefers-reduced-motion: reduce) {
  .splash.is-warping .splash-logo, .splash.is-arriving .splash-logo { animation: none; }
  .splash-flash, .splash-glow { display: none; }
}
