/* Public pre-bundle splash screen (loaded from /preloader.html) */

#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  opacity: 1;
  background:
    radial-gradient(1200px 600px at 50% 30%, rgba(38, 94, 230, 0.16), transparent 60%),
    radial-gradient(900px 500px at 20% 70%, rgba(165, 112, 249, 0.16), transparent 55%),
    radial-gradient(900px 520px at 80% 75%, rgba(255, 193, 171, 0.14), transparent 55%),
    #f5f6fa;
  transition: opacity 0.3s ease-out;
}

#preloader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.preloader-inner {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px;
}

.preloader-wordmark {
  /* Total loop duration */
  --cycle: 4200ms;
  display: inline-flex;
  align-items: baseline;
  gap: 0.06em;
  position: relative;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    "Apple Color Emoji",
    "Segoe UI Emoji";
  font-size: clamp(40px, 6vw, 66px);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  filter: drop-shadow(0 10px 24px rgba(38, 94, 230, 0.14));
}

.pl-letter {
  position: relative;
  display: inline-block;
  color: transparent;
  -webkit-text-fill-color: transparent;
  /* the pseudo-elements render the letter */
  z-index: 1;
}

/* Outline "draw" layer */
.pl-letter::before {
  content: attr(data-char);
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-stroke: 2px rgba(38, 94, 230, 0.95);
  text-stroke: 2px rgba(38, 94, 230, 0.95);
  opacity: 0;
  /* reveal from a center "dot" spreading outward */
  clip-path: circle(0% at 50% 55%);
  animation: pl-draw var(--cycle) ease-in-out infinite;
  animation-delay: var(--d, 0ms);
}

/* Fill layer (no dark colors) */
.pl-letter::after {
  content: attr(data-char);
  position: absolute;
  inset: 0;
  color: transparent;
  background: linear-gradient(90deg,
      #265ee6 0%,
      #866aef 22%,
      #a570f9 48%,
      #c877f7 74%,
      #ffc1ab 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  opacity: 0;
  /* reveal from a center "dot" spreading outward */
  clip-path: circle(0% at 50% 55%);
  animation: pl-fill var(--cycle) ease-in-out infinite;
  animation-delay: var(--d, 0ms);
}

.preloader-underline {
  position: relative;
  width: min(260px, 64vw);
  height: 3px;
  border-radius: 999px;
  background: rgba(38, 94, 230, 0.14);
  overflow: hidden;
}

.preloader-underline::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-60%);
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(38, 94, 230, 0.85) 20%,
      rgba(165, 112, 249, 0.85) 45%,
      rgba(200, 119, 247, 0.85) 68%,
      rgba(255, 193, 171, 0.8) 82%,
      transparent 100%);
  animation: preloader-sweep 1200ms ease-in-out infinite;
}

@keyframes pl-draw {
  0% {
    opacity: 0;
    clip-path: circle(0% at 50% 55%);
  }

  10% {
    opacity: 1;
  }

  38% {
    opacity: 1;
    clip-path: circle(140% at 50% 55%);
  }

  /* fade outline out before fill peaks */
  50% {
    opacity: 0;
    clip-path: circle(140% at 50% 55%);
  }

  60% {
    opacity: 0;
    clip-path: circle(0% at 50% 55%);
  }

  100% {
    opacity: 0;
    clip-path: circle(0% at 50% 55%);
  }
}

@keyframes pl-fill {
  0% {
    opacity: 0;
    clip-path: circle(0% at 50% 55%);
    background-position: 0% 50%;
  }

  45% {
    opacity: 0;
    clip-path: circle(0% at 50% 55%);
  }

  58% {
    opacity: 1;
    clip-path: circle(140% at 50% 55%);
    background-position: 100% 50%;
  }

  /* keep the filled letter visible a bit longer (no overlay text) */
  82% {
    opacity: 1;
    clip-path: circle(140% at 50% 55%);
  }

  92% {
    opacity: 0;
    clip-path: circle(140% at 50% 55%);
  }

  100% {
    opacity: 0;
    clip-path: circle(0% at 50% 55%);
    background-position: 0% 50%;
  }
}

@keyframes preloader-sweep {
  0% {
    transform: translateX(-70%);
    opacity: 0.65;
  }

  50% {
    transform: translateX(0%);
    opacity: 1;
  }

  100% {
    transform: translateX(70%);
    opacity: 0.65;
  }
}

@media (prefers-reduced-motion: reduce) {

  .pl-letter::before,
  .pl-letter::after,
  .preloader-underline::before {
    animation: none !important;
  }

  .pl-letter::before {
    opacity: 0;
  }

  .pl-letter::after {
    opacity: 1;
    clip-path: circle(140% at 50% 55%);
  }
}