:root {
  --bg: #000;
  --ink: #f0f0ec;
  --muted: #8b8b86;
  --dim: #5c5c58;
  --line: rgba(255,255,255,.1);
  --red: #ff3b2f;
  --amber: #f2b632;
  --teal: #22b8a0;
  --blue: #3d8bff;
  --sans: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --hud-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  background-color: var(--bg);
  background-image: radial-gradient(#1a1a1a 1px, transparent 1.3px);
  background-size: 8px 8px;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.locked { overflow: hidden; height: 100vh; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--red); color: #000; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

/* pixel mark (logo) */
.pix { display: grid; grid-template-columns: repeat(2, 9px); gap: 2px; flex: none; }
.pix i { width: 9px; height: 9px; background: #4a4a4a; transition: background .3s; }
.pix i:nth-child(1) { background: var(--red); }
.pix i:nth-child(4) { background: var(--blue); }
a:hover .pix i:nth-child(2) { background: var(--amber); }
a:hover .pix i:nth-child(3) { background: var(--teal); }

/* ---------- gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 80; background: #000;
  background-image: radial-gradient(#161616 1px, transparent 1.3px); background-size: 8px 8px;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 24px 24vh;
  transition: opacity .9s ease, visibility .9s;
}
.gate-inner { width: min(700px, 100%); display: flex; justify-content: space-between; align-items: flex-end; gap: 36px; flex-wrap: wrap; }
.gate-mark { display: flex; gap: 16px; align-items: flex-start; }
.gate-mark .pix { margin-top: 6px; }
.gate-mark strong { display: block; font-size: 30px; font-weight: 600; line-height: 1.02; letter-spacing: -.02em; }
.gate-mark small { display: block; margin-top: 12px; font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.gate-action { width: 250px; display: flex; flex-direction: column; gap: 12px; }
.enter { position: relative; overflow: hidden; height: 54px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; background: #2e2e2e; font-weight: 600; font-size: 15px; transition: background .25s, color .25s; }
.enter:disabled { cursor: progress; color: #8a8a86; }
.enter:not(:disabled):hover { background: var(--ink); color: #000; }
.enter-bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--red); transition: width .3s; }
.gate-sound { display: flex; gap: 8px; align-items: center; font: 400 10.5px var(--mono); color: var(--muted); cursor: pointer; user-select: none; }
.gate-sound input { position: absolute; opacity: 0; pointer-events: none; }
.gate-sound .tick { width: 11px; height: 11px; border: 1px solid #555; }
.gate-sound input:checked + .tick { background: var(--red); border-color: var(--red); }
.gate-sound input:focus-visible + .tick { outline: 2px solid var(--blue); outline-offset: 2px; }
body.entered .gate { opacity: 0; visibility: hidden; pointer-events: none; }

/* ---------- canvases ---------- */
#scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
#pixels { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
#track { position: relative; z-index: -1; }

/* ---------- HUD sidebar ---------- */
.hud {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
  width: var(--hud-w);
  display: flex; flex-direction: column;
  padding: 30px 28px 26px;
  background: linear-gradient(90deg, rgba(0,0,0,.92) 0%, rgba(0,0,0,.78) 100%);
  border-right: 1px solid var(--line);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transform: translateX(-12px);
  transition: opacity .8s .5s, transform .8s .5s;
}
body.entered .hud { opacity: 1; transform: none; }
.hud-logo { display: flex; gap: 14px; text-decoration: none; align-items: flex-start; }
.hud-logo .pix { margin-top: 4px; }
.hud-name { font-weight: 600; font-size: 19px; line-height: 1.05; letter-spacing: -.015em; }
.hud-nav { margin-top: 13vh; display: flex; flex-direction: column; gap: 2px; }
.hud-nav a {
  position: relative; display: flex; align-items: baseline; gap: 12px;
  padding: 8px 0 8px 18px; text-decoration: none;
  font-size: 15px; font-weight: 500; color: #9d9d98;
  transition: color .2s, padding .25s;
}
.hud-nav a::before { content: ""; position: absolute; left: 0; top: 50%; width: 7px; height: 7px; margin-top: -3px; background: #333; transition: background .25s; }
.hud-nav a em { font: normal 400 10px var(--mono); color: var(--dim); transition: color .2s; }
.hud-nav a:hover { color: var(--ink); padding-left: 22px; }
.hud-nav a.active { color: var(--ink); }
.hud-nav a.active::before { background: var(--red); }
.hud-nav a.active em { color: var(--red); }
.hud-foot { margin-top: auto; display: flex; flex-direction: column; gap: 18px; }
.hud-progress { display: flex; flex-direction: column; gap: 8px; font: 400 10px var(--mono); color: var(--dim); letter-spacing: .04em; }
.hud-progress .bar { height: 2px; background: #222; position: relative; }
.hud-progress .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--red); }
.sound { display: flex; align-items: center; gap: 10px; font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: #bdbdb8; padding: 10px 12px; border: 1px solid var(--line); align-self: flex-start; transition: border-color .2s, color .2s; }
.sound:hover { border-color: #555; color: var(--ink); }
.sound b { font-weight: 500; color: var(--ink); min-width: 2.4em; text-align: left; }
.sound[aria-pressed="true"] b { color: var(--red); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i { width: 2px; height: 3px; background: currentColor; }
.sound[aria-pressed="true"] .bars i { animation: eq 1s ease-in-out infinite; }
.sound[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -.3s; }
.sound[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -.6s; }
.sound[aria-pressed="true"] .bars i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%,100% { height: 3px; } 50% { height: 12px; } }
.menu-btn { display: none; }

/* ---------- scroll hint + contact card ---------- */
.scroll-hint {
  position: fixed; z-index: 30; bottom: 34px; left: calc(var(--hud-w) + (100vw - var(--hud-w)) / 2);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font: 400 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  opacity: 0; transition: opacity .6s;
  pointer-events: none;
}
.scroll-hint span { width: 1px; height: 34px; background: #333; position: relative; overflow: hidden; }
.scroll-hint span::after { content: ""; position: absolute; left: -2px; top: -6px; width: 5px; height: 5px; background: var(--red); animation: drip 1.8s cubic-bezier(.6,0,.3,1) infinite; }
@keyframes drip { to { top: 40px; } }
body.entered .scroll-hint.show { opacity: 1; transition-delay: 1.6s; }

.contact-card {
  position: fixed; z-index: 30;
  left: calc(var(--hud-w) + (100vw - var(--hud-w)) / 2); bottom: 6vh;
  transform: translate(-50%, 20px);
  width: min(560px, calc(100vw - var(--hud-w) - 48px));
  padding: 24px 28px 22px;
  background: rgba(0,0,0,.88); border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  opacity: 0; visibility: hidden;
  transition: opacity .6s, transform .6s, visibility .6s;
}
.contact-card.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.cc-label { font: 400 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cc-label .sq { display: inline-block; width: 8px; height: 8px; background: var(--red); margin-right: 10px; }
.cc-mail-unused { display: inline-flex; gap: 12px; margin-top: 12px; font-size: clamp(19px, 2.3vw, 28px); font-weight: 600; letter-spacing: -.02em; text-decoration: none; border-bottom: 1px solid #444; padding-bottom: 4px; transition: color .2s, border-color .2s; word-break: break-all; }
.cc-mail:hover { color: var(--red); border-color: var(--red); }
.cc-meta { margin-top: 14px; font: 400 11px var(--mono); color: var(--dim); }

/* ---------- accessible content ---------- */
.a11y { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
body.no-webgl .a11y { position: relative; width: auto; height: auto; clip: auto; clip-path: none; white-space: normal; overflow: visible; z-index: 2; margin-left: var(--hud-w); padding: 12vh 6vw; max-width: 900px; }
body.no-webgl .a11y section { margin-bottom: 64px; }
body.no-webgl .a11y h1 { font-size: 56px; letter-spacing: -.03em; }
body.no-webgl .a11y h2 { font: 400 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--red); margin-bottom: 14px; }
body.no-webgl .a11y h3 { font-size: 18px; margin: 18px 0 6px; }
body.no-webgl .a11y p, body.no-webgl .a11y li { color: #c4c4bf; line-height: 1.6; }
body.no-webgl .a11y ul { padding-left: 18px; }
body.no-webgl #scene, body.no-webgl #track, body.no-webgl .scroll-hint { display: none; }

/* ---------- mobile: sidebar becomes a top bar ---------- */
@media (max-width: 860px) {
  :root { --hud-w: 0px; }
  .hud {
    right: 0; bottom: auto; width: auto; height: 60px;
    flex-direction: row; align-items: center; gap: 10px;
    padding: 0 14px;
    border-right: 0; border-bottom: 1px solid var(--line);
    transform: translateY(-10px);
  }
  .hud-name { font-size: 15px; }
  .hud-logo .pix { margin-top: 2px; }
  .hud-nav {
    position: fixed; top: 60px; left: 0; right: 0; bottom: 0; margin: 0;
    padding: 8vh 24px; background: rgba(0,0,0,.96);
    opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s;
  }
  .hud-nav.open { opacity: 1; visibility: visible; }
  .hud-nav a { font-size: 28px; font-weight: 600; color: var(--ink); padding: 10px 0 10px 22px; }
  .hud-nav a em { font-size: 12px; }
  .hud-foot { margin: 0 0 0 auto; flex-direction: row; }
  .hud-progress { display: none; }
  .sound { padding: 8px 10px; font-size: 10px; }
  .menu-btn { display: block; width: 40px; height: 38px; position: relative; border: 1px solid var(--line); flex: none; }
  .menu-btn i { position: absolute; left: 11px; right: 11px; height: 2px; background: var(--ink); transition: transform .3s; }
  .menu-btn i:first-child { top: 14px; } .menu-btn i:last-child { top: 21px; }
  .menu-btn[aria-expanded="true"] i:first-child { transform: translateY(3.5px) rotate(45deg); }
  .menu-btn[aria-expanded="true"] i:last-child { transform: translateY(-3.5px) rotate(-45deg); }
  .contact-card { width: calc(100vw - 32px); bottom: 20px; padding: 20px; }
  .gate { padding-bottom: 14vh; }
  .gate-action { width: 100%; }
  body.no-webgl .a11y { margin-left: 0; padding: 90px 18px 40px; }
}
@media (max-width: 380px) { .sound .bars { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
.cc-credit { margin-top: 6px; font: 400 9.5px var(--mono); color: #4a4a46; letter-spacing: .02em; }
.cc-credit:empty { display: none; }

/* ---------- contact form (Netlify) ---------- */
.cc-form { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.cc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cc-field { display: flex; flex-direction: column; gap: 5px; }
.cc-field span { font: 400 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cc-field em { font-style: normal; color: var(--dim); text-transform: none; letter-spacing: 0; }
.cc-field input, .cc-field textarea {
  width: 100%; background: #0b0b0b; border: 1px solid #2c2c2c; color: var(--ink);
  font: 400 15px/1.4 var(--sans); padding: 10px 12px; border-radius: 0; resize: vertical; min-height: 42px;
  transition: border-color .2s, background .2s;
}
.cc-field textarea { min-height: 76px; }
.cc-field input:focus, .cc-field textarea:focus { outline: none; border-color: var(--red); background: #111; }
.cc-actions { display: flex; align-items: center; gap: 16px; margin-top: 4px; flex-wrap: wrap; }
.cc-send { display: inline-flex; align-items: center; gap: 12px; height: 44px; padding: 0 18px; background: var(--ink); color: #000; font-weight: 600; font-size: 14px; transition: background .2s, color .2s; }
.cc-send:hover { background: var(--red); color: #000; }
.cc-send:disabled { opacity: .5; cursor: progress; }
.cc-status { font: 400 11px/1.4 var(--mono); color: var(--muted); }
.cc-status.ok { color: var(--teal); }
.cc-status.err { color: var(--red); }
.cc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contact-card { max-height: calc(100vh - 40px); overflow-y: auto; }
@media (min-width: 861px) {
  .contact-card { left: auto; right: 40px; bottom: auto; top: 50%; transform: translate(0, -46%); width: min(440px, calc(100vw - var(--hud-w) - 80px)); }
  .contact-card.show { transform: translate(0, -50%); }
}
@media (max-width: 860px) {
  .cc-row { grid-template-columns: 1fr; }
  .cc-field textarea { min-height: 64px; }
}
body.no-webgl .contact-card { display: block; position: relative; left: auto; right: auto; top: auto; bottom: auto; transform: none; opacity: 1; visibility: visible; margin: 0 0 60px var(--hud-w); max-height: none; }

.cc-field input::placeholder, .cc-field textarea::placeholder { color: transparent; }
@media (max-width: 860px) {
  /* compact form on phones: placeholders instead of labels */
  .contact-card { padding: 14px 16px; bottom: 12px; }
  .cc-form { gap: 7px; margin-top: 10px; }
  .cc-row { grid-template-columns: 1fr 1fr; gap: 7px; }
  .cc-field span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .cc-field input::placeholder, .cc-field textarea::placeholder { color: #6a6a66; }
  .cc-field input, .cc-field textarea { font-size: 16px; padding: 8px 10px; min-height: 38px; }
  .cc-field textarea { min-height: 56px; }
  .cc-send { height: 40px; }
  .cc-meta { margin-top: 8px; font-size: 10px; }
}
