@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap");

:root {
  color-scheme: dark;
  --navy-950: #02092e;
  --navy-900: #03143f;
  --navy-800: #071a4d;
  --blue-800: #042a77;
  --blue-700: #0c4bac;
  --blue-600: #0f67d5;
  --blue-500: #1285ee;
  --blue-400: #259df3;
  --blue-300: #76b3ea;
  --ice-100: #eaf5ff;
  --ice-50: #f7fbff;
  --line-soft: rgba(118, 179, 234, 0.18);
  --font-sans: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.ecosystem-body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ice-100);
  letter-spacing: -0.01em;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--navy-900) 0%, var(--navy-950) 62%, #010520 100%);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- header ---------- */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(18px, 4vw, 48px);
  background: rgba(2, 9, 46, 0.62);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-icon {
  display: block;
  width: 34px;
  height: 32px;
  object-fit: contain;
}

.brand-word {
  color: #ffffff;
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.045em;
}

.brand-page {
  margin-left: 4px;
  padding-left: 15px;
  border-left: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue-300);
}

.header-links {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4vw, 28px);
  font-size: 14px;
  font-weight: 650;
  color: var(--blue-300);
}

.header-links a:hover {
  color: var(--ice-100);
}

.button-portal {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(18, 133, 238, 0.14);
  color: var(--ice-100);
  font-weight: 650;
  font-size: 14px;
  transition: background 160ms ease, border-color 160ms ease;
}

.button-portal:hover {
  background: rgba(18, 133, 238, 0.28);
  border-color: rgba(118, 179, 234, 0.4);
}

/* ---------- scene ---------- */

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#scene canvas {
  display: block;
}

.scroll-track {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

/* ---------- floating node labels ---------- */

#labelLayer {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}

.node-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -120%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 7px 10px 8px;
  border-radius: 10px;
  background: rgba(3, 20, 63, 0.66);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity;
}

.node-label .node-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ice-100);
}

.node-label .node-name::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--blue-500);
  flex: none;
}

.node-label .node-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0;
  color: var(--blue-300);
}

/* ---------- stage panel ---------- */

.stage-panel {
  position: fixed;
  z-index: 20;
  left: clamp(18px, 4vw, 48px);
  top: 50%;
  transform: translateY(-50%);
  width: min(400px, calc(100vw - 36px));
  padding: 26px 28px 24px;
  border-radius: 18px;
  background: rgba(3, 20, 63, 0.72);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.stage-panel.is-switching {
  opacity: 0;
  transform: translateY(calc(-50% + 8px));
}

.stage-panel .eyebrow {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--blue-400);
}

.stage-panel h2 {
  margin: 0 0 12px;
  font-size: clamp(24px, 2.6vw, 31px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.045em;
  color: #ffffff;
}

.stage-panel .stage-copy {
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.62;
  color: rgba(234, 245, 255, 0.78);
}

.stage-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-stats span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: rgba(18, 133, 238, 0.1);
  color: var(--blue-300);
}

.stage-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.stage-links a {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
}

.stage-links a.primary {
  background: var(--blue-600);
  color: #ffffff;
}

.stage-links a.primary:hover {
  background: var(--blue-500);
}

.stage-links a.secondary {
  border: 1px solid var(--line-soft);
  color: var(--ice-100);
}

.stage-links a.secondary:hover {
  border-color: rgba(118, 179, 234, 0.4);
}

/* ---------- stage rail ---------- */

.stage-rail {
  position: fixed;
  z-index: 20;
  right: clamp(18px, 3vw, 40px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stage-rail button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  color: rgba(118, 179, 234, 0.55);
  transition: color 160ms ease;
}

.stage-rail button::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  background: rgba(118, 179, 234, 0.35);
  transition: background 160ms ease, transform 160ms ease;
}

.stage-rail button:hover {
  color: var(--ice-100);
}

.stage-rail button.is-active {
  color: var(--ice-100);
}

.stage-rail button.is-active::before {
  background: var(--blue-500);
  transform: scale(1.25);
}

/* ---------- hint ---------- */

.hint {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: rgba(118, 179, 234, 0.7);
  transition: opacity 400ms ease;
  pointer-events: none;
}

.hint.is-hidden {
  opacity: 0;
}

/* ---------- fallback ---------- */

.scene-fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--navy-950);
}

.scene-fallback p {
  max-width: 460px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--blue-300);
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .header-links {
    display: none;
  }

  .stage-rail {
    display: none;
  }

  .stage-panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 14px;
    transform: none;
    width: auto;
    padding: 18px 18px 16px;
    max-height: 46vh;
    overflow-y: auto;
  }

  .stage-panel.is-switching {
    transform: translateY(8px);
  }

  .stage-panel h2 {
    font-size: 21px;
  }

  .stage-panel .stage-copy {
    font-size: 13.5px;
  }

  .hint {
    bottom: auto;
    top: 84px;
  }

  .node-label {
    display: none;
  }

  .node-label.is-key {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .stage-panel,
  .stage-panel.is-switching {
    transition: none;
  }
}
