/*
 * FortuneSpin splash / full-page loader.
 * Used twice with identical markup:
 *   1. index.html  — shown instantly while the JS bundle loads (and while Vite re-optimizes in dev)
 *   2. <FortuneSpinSplash /> (src/components/Loader) — shown while the session loads and as the page loader
 * Lives in /public so it is served immediately, without waiting for the bundler.
 *
 * Colours: the navy of the Midnight Navy theme (src/features/theme/themes.css) with blue light. Gold is left to
 * the logo (the wheel and the wordmark). The value after each comma below is used for the very first paint,
 * before the app's theme stylesheet has loaded: when the theme's navy changes, change these to match, together
 * with theme-color in index.html and the two colours in manifest.webmanifest.
 */
.fs-splash {
  --fs-splash-deep: var(--fs-bg0, #080b14);
  --fs-splash-page: var(--fs-surface, #0b0f1a);
  --fs-splash-mid: var(--fs-raised, #12182a);
  --fs-splash-core: var(--fs-edge, #1d2438);
  --fs-splash-text: var(--fs-mute, #949cb2);
  --fs-splash-light: 110, 168, 255; /* blue light (the theme's --fs-second) as r, g, b: rays, glow, sparkles, bar */
  --fs-splash-light-hi: #dbe8ff;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(var(--fs-splash-light), 0.16), transparent 70%),
    radial-gradient(circle at 50% 42%, var(--fs-splash-core) 0%, var(--fs-splash-mid) 38%, var(--fs-splash-page) 72%, var(--fs-splash-deep) 100%);
  font-family: "Montserrat", "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fs-splash-text);
  animation: fs-splash-in 0.45s ease-out both;
}

/* Slow-turning light rays behind the wheel */
.fs-splash__rays {
  position: absolute;
  top: 42%;
  left: 50%;
  width: 160vmax;
  height: 160vmax;
  margin: -80vmax 0 0 -80vmax;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(var(--fs-splash-light), 0.06) 0deg 6deg,
    transparent 6deg 18deg
  );
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0.45) 18%, transparent 40%);
  mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0.45) 18%, transparent 40%);
  animation: fs-rays 60s linear infinite;
  pointer-events: none;
}

/* Floating sparkles */
.fs-splash__sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.fs-splash__sparkles i {
  position: absolute;
  bottom: -12px;
  width: var(--s, 6px);
  height: var(--s, 6px);
  background: var(--fs-splash-light-hi);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 4px rgba(var(--fs-splash-light), 0.9));
  opacity: 0;
  animation: fs-float var(--d, 7s) linear infinite;
  animation-delay: var(--delay, 0s);
}
.fs-splash__sparkles i:nth-child(1)  { left: 8%;  --s: 6px;  --d: 8s;   --delay: 0s; }
.fs-splash__sparkles i:nth-child(2)  { left: 17%; --s: 9px;  --d: 9.5s; --delay: 2.4s; }
.fs-splash__sparkles i:nth-child(3)  { left: 26%; --s: 5px;  --d: 7s;   --delay: 4.1s; }
.fs-splash__sparkles i:nth-child(4)  { left: 37%; --s: 8px;  --d: 10s;  --delay: 1.2s; }
.fs-splash__sparkles i:nth-child(5)  { left: 46%; --s: 5px;  --d: 8.5s; --delay: 5.6s; }
.fs-splash__sparkles i:nth-child(6)  { left: 57%; --s: 10px; --d: 9s;   --delay: 3.3s; }
.fs-splash__sparkles i:nth-child(7)  { left: 66%; --s: 6px;  --d: 7.5s; --delay: 0.7s; }
.fs-splash__sparkles i:nth-child(8)  { left: 75%; --s: 8px;  --d: 10.5s;--delay: 4.8s; }
.fs-splash__sparkles i:nth-child(9)  { left: 84%; --s: 5px;  --d: 8s;   --delay: 2s; }
.fs-splash__sparkles i:nth-child(10) { left: 93%; --s: 7px;  --d: 9s;   --delay: 6.2s; }

/* Wheel */
.fs-splash__stage {
  position: relative;
  width: clamp(150px, 34vmin, 230px);
  aspect-ratio: 1;
  animation: fs-bob 3.6s ease-in-out infinite;
}
.fs-splash__stage::before {
  /* blue glow under the wheel */
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--fs-splash-light), 0.5), rgba(var(--fs-splash-light), 0) 68%);
  filter: blur(18px);
  animation: fs-glow 1.8s ease-in-out infinite alternate;
}
.fs-splash__wheel {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.55));
}

/* Wordmark + progress */
.fs-splash__brand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.fs-splash__wordmark {
  display: block;
  width: clamp(200px, 52vmin, 300px);
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}
.fs-splash__bar {
  position: relative;
  width: clamp(150px, 36vmin, 210px);
  height: 4px;
  border-radius: 999px;
  background: rgba(var(--fs-splash-light), 0.16);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.fs-splash__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgb(var(--fs-splash-light)), var(--fs-splash-light-hi), rgb(var(--fs-splash-light)), transparent);
  box-shadow: 0 0 10px rgba(var(--fs-splash-light), 0.6);
  animation: fs-bar 1.5s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.fs-splash__caption {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--fs-splash-text);
  opacity: 0.9;
  padding-left: 0.32em; /* optical centring for the letter-spacing */
}

@keyframes fs-splash-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fs-rays { to { transform: rotate(360deg); } }
@keyframes fs-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes fs-glow { from { opacity: 0.55; transform: scale(0.94); } to { opacity: 1; transform: scale(1.06); } }
@keyframes fs-bar { from { transform: translateX(-110%); } to { transform: translateX(250%); } }
@keyframes fs-float {
  0%   { transform: translateY(0) rotate(0deg) scale(0.6); opacity: 0; }
  12%  { opacity: 0.9; }
  70%  { opacity: 0.6; }
  100% { transform: translateY(-105vh) rotate(220deg) scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .fs-splash, .fs-splash__rays, .fs-splash__stage, .fs-splash__stage::before { animation: none; }
  .fs-splash__sparkles { display: none; }
  .fs-splash__bar::after { animation-duration: 3s; }
}
