@import url('https://fonts.googleapis.com/css2?family=VT323&family=Space+Mono:wght@400;700&display=swap');

:root {
  --bg: #0a0a0a;
  --fg: #c0c0c0;
  --accent: #00dcc8;
  --pink: #ff2d95;
  --cable-width: 5px;
  --cable-color: #00dcc8;
  --glow: 0 0 12px rgba(0, 220, 200, 0.5);
  --font-mono: 'VT323', monospace;
  --font-body: 'Space Mono', monospace;
}

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

html {
  scroll-behavior: auto;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='3' fill='none' stroke='%2300dcc8' stroke-width='1.5'/%3E%3Cline x1='12' y1='4' x2='12' y2='8' stroke='%2300dcc8' stroke-width='1'/%3E%3Cline x1='12' y1='16' x2='12' y2='20' stroke='%2300dcc8' stroke-width='1'/%3E%3Cline x1='4' y1='12' x2='8' y2='12' stroke='%2300dcc8' stroke-width='1'/%3E%3Cline x1='16' y1='12' x2='20' y2='12' stroke='%2300dcc8' stroke-width='1'/%3E%3C/svg%3E") 12 12, crosshair;
  -webkit-font-smoothing: antialiased;
}

/* ── Scroll spacer ── */
#scroll-spacer {
  height: 15000px;
  position: relative;
}

/* ── SVG Cable Layer ── */
#cable-svg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

#cable-path {
  fill: none;
  stroke: var(--cable-color);
  stroke-width: var(--cable-width);
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s;
  filter: drop-shadow(0 0 6px rgba(0, 220, 200, 0.4));
}

#cable-glow {
  fill: none;
  stroke: var(--cable-color);
  stroke-width: 12px;
  stroke-linecap: round;
  opacity: 0.15;
  filter: blur(8px);
}

/* ── Canvas Glitch Overlay ── */
#glitch-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

#glitch-canvas.active {
  opacity: 1;
}

/* ── Knots ── */
.knot {
  position: fixed;
  z-index: 5;
  pointer-events: all;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: rgba(0, 220, 200, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--accent);
  text-decoration: none;
  transition: all 0.3s ease;
  animation: knot-pulse 2s ease-in-out infinite;
  opacity: 0;
}

.knot:hover {
  background: rgba(0, 220, 200, 0.3);
  box-shadow: var(--glow);
  transform: scale(1.3);
}

.knot.visible {
  opacity: 1;
}

.knot-label {
  position: absolute;
  left: 48px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  text-shadow: 0 0 8px rgba(0, 220, 200, 0.6);
  pointer-events: none;
}

.knot:hover .knot-label {
  opacity: 1;
}

@keyframes knot-pulse {
  0%, 100% {
    box-shadow: 0 0 4px rgba(0, 220, 200, 0.3);
  }
  50% {
    box-shadow: 0 0 16px rgba(0, 220, 200, 0.6);
  }
}

/* ── Dust Bunnies (content fragments) ── */
.dust {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
  opacity: 0;
  transition: opacity 0.8s;
  max-width: 260px;
}

.dust.visible {
  opacity: 0.7;
}

.dust.popup {
  background: #c0c0c0;
  color: #000;
  border: 2px outset #fff;
  padding: 4px 8px;
  font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
  font-size: 11px;
  box-shadow: 2px 2px 0 #808080;
}

.dust.popup .title-bar {
  background: linear-gradient(90deg, #000080, #1084d0);
  color: white;
  padding: 2px 4px;
  margin: -4px -8px 4px;
  font-weight: bold;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
}

.dust.counter {
  background: #000;
  border: 1px solid #333;
  padding: 4px 10px;
  color: #0f0;
  font-size: 11px;
  text-align: center;
}

.dust img {
  image-rendering: pixelated;
  max-width: 100px;
  display: block;
}

.dust.construction {
  color: #ff0;
  font-size: 16px;
  text-shadow: 1px 1px 0 #000;
}

/* ── Mute button ── */
#mute-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: rgba(10, 10, 10, 0.8);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  backdrop-filter: blur(4px);
}

#mute-btn:hover {
  background: rgba(0, 220, 200, 0.15);
  box-shadow: var(--glow);
}

#mute-btn.muted {
  color: #666;
  border-color: #333;
}

/* ── Ending ── */
#ending-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s;
}

#ending-overlay.active {
  opacity: 1;
  pointer-events: all;
}

#ending-overlay .end-text {
  font-family: var(--font-body);
  font-size: 24px;
  color: #0a0a0a;
  text-align: center;
  opacity: 0;
  transition: opacity 1s;
}

#ending-overlay .end-text.show {
  opacity: 1;
}

#ending-overlay .reconnect {
  margin-top: 30px;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--accent);
  cursor: pointer;
  opacity: 0;
  transition: opacity 1s;
  background: none;
  border: 1px solid var(--accent);
  padding: 8px 24px;
}

#ending-overlay .reconnect.show {
  opacity: 1;
}

#ending-overlay .reconnect:hover {
  background: var(--accent);
  color: #0a0a0a;
}

/* ── Scanline subtle bg ── */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ── Reduced motion ── */
.reduced-motion .knot {
  animation: none;
}

.reduced-motion #glitch-canvas {
  display: none;
}

.reduced-motion .dust {
  transition: none;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root {
    --cable-width: 3px;
  }

  .knot {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .knot-label {
    display: none;
  }

  .dust {
    max-width: 160px;
    font-size: 10px;
  }
}
