/* OpenLock cold-start splash.
 *
 * Shown from the very first paint (the static #splash markup lives in index.html)
 * until app.js boots and removes it. This file sits at the site root and is loaded
 * via a same-origin <link> in <head>, so it paints BEFORE the content-hashed JS/CSS
 * bundle finishes loading — which is what kills the blank-white flash on a cold PWA
 * launch. CSP-safe: an external stylesheet, no inline styles anywhere.
 *
 * Design note: the splash is ALWAYS the dark brand design (matches the app's default
 * dark theme + the manifest background_color, so it blends with the OS splash). The
 * animations below are purely additive — the logo and wordmark sit visible at rest, so
 * the splash always SHOWS even if the animation engine is disabled; motion is a bonus,
 * never a prerequisite for content appearing. */

#splash {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #0f1115; /* matches manifest background_color + the OS splash on Android */
  color: #f1f2f5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  opacity: 1;
  transition: opacity 0.32s ease;
  -webkit-tap-highlight-color: transparent;
  /* Safety net: if the JS bundle never boots (blocked/broken), don't trap the user
     behind a frozen splash forever — fade it away after a long grace period so the
     app shell (or the <noscript> notice) becomes reachable. The normal path removes
     this node within a few hundred ms, long before this delay elapses. */
  animation: splash-failsafe 0.4s ease 12s forwards;
}

.splash-logo {
  width: 84px;
  height: 84px;
  filter: drop-shadow(0 8px 26px rgba(228, 192, 116, 0.35)); /* soft gold glow = app accent */
  /* default animation fill-mode (none) → at rest the logo is fully visible, so a
     missing/disabled animation can never leave it invisible. */
  animation: splash-rise 0.45s ease-out;
}

.splash-word {
  font: 600 19px/1 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  letter-spacing: 0.04em;
  animation: splash-rise 0.45s ease-out 0.06s;
}

.splash-spin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(228, 192, 116, 0.25);
  border-top-color: #e4c074;
  animation: splash-spin 0.8s linear infinite;
}

@keyframes splash-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes splash-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes splash-failsafe {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* app.js adds this once the app has rendered, then removes the node after the fade. */
#splash.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Respect reduced-motion: no spin / rise (everything still shows, just static). */
@media (prefers-reduced-motion: reduce) {
  .splash-logo,
  .splash-word {
    animation: none;
  }
  .splash-spin {
    animation: none;
    border-color: #e4c074;
  }
}
