:root {
  --ink: #2b2833;
  --muted: rgba(43, 40, 51, 0.55);
  --accent: #7d76a6;
}

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

html {
  background: #eef0f3;
  /* Stop iOS from auto-inflating text (reads as a surprise "zoom") */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: radial-gradient(circle at 50% 32%, #ffffff 0%, #eef0f3 55%, #e4e6ec 100%);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  overflow-x: hidden;
  /* Don't let long-press select the UI or pull-to-refresh fight scroll-zoom */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior-y: none;
  /* Allow scrolling/panning but remove the double-tap-to-zoom delay on touch */
  touch-action: manipulation;
}

/* Canvas pinned behind everything */
#scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  /* Stable viewport height: the mobile address bar showing/hiding no longer
     resizes the canvas (which used to reframe the scene mid-gesture). */
  height: 100vh;
  height: 100svh;
  display: block;
  z-index: 0;
  /* We handle all touch gestures ourselves (drag = orbit, pinch = zoom) */
  touch-action: none;
  /* Keep the canvas on its own GPU layer so iOS doesn't drop it behind overlays */
  transform: translateZ(0);
  will-change: transform;
}

/* Spacer that gives us room to scroll */
.scroll-track {
  position: relative;
  height: 280vh;
  z-index: 1;
  pointer-events: none;
}

/* Fixed overlay that holds all text, driven by JS opacity */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.overlay > * {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  will-change: opacity, transform;
}

/* Node essay panel — anchored to the side so it never covers the vertex */
.node-panel {
  left: auto;
  right: 6vw;
  top: 50%;
  transform: translate(0, -50%);
  width: min(380px, 86vw);
  text-align: left;
  opacity: 0;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(43, 40, 51, 0.1);
  border-radius: 20px;
  padding: 2.2rem 2rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 70px rgba(43, 40, 51, 0.14);
  pointer-events: auto;
}

.node-panel .kicker {
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.1rem;
}

.node-panel h2 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.node-panel .meta {
  margin-top: 0.6rem;
  font-family: "Space Mono", monospace;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.node-panel .excerpt {
  margin-top: 1.1rem;
  font-size: 0.98rem;
  line-height: 1.65;
  color: rgba(43, 40, 51, 0.78);
}

.read-link {
  display: inline-block;
  margin-top: 1.4rem;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}

.read-link:hover {
  border-color: var(--accent);
}

.nav-hint {
  margin-top: 1.6rem;
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(43, 40, 51, 0.4);
}

@media (max-width: 720px) {
  .node-panel {
    right: 50%;
    top: auto;
    bottom: 6vh;
    transform: translate(50%, 0);
    padding: 1.6rem 1.4rem;
  }
}

/* Touch devices: the side panel drops its backdrop blur (iOS flashes white with
   it). The reading view is the same see-through card as desktop, just sized for
   a phone — see the .reader-inner override below. */
@media (pointer: coarse) {
  .node-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* The article scrolls vertically; everything else (zoom/pan) stays ours. */
  .reader {
    touch-action: pan-y;
  }

  /* Same glassy, see-through card as desktop, narrower for the phone and a
     touch more tint so the text stays legible over the live ink grid. */
  .reader-inner {
    margin: 8vh auto;
    width: 90vw;
    max-width: 480px;
    padding: 2rem 1.4rem;
    background: rgba(247, 247, 250, 0.5);
  }
}

/* Reading view */
.reader {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
}

.reader-inner {
  max-width: 660px;
  margin: 12vh auto;
  padding: 3rem clamp(1.5rem, 5vw, 3.5rem);
  /* See-through, not milky: a light tint and NO backdrop blur. The blur was
     smearing the sparse beads on the near-white page into a solid white sheet
     (the card "went opaque") — without it the crisp ink grid shows straight
     through, like the margins. Tint alpha 0.3–0.6 to taste; add a small
     blur(2–4px) back only if you want a touch of frost. */
  background: rgba(247, 247, 250, 0.34);
  border: 1px solid rgba(43, 40, 51, 0.08);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(43, 40, 51, 0.14);
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
}

.reader-close {
  font-family: "Space Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 2rem;
  cursor: pointer;
}

.reader .kicker {
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

.reader h1 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.reader .meta {
  margin-top: 0.7rem;
  font-family: "Space Mono", monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.reader-body {
  margin-top: 2rem;
}

.reader-body p {
  margin-bottom: 1.3rem;
  font-size: 1.06rem;
  line-height: 1.85;
  color: rgba(43, 40, 51, 0.86);
}
