@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #05060a;
  --ink: rgba(236, 240, 255, 0.92);
  --ink-soft: rgba(226, 232, 255, 0.62);
  --ink-faint: rgba(226, 232, 255, 0.34);
  --line: rgba(226, 232, 255, 0.16);
  --accent: #8fe9ff;
  --display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --tag-top: 58%;
  --gutter: max(18px, env(safe-area-inset-right, 0px));
  --gutter-bottom: max(18px, env(safe-area-inset-bottom, 0px));
}

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

/* ── Stage ─────────────────────────────────────────────────────────────── */

#stage {
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, #0a0d18 0%, var(--bg) 70%);
  touch-action: none;
  cursor: crosshair;
}

#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1100ms ease;
}

#stage canvas.on { opacity: 1; }

/* ── Identity ──────────────────────────────────────────────────────────── */

#identity {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* Before a scene runs (or if none can), the name is plain, real text. */
#name {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  margin: 0;
  width: 86vw;
  text-align: center;
  font-weight: 700;
  font-size: clamp(1.7rem, 5.5vw, 4.6rem);
  line-height: 0.95;
  color: var(--ink-soft);
  letter-spacing: -0.02em;
  text-wrap: balance;
  opacity: 0;
  transition: opacity 600ms ease;
}

body.fallback #name { opacity: 1; }

/* If no scene has started after a few seconds (no JavaScript, a failed
   load), show the plain text anyway. */
@keyframes late-reveal { to { opacity: 1; } }
#name, #tagline { animation: late-reveal 600ms ease 3500ms forwards; }
body.live #name { animation: none; }

/* Once a scene draws the name itself, keep the heading for assistive tech only. */
body.live #name {
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0;
}

#tagline {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--tag-top);
  margin: 0;
  padding: 0 var(--gutter);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.35em 1.1em;
  font-size: clamp(0.68rem, 0.62rem + 0.22vw, 0.86rem);
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-shadow: 0 0 18px rgba(5, 6, 10, 0.9), 0 1px 2px rgba(5, 6, 10, 0.8);
  opacity: 0;
  transition: opacity 1400ms ease 500ms, top 500ms ease;
}

body.live #tagline,
body.fallback #tagline { opacity: 1; }

#contact:empty { display: none; }

#contact::before {
  content: "";
  display: inline-block;
  width: 1.6em;
  height: 1px;
  margin-right: 1.1em;
  vertical-align: middle;
  background: var(--ink-faint);
}

#contact a {
  pointer-events: auto;
  color: inherit;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0.12em;
  border-bottom: 1px solid transparent;
  transition: color 200ms ease, border-color 200ms ease;
}

#contact a:hover,
#contact a:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink-faint);
  outline: none;
}

/* ── Controls: present, but only when you look for them ────────────────── */

#controls {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter-bottom);
  display: flex;
  align-items: center;
  gap: 14px;
  opacity: 0.55;
  transition: opacity 500ms ease;
}

body.idle #controls:not(:hover):not(:focus-within) {
  opacity: 0;
  transition-duration: 1600ms;
}

#controls:hover,
#controls:focus-within { opacity: 1; }

#dots {
  display: flex;
  align-items: center;
  gap: 2px;
}

#dots button {
  position: relative;
  width: 18px;
  height: 22px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

#dots button::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: background 250ms ease, transform 250ms ease, box-shadow 250ms ease;
}

#dots button:hover::before,
#dots button:focus-visible::before {
  background: var(--ink);
  transform: scale(1.3);
}

#dots button[aria-current="true"]::before {
  background: var(--ink);
  box-shadow: 0 0 8px rgba(190, 220, 255, 0.7);
}

#dots button:focus-visible,
#btn-sound:focus-visible,
#btn-term:focus-visible {
  outline: 1px solid var(--ink-faint);
  outline-offset: 2px;
  border-radius: 4px;
}

#btn-sound,
#btn-term {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  min-width: 22px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 200ms ease;
}

#btn-sound:hover,
#btn-term:hover,
#btn-sound[aria-pressed="true"],
#btn-term[aria-expanded="true"] { color: var(--ink); }

#btn-sound svg { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
#btn-sound .ico-body { fill: currentColor; stroke: none; }
#btn-sound .ico-on { display: none; }
#btn-sound[aria-pressed="true"] .ico-on { display: inline; }
#btn-sound[aria-pressed="true"] .ico-off { display: none; }

/* ── Terminal ──────────────────────────────────────────────────────────── */

#terminal {
  position: fixed;
  left: var(--gutter);
  bottom: var(--gutter-bottom);
  width: min(460px, calc(100vw - 2 * var(--gutter)));
  /* Stays below the role/contact line. */
  max-height: min(38vh, 340px);
  display: flex;
  flex-direction: column;
  padding: 12px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 9, 15, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  font: 400 12.5px/1.55 var(--mono);
  color: var(--ink-soft);
  animation: term-in 220ms ease both;
}

@keyframes term-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

#term-log {
  overflow-y: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

#term-log .cmd { color: var(--ink); }
#term-log .cmd::before { content: "> "; color: var(--accent); }
#term-log .dim { color: var(--ink-faint); }
#term-log .hi { color: var(--accent); }
#term-log a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-faint); text-underline-offset: 3px; }

#term-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

#term-prompt { color: var(--accent); }

#term-input {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  /* 16px on touch devices stops iOS from zooming the page on focus. */
  caret-color: var(--accent);
}

@media (pointer: coarse) {
  #term-input { font-size: 16px; }
}

/* ── Debug and fallbacks ───────────────────────────────────────────────── */

#debug {
  position: fixed;
  left: var(--gutter);
  top: max(14px, env(safe-area-inset-top, 0px));
  margin: 0;
  padding: 8px 10px;
  max-width: calc(100vw - 2 * var(--gutter));
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #b9f5c8;
  font: 11px/1.5 var(--mono);
  white-space: pre-wrap;
  pointer-events: none;
}

.noscript {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 12vh;
  margin: 0;
  padding: 0 var(--gutter);
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  #stage canvas, #tagline, #controls, #name { transition-duration: 1ms; transition-delay: 0ms; }
  #terminal { animation: none; }
}
