/* Application splash. Loaded in the head so it is render-blocking: the overlay
   is painted before any page content and covers it until splash.js hides it.
   The splash-in keyframes are adapted from Computey's css/motion/liquid-motion.css
   (liquid-splash). */

.splash {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2vw, 24px);
  /* The hero's grid (same 1.75rem cell, same 0.05 strength), drawn in charcoal
     because the ground is off-white. Fixed, so the lines sit where the hero's
     do and the fade into the page does not shift them. */
  background:
    linear-gradient(rgba(var(--charcoal-rgb), 0.05) 1px, transparent 1px) 0 0 / 1.75rem 1.75rem fixed,
    linear-gradient(90deg, rgba(var(--charcoal-rgb), 0.05) 1px, transparent 1px) 0 0 / 1.75rem 1.75rem fixed,
    var(--off-white);
  color: var(--charcoal);
  /* Failsafe: if splash.js never runs the overlay still gets out of the way. */
  animation: splash-failsafe 0.01s linear 8s forwards;
}

.splash[hidden] {
  display: none;
}

/* One fade on the whole overlay. The logo and bar have no exit of their own. */
.splash.is-leaving {
  animation: splash-fade 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

html:has(.splash:not([hidden])) {
  overflow: hidden;
}

html.no-splash .splash {
  display: none;
}

html.no-splash:has(.splash:not([hidden])) {
  overflow: auto;
}

.splash img {
  width: clamp(56px, 6vw, 72px);
  height: auto;
  animation: splash-in 1.5s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.splash span {
  width: clamp(96px, 10vw, 128px);
  height: 1px;
  background: rgba(var(--charcoal-rgb), 0.14);
  overflow: hidden;
}

.splash span::after {
  content: "";
  display: block;
  height: 100%;
  background: var(--crimson);
  transform: scaleX(0);
  transform-origin: left;
  /* Runs for the 2 second minimum, matching splash.js. */
  animation: splash-progress 2s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes splash-in {
  0% {
    opacity: 0;
    filter: blur(8px);
    transform: translate3d(0, 10px, 0) scale(0.88);
  }

  58% {
    opacity: 1;
    filter: blur(0);
    transform: translate3d(0, -2px, 0) scale(1.008);
  }

  100% {
    opacity: 1;
    filter: blur(0);
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes splash-progress {
  to {
    transform: scaleX(1);
  }
}

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

@keyframes splash-failsafe {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash img {
    animation: none;
  }

  .splash span::after {
    animation-duration: 0.01s;
    transform: scaleX(1);
  }

  .splash.is-leaving {
    animation-duration: 0.01s;
  }
}
