/*
 * splash.css: the Unis launch splash.
 *
 * The markup is in index.html (#unis-splash, outside #root), so it paints on
 * the very first frame, before any JavaScript. public/splash-boot.js sets the
 * theme first; src/boot/bootSplash.js decides when it leaves (a fade).
 *
 * The look is the in-app loader's (src/components/unisLoader.scss), the one
 * on the earnings page, only larger: a band of light sweeps in from the right
 * writing the UNIS wordmark in, it holds, a second band wipes it out, and the
 * loop runs until the app is ready. The light is the theme colour with its
 * two neighbouring hues, so it shimmers without leaving the theme.
 *
 * Three layers, all the size of the wordmark:
 *   .us-word  the real logo (theme version), shown through a moving mask
 *   .us-edge  a sharp band of light, cut to the letter shapes
 *   .us-glow  the same band, blurred so its light spills past the letters
 * The mask and the bands are one gradient five times the logo's width,
 * sliding right to left: empty · band in · logo · band out · empty.
 * Keep the stops and timings in step with unisLoader.scss.
 */

html { background: #07090f; }

#unis-splash {
  --sp-primary: #163387;
  --sp-word: url(/brand/splash/wordmark-blue.svg);
  --sp-mask: url(/brand/splash/wordmark-blue.svg);
  --sp-c: color-mix(in srgb, var(--sp-primary), white 30%);
  --sp-a: color-mix(in srgb, var(--sp-primary), white 55%);
  --sp-b: color-mix(in srgb, var(--sp-primary), white 15%);
  --sp-loop: 2.8s;

  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@supports (color: oklch(from red l c h)) {
  #unis-splash {
    --sp-a: oklch(from var(--sp-primary) calc(l + 0.28) c calc(h - 42));
    --sp-b: oklch(from var(--sp-primary) calc(l + 0.22) c calc(h + 42));
  }
}

html[data-splash-theme="orange"] #unis-splash { --sp-primary: #C44B0A; --sp-word: url(/brand/splash/wordmark-orange.png); }
html[data-splash-theme="red"]    #unis-splash { --sp-primary: #B51C24; --sp-word: url(/brand/splash/wordmark-red.png); }
html[data-splash-theme="green"]  #unis-splash { --sp-primary: #0F7A3E; --sp-word: url(/brand/splash/wordmark-green.png); }
html[data-splash-theme="purple"] #unis-splash { --sp-primary: #4A1A8C; --sp-word: url(/brand/splash/wordmark-purple.png); }
html[data-splash-theme="yellow"] #unis-splash { --sp-primary: #C49A0A; --sp-word: url(/brand/splash/wordmark-yellow.png); }
html[data-splash-theme="dianna"] #unis-splash { --sp-primary: #5d4703; --sp-word: url(/brand/splash/wordmark-dianna.png); }

#unis-splash.is-leaving { pointer-events: none; }

.us-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Stage ──────────────────────────────────────────────────────────────── */

.us-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    #07090f;
}

.us-aura {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(140vw, 900px);
  aspect-ratio: 2 / 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--sp-primary) 26%, transparent), transparent 100%);
  opacity: 0;
  animation: us-aura-in 0.9s ease-out 0.05s both, us-breathe 3.4s ease-in-out 1s infinite;
}

/* ── The wordmark and its light ─────────────────────────────────────────── */

.us-mark {
  position: relative;
  width: min(62vw, 360px);
  aspect-ratio: 931.2 / 207.2;
}

.us-word,
.us-edge,
.us-glow,
.us-glow > i {
  position: absolute;
  inset: 0;
}

.us-word {
  background: var(--sp-word) center / 100% 100% no-repeat;
  -webkit-mask-image: linear-gradient(90deg,
    transparent 0%, transparent 20%,
    #000 25%, #000 75%,
    transparent 80%, transparent 100%);
          mask-image: linear-gradient(90deg,
    transparent 0%, transparent 20%,
    #000 25%, #000 75%,
    transparent 80%, transparent 100%);
  -webkit-mask-size: 500% 100%;
          mask-size: 500% 100%;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  animation: us-sweep-mask var(--sp-loop) linear infinite;
}

.us-edge,
.us-glow > i,
.us-glow::after {
  background: linear-gradient(90deg,
    transparent 0%,
    transparent 19%,
    var(--sp-a) 20.8%,
    #fff 22.5%,
    var(--sp-c) 23.7%,
    var(--sp-b) 24.8%,
    transparent 26%,
    transparent 74%,
    var(--sp-b) 75.2%,
    var(--sp-c) 76.3%,
    #fff 77.5%,
    var(--sp-a) 79.2%,
    transparent 81%,
    transparent 100%) 0% 0 / 500% 100% no-repeat;
  -webkit-mask: var(--sp-mask) center / 100% 100% no-repeat;
          mask: var(--sp-mask) center / 100% 100% no-repeat;
  animation: us-sweep-band var(--sp-loop) linear infinite;
}

.us-edge { mix-blend-mode: screen; }

.us-glow {
  filter: blur(12px) saturate(1.5) brightness(1.3);
  transform: scale(1.06, 1.25);
}

.us-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  filter: blur(14px);
  opacity: 0.8;
  transform: scale(1.1, 1.6);
}

/* ── Keyframes ──────────────────────────────────────────────────────────── */

@keyframes us-sweep-mask {
  0%   { -webkit-mask-position: 0% 0;      mask-position: 0% 0;      animation-timing-function: cubic-bezier(0.3, 0.1, 0.25, 1); }
  36%  { -webkit-mask-position: 31.25% 0;  mask-position: 31.25% 0; }
  58%  { -webkit-mask-position: 68.75% 0;  mask-position: 68.75% 0;  animation-timing-function: cubic-bezier(0.55, 0, 0.7, 0.9); }
  90%  { -webkit-mask-position: 100% 0;    mask-position: 100% 0; }
  100% { -webkit-mask-position: 100% 0;    mask-position: 100% 0; }
}

@keyframes us-sweep-band {
  0%   { background-position: 0% 0;      animation-timing-function: cubic-bezier(0.3, 0.1, 0.25, 1); }
  36%  { background-position: 31.25% 0; }
  58%  { background-position: 68.75% 0;  animation-timing-function: cubic-bezier(0.55, 0, 0.7, 0.9); }
  90%  { background-position: 100% 0; }
  100% { background-position: 100% 0; }
}

@keyframes us-aura-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.86); }
  to   { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
}

@keyframes us-breathe {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 0.85; transform: translate(-50%, -50%) scale(1.05); }
}

/* ── Reduced motion: the still logo on a soft glow ──────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .us-aura { animation: none; opacity: 0.6; }
  .us-word {
    animation: none;
    -webkit-mask-image: none;
            mask-image: none;
  }
  .us-edge,
  .us-glow { display: none; }
}
