/* ==========================================================================
   splash.css — intro animation (home page, first visit per session)

   Timeline (seconds from load):
     0.15  gear outline draws while it spins in
     0.85  blue ring sweeps clockwise
     1.35  the two D shapes slide in and snap together
     1.75  wordmark letters rise out of their lines
     2.10  shine passes over the emblem
     2.35  rule and tagline appear
   splash.js decides when to leave: once the page is ready *and* the minimum
   time has passed, the content fades and the splash lifts like a shutter.
   ========================================================================== */

@property --sp-sweep {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

html.is-splashing {
  overflow: hidden;
}

.splash {
  --sp-size: clamp(150px, 17vw, 250px); /* emblem diameter; everything scales from it */

  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--ink);
  color: var(--white);
  will-change: transform;
  transition: transform 1s cubic-bezier(0.76, 0, 0.2, 1);
  /* Safety net: if the script never runs, the splash still clears itself. */
  animation: splash-failsafe 0.01s linear 16s forwards;
}

.splash *,
.splash *::before,
.splash *::after {
  box-sizing: border-box;
}

.splash.is-lift {
  transform: translateY(-100%);
}

.splash.is-gone {
  display: none;
}

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

.splash__defs {
  position: absolute;
}

/* ---- Background -------------------------------------------------------- */
.splash__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: center;
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 48%, #000, transparent);
  mask-image: radial-gradient(ellipse 60% 55% at 50% 48%, #000, transparent);
  opacity: 0;
  animation: splash-fade-in 1.2s 0.1s ease forwards;
}

.splash__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55));
}

.splash__scan {
  position: absolute;
  left: 0;
  right: 0;
  top: -40vh;
  height: 38vh;
  background: linear-gradient(transparent, rgba(var(--accent-rgb), 0.07), transparent);
  animation: splash-scan 3.4s 1.2s ease-in-out infinite;
}

@keyframes splash-scan {
  to {
    transform: translateY(150vh);
  }
}

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

/* Corner brackets */
.splash__corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 0 solid var(--accent);
  opacity: 0;
  animation: splash-corner 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.splash__corner--tl { top: 26px;    left: 26px;  border-top-width: 2px;    border-left-width: 2px;  animation-delay: 0.3s; }
.splash__corner--tr { top: 26px;    right: 26px; border-top-width: 2px;    border-right-width: 2px; animation-delay: 0.4s; }
.splash__corner--bl { bottom: 50px; left: 26px;  border-bottom-width: 2px; border-left-width: 2px;  animation-delay: 0.5s; }
.splash__corner--br { bottom: 50px; right: 26px; border-bottom-width: 2px; border-right-width: 2px; animation-delay: 0.6s; }

@keyframes splash-corner {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 0.85; transform: none; }
}

/* ---- Stage ------------------------------------------------------------- */
.splash__stage {
  position: relative;
  z-index: 3;
  transition: opacity 0.45s ease, transform 0.6s cubic-bezier(0.5, 0, 0.2, 1);
}

.splash.is-leaving .splash__stage {
  opacity: 0;
  transform: scale(1.06);
}

.splash__lockup {
  display: flex;
  align-items: center;
  gap: calc(var(--sp-size) * 0.14);
}

.splash__emblem {
  position: relative;
  flex: none;
  width: var(--sp-size);
  height: var(--sp-size);
}

.splash__emblem > svg,
.splash__emblem > div {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.splash__glow {
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.42), transparent 62%);
  transform: scale(1.9);
  opacity: 0;
  animation:
    splash-glow-in 1.6s 0.5s ease forwards,
    splash-glow-breathe 3s 2.2s ease-in-out infinite;
}

@keyframes splash-glow-in {
  to { opacity: 0.9; }
}

@keyframes splash-glow-breathe {
  0%, 100% { opacity: 0.9; }
  50%      { opacity: 0.55; }
}

/* Orbiting loader ring (appears once the emblem has assembled) */
.splash__orbit {
  inset: -1.5% !important;
  width: 103% !important;
  height: 103% !important;
  border-radius: 50%;
  opacity: 0;
  background: conic-gradient(from 0deg, transparent 0 62%, rgba(90, 162, 255, 0.9));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation:
    splash-fade-in 0.6s 2s ease forwards,
    splash-spin 1.9s 2s linear infinite;
}

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

/* ---- Emblem layers ----------------------------------------------------- */
/* The gear's tapered tail is part of its outline, so it must come to rest at 0deg. */
.sp-gear-spin {
  animation: sp-gear-spin 1.9s 0.15s cubic-bezier(0.12, 0.85, 0.2, 1) both;
}

@keyframes sp-gear-spin {
  from { transform: rotate(-200deg) scale(0.82); }
  to   { transform: none; }
}

.sp-gear {
  fill: var(--white);
  fill-rule: evenodd;
  fill-opacity: 0;
  stroke: var(--white);
  stroke-width: 0.9;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation:
    sp-draw 1.2s 0.15s cubic-bezier(0.5, 0, 0.2, 1) forwards,
    sp-fill 0.6s 0.95s ease forwards,
    sp-stroke-off 0.4s 1.5s ease forwards;
}

@keyframes sp-draw       { to { stroke-dashoffset: 0; } }
@keyframes sp-fill       { to { fill-opacity: 1; } }
@keyframes sp-stroke-off { to { stroke-opacity: 0; } }

/* Ring: revealed with a conic mask whose sweep angle is animated */
.sp-ring {
  --sp-sweep: 0;
  -webkit-mask-image: conic-gradient(from 0deg at 50.7% 49.5%, #000 calc(var(--sp-sweep) * 1%), transparent calc(var(--sp-sweep) * 1% + 0.3%));
  mask-image: conic-gradient(from 0deg at 50.7% 49.5%, #000 calc(var(--sp-sweep) * 1%), transparent calc(var(--sp-sweep) * 1% + 0.3%));
  animation: sp-sweep 1.1s 0.85s cubic-bezier(0.5, 0, 0.2, 1) forwards;
}

.sp-ring use {
  fill: var(--accent);
  fill-rule: evenodd;
}

@keyframes sp-sweep {
  to { --sp-sweep: 101; }
}

/* The two D shapes snap together with a slight overshoot */
.sp-d {
  fill-rule: evenodd;
  opacity: 0;
}

.sp-d--white {
  fill: var(--white);
  animation: sp-d-white 0.85s 1.35s cubic-bezier(0.2, 1.25, 0.3, 1) forwards;
}

.sp-d--blue {
  fill: var(--accent);
  animation: sp-d-blue 0.85s 1.45s cubic-bezier(0.2, 1.25, 0.3, 1) forwards;
}

@keyframes sp-d-white {
  from { opacity: 0; transform: translate(-26px, -18px); }
  35%  { opacity: 1; }
  to   { opacity: 1; transform: none; }
}

@keyframes sp-d-blue {
  from { opacity: 0; transform: translate(26px, 22px); }
  35%  { opacity: 1; }
  to   { opacity: 1; transform: none; }
}

.splash__shock {
  inset: 20% !important;
  width: 60% !important;
  height: 60% !important;
  border: 2px solid var(--accent-bright);
  border-radius: 50%;
  opacity: 0;
  animation: splash-shock 1s 2.05s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

@keyframes splash-shock {
  0%   { opacity: 0.9; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(2.1); }
}

.sp-shine rect {
  fill: url(#spShine);
  transform: translateX(-140px);
  animation: sp-shine 1s 2.1s cubic-bezier(0.5, 0, 0.3, 1) forwards;
}

@keyframes sp-shine {
  to { transform: translateX(140px); }
}

/* ---- Wordmark ---------------------------------------------------------- */
.splash__word {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.splash__word svg {
  display: block;
  width: calc(var(--sp-size) * 1.9);
  height: auto;
  overflow: hidden;
}

.sp-letter {
  fill: var(--white);
  fill-rule: evenodd;
  opacity: 0;
  transform: translateY(72px);
  animation: sp-letter 0.8s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

@keyframes sp-letter {
  to { opacity: 1; transform: none; }
}

.splash__rule {
  width: calc(var(--sp-size) * 1.9);
  height: 2px;
  margin-top: calc(var(--sp-size) * 0.1);
  background: linear-gradient(90deg, var(--accent), rgba(var(--accent-rgb), 0));
  transform: scaleX(0);
  transform-origin: left;
  animation: splash-rule 1s 2.35s cubic-bezier(0.6, 0, 0.2, 1) forwards;
}

@keyframes splash-rule {
  to { transform: none; }
}

.splash__tag {
  margin-top: calc(var(--sp-size) * 0.08);
  font-family: var(--font-display);
  font-size: clamp(0.8125rem, calc(var(--sp-size) * 0.07), 1.125rem);
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--on-dark-muted);
  opacity: 0;
  transform: translateY(8px);
  animation: splash-tag 0.9s 2.5s ease forwards;
}

.splash__tag b {
  color: var(--accent-bright);
  font-weight: 500;
}

@keyframes splash-tag {
  to { opacity: 1; transform: none; }
}

/* ---- Progress ---------------------------------------------------------- */
.splash__progress {
  position: absolute;
  left: 50%;
  bottom: calc(20px + 9vh);
  z-index: 4;
  width: min(320px, 62vw);
  opacity: 0;
  transform: translateX(-50%);
  animation: splash-fade-in 0.8s 0.7s ease forwards;
  transition: opacity 0.3s;
}

.splash.is-leaving .splash__progress {
  opacity: 0 !important;
}

.splash__progress-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--on-dark-dim);
}

.splash__progress-row [data-splash-num] {
  color: var(--on-dark);
  font-variant-numeric: tabular-nums;
}

.splash__bar {
  height: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.splash__bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  box-shadow: 0 0 12px rgba(90, 162, 255, 0.8);
  transform: scaleX(0);
  transform-origin: left;
}

/* Rolling-shutter bottom rail with handle */
.splash__rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: 20px;
  background: linear-gradient(#222a36, #12161d);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 3px solid var(--accent);
}

.splash__rail::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 6px;
  margin: -4px 0 0 -32px;
  border-radius: 3px;
  background: #05070a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* ---- Narrow / portrait: stack emblem over wordmark --------------------- */
@media (max-width: 700px), (max-aspect-ratio: 1/1) {
  .splash {
    --sp-size: clamp(130px, 44vw, 200px);
  }

  .splash__lockup {
    flex-direction: column;
    gap: calc(var(--sp-size) * 0.16);
  }

  .splash__word {
    align-items: center;
  }

  .splash__word svg,
  .splash__rule {
    width: min(78vw, calc(var(--sp-size) * 2.56));
  }

  .splash__rule {
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    transform-origin: center;
  }

  .splash__tag {
    font-size: 0.8125rem;
    letter-spacing: 0.22em;
  }

  .splash__corner--tl, .splash__corner--tr { top: 16px; }
  .splash__corner--tl, .splash__corner--bl { left: 16px; }
  .splash__corner--tr, .splash__corner--br { right: 16px; }
  .splash__corner--bl, .splash__corner--br { bottom: 40px; }
}

/* Reduced motion: show the finished logo, no spinning or sweeping */
@media (prefers-reduced-motion: reduce) {
  .splash *,
  .splash *::before,
  .splash *::after {
    animation-duration: 0.01s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }

  .splash__orbit,
  .splash__scan {
    display: none;
  }

  .splash {
    transition-duration: 0.5s;
  }
}
