/* Native first paint. React replaces this scene on its first commit; no timed delay. */
html:has(.app-startup) body { margin: 0; }

.app-startup {
  --startup-bg: #f3f6fb;
  --startup-ink: #182330;
  --startup-muted: #4e6173;
  --startup-border: #75899d;
  --startup-track: #d5e0ec;
  --startup-accent: #286aaf;
  --startup-grid: rgb(40 106 175 / 6%);
  --startup-glow: rgb(40 106 175 / 8%);
  --startup-logo-filter: none;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  color: var(--startup-ink);
  background: var(--startup-bg);
  font-family: system-ui, sans-serif;
}

html[data-theme='dark'] .app-startup {
  --startup-bg: #0b111a;
  --startup-ink: #edf3f8;
  --startup-muted: #c3d1dd;
  --startup-border: #8293a3;
  --startup-track: #263b4a;
  --startup-accent: #8ccfff;
  --startup-grid: rgb(140 207 255 / 7%);
  --startup-glow: rgb(83 163 232 / 10%);
  --startup-logo-filter: invert(1);
}

.app-startup::before,
.app-startup::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.app-startup::before {
  inset: -40%;
  z-index: 0;
  background-image:
    linear-gradient(var(--startup-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--startup-grid) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(700px) rotateX(42deg) rotateZ(-18deg);
  animation: app-startup-grid 7s linear infinite;
}

.app-startup::after {
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 20%, var(--startup-bg) 76%);
}

.app-startup-scene {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  pointer-events: none;
}

.app-startup-diagram {
  display: block;
  width: min(1200px, 150vw);
  max-width: none;
  overflow: visible;
  color: var(--startup-accent);
  stroke: currentColor;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-startup-traces {
  opacity: 0.22;
  stroke-dasharray: 1000;
  animation: app-startup-draw 1.1s cubic-bezier(.2, .7, .2, 1) both;
}

.app-startup-flow use {
  stroke-width: 2;
  stroke-dasharray: 70 930;
  animation: app-startup-flow 1.8s linear infinite;
}

.app-startup-flow use:nth-child(2n) { animation-delay: -0.9s; }
.app-startup-flow use:nth-child(3n) { animation-delay: -0.45s; }
.app-startup-flow use:nth-child(5n) { animation-direction: reverse; }

.app-startup-nodes { fill: var(--startup-bg); stroke-width: 1.5; }
.app-startup-nodes circle { animation: app-startup-node 1.8s ease-in-out infinite alternate; }
.app-startup-nodes circle:nth-child(2n) { animation-delay: -0.9s; }

.app-startup-orbit {
  transform-origin: 0 0;
  animation: app-startup-orbit 8s linear infinite;
}

.app-startup-orbit > circle:first-child { opacity: 0.42; }
.app-startup-arc { stroke-width: 2; opacity: 0.85; }
.app-startup-satellite { fill: currentColor; stroke: none; }

.app-startup-reticle {
  opacity: 0.4;
  transform-origin: 0 0;
  animation: app-startup-lock 2.8s ease-in-out infinite alternate;
}

.app-startup-ripple {
  opacity: 0.1;
  transform-origin: 0 0;
  animation: app-startup-ripple 3.2s ease-out infinite;
}

.app-startup-ripple--second { animation-delay: -1.6s; }

.app-startup-scan {
  position: absolute;
  inset: -40% auto -40% -30%;
  z-index: 3;
  width: 18%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--startup-glow), transparent);
  transform: skewX(-18deg);
  opacity: 0.6;
  animation: app-startup-scan 3.6s cubic-bezier(.4, 0, .2, 1) infinite;
}

.app-startup-content {
  position: relative;
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 28px;
  padding: 24px;
  text-align: center;
}

.app-startup-identity > img {
  display: block;
  max-width: 60vw;
  height: auto;
  filter: var(--startup-logo-filter);
}

.app-startup-progress {
  width: 144px;
  height: 3px;
  overflow: hidden;
  background: var(--startup-track);
}

.app-startup-progress::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: var(--startup-accent);
  animation: app-startup-progress 1100ms ease-in-out infinite;
}

.app-startup-error {
  display: none;
  max-width: 280px;
  color: var(--startup-muted);
  font-size: 14px;
  line-height: 1.6;
}

.app-startup-error button {
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid var(--startup-border);
  border-radius: 6px;
  background: var(--startup-bg);
  color: var(--startup-ink);
  font: inherit;
  cursor: pointer;
}

.app-startup-error button:focus-visible {
  outline: 2px solid var(--startup-accent);
  outline-offset: 3px;
}

.app-startup[data-state='error'] .app-startup-progress { display: none; }
.app-startup[data-state='error'] .app-startup-error { display: block; }
.app-startup[data-state='error'] *,
.app-startup[data-state='error']::before { animation-play-state: paused; }

@keyframes app-startup-grid {
  from { transform: perspective(700px) rotateX(42deg) rotateZ(-18deg) translate3d(0, 0, 0); }
  to { transform: perspective(700px) rotateX(42deg) rotateZ(-18deg) translate3d(48px, 48px, 0); }
}
@keyframes app-startup-draw { from { stroke-dashoffset: 1000; } to { stroke-dashoffset: 0; } }
@keyframes app-startup-flow { from { stroke-dashoffset: 1000; } to { stroke-dashoffset: 0; } }
@keyframes app-startup-orbit { to { transform: rotate(360deg); } }
@keyframes app-startup-node { from { fill: var(--startup-bg); } to { fill: currentColor; } }
@keyframes app-startup-lock { from { transform: scale(.98); opacity: .25; } to { transform: scale(1.02); opacity: .55; } }
@keyframes app-startup-ripple { from { transform: scale(.9); opacity: .16; } to { transform: scale(1.5); opacity: 0; } }
@keyframes app-startup-scan { from { transform: skewX(-18deg) translateX(0); } to { transform: skewX(-18deg) translateX(850%); } }
@keyframes app-startup-progress { from { transform: translateX(-100%); } to { transform: translateX(350%); } }

@media (prefers-reduced-motion: reduce) {
  .app-startup *, .app-startup *::after, .app-startup::before { animation: none !important; }
}

[data-reduce-effects='on'] .app-startup *,
[data-reduce-effects='on'] .app-startup *::after,
[data-reduce-effects='on'] .app-startup::before { animation: none !important; }
