/**
 * Homepage splash loader — index.html only
 * Layout: dp-icon on top, name slides up from directly below
 * Timings: adjust --splash-* on .splash-loader
 */

body.is-splash-loading {
  overflow: hidden;
}

body.is-splash-loading > :not(#splash-loader) {
  visibility: hidden;
}

.splash-loader {
  --splash-icon-duration: 1.05s;
  --splash-icon-delay: 0.12s;
  --splash-icon-hold: 0.55s;
  --splash-name-duration: 0.95s;
  --splash-name-delay: 0s;
  --splash-name-hold: 0.7s;
  --splash-logo-fade: 0.6s;
  --splash-tagline-color: #092eff;
  --splash-exit-duration: 0.7s;
  --splash-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --splash-ease-in-out: cubic-bezier(0.45, 0, 0.2, 1);
  --splash-name-rise: clamp(2.5rem, 9vh, 4rem);

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

.splash-loader__backdrop {
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, #ffffff 0%, #f7f9ff 48%, #eef2ff 100%);
  opacity: 1;
  transition: opacity var(--splash-exit-duration) var(--splash-ease-in-out);
}

.splash-loader__stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  box-sizing: border-box;
}

.splash-loader__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(96vw, 540px);
}

.splash-loader__brand--logo {
  transition:
    opacity var(--splash-logo-fade) var(--splash-ease-in-out),
    transform var(--splash-logo-fade) var(--splash-ease-in-out),
    visibility 0s linear var(--splash-logo-fade);
}

.splash-loader.is-logo-out .splash-loader__brand--logo {
  opacity: 0;
  transform: scale(0.96);
  visibility: hidden;
  pointer-events: none;
}

/* Phase 3: centered tagline with typing effect */
.splash-loader__tagline {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.45s var(--splash-ease-out),
    visibility 0s linear 0.45s;
}

.splash-loader.is-tagline-active .splash-loader__tagline {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.45s var(--splash-ease-out),
    visibility 0s linear 0s;
}

.splash-loader__tagline-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  margin: 0;
  max-width: min(92vw, 40rem);
  text-align: center;
}

/* Match index hero .hero-focus-text / .typing-text sizing */
.splash-loader__tagline-text {
  font-family: "Manrope", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.45rem, 3.1vw, 2.6rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--splash-tagline-color);
  text-transform: none;
  white-space: nowrap;
}

.splash-loader__tagline-cursor {
  display: inline-block;
  width: 2px;
  height: 0.92em;
  margin-left: 2px;
  background: var(--splash-tagline-color);
  border-radius: 1px;
  vertical-align: -0.06em;
  animation: splashCursorBlink 0.6s step-end infinite;
}

.splash-loader.is-tagline-done .splash-loader__tagline-cursor {
  opacity: 0;
  animation: none;
}

/* Vertical stack: icon top, name below */
.splash-loader__cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.splash-loader__icon,
.splash-loader__name {
  display: block;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.splash-loader__icon {
  width: clamp(4.25rem, 24vw, 7.5rem);
  max-height: min(38vh, 7.5rem);
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(calc(-50vw - 120%));
  will-change: transform, opacity;
}

/* Slot collapses until name animates — keeps icon alone in screen center */
.splash-loader__name-slot {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

.splash-loader__name {
  width: clamp(9.5rem, 62vw, 19.5rem);
  max-height: min(26vh, 5.75rem);
  opacity: 0;
  transform: translateY(var(--splash-name-rise));
  will-change: transform, opacity;
}

/* Phase 1: icon slides in from left — ends centered and still */
.splash-loader.is-icon-in .splash-loader__icon {
  animation: splashIconEnter var(--splash-icon-duration) var(--splash-ease-out)
    var(--splash-icon-delay) forwards;
}

/* Icon locked in place before name starts (class added from JS after hold) */
.splash-loader.is-icon-settled .splash-loader__icon {
  opacity: 1;
  transform: translateX(0);
  will-change: auto;
}

/* Phase 2: only after icon is settled — name rises from below */
.splash-loader.is-name-in .splash-loader__name-slot {
  animation: splashNameSlotOpen var(--splash-name-duration) var(--splash-ease-out) forwards;
}

.splash-loader.is-name-in .splash-loader__name {
  animation: splashNameRise var(--splash-name-duration) var(--splash-ease-out)
    var(--splash-name-delay) forwards;
}

.splash-loader.is-exiting {
  pointer-events: none;
}

.splash-loader.is-exiting .splash-loader__backdrop {
  opacity: 0;
}

.splash-loader.is-exiting .splash-loader__stage {
  animation: splashStageOut var(--splash-exit-duration) var(--splash-ease-in-out) forwards;
}

@keyframes splashIconEnter {
  0% {
    opacity: 0;
    transform: translateX(calc(-50vw - 120%));
  }
  40% {
    opacity: 0.9;
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes splashNameSlotOpen {
  0% {
    max-height: 0;
    opacity: 0;
  }
  100% {
    max-height: min(28vh, 6.5rem);
    opacity: 1;
  }
}

@keyframes splashNameRise {
  0% {
    opacity: 0;
    transform: translateY(var(--splash-name-rise));
  }
  55% {
    opacity: 0.75;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes splashCursorBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes splashStageOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.99);
  }
}

body.splash-complete > :not(#splash-loader) {
  visibility: visible;
  animation: splashSiteReveal 0.55s var(--splash-ease-out) both;
}

@keyframes splashSiteReveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 759px) {
  .splash-loader__tagline-text {
    font-size: clamp(1.18rem, 3.65vw, 1.82rem);
    line-height: 1.22;
    white-space: normal;
    text-wrap: balance;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-loader__icon,
  .splash-loader__name,
  .splash-loader__name-slot,
  .splash-loader__cluster,
  body.splash-complete > :not(#splash-loader) {
    animation: none !important;
    transition: none !important;
  }

  .splash-loader.is-icon-in .splash-loader__icon,
  .splash-loader.is-name-in .splash-loader__name {
    opacity: 1;
    transform: none;
  }

  .splash-loader.is-name-in .splash-loader__name-slot {
    max-height: min(28vh, 6.5rem);
    opacity: 1;
  }

  .splash-loader.is-exiting .splash-loader__backdrop {
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .splash-loader.is-tagline-active .splash-loader__tagline {
    opacity: 1;
    visibility: visible;
  }

  .splash-loader__tagline-text {
    white-space: normal;
  }
}
