@font-face {
  font-family: "Geist";
  src: url("fonts/geist-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a0a0b;
  --fg: #ededee;
  --fg-dim: rgb(237 237 238 / 0.55);
  --line: rgb(237 237 238 / 0.14);
  --live: #ff3b30;

  --margin: clamp(16px, 2.2vw, 36px);
  --hud-size: 11px;
  --row: 56px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* First guess; main.js measures the text and fits it exactly. */
  --wordmark-size: calc((100vw - 2 * var(--margin)) / 6.55);

  color-scheme: dark;
}

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

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Scene ---------- */

#scene,
.fallback {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#scene {
  display: block;
}

.fallback {
  display: none;
  background:
    radial-gradient(circle 3vmin at 38% 34%, rgb(255 255 255 / 0.85), transparent),
    radial-gradient(circle 21vmin at 42% 40%, #eef0f3 0%, #aeb3bc 20%, #4a4e56 50%, #16171b 80%, transparent 100%),
    radial-gradient(ellipse 70% 35% at 50% 100%, rgb(237 237 238 / 0.05), transparent 70%),
    var(--bg);
}

.no-gl #scene {
  display: none;
}

.no-gl .fallback {
  display: block;
}

/* ---------- Viewport guides (mouse only) ---------- */

.guides {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms;
}

.guides.is-active {
  opacity: 1;
}

@media (pointer: fine) {
  .guides {
    display: block;
  }
}

.guide-x,
.guide-y {
  position: absolute;
  background: rgb(237 237 238 / 0.1);
}

.guide-x {
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  transform: translate3d(0, var(--gy, -10px), 0);
}

.guide-y {
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  transform: translate3d(var(--gx, -10px), 0, 0);
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding:
    calc(var(--margin) * 0.75 + env(safe-area-inset-top))
    calc(var(--margin) + env(safe-area-inset-right))
    0
    calc(var(--margin) + env(safe-area-inset-left));
  font-family: var(--mono);
  font-size: var(--hud-size);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--fg-dim);
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 2.2em;
}

.hud-right {
  justify-content: flex-end;
}

.hud-center,
.hud-fps-wrap {
  display: none;
}

.hud-live {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  color: var(--fg);
}

.hud-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: blink 1s steps(1, end) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

.hud-target {
  display: none;
  align-items: center;
  gap: 0.6em;
  color: var(--fg);
}

.hud-target::before {
  content: "";
  width: 10px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M0 5h8.5M5.5 2l3 3-3 3' fill='none' stroke='%23ededee' stroke-width='1.2'/%3E%3C/svg%3E") center / contain no-repeat;
}

.hud.is-targeting .hud-coords {
  display: none;
}

.hud.is-targeting .hud-target {
  display: inline-flex;
}

/* ---------- Stage: mobile first ---------- */

/* The wordmark's font content area pokes below its 0.8 line box; clip it at the
   stage edge so it can't make the page scroll. Glyph descenders stay inside the padding. */
.stage {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  overflow: clip;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: calc(var(--margin) * 1.5);
  padding:
    calc(var(--margin) * 4 + env(safe-area-inset-top))
    calc(var(--margin) + env(safe-area-inset-right))
    calc(var(--margin) + env(safe-area-inset-bottom))
    calc(var(--margin) + env(safe-area-inset-left));
}

/* Wordmark. No z-index or opacity on ancestors: the difference blend
   has to reach the canvas underneath. */
.wordmark {
  margin: 0;
  font-size: var(--wordmark-size);
  font-weight: 500;
  line-height: 0.8;
  letter-spacing: -0.045em;
  white-space: nowrap;
  color: #fff;
  mix-blend-mode: difference;
}

.wordmark-text {
  display: inline-block;
  clip-path: inset(-0.3em -0.1em -0.3em -0.1em);
}

.char {
  display: inline-block;
  animation: rise 900ms var(--ease-out) both;
  animation-delay: calc(300ms + var(--i, 0) * 25ms);
}

.char:nth-child(2) { --i: 1; }
.char:nth-child(3) { --i: 2; }
.char:nth-child(4) { --i: 3; }
.char:nth-child(5) { --i: 4; }
.char:nth-child(6) { --i: 5; }
.char:nth-child(7) { --i: 6; }
.char:nth-child(8) { --i: 7; }
.char:nth-child(9) { --i: 8; }
.char:nth-child(10) { --i: 9; }
.char:nth-child(11) { --i: 10; }
.char:nth-child(12) { --i: 11; }
.char:nth-child(13) { --i: 12; }

@keyframes rise {
  from {
    transform: translateY(150%);
  }
}

/* ---------- Links ---------- */

.links ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The top rule sits on the first item so it reveals together with it. */
.links li:first-child {
  border-top: 1px solid var(--line);
}

.links li {
  border-bottom: 1px solid var(--line);
  animation: fade-up 800ms var(--ease-out) both;
  animation-delay: calc(600ms + var(--i, 0) * 60ms);
}

.links li:nth-child(2) { --i: 1; }
.links li:nth-child(3) { --i: 2; }
.links li:nth-child(4) { --i: 3; }

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.link {
  position: relative;
  display: grid;
  grid-template-columns: 3.2em 1fr auto;
  align-items: center;
  min-height: var(--row);
  color: var(--fg);
  font-size: clamp(18px, 1.55vw, 22px);
  letter-spacing: -0.01em;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 500ms var(--ease-out);
}

.link-index {
  font-family: var(--mono);
  font-size: var(--hud-size);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--fg-dim);
  transition: color 300ms;
}

.link-name {
  transition: transform 500ms var(--ease-out);
}

.link-arrow {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  transition: transform 500ms var(--ease-out);
}

.link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
}

.link:focus-visible::after {
  transform: scaleX(1);
}

.link:focus-visible .link-index {
  color: var(--fg);
}

.link:focus-visible .link-name {
  transform: translateX(6px);
}

.link:focus-visible .link-arrow {
  transform: translate(3px, -3px);
}

@media (hover: hover) {
  .link:hover::after {
    transform: scaleX(1);
  }

  .link:hover .link-index {
    color: var(--fg);
  }

  .link:hover .link-name {
    transform: translateX(6px);
  }

  .link:hover .link-arrow {
    transform: translate(3px, -3px);
  }
}

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  .hud {
    grid-template-columns: 1fr auto 1fr;
  }

  .hud-center {
    display: flex;
    justify-content: center;
  }

  .hud-fps-wrap {
    display: inline;
  }

  .stage {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: 1fr auto;
    column-gap: var(--margin);
    row-gap: calc(var(--margin) * 2);
  }

  .wordmark {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .links {
    grid-column: 9 / -1;
    grid-row: 1;
    align-self: center;
  }
}

@media (max-width: 899px) {
  .fallback {
    background:
      radial-gradient(circle 3.4vmin at 46% 24%, rgb(255 255 255 / 0.85), transparent),
      radial-gradient(circle 26vmin at 50% 30%, #eef0f3 0%, #aeb3bc 20%, #4a4e56 50%, #16171b 80%, transparent 100%),
      var(--bg);
  }
}

/* ---------- Intro: html.is-intro is set by intro.js before first paint ---------- */

.hud {
  transition: opacity 600ms var(--ease-out);
}

.is-intro .hud {
  opacity: 0;
}

.is-intro .guides {
  visibility: hidden;
}

/* Clicks fall through to the window, where they skip the intro. */
.is-intro .stage {
  pointer-events: none;
}

/* Paused before they start, the reveals hold their hidden first keyframe. */
.is-intro .char,
.is-intro .links li {
  animation-play-state: paused;
}

/* ---------- Reduced motion and still mode ---------- */

@media (prefers-reduced-motion: reduce) {
  .char,
  .links li,
  .hud-dot {
    animation: none;
  }

  .link::after,
  .link-name,
  .link-arrow,
  .guides {
    transition: none;
  }
}

.is-still .char,
.is-still .links li,
.is-still .hud-dot {
  animation: none;
}
