/* =======================================================================
   EPI ONE - Premium Progressive Puzzle Construction Splash Screen
   Visual Storytelling Sequence:
   - STAGE 1 (0.0s - 0.5s): Discovery — Faint 90° orthogonal tracks fade in
   - STAGE 2 (0.5s - 1.2s): Arrows travel along maze paths
   - STAGE 3 (1.2s - 2.0s): Progressive E construction (Spine -> Top -> Mid -> Bottom)
   - STAGE 4 (2.0s - 2.5s): Sequential arrival of final pieces -> 2.45s final snap
   - STAGE 5 (2.5s - 3.2s+): Stabilized brand reveal + typography slide
   ======================================================================= */

/* Host element */
body fuse-splash-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #faf8ff 50%, #f3f0ff 100%);
  z-index: 999999;
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  transition: opacity 450ms cubic-bezier(0.16, 1, 0.3, 1),
              visibility 450ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

body fuse-splash-screen .spinner {
  display: none !important;
}

body:not(.fuse-splash-screen-hidden),
body:has(fuse-splash-screen:not(.epi-splash-fade-out)) {
  overflow: hidden;
}

body fuse-splash-screen.epi-splash-fade-out {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ── Central Stage Container ── */
fuse-splash-screen .epi-splash {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 500px;
  height: 500px;
  max-width: 90vw;
  max-height: 90vw;
}

/* ── Ambient Radial Glow ── */
fuse-splash-screen .epi-splash__glow {
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  background: radial-gradient(
    ellipse 60% 60% at 50% 50%,
    rgba(124, 58, 237, 0.10) 0%,
    rgba(99, 102, 241, 0.04) 50%,
    transparent 70%
  );
  animation: epi-ambient-breath 3.5s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes epi-ambient-breath {
  0%   { opacity: 0.5; transform: scale(0.95); }
  100% { opacity: 1.0; transform: scale(1.05); }
}

/* ══════════════════════════════════════════════════════════════════════
   PUZZLE STAGE (Tracks, Drawing Strokes, Traveling Arrows, Pings)
   ══════════════════════════════════════════════════════════════════════ */
fuse-splash-screen .epi-puzzle-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  animation: epi-puzzle-retract 0.5s cubic-bezier(0.16, 1, 0.3, 1) 2.45s forwards;
}

@keyframes epi-puzzle-retract {
  to {
    opacity: 0;
    transform: scale(0.97);
  }
}

/* STAGE 1: Discovery tracks appear (0.0s - 0.4s) */
fuse-splash-screen .epi-track {
  fill: none;
  stroke: rgba(124, 58, 237, 0.12);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  opacity: 0;
  animation: epi-fade-in 0.45s ease-out 0.05s forwards;
}

fuse-splash-screen .epi-grid-guide {
  stroke: rgba(124, 58, 237, 0.05);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0;
  animation: epi-fade-in 0.4s ease-out 0.02s forwards;
}

/* STAGE 2, 3, 4: Drawing Strokes behind traveling arrows */
fuse-splash-screen .epi-draw-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

/* Path 1: Upper vertical spine (begins 0.50s, docks at 1.20s) */
fuse-splash-screen .epi-dp-1 {
  stroke: #7c3aed;
  stroke-width: 2.5;
  stroke-dasharray: 310;
  stroke-dashoffset: 310;
  animation: epi-draw-1 0.70s cubic-bezier(0.16, 1, 0.3, 1) 0.50s forwards;
}
@keyframes epi-draw-1 {
  0%   { stroke-dashoffset: 310; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* Path 2: Lower vertical spine (begins 0.65s, docks at 1.40s) */
fuse-splash-screen .epi-dp-2 {
  stroke: #6366f1;
  stroke-width: 2.5;
  stroke-dasharray: 310;
  stroke-dashoffset: 310;
  animation: epi-draw-2 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.65s forwards;
}
@keyframes epi-draw-2 {
  0%   { stroke-dashoffset: 310; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* Path 3: Top arm of E (begins 0.85s, docks at 1.60s) */
fuse-splash-screen .epi-dp-3 {
  stroke: #8b5cf6;
  stroke-width: 2.5;
  stroke-dasharray: 285;
  stroke-dashoffset: 285;
  animation: epi-draw-3 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.85s forwards;
}
@keyframes epi-draw-3 {
  0%   { stroke-dashoffset: 285; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* Path 4: Middle arm of E (begins 1.05s, docks at 1.80s) */
fuse-splash-screen .epi-dp-4 {
  stroke: #7c3aed;
  stroke-width: 2.5;
  stroke-dasharray: 310;
  stroke-dashoffset: 310;
  animation: epi-draw-4 0.75s cubic-bezier(0.16, 1, 0.3, 1) 1.05s forwards;
}
@keyframes epi-draw-4 {
  0%   { stroke-dashoffset: 310; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* Path 5: Bottom arm of E (begins 1.25s, docks at 2.00s) */
fuse-splash-screen .epi-dp-5 {
  stroke: #6366f1;
  stroke-width: 2.5;
  stroke-dasharray: 295;
  stroke-dashoffset: 295;
  animation: epi-draw-5 0.75s cubic-bezier(0.16, 1, 0.3, 1) 1.25s forwards;
}
@keyframes epi-draw-5 {
  0%   { stroke-dashoffset: 295; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* Path 6: Upper squircle contour (begins 1.45s, docks at 2.15s) */
fuse-splash-screen .epi-dp-6 {
  stroke: #8b5cf6;
  stroke-width: 2.0;
  stroke-dasharray: 365;
  stroke-dashoffset: 365;
  animation: epi-draw-6 0.70s cubic-bezier(0.16, 1, 0.3, 1) 1.45s forwards;
}
@keyframes epi-draw-6 {
  0%   { stroke-dashoffset: 365; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* Path 7: Lower squircle contour (begins 1.60s, docks at 2.30s) */
fuse-splash-screen .epi-dp-7 {
  stroke: #7c3aed;
  stroke-width: 2.0;
  stroke-dasharray: 365;
  stroke-dashoffset: 365;
  animation: epi-draw-7 0.70s cubic-bezier(0.16, 1, 0.3, 1) 1.60s forwards;
}
@keyframes epi-draw-7 {
  0%   { stroke-dashoffset: 365; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* Path 8: Final key piece (begins 1.80s, docks at 2.45s) */
fuse-splash-screen .epi-dp-8 {
  stroke: #6366f1;
  stroke-width: 2.2;
  stroke-dasharray: 245;
  stroke-dashoffset: 245;
  animation: epi-draw-8 0.65s cubic-bezier(0.16, 1, 0.3, 1) 1.80s forwards;
}
@keyframes epi-draw-8 {
  0%   { stroke-dashoffset: 245; opacity: 0; }
  1%   { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 1; }
}

/* ── Arrowhead Runners traveling through 90° maze paths ── */
fuse-splash-screen .epi-runner {
  opacity: 0;
  filter: drop-shadow(0 1px 3px rgba(124, 58, 237, 0.4));
}

fuse-splash-screen .epi-runner-1 {
  offset-path: path("M 50 130 H 180 V 232 H 237 V 250");
  offset-rotate: auto;
  animation: epi-run-1 0.70s cubic-bezier(0.16, 1, 0.3, 1) 0.50s forwards;
}
@keyframes epi-run-1 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

fuse-splash-screen .epi-runner-2 {
  offset-path: path("M 50 370 H 190 V 268 H 237 V 250");
  offset-rotate: auto;
  animation: epi-run-2 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.65s forwards;
}
@keyframes epi-run-2 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

fuse-splash-screen .epi-runner-3 {
  offset-path: path("M 290 30 V 160 H 237 V 233 H 263");
  offset-rotate: auto;
  animation: epi-run-3 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.85s forwards;
}
@keyframes epi-run-3 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

fuse-splash-screen .epi-runner-4 {
  offset-path: path("M 30 250 H 140 V 290 H 220 V 250 H 257");
  offset-rotate: auto;
  animation: epi-run-4 0.75s cubic-bezier(0.16, 1, 0.3, 1) 1.05s forwards;
}
@keyframes epi-run-4 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

fuse-splash-screen .epi-runner-5 {
  offset-path: path("M 300 470 V 340 H 237 V 267 H 263");
  offset-rotate: auto;
  animation: epi-run-5 0.75s cubic-bezier(0.16, 1, 0.3, 1) 1.25s forwards;
}
@keyframes epi-run-5 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

fuse-splash-screen .epi-runner-6 {
  offset-path: path("M 470 90 H 360 V 218 H 234");
  offset-rotate: auto;
  animation: epi-run-6 0.70s cubic-bezier(0.16, 1, 0.3, 1) 1.45s forwards;
}
@keyframes epi-run-6 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

fuse-splash-screen .epi-runner-7 {
  offset-path: path("M 470 410 H 370 V 282 H 234");
  offset-rotate: auto;
  animation: epi-run-7 0.70s cubic-bezier(0.16, 1, 0.3, 1) 1.60s forwards;
}
@keyframes epi-run-7 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

fuse-splash-screen .epi-runner-8 {
  offset-path: path("M 480 250 H 320 V 235 H 282 V 265");
  offset-rotate: auto;
  animation: epi-run-8 0.65s cubic-bezier(0.16, 1, 0.3, 1) 1.80s forwards;
}
@keyframes epi-run-8 {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* ── Connection Feedback Pings (Subtle glow when pieces lock in) ── */
fuse-splash-screen .epi-ping {
  opacity: 0;
  transform-origin: center;
}

/* Ping 1: Spine connection at 1.40s */
fuse-splash-screen .epi-ping-1 {
  animation: epi-ping-anim 0.35s ease-out 1.40s forwards;
}
/* Ping 2: Top arm connection at 1.60s */
fuse-splash-screen .epi-ping-2 {
  animation: epi-ping-anim 0.35s ease-out 1.60s forwards;
}
/* Ping 3: Middle arm connection at 1.80s */
fuse-splash-screen .epi-ping-3 {
  animation: epi-ping-anim 0.35s ease-out 1.80s forwards;
}
/* Ping 4: Bottom arm connection at 2.00s */
fuse-splash-screen .epi-ping-4 {
  animation: epi-ping-anim 0.35s ease-out 2.00s forwards;
}
/* Ping 5: Final puzzle piece snap at 2.45s */
fuse-splash-screen .epi-ping-5 {
  animation: epi-ping-snap 0.45s ease-out 2.45s forwards;
}

@keyframes epi-ping-anim {
  0%   { opacity: 0; r: 2; stroke-width: 2.5; stroke: #7c3aed; }
  50%  { opacity: 1; r: 7; stroke-width: 1.5; stroke: #a78bfa; }
  100% { opacity: 0; r: 12; stroke-width: 0.5; stroke: #c4b5fd; }
}

@keyframes epi-ping-snap {
  0%   { opacity: 0; r: 4; stroke-width: 3.5; stroke: #7c3aed; }
  40%  { opacity: 1; r: 18; stroke-width: 2.0; stroke: #a78bfa; }
  100% { opacity: 0; r: 32; stroke-width: 0.5; stroke: #c4b5fd; }
}

/* ══════════════════════════════════════════════════════════════════════
   STAGE 5: FINAL EPI ONE LOGO IDENTITY & TYPOGRAPHY
   ══════════════════════════════════════════════════════════════════════ */
fuse-splash-screen .epi-identity {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: 85vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

fuse-splash-screen .epi-splash-logo {
  display: block !important;
  width: 280px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin-bottom: 24px;
  filter: drop-shadow(0 10px 25px rgba(101, 55, 255, 0.12));
  animation: epi-logo-entrance 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes epi-logo-entrance {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Solid rounded squircle badge */
fuse-splash-screen .epi-splash-badge {
  display: none !important;
}

/* Phase 5: Brand Typography Container */
fuse-splash-screen .epi-typography {
  display: none !important;
}

/* Track */
fuse-splash-screen .epi-loader-bar {
  position: relative;
  width: 220px;
  max-width: 80%;
  height: 3px;
  background: rgba(124, 58, 237, 0.12);
  border-radius: 99px;
  overflow: hidden;
  opacity: 1;
}

/* Fill — charges smoothly */
fuse-splash-screen .epi-loader-bar__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #7c3aed 0%, #6366f1 60%, #a78bfa 100%);
  animation: epi-bar-charge 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}

@keyframes epi-bar-charge {
  0%   { width: 0%;   opacity: 1; }
  100% { width: 100%; opacity: 1; }
}

/* Shimmer overlay on the fill */
fuse-splash-screen .epi-loader-bar__fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  animation: epi-bar-shimmer 0.9s ease-in-out 0.4s infinite;
}

@keyframes epi-bar-shimmer {
  0%   { left: -60%; }
  100% { left: 110%; }
}

/* ══════════════════════════════════════════════════════════════════════
   SHARED UTILITIES & REDUCED MOTION
   ══════════════════════════════════════════════════════════════════════ */
@keyframes epi-fade-in {
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  fuse-splash-screen .epi-puzzle-stage {
    display: none !important;
  }
  fuse-splash-screen .epi-splash-badge {
    animation: none !important;
    opacity: 1 !important;
    transform: translateX(-70px) !important;
  }
  fuse-splash-screen .epi-splash-badge__letter {
    animation: none !important;
    opacity: 1 !important;
  }
  fuse-splash-screen .epi-typography {
    animation: none !important;
    opacity: 1 !important;
    transform: translateY(-50%) translateX(0) !important;
  }
  fuse-splash-screen .epi-loader-bar {
    animation: none !important;
    opacity: 1 !important;
  }
  fuse-splash-screen .epi-loader-bar__fill {
    animation: none !important;
    width: 100% !important;
  }
}
