/* ============================================================
   BASE.CSS: BROWN TO CREAM scroll journey
   No visitor toggle. effects.js writes two numbers on <html> every
   frame and CSS does the mixing:
     --j   0 to 1  background: brown (top) to cream (contact)
     --jt  0 to 1  text: cream to deep brown, flips in a short band
                   (around j = 0.36 to 0.46) where neither is weak
   Palette: base #2C2016 (60%; darkened twice on 10 Nov 2026 at Onkar's
   request, from #5B4632 to #3E2F20 to this), cream #F4D9A0 (20%),
   accent #C8792C, deep brown #1A120B (shadows, text on cream and orange).
   Contrast (earlier hex, to be re-run): cream on brown 6.4:1, deep on
   cream 11.1:1, deep on orange 4.5:1. Orange on brown or cream is about 2.5:1,
   so orange is for glows, lines, dots and large type, not small text.
   Canvases (brain / net / figure) read MIND.theme, set by effects.js.
   ============================================================ */

:root {
  --sans: 'Sora', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
  --ease-out: cubic-bezier(0.19, 1, 0.22, 1);

  --brown: #2C2016;
  --cream: #F4D9A0;   /* text on dark, glows, tags */
  --paper: #E3D7C3;   /* the light end of the journey: muted warm stone, less yellow than cream */
  --accent: #C8792C;
  --deep: #1A120B;

  --j: 0;
  --jt: 0;

  /* srgb, not oklab: oklab turns the middle of the mix into a saturated mustard tan */
  --bg: color-mix(in srgb, var(--brown) calc((1 - var(--j)) * 100%), var(--paper));
  --txt: color-mix(in oklab, var(--cream) calc((1 - var(--jt)) * 100%), var(--deep));
  --muted: color-mix(in oklab, var(--txt) 72%, var(--bg));
  --line: color-mix(in srgb, var(--txt) 18%, transparent);
  --panel: color-mix(in oklab, var(--bg) 90%, var(--txt));
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: auto; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  overflow-x: hidden;
  cursor: none;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--deep); }

/* fine film grain over the background: polish, and hides banding in the long colour mix */
body::before {
  content: '';
  position: fixed; inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .9  0 0 0 0 .72  0 0 0 .75 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- layer stack ---------- */
#net-canvas, #brain-canvas, #stick-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
}
#net-canvas   { z-index: 0; }
#brain-canvas { z-index: 1; }
#stick-canvas { z-index: 4; }   /* above content: the guide sits ON the words */
#smooth-wrapper {
  position: fixed; top: 0; left: 0; width: 100%;
  will-change: transform;
  z-index: 3;
}
#smooth-content { position: relative; }

/* ============================================================
   LOADER: neurons firing, then it dismisses itself (effects.js)
   (fixed deep-brown stage)
   ============================================================ */
#loader {
  position: fixed; inset: 0;
  z-index: 1000;
  background: var(--deep);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 26px;
  transition: opacity 0.7s ease, visibility 0.7s;
}
#loader.done { opacity: 0; visibility: hidden; }
#loader .nr {
  fill: var(--deep); stroke: var(--accent); stroke-width: 1.5;
  animation: neuronFire 1.4s ease-in-out infinite;
}
#loader .nr:nth-of-type(2) { animation-delay: 0.2s; }
#loader .nr:nth-of-type(3) { animation-delay: 0.4s; }
#loader .nr:nth-of-type(4) { animation-delay: 0.6s; }
#loader .nr:nth-of-type(5) { animation-delay: 0.8s; }
#loader .ax {
  stroke: rgba(244, 217, 160, 0.25); stroke-width: 1;
  stroke-dasharray: 6 5;
  animation: axonFlow 1.2s linear infinite;
}
#loader .loader-line {
  font-family: var(--mono);
  font-size: 0.72rem; letter-spacing: 0.28em;
  color: rgba(244, 217, 160, 0.7);
  text-transform: uppercase;
}

/* ============================================================
   TERMINAL-TAKEOVER GLITCH (the dive moment)
   Amber phosphor garbage floods the screen like a CRT dying.
   ============================================================ */
#glitch-overlay {
  position: fixed; inset: 0;
  z-index: 500;
  pointer-events: none;
  background: #3B2B1A;
  opacity: 0;
  visibility: hidden;
  contain: strict;                  /* its own paint area: the page behind is not re-laid-out while it flickers */
}
#glitch-overlay.play {
  visibility: visible;
  animation: crtFlicker 1.5s linear both;
}
#glitch-overlay pre {
  position: absolute; inset: 0;
  padding: 4vh 4vw;
  font-family: var(--mono);
  font-size: clamp(10px, 1.4vw, 15px);
  line-height: 1.5;
  color: var(--cream);
  overflow: hidden;
  white-space: pre;
}
#glitch-overlay.play pre { animation: crtTear 1.5s steps(8) both; }
#glitch-overlay::after {              /* scanlines */
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg,
    transparent 0 2px, rgba(0, 0, 0, 0.35) 2px 4px);
}

/* ---------- training HUD ---------- */
.hud { position: fixed; top: 0; left: 0; right: 0; z-index: 200; pointer-events: none; }
.hud-bar { height: 2px; background: color-mix(in srgb, var(--line) 60%, transparent); }
.hud-bar i { display: block; height: 100%; width: 0%; background: var(--accent); }
.hud-label {
  position: absolute; top: 10px; right: 5vw;
  font-family: var(--mono); font-size: 0.65rem;
  letter-spacing: 0.12em; color: var(--muted);
}

/* ---------- custom cursor ---------- */
.cursor-dot, .cursor-ring {
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9999;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.cursor-dot { width: 6px; height: 6px; background: var(--accent); }
.cursor-ring {
  width: 36px; height: 36px;
  border: 1px solid var(--muted);
  transition: width 0.25s, height 0.25s, border-color 0.25s, background 0.25s;
}
.cursor-ring.hovering {
  width: 60px; height: 60px;
  border-color: var(--accent);
  background: var(--accent-soft);
}
@media (hover: none) {
  body { cursor: auto; }
  .cursor-dot, .cursor-ring { display: none; }
}

/* ---------- nav ---------- */
nav {
  position: fixed; top: 2px; left: 0; right: 0;
  z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 5vw;
}
.logo {
  font-family: var(--mono); font-size: 0.95rem;
  color: var(--txt); text-decoration: none; letter-spacing: 0.04em;
}
.logo b { color: var(--accent); font-weight: 400; }
.nav-right { display: flex; align-items: center; gap: 22px; }
.nav-links { display: flex; gap: 26px; list-style: none; }
.nav-links a {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em;
  color: var(--muted); text-decoration: none;
  position: relative; transition: color 0.2s;
}
.nav-links a::after {
  content: '';
  position: absolute; left: 0; bottom: -6px;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.35s var(--ease-out);
}
.nav-links a:hover { color: var(--txt); }
.nav-links a:hover::after { transform: scaleX(1); }
@media (max-width: 820px) { .nav-links { display: none; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 14px 32px;
  border-radius: 4px;
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.06em;
  text-decoration: none;
  will-change: transform;
  transition: box-shadow 0.3s, background 0.3s, color 0.3s, border-color 0.3s;
}
.btn-solid { background: var(--txt); color: var(--bg); font-weight: 700; }
.btn-solid:hover { background: var(--accent); color: var(--deep); box-shadow: 0 0 32px var(--accent-soft); }
.btn-ghost { border: 1px solid var(--line); color: var(--txt); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- footer ---------- */
footer {
  text-align: center;
  padding: 40px;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.7rem;
  letter-spacing: 0.1em; color: var(--muted);
}
footer b { color: var(--accent); font-weight: 400; }

/* ---------- konami overclock: the page inverts like flipped film ---------- */
body.overclock { animation: inkFlip 3.5s steps(6) both; }

/* ---------- loader: sound choice ---------- */
.sound-select {
  text-align: center;
  opacity: 0;
  animation: fadeUp 0.6s var(--ease-out) 1.2s forwards;
}
.sound-select p {
  font-family: var(--mono);
  font-size: 0.68rem; letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(244, 217, 160, 0.85);
  margin-bottom: 16px;
}
.sound-select button {
  background: none;
  border: 1px solid rgba(244, 217, 160, 0.3);
  color: rgba(244, 217, 160, 0.75);
  font-family: var(--mono); font-size: 0.85rem;
  letter-spacing: 0.1em;
  padding: 12px 26px; margin: 0 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.sound-select button:hover, .sound-select button:focus-visible {
  color: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 26px rgba(200, 121, 44, 0.2);
  outline: none;
}
@media (max-width: 480px) { .sound-select button { margin: 6px 4px; padding: 12px 16px; } }

/* ---------- the mute button ---------- */
#sound-btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 160;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--deep) 80%, transparent);
  border: 1px solid color-mix(in srgb, var(--cream) 30%, transparent);
  color: var(--cream);
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s;
}
#sound-btn:hover, #sound-btn:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
#sound-btn svg { width: 18px; height: 18px; }
#sound-btn .off { display: none; }
#sound-btn[aria-pressed="false"] .on { display: none; }
#sound-btn[aria-pressed="false"] .off { display: block; }
@media (hover: none) { #sound-btn { cursor: pointer; } }

/* phones: page text scrolls under the fixed name at the top, so give the nav a soft cover in the page colour */
@media (max-width: 820px) {
  nav { background: linear-gradient(var(--bg) 55%, transparent); padding-bottom: 14px; }
}

/* phones: the full-screen film grain is a large translucent layer the GPU has to composite every frame; the
   brain forming and the scroll are smoother without it, and the picture does not band visibly */
@media (max-width: 820px), (pointer: coarse) { body::before { display: none; } }
