/* nvsble labs: fonts, tokens, layout, and components. */

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/IBMPlexMono-Italic-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/IBMPlexMono-Bold-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "Departure Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/DepartureMono-Regular.woff2") format("woff2");
}

:root {
  --bg: #1313ba;
  --ink: #ffffff;
  --ink-2: rgb(255 255 255 / 0.64);
  --ink-3: rgb(255 255 255 / 0.4);
  --line: rgb(255 255 255 / 0.16);
  --selection: rgb(255 255 255 / 0.24);

  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* Departure Mono is pixel-aligned at multiples of 11px; it is only used at 11px. */
  --pixel: "Departure Mono", var(--mono);

  --measure: 640px;
  --gutter: 16px;
  --column: min(100% - 2 * var(--gutter), var(--measure));
  --rhythm: 26px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px / var(--rhythm) var(--mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--selection);
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.24em;
  text-decoration-color: var(--ink-3);
  transition: text-decoration-color 160ms;
}
a:hover {
  text-decoration-color: currentColor;
}
:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Layout: one reading column, bounded by hairlines across the whole page */
.rules {
  position: fixed;
  inset: 0 auto 0 50%;
  width: calc(var(--column) + 2 * 32px);
  transform: translateX(-50%);
  border-inline: 1px solid var(--line);
  pointer-events: none;
}

.column {
  position: relative;
  width: var(--column);
  margin-inline: auto;
}

/* Pinned header: only the ghost and the links, with no background */
.masthead-bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  pointer-events: none;
}
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-block: 20px;
}
.masthead a,
.masthead button {
  pointer-events: auto;
}
.masthead nav {
  display: flex;
  gap: 4px;
}

/* Bracketed controls: [ md ] */
.bracket {
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 2px;
  font: 400 11px / 1 var(--pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
  white-space: pre;
}
.bracket::before {
  content: "[ ";
}
.bracket::after {
  content: " ]";
}
.bracket:hover,
.bracket[aria-pressed="true"] {
  color: var(--ink);
}

/* Ghost and lockup */
.ghost {
  display: block;
  color: currentColor;
}
.lockup {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.18em;
  font: 700 var(--lockup-size, 22px) / 1 var(--mono);
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
}
.lockup .ghost {
  height: 0.9em;
  width: auto;
}
.lockup .labs {
  color: var(--ink-2);
  /* Optical alignment: the ghost's feet sit on the baseline of "labs" */
  transform: translateY(0.06em);
}
.lockup .underscore {
  animation: prompt 1.1s steps(1) 4 both;
}
@keyframes prompt {
  50% {
    opacity: 0;
  }
}

/* Hero ghost: a button that hops when clicked; five quick clicks start the game */
.ghost-button {
  appearance: none;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ghost-button.is-hopping .ghost {
  animation: hop 280ms steps(4);
}
@keyframes hop {
  50% {
    transform: translateY(-12%);
  }
}

/* Hero */
.hero {
  position: relative;
  display: grid;
  place-items: center;
  height: 100svh;
  min-height: 600px;
  /* No padding here: container units resolve against the content box, which must equal the hero. */
  container-type: size;
  isolation: isolate;
  overflow: hidden;
}
.hero-inner {
  display: grid;
  justify-items: center;
  gap: 48px;
  padding: 96px var(--gutter);
  text-align: center;
}
.hero-inner,
.scroll-cue {
  transition:
    opacity 400ms,
    visibility 400ms;
}
.hero.is-playing .hero-inner,
.hero.is-playing .scroll-cue {
  opacity: 0;
  visibility: hidden;
}
.hero .lockup {
  --lockup-size: clamp(56px, 9vw, 100px);
}
.headline {
  margin: 0;
  font-size: clamp(18px, 1.9vw, 24px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.headline .line {
  display: block;
}
.scroll-cue {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  font: 400 11px / 1 var(--pixel);
  color: var(--ink-3);
  animation: drift 2.4s ease-in-out infinite;
}
@keyframes drift {
  50% {
    transform: translate(-50%, 4px);
  }
}

/* Sky: the glow and the ASCII share one frame with the source image's aspect ratio, so they stay aligned. */
.sky {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  /* Fade in from the top edge so overscroll meets plain field, and out at the bottom. */
  mask-image: linear-gradient(to bottom, transparent 0, #000 10%, #000 64%, transparent 100%);
}
.sky-frame {
  --aspect: 1.7778; /* 2560 / 1440 */
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, 100cqh * var(--aspect));
  aspect-ratio: var(--aspect);
  transform: translate(-50%, -50%);
  container-type: inline-size;
}
.sky-frame::before {
  /* A grey cloud mask of the photo, screened onto the field as a soft glow. It drains with the characters. */
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/clouds.webp") center / 100% 100% no-repeat;
  mix-blend-mode: screen;
  opacity: calc(0.16 * (1 - var(--fall, 0)));
}
.sky-ascii {
  position: absolute;
  inset: 0;
  /* Keep the lockup and headline clear. */
  mask-image: radial-gradient(ellipse 30% 26% at 50% 50%, transparent 20%, #000 100%);
}
.ascii {
  margin: 0;
  /* Columns × 0.6em advance fill the frame width exactly; site.js sets --ascii-cols. */
  font: 400 calc(100cqw / (var(--ascii-cols, 260) * 0.6)) / 1.2 var(--mono);
  white-space: pre;
  user-select: none;
  opacity: 0;
  transition: opacity 1.6s ease-out;
}
.ascii.is-ready {
  opacity: 0.3;
}

/* Game: the ghost hops over clouds made of the sky's characters (assets/js/game.js) */
.game {
  position: absolute;
  inset: 0;
  z-index: 1;
  outline: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* The whole game is one tap target: no tap flash, text callout, or double-tap zoom. */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.game-ghost {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--ink);
  will-change: transform;
}
.game-layer {
  opacity: 0;
  transition: opacity 400ms;
}
.game.is-ready .game-layer {
  opacity: 1;
}
.game-ground,
.game-puff {
  position: absolute;
  left: 0;
  margin: 0;
  font: 400 var(--char-size) / 1.2 var(--mono);
  white-space: pre;
  will-change: transform;
}
.game-ground {
  color: var(--ink-3);
}
.game-puff {
  top: 0;
  color: rgb(255 255 255 / 0.72);
}
.game-hud {
  position: absolute;
  top: 76px;
  left: 50%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: var(--column);
  transform: translateX(-50%);
  font: 400 11px / 1 var(--pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.game-score {
  font-size: 22px;
  color: var(--ink);
}
.game-message {
  position: absolute;
  top: 36%;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font: 400 11px / 2.2 var(--pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* Letter */
.letter {
  padding-top: calc(var(--rhythm) * 2);
}
.closing {
  padding-bottom: calc(var(--rhythm) * 2);
}
.letter p,
.closing p {
  margin: 0 0 var(--rhythm);
  max-width: 60ch;
  color: var(--ink-2);
  text-wrap: pretty;
}
.letter .lede,
.closing .lede {
  color: var(--ink);
}

/* Principles: a one-word label beside a statement */
.principles {
  list-style: none;
  margin: calc(var(--rhythm) * 2) 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.principles li {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0 16px;
  padding-block: 22px 26px;
  border-bottom: 1px solid var(--line);
}
.principles .label {
  font: 400 11px / var(--rhythm) var(--pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.principles h2 {
  margin: 0;
  font-size: 16px;
  line-height: var(--rhythm);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.principles p {
  grid-column: 2;
  margin: 6px 0 0;
  color: var(--ink-2);
  text-wrap: pretty;
}
@media (max-width: 560px) {
  .principles li {
    grid-template-columns: 1fr;
  }
  .principles p {
    grid-column: 1;
  }
}

/* nvsble → invisible: the missing i's appear on hover */
.name {
  white-space: nowrap;
  cursor: help;
}
.name .i {
  display: inline-block;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  vertical-align: bottom;
  transition:
    max-width 320ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 320ms;
}
.name:hover .i,
.name:focus-visible .i {
  max-width: 1ch;
  opacity: 0.4;
}

/* Footer */
.colophon {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 28px 40px;
  border-top: 1px solid var(--line);
  font: 400 11px / 1.6 var(--pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.colophon a {
  color: var(--ink-2);
  text-decoration: none;
}
.colophon a:hover {
  color: var(--ink);
}
.colophon .clock {
  font-variant-numeric: tabular-nums;
}

/* Markdown view: the same page, as an agent reads it */
.markdown-view {
  display: none;
  margin-block: 0 calc(var(--rhythm) * 2);
  padding-top: 8px;
  font: 400 14px / 24px var(--mono);
  white-space: pre-wrap;
}
body.is-markdown main {
  padding-top: 104px;
}
body.is-markdown .markdown-view {
  display: block;
}
body.is-markdown .page-content {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
