/* ═══════════════════════════════════════════════════
   TOKENS & RESET
═══════════════════════════════════════════════════ */
:root {
  --paper: #050a0f;
  --ink: #e0e7ff;
  --ink-dim: rgba(224,231,255,0.45);
  --accent: #00f2ff;
  --accent-dim: rgba(0,242,255,0.12);
  --accent-glow: rgba(0,242,255,0.35);
  --grid: rgba(0,242,255,0.04);
  --border: rgba(0,242,255,0.15);

  /* Engine vars — driven by sliders */
  --eng-freq: 2;
  --eng-amp: 0.5;
  --eng-density: 3;
  --eng-speed: 1;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Hanken Grotesk', sans-serif;
  overflow-x: hidden;
  cursor: none;
}

/* ═══════════════════════════════════════════════════
   CUSTOM CURSOR
═══════════════════════════════════════════════════ */
#cursor-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: transform 0.08s ease, background 0.2s;
  box-shadow: 0 0 8px var(--accent), 0 0 20px var(--accent-glow);
}
#cursor-ring {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9998;
  transform: translate(-50%, -50%);
  transition: transform 0.18s ease, width 0.2s, height 0.2s, border-color 0.2s;
}
body:has(a:hover) #cursor-ring,
body:has(button:hover) #cursor-ring {
  width: 48px; height: 48px;
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   GRID OVERLAY
═══════════════════════════════════════════════════ */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════
   NAV
═══════════════════════════════════════════════════ */
nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 3rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.4s, background 0.4s, backdrop-filter 0.4s;
}
nav.scrolled {
  border-color: var(--border);
  background: rgba(5,10,15,0.7);
  backdrop-filter: blur(20px);
}
.nav-logo {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.08em;
}
.nav-logo span { color: var(--accent); }
.nav-links {
  display: flex; gap: 2.5rem;
  list-style: none;
}
.nav-links a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-dim);
  text-decoration: none;
  letter-spacing: 0.12em;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent); }
.nav-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  letter-spacing: 0.1em;
}

/* ═══════════════════════════════════════════════════
   SECTION COMMONS
═══════════════════════════════════════════════════ */
section { position: relative; z-index: 1; }

.section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-label::after {
  content: '';
  height: 1px;
  width: 60px;
  background: var(--accent);
  opacity: 0.4;
}

/* ═══════════════════════════════════════════════════
   §1 KINETIC HERO
═══════════════════════════════════════════════════ */
#hero {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 3rem;
  overflow: hidden;
}

#particle-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 900px;
}

.hero-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.2em;
  margin-bottom: 2rem;
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 0.7s 0.3s forwards;
}

.hero-h1 {
  font-size: clamp(3.5rem, 9vw, 8.5rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.03em;
  margin-bottom: 2.5rem;
  overflow: hidden;
}

.hero-line {
  display: block;
  opacity: 0;
  transform: translateY(100%);
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hero-line:nth-child(1) { animation-delay: 0.5s; }
.hero-line:nth-child(2) { animation-delay: 0.65s; color: var(--accent); }
.hero-line:nth-child(3) { animation-delay: 0.8s; color: var(--ink-dim); font-weight: 300; font-style: italic; }

.hero-desc {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: var(--ink-dim);
  line-height: 1.8;
  max-width: 420px;
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 0.7s 1.0s forwards;
}
.hero-desc em { color: var(--accent); font-style: normal; }

.hero-scroll {
  position: absolute;
  bottom: 2.5rem;
  left: 3rem;
  z-index: 2;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--ink-dim);
  letter-spacing: 0.15em;
  display: flex;
  align-items: center;
  gap: 1rem;
  opacity: 0;
  animation: fadeUp 0.6s 1.3s forwards;
}
.scroll-line {
  width: 40px; height: 1px;
  background: var(--ink-dim);
  position: relative;
  overflow: hidden;
}
.scroll-line::after {
  content: '';
  position: absolute;
  height: 100%;
  width: 100%;
  background: var(--accent);
  left: -100%;
  animation: scanLine 2s 1.5s infinite;
}

/* ═══════════════════════════════════════════════════
   §2 SCROLL-TRIGGERED DATA
═══════════════════════════════════════════════════ */
#data {
  padding: 8rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
}

.data-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-bottom: 6rem;
  align-items: end;
}

.data-h2 {
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}
.data-h2 .accent { color: var(--accent); }

.data-intro {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--ink-dim);
  line-height: 1.9;
  border-left: 1px solid var(--border);
  padding-left: 1.5rem;
}

/* Stats row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 6rem;
}

.stat-cell {
  background: var(--paper);
  padding: 3rem 2rem;
  position: relative;
  overflow: hidden;
}
.stat-cell::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  transform: scaleX(0);
  transition: transform 0.6s cubic-bezier(0.16,1,0.3,1);
}
.stat-cell.visible::before { transform: scaleX(1); }

.stat-num {
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  font-weight: 900;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}
.stat-num .unit {
  font-size: 0.45em;
  color: var(--accent);
  vertical-align: super;
}
.stat-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--ink-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* SVG chart area */
.chart-area {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: start;
}

.chart-box {
  border: 1px solid var(--border);
  padding: 2rem;
  background: rgba(0,242,255,0.02);
  position: relative;
}
.chart-box-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
}

#line-chart {
  width: 100%;
  height: 200px;
  overflow: visible;
}
.chart-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-fill {
  opacity: 0.08;
  fill: var(--accent);
}
.chart-dot {
  fill: var(--accent);
  r: 3;
  opacity: 0;
  transition: opacity 0.3s;
}
.chart-box.visible .chart-dot {
  opacity: 1;
}

.radial-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.radial-item {
  border: 1px solid var(--border);
  padding: 1.5rem;
  background: rgba(0,242,255,0.02);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.radial-svg { flex-shrink: 0; }
.radial-circle-bg {
  stroke: rgba(0,242,255,0.1);
  fill: none;
  stroke-width: 3;
}
.radial-circle-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 125.6;
  stroke-dashoffset: 125.6;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.16,1,0.3,1);
  transform: rotate(-90deg);
  transform-origin: center;
}
.radial-item.visible .radial-circle-fg {
  stroke-dashoffset: var(--target-offset, 0);
}
.radial-info {}
.radial-pct {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.radial-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
  margin-top: 0.2rem;
}

/* ═══════════════════════════════════════════════════
   §3 PROCESS FLOW (node diagram)
═══════════════════════════════════════════════════ */
#process {
  padding: 8rem 3rem;
  background: linear-gradient(180deg, transparent, rgba(0,242,255,0.02) 50%, transparent);
  overflow: hidden;
}

.process-inner {
  max-width: 1400px;
  margin: 0 auto;
}

.process-h2 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 5rem;
}
.process-h2 span { color: var(--accent); }

.node-diagram {
  position: relative;
  width: 100%;
  overflow: visible;
}

#process-svg {
  width: 100%;
  height: 320px;
  overflow: visible;
}

.proc-node {
  cursor: pointer;
}
.proc-node-bg {
  fill: var(--paper);
  stroke: var(--border);
  stroke-width: 1;
  transition: stroke 0.25s, fill 0.25s;
}
.proc-node:hover .proc-node-bg,
.proc-node.active .proc-node-bg {
  stroke: var(--accent);
  fill: rgba(0,242,255,0.06);
}
.proc-node-icon {
  fill: var(--ink-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 400;
  transition: fill 0.25s;
}
.proc-node:hover .proc-node-icon,
.proc-node.active .proc-node-icon { fill: var(--accent); }

.proc-node-label {
  fill: var(--ink-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-anchor: middle;
  transition: fill 0.25s;
}
.proc-node:hover .proc-node-label,
.proc-node.active .proc-node-label { fill: var(--ink); }

.proc-connector {
  stroke: var(--border);
  stroke-width: 1;
  fill: none;
  stroke-dasharray: 6 4;
}
.proc-connector-active {
  stroke: var(--accent);
  stroke-width: 1.5;
  fill: none;
  opacity: 0;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  transition: stroke-dashoffset 0.6s ease, opacity 0.2s;
}
.proc-connector-active.lit {
  opacity: 1;
  stroke-dashoffset: 0;
}

.node-detail-panel {
  border: 1px solid var(--border);
  padding: 2rem;
  margin-top: 3rem;
  background: rgba(0,242,255,0.03);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  align-items: start;
  min-height: 120px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}
.node-detail-panel.active {
  opacity: 1;
  transform: translateY(0);
}
.node-detail-num {
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  opacity: 0.3;
}
.node-detail-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.node-detail-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--ink-dim);
  line-height: 1.8;
}
.node-detail-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  letter-spacing: 0.1em;
}

/* ═══════════════════════════════════════════════════
   §4 ENGINE
═══════════════════════════════════════════════════ */
#engine {
  padding: 8rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
}

.engine-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: end;
  margin-bottom: 4rem;
}

.engine-h2 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}
.engine-h2 .accent { color: var(--accent); }

.engine-desc {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-dim);
  line-height: 1.9;
}

.engine-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}

#engine-canvas {
  width: 100%;
  height: 380px;
  border: 1px solid var(--border);
  display: block;
  background: rgba(0,0,0,0.4);
}

.engine-controls {
  border: 1px solid var(--border);
  padding: 2rem;
  background: rgba(0,242,255,0.02);
}

.controls-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: var(--accent);
  letter-spacing: 0.2em;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.control-group {
  margin-bottom: 2rem;
}
.control-group:last-of-type { margin-bottom: 0; }

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}
.control-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}
.control-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: var(--accent);
  min-width: 3ch;
  text-align: right;
}

.slider-track {
  position: relative;
  height: 2px;
  background: rgba(0,242,255,0.15);
  cursor: pointer;
}
.slider-fill {
  height: 100%;
  background: var(--accent);
  pointer-events: none;
  box-shadow: 0 0 8px var(--accent-glow);
}
input[type=range] {
  position: absolute;
  inset: -8px 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
  height: 20px;
}

.control-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  margin-top: 2rem;
}
.mode-btn {
  background: var(--paper);
  border: none;
  color: var(--ink-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-transform: uppercase;
}
.mode-btn.active {
  background: rgba(0,242,255,0.1);
  color: var(--accent);
}

.engine-readout {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.readout-line {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  color: var(--ink-dim);
  line-height: 2;
}
.readout-val { color: var(--accent); }

/* ═══════════════════════════════════════════════════
   §5 FLUID FOOTER
═══════════════════════════════════════════════════ */
#footer {
  position: relative;
  padding: 10rem 3rem 4rem;
  overflow: hidden;
  text-align: center;
}

.wave-container {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 200px;
  overflow: hidden;
}

#wave-canvas {
  width: 100%;
  height: 100%;
}

.footer-inner {
  position: relative;
  z-index: 2;
  max-width: 700px;
  margin: 0 auto;
}

.footer-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.25em;
  margin-bottom: 2rem;
}

.footer-h2 {
  font-size: clamp(3rem, 7vw, 6rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 2rem;
}
.footer-h2 span { color: var(--accent); }

.footer-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-dim);
  line-height: 1.8;
  margin-bottom: 3.5rem;
}

.cta-btn {
  display: inline-block;
  position: relative;
  background: var(--accent);
  color: var(--paper);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-decoration: none;
  padding: 1.1rem 3rem;
  text-transform: uppercase;
  overflow: hidden;
  transition: box-shadow 0.3s;
}
.cta-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.2s;
}
.cta-btn:hover::before { opacity: 0.15; }
.cta-btn.pulse {
  animation: ctaPulse 2.5s infinite;
}

.footer-meta {
  margin-top: 6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}
.footer-logo {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--ink-dim);
}
.footer-logo span { color: var(--accent); }
.footer-copy {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: var(--ink-dim);
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════
   KEYFRAMES
═══════════════════════════════════════════════════ */
@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scanLine {
  0%   { left: -100%; }
  100% { left: 100%; }
}
@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,242,255,0.4); }
  50%       { box-shadow: 0 0 0 20px rgba(0,242,255,0); }
}

/* ═══════════════════════════════════════════════════
   SCROLL REVEAL BASE STATES
═══════════════════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16,1,0.3,1), transform 0.8s cubic-bezier(0.16,1,0.3,1);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.35s; }

/* ═══════════════════════════════════════════════════
   NOISE OVERLAY
═══════════════════════════════════════════════════ */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 150px 150px;
}

/* Scanline effect */
#hero::after {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(0,242,255,0.04);
  box-shadow: 0 0 20px rgba(0,242,255,0.1);
  animation: scanEffect 8s linear infinite;
  pointer-events: none;
  z-index: 3;
}
@keyframes scanEffect {
  from { top: -1%; }
  to   { top: 101%; }
}

@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
  body {
    cursor: auto;
  }

  #cursor-dot,
  #cursor-ring {
    display: none;
  }
}

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

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .hero-eyebrow,
  .hero-line,
  .hero-desc,
  .hero-scroll,
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
