/*
 * Splash screen - critical CSS, loaded render-blocking from index.html.
 * The markup paints before React boots, so the logo is visible immediately and
 * there is no white flash. The whole sequence is driven by CSS animations and
 * ends in `visibility: hidden`, so the splash always disappears even if the JS
 * bundle fails to load.
 *
 * Copy: the tagline is static here. If you change it in the admin panel, update
 * this file too.
 *
 * The logo is a dark violet wordmark, so the halo below keeps it legible on the
 * dark backdrop without putting it back inside a card.
 */

:root {
  --splash-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --splash-ink: #1e1b4b;
  --splash-muted: #5b5bd6;
}

#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, #f5f3ff 0%, #eef2ff 45%, #f8fafc 100%);
  animation: splash-hide 0.45s ease 2.05s forwards;
}

html.dark #splash {
  background: radial-gradient(120% 120% at 50% 0%, #171733 0%, #0c0c18 55%, #08080e 100%);
  --splash-ink: #f5f3ff;
  --splash-muted: #b9b6f5;
}

/* ---------------------------------------------------------------- backdrop */
.splash-orb {
  --orb-opacity: 0.5;
  position: absolute;
  border-radius: 9999px;
  filter: blur(60px);
  opacity: 0;
  /* `both` so the orb holds opacity 0 during its delay instead of popping in
     at full strength the instant the animation starts */
  animation: splash-orb-in 1.1s var(--splash-ease-out) both;
}

.splash-orb-1 {
  --orb-opacity: 0.5;
  width: 42vmin;
  height: 42vmin;
  top: -8vmin;
  inset-inline-start: -6vmin;
  background: #8b5cf6;
}

.splash-orb-2 {
  --orb-opacity: 0.4;
  width: 36vmin;
  height: 36vmin;
  bottom: -10vmin;
  inset-inline-end: -8vmin;
  background: #22d3ee;
  animation-delay: 0.1s;
}

.splash-orb-3 {
  --orb-opacity: 0.28;
  width: 26vmin;
  height: 26vmin;
  bottom: 12vmin;
  inset-inline-start: 18vmin;
  background: #f472b6;
  animation-delay: 0.18s;
}

@keyframes splash-orb-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: var(--orb-opacity);
    transform: scale(1);
  }
}

/* -------------------------------------------------------------- grid lines */
.splash-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgb(109 40 217 / 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(109 40 217 / 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(60% 50% at 50% 50%, #000 0%, transparent 100%);
  opacity: 0;
  animation: splash-fade 0.9s ease 0.05s both;
}

/* ------------------------------------------------------------------ layout */
.splash-inner {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2.5rem;
}

.splash-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(72vw, 244px);
  aspect-ratio: 1;
}

/* ------------------------------------------------------------------- rings */
.splash-rings {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.splash-ring {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  transform-origin: 50% 50%;
}

.splash-ring-draw {
  stroke: url(#splash-gradient);
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transform: rotate(-90deg);
  animation: splash-ring-draw 1s var(--splash-ease-out) 0.15s both;
}

.splash-ring-spin {
  stroke: rgb(109 40 217 / 0.3);
  stroke-dasharray: 9 91;
  animation: splash-ring-spin 2.6s linear infinite;
}

html.dark .splash-ring-spin {
  stroke: rgb(196 181 253 / 0.38);
}

@keyframes splash-ring-draw {
  to {
    stroke-dashoffset: 0;
  }
}

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

/* -------------------------------------------------------------------- core */
/* a soft glow rather than a card: it keeps the dark wordmark readable on the
   dark backdrop and adds no hard edges */
.splash-halo {
  position: absolute;
  width: 76%;
  height: 76%;
  border-radius: 9999px;
  background: radial-gradient(
    circle,
    rgb(255 255 255 / 0.92) 0%,
    rgb(255 255 255 / 0.62) 44%,
    rgb(255 255 255 / 0) 72%
  );
  opacity: 0;
  animation: splash-fade 0.8s ease 0.35s both;
}

html.dark .splash-halo {
  background: radial-gradient(
    circle,
    rgb(255 255 255 / 0.88) 0%,
    rgb(255 255 255 / 0.5) 40%,
    rgb(255 255 255 / 0) 68%
  );
}

.splash-core {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.7rem;
  padding: 0 0.5rem;
}

.splash-logo {
  width: auto;
  height: clamp(50px, 13.5vw, 64px);
  opacity: 0;
  transform: scale(0.94);
  animation: splash-logo-in 0.7s var(--splash-ease-out) 0.5s both;
}

@keyframes splash-logo-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.splash-tag {
  max-width: 100%;
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: clamp(0.7rem, 3.3vw, 0.8125rem);
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
  color: var(--splash-muted);
  opacity: 0;
  transform: translateY(8px);
  animation: splash-text-in 0.6s var(--splash-ease-out) 0.88s both;
}

@keyframes splash-text-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------------------------------------------------------- progress */
.splash-bar {
  position: relative;
  width: 132px;
  height: 3px;
  border-radius: 9999px;
  background: rgb(109 40 217 / 0.12);
  overflow: hidden;
  opacity: 0;
  animation: splash-fade 0.4s ease 1.05s both;
}

html.dark .splash-bar {
  background: rgb(255 255 255 / 0.16);
}

.splash-bar::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, #2563eb, #06b6d4);
  /* `both` keeps the fill at width 0 during the delay (the base rule is 40%) */
  animation: splash-bar 1.05s var(--splash-ease-out) 1.05s both;
}

@keyframes splash-bar {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

/* ------------------------------------------------------------------- exit */
@keyframes splash-hide {
  from {
    opacity: 1;
    visibility: visible;
  }
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/*
 * Hand-off to the app.
 *
 * Only opacity is animated on #root: a transform there would turn it into the
 * containing block for `position: fixed` descendants and drop the mobile bottom
 * navigation to the bottom of the document (below the footer). The rise effect
 * therefore lives on <main>, which does not contain the fixed elements.
 */
body.splash-done #root {
  animation: splash-content-fade 0.5s ease both;
}

body.splash-done main {
  animation: splash-content-rise 0.6s var(--splash-ease-out) 0.06s both;
}

body.splash-instant main {
  animation: none;
}

@keyframes splash-content-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes splash-content-rise {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes splash-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ----------------------------------------------------------------- a11y */
@media (prefers-reduced-motion: reduce) {
  #splash {
    animation: splash-hide 0.25s ease 0.3s forwards;
  }

  .splash-grid,
  .splash-halo,
  .splash-core,
  .splash-bar {
    animation: splash-fade 0.2s ease 0.05s both;
    transform: none;
  }

  .splash-orb {
    animation: splash-orb-fade 0.2s ease 0.05s both;
    transform: none;
  }

  .splash-logo {
    animation: splash-fade 0.2s ease 0.05s both;
    transform: none;
  }

  .splash-tag {
    animation: splash-fade 0.2s ease 0.1s both;
    transform: none;
  }

  .splash-ring-draw,
  .splash-bar::before,
  .splash-ring-spin,
  body.splash-done #root,
  body.splash-done main {
    animation: none;
    transform: none;
  }

  .splash-ring-draw {
    stroke-dashoffset: 0;
  }
}

@keyframes splash-orb-fade {
  to {
    opacity: var(--orb-opacity);
  }
}
