/* ─── Custom Properties ─── */
:root {
  --void: #06060c;
  --deep: #0d0d18;
  --life: #00e88a;
  --signal: #00c4d4;
  --depth: #4c1d95;
  --whisper: rgba(139, 92, 246, 0.12);
  --terminal: #0a0a0a;
  --text: #d4d4e0;
  --bright: #f0f0f8;
}

/* ─── Screen Reader Only ─── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.sr-only-focusable:focus {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10000;
  width: auto;
  height: auto;
  padding: 0.75rem 1.5rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--void);
  color: var(--life);
  border: 1px solid var(--life);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 1rem;
  text-decoration: none;
  border-radius: 4px;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  background: var(--void);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  overflow-x: hidden;
  height: 500vh;
}

/* ─── Canvas ─── */
#mesh-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
}

/* ─── Loading State ─── */
#loader {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 4px; height: 4px;
  background: var(--life);
  border-radius: 50%;
  z-index: 1000;
  animation: loader-pulse 1.5s ease-in-out infinite;
}
#loader.hidden {
  opacity: 0;
  transition: opacity 0.5s ease-out;
  pointer-events: none;
}
@keyframes loader-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
  50% { transform: translate(-50%, -50%) scale(3); opacity: 1; }
}

/* ─── Section Layout ─── */
main { position: relative; z-index: 1; }
section {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ─── Typography ─── */
.hero-name {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(4rem, 10vw, 8rem);
  color: var(--bright);
  letter-spacing: -0.02em;
  opacity: 0;
}
.acronym-lines {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.75rem, 1.5vw, 1rem);
  color: var(--life);
  text-align: center;
  line-height: 1.8;
}
.acronym-line { opacity: 0; }
.acronym-cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--life);
  animation: cursor-blink 0.8s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.tagline {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text);
  opacity: 0;
  margin-top: 2rem;
  font-style: italic;
}

/* ─── Scroll Indicator ─── */
.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  width: 1px; height: 40px;
  background: var(--life);
  opacity: 0.4;
  animation: scroll-pulse 2s ease-in-out infinite;
}
@keyframes scroll-pulse {
  0%, 100% { transform: translateX(-50%) scaleY(1); opacity: 0.2; }
  50% { transform: translateX(-50%) scaleY(1.5); opacity: 0.6; }
}

/* ─── Pulse Section ─── */
.data-fragments {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
}
.data-fragment {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(10px, 1.2vw, 14px);
  color: var(--life);
  opacity: 0.15;
  pointer-events: none;
  white-space: nowrap;
}
.pulse-word {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(2.5rem, 6vw, 5rem);
  color: var(--bright);
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

/* ─── Synapse Labels ─── */
.synapse-labels {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
}
.synapse-label {
  position: absolute;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 500;
  font-size: clamp(0.875rem, 1.5vw, 1.125rem);
  color: var(--bright);
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: auto;
}
.synapse-label:hover { opacity: 1; }

/* ─── Terminal Bleed ─── */
.terminal-crack {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 0; height: 0;
  overflow: hidden;
  z-index: 3;
  clip-path: polygon(50% 50%, 50% 50%, 50% 50%);
  box-shadow: 0 0 40px rgba(0, 232, 138, 0.3), 0 0 80px rgba(76, 29, 149, 0.2);
}
.terminal-content {
  background: var(--terminal);
  width: 80vw; height: 60vh;
  padding: 2rem;
  overflow: hidden;
  position: relative;
}
.terminal-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--life);
  line-height: 1.8;
  white-space: nowrap;
  opacity: 0.85;
}
.scan-line {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--life), transparent);
  opacity: 0.15;
  animation: scan 4s linear infinite;
}
@keyframes scan {
  0% { top: 0; }
  100% { top: 100%; }
}

/* ─── Glitch Effect ─── */
@keyframes glitch-jitter {
  0%, 95%, 100% { clip-path: inherit; }
  96% { clip-path: polygon(48% 48%, 52% 48%, 55% 52%, 45% 55%); }
  97% { clip-path: polygon(46% 46%, 54% 46%, 56% 54%, 44% 56%); }
}
.terminal-crack.glitching {
  animation: glitch-jitter 0.05s step-end;
}

/* ─── Heartbeat ─── */
#heartbeat {
  justify-content: flex-end;
  padding-bottom: 15vh;
}
.heartbeat-line {
  width: clamp(200px, 60vw, 600px);
  height: 60px;
  margin-bottom: 2rem;
}
.heartbeat-line path {
  stroke: var(--life);
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 0 6px var(--signal));
}
.alive-status {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(12px, 1.2vw, 16px);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alive-dot {
  width: 6px; height: 6px;
  background: var(--life);
  border-radius: 50%;
  animation: alive-pulse 1.5s ease-in-out infinite;
}
@keyframes alive-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.4); }
}
.github-link {
  margin-top: 1.5rem;
  color: var(--text);
  opacity: 0.5;
  transition: opacity 0.3s;
}
.github-link:hover { opacity: 1; color: var(--life); }
.github-link svg { width: 24px; height: 24px; fill: currentColor; }
.domain-text {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 12px;
  color: var(--text);
  opacity: 0.4;
  margin-top: 0.75rem;
}

/* ─── Noscript ─── */
noscript {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: var(--void);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
noscript .ns-name {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(3rem, 8vw, 6rem);
  color: var(--bright);
}
noscript .ns-acronym {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.7rem, 1.2vw, 0.9rem);
  color: var(--life);
  margin-top: 1rem;
  line-height: 1.8;
}
noscript .ns-tagline {
  color: var(--text);
  font-style: italic;
  margin-top: 1.5rem;
}

/* ─── CSS Fallback Background ─── */
body.no-webgl {
  background:
    radial-gradient(ellipse at 30% 40%, rgba(0, 232, 138, 0.03) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 60%, rgba(0, 196, 212, 0.02) 0%, transparent 60%),
    var(--void);
  background-size: 200% 200%;
  animation: fallback-drift 20s ease-in-out infinite alternate;
}
@keyframes fallback-drift {
  0% { background-position: 0% 0%; }
  100% { background-position: 100% 100%; }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  #loader { display: none; }
  .hero-name, .tagline, .pulse-word { opacity: 1 !important; }
  .acronym-line { opacity: 1 !important; }
  .data-fragments { display: none; }
  .scroll-indicator { display: none; }
  section { height: auto; min-height: 100vh; padding: 4rem 2rem; }
}

/* ─── Purple Whisper Hazes ─── */
#pulse::before {
  content: '';
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80vw; height: 80vh;
  background: radial-gradient(ellipse, var(--whisper) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 1s;
}
#synapses::before {
  content: '';
  position: fixed;
  top: 40%; left: 60%;
  transform: translate(-50%, -50%);
  width: 60vw; height: 60vh;
  background: radial-gradient(ellipse, rgba(76, 29, 149, 0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 1s;
}
#pulse.haze-active::before,
#synapses.haze-active::before { opacity: 1; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .hero-name { letter-spacing: -0.03em; }
  .acronym-lines { padding: 0 1rem; }
  .synapse-labels { flex-direction: column; }
  .terminal-crack { width: 95vw !important; }
  .terminal-content { width: 95vw; height: 50vh; padding: 1rem; }
  .terminal-line { font-size: 11px; }
  #heartbeat { padding-bottom: 10vh; }
  .synapse-label { font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .hero-name { font-size: clamp(2.5rem, 12vw, 4rem); }
  .acronym-lines { font-size: 0.65rem; }
}
