.test-flow-page,
.stage {
  --bg: #070b14;
  --bg-mid: #0e1624;
  --bg-subtle: #121c2e;
  --bg-far: #05080f;
  --text: #e8eef8;
  --muted: rgba(232, 238, 248, 0.64);
  --line: rgba(62, 200, 240, 0.35);
  --accent: #3ec8f0;
  --border: rgba(62, 200, 240, 0.16);
  --card: rgba(14, 22, 36, 0.92);
  --font-display: "Outfit", sans-serif;
  --font-body: "DM Sans", sans-serif;
}

.test-flow-page *,
.test-flow-page *::before,
.test-flow-page *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html:has(body.test-flow-page) {
  background: var(--bg);
}

body.test-flow-page {
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(
      ellipse 90% 78% at 50% 44%,
      #10192a 0%,
      #070b14 42%,
      var(--bg-subtle) 78%,
      var(--bg-far) 100%
    );
}

.test-flow-page img {
  display: block;
  max-width: 100%;
}

.test-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 14, 26, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: relative;
  z-index: 2;
}

.test-bar a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.test-bar p {
  font-size: 0.8rem;
  color: var(--muted);
}

.stage {
  position: relative;
  isolation: isolate;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
  overflow: hidden;
}

.scene-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.scene-fx__aurora {
  position: absolute;
  inset: -18%;
  background:
    radial-gradient(ellipse 42% 34% at 28% 38%, rgba(0, 153, 204, 0.22), transparent 62%),
    radial-gradient(ellipse 36% 30% at 74% 58%, rgba(0, 119, 170, 0.16), transparent 64%),
    radial-gradient(ellipse 28% 24% at 52% 28%, rgba(62, 200, 240, 0.12), transparent 58%);
  filter: blur(12px);
  animation: aurora-shift 18s ease-in-out infinite alternate;
}

.scene-fx__grid {
  position: absolute;
  left: -15%;
  right: -15%;
  top: 18%;
  height: 140%;
  background-image:
    linear-gradient(rgba(0, 153, 204, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 153, 204, 0.09) 1px, transparent 1px);
  background-size: 52px 52px;
  transform: perspective(900px) rotateX(62deg) scale(1.15);
  transform-origin: center top;
  mask-image: radial-gradient(ellipse 75% 70% at 50% 0%, rgba(0, 0, 0, 0.55), transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 0%, rgba(0, 0, 0, 0.55), transparent 78%);
  animation: grid-drift 32s linear infinite;
}

.scene-fx__particles span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #7dd3f0;
  opacity: 0.45;
  box-shadow: 0 0 8px rgba(0, 153, 204, 0.8);
  animation: twinkle 3.6s ease-in-out infinite;
}

.scene-fx__particles span:nth-child(1) { top: 10%; left: 7%; }
.scene-fx__particles span:nth-child(2) { top: 18%; left: 88%; animation-delay: 0.4s; }
.scene-fx__particles span:nth-child(3) { top: 28%; left: 4%; animation-delay: 0.9s; width: 2px; height: 2px; }
.scene-fx__particles span:nth-child(4) { top: 72%; left: 9%; animation-delay: 1.3s; }
.scene-fx__particles span:nth-child(5) { top: 82%; left: 91%; animation-delay: 0.6s; }
.scene-fx__particles span:nth-child(6) { top: 14%; left: 22%; animation-delay: 1.8s; width: 2px; height: 2px; }
.scene-fx__particles span:nth-child(7) { top: 8%; left: 62%; animation-delay: 2.1s; }
.scene-fx__particles span:nth-child(8) { top: 88%; left: 18%; animation-delay: 0.2s; }
.scene-fx__particles span:nth-child(9) { top: 64%; left: 94%; animation-delay: 1.1s; width: 2px; height: 2px; }
.scene-fx__particles span:nth-child(10) { top: 36%; left: 96%; animation-delay: 2.4s; }
.scene-fx__particles span:nth-child(11) { top: 78%; left: 78%; animation-delay: 1.6s; }
.scene-fx__particles span:nth-child(12) { top: 22%; left: 48%; animation-delay: 0.8s; width: 2px; height: 2px; opacity: 0.28; }

.scene-fx__grain {
  position: absolute;
  inset: 0;
  opacity: 0.045;
  background-image: radial-gradient(rgba(15, 23, 42, 0.55) 0.6px, transparent 0.6px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

.flow {
  position: relative;
  z-index: 1;
  width: min(1320px, 100%);
  display: grid;
  grid-template-columns: 372px 250px 200px;
  justify-content: center;
  gap: 1.35rem 5.75rem;
  align-items: center;
}

.flow__wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.flow__wires path {
  fill: none;
  stroke: none;
  opacity: 0;
}

.flow__inputs {
  position: relative;
  z-index: 1;
  width: 372px;
  max-width: 100%;
  align-self: center;
}

.flow__core {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
}

.flow__outputs {
  position: relative;
  z-index: 1;
  width: 200px;
  max-width: 100%;
  align-self: center;
}

.flow__heading {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
  color: var(--text);
}

.flow__heading--later {
  margin-top: 1.35rem;
}

.flow__heading--out {
  text-align: right;
  margin-bottom: 0.7rem;
}

.chip-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.95rem;
  margin-bottom: 0.5rem;
}

.flow__cluster-body .chip-row:last-child {
  margin-bottom: 0;
}

.chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.58rem 0.7rem;
  min-height: 52px;
  border: 1.5px solid rgba(0, 153, 204, 0.22);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(20, 32, 52, 0.94) 0%, rgba(10, 16, 28, 0.94) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 10px 28px rgba(0, 0, 0, 0.28);
  color: var(--text);
}

.chip img {
  width: auto;
  height: auto;
  max-width: 32px;
  max-height: 32px;
  object-fit: contain;
  flex: 0 0 auto;
}

.chip span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
}

.core-halo,
.core-orbit,
.core-pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
}

.core-halo {
  width: 340px;
  height: 340px;
  margin: -170px 0 0 -170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 153, 204, 0.3) 0%, rgba(0, 153, 204, 0.1) 38%, transparent 70%);
  animation: halo-breathe 4.8s ease-in-out infinite;
  z-index: 0;
}

.core-orbit {
  width: 272px;
  height: 272px;
  margin: -136px 0 0 -136px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 153, 204, 0.12);
  border-top-color: rgba(0, 153, 204, 0.85);
  border-right-color: rgba(125, 211, 240, 0.35);
  animation: process-spin 7.5s linear infinite;
  z-index: 1;
}

.core-orbit--slow {
  width: 300px;
  height: 300px;
  margin: -150px 0 0 -150px;
  border-width: 1px;
  border-color: rgba(0, 153, 204, 0.08);
  border-bottom-color: rgba(0, 153, 204, 0.55);
  animation-duration: 14s;
  animation-direction: reverse;
}

.core-pulse {
  width: 236px;
  height: 236px;
  margin: -118px 0 0 -118px;
  border-radius: 50%;
  border: 1px solid rgba(0, 153, 204, 0.4);
  animation: pulse-out 3.8s ease-out infinite;
  z-index: 1;
}

.core-pulse--late {
  animation-delay: 1.9s;
}

.core-ring {
  position: relative;
  width: 236px;
  height: 236px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1.5rem 1.3rem;
  background: transparent;
  z-index: 2;
}

.core-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dotted rgba(62, 200, 240, 0.38);
  pointer-events: none;
  z-index: 1;
}

.core-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #0b1220;
  z-index: 0;
  transform-origin: center center;
}

.core-ring img {
  width: 100%;
  height: auto;
  object-fit: contain;
  position: relative;
  z-index: 2;
}

.flow.is-processing .core-halo {
  animation-duration: 2.4s;
  filter: saturate(1.25);
}

.flow.is-processing .core-orbit {
  animation-duration: 3.2s;
  box-shadow: 0 0 18px rgba(0, 153, 204, 0.25);
}

.flow.is-processing .core-ring::before {
  animation: process-spin 3.8s linear infinite;
}

.flow.is-processing .core-ring::after {
  animation: process-glow 1.6s ease-in-out infinite,
             circle-beat 2.2s ease-in-out infinite;
}

.flow__core p {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 168px);
  width: max-content;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  z-index: 3;
}

.flow__outputs {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.8rem;
}

.report {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1.5px solid rgba(0, 153, 204, 0.22);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(20, 32, 52, 0.94) 0%, rgba(10, 16, 28, 0.94) 100%);
  padding: 0.85rem 0.65rem 0.95rem;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 10px 28px rgba(0, 0, 0, 0.28);
}

.report img {
  width: auto;
  height: 64px;
  object-fit: contain;
  margin: 0 auto 0.6rem;
}

.report h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
}

.report h3 span {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.12em;
}

.flow [data-step] {
  opacity: 0;
  transform: translateY(10px);
}

.flow.is-static [data-step],
.flow.is-run [data-step] {
  animation: rise-in 0.28s ease forwards;
}

.flow.is-run [data-step] {
  animation-delay: 0s;
}

.flow.is-run [data-step="outputs"] { animation-delay: 3.9s; }
.flow.is-run [data-step="out-1"] { animation-delay: 4.7s; }
.flow.is-run [data-step="out-2"] { animation-delay: 5.9s; }
.flow.is-run [data-step="out-3"] { animation-delay: 7.1s; }

.flow.is-static [data-step] {
  animation-delay: 0s;
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes process-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(0, 153, 204, 0);
  }
  50% {
    box-shadow: 0 0 22px 3px rgba(0, 153, 204, 0.32);
  }
}

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

@keyframes halo-breathe {
  0%, 100% {
    opacity: 0.65;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes pulse-out {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.58);
    opacity: 0;
  }
}

@keyframes aurora-shift {
  from {
    transform: translate3d(-3%, -2%, 0) scale(1);
  }
  to {
    transform: translate3d(3.5%, 2.5%, 0) scale(1.06);
  }
}

@keyframes grid-drift {
  to {
    background-position: 52px 52px;
  }
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.18;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.55);
  }
}

@keyframes circle-beat {
  0%, 100% {
    transform: scale(1);
  }
  8% {
    transform: scale(1.08);
  }
  16% {
    transform: scale(1);
  }
  24% {
    transform: scale(1.08);
  }
  40% {
    transform: scale(1);
  }
}

.flow-dot,
.flow-dot--burst {
  fill: #0099cc;
  stroke: #ffffff;
  stroke-width: 1;
  pointer-events: none;
}

.flow.is-static .flow-dot {
  display: none;
}

@media (max-width: 900px) {
  .flow {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 2.25rem;
  }

  .flow__inputs {
    width: min(372px, 100%);
  }

  .flow__core {
    order: 2;
    align-self: center;
    width: 236px;
    margin-inline: auto;
    margin-bottom: 2.4rem;
  }

  .flow__core p {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 132px);
    margin: 0;
  }

  .flow__outputs {
    order: 3;
    width: min(200px, 100%);
  }

  .flow__heading--out {
    text-align: center;
  }

  .flow__wires path.flow-wire-out {
    stroke: rgba(0, 153, 204, 0.45);
    stroke-width: 2;
    opacity: 1;
  }

  .flow .report[data-step],
  .flow [data-step="outputs"] {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

@media (max-width: 400px) {
  .flow__core {
    transform: scale(0.84);
    transform-origin: top center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow [data-step],
  .flow.is-run .core-ring::before,
  .flow.is-run .core-ring::after,
  .flow.is-processing .core-ring::before,
  .flow.is-processing .core-ring::after {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .scene-fx__aurora,
  .scene-fx__grid,
  .scene-fx__particles span,
  .core-halo,
  .core-orbit,
  .core-pulse {
    animation: none;
  }

  .core-pulse {
    display: none;
  }

  .flow-dot {
    display: none;
  }
}
