@font-face { font-family: "Plex Mono"; src: url("/fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/fonts/plex-mono-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --paper: #000;
  --ink: #fff;
  --text: #D4D4D4;
  --dim: #858585;
  --font: "Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --step--1: 0.875rem;
  --step-1: 1.25rem;
  --step-2: 1.5rem;
  --gutter: clamp(1.25rem, 5vw, 4rem);
  color-scheme: dark;
}

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

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(1rem, 0.85rem + 0.75vw, 1.375rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-size: inherit; line-height: inherit; }
p { margin: 0; }
a { color: inherit; text-underline-offset: 0.25em; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

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

/* Terminal session */
.term { padding: var(--gutter); max-width: 60ch; }
.ps1 { color: var(--dim); }
.out { margin-bottom: 1.2em; }
.term h1 { color: var(--ink); font-weight: 700; }
.cmd { display: inline-block; vertical-align: bottom; overflow: hidden; white-space: nowrap; color: var(--ink); }
.l1 .cmd { --n: 6; }
.l2 .cmd { --n: 10; }
.l3 .cmd { --n: 9; }
.l4 .cmd { --n: 6; }
.l5 .cmd { --n: 9; }
.l6 .cmd { --n: 2; }
.ls { display: flex; flex-wrap: wrap; column-gap: 2ch; }
.ls span { color: var(--ink); font-weight: 700; }
.ls .file { color: var(--text); font-weight: 400; }
.term a { text-decoration: underline dotted var(--dim); }
@media (hover: hover) { .term a:hover { text-decoration-color: var(--ink); } }
.cursor { display: inline-block; width: 0.6em; height: 1.15em; margin-left: 0.15em; vertical-align: -0.2em; background: var(--ink); }
.cursor.fallback { display: none; }
form[hidden] + .cursor.fallback { display: inline-block; }

/* The live prompt */
.prompt { display: flex; gap: 1ch; align-items: baseline; }
.prompt form { flex: 1; min-width: 0; margin: 0; }
.prompt input {
  width: 100%; padding: 0; border: 0; border-radius: 0; background: none; outline: none;
  font: inherit; color: var(--ink); caret-color: var(--ink); caret-shape: block;
}
.prompt input::placeholder { color: var(--dim); opacity: 1; }
.typed { color: var(--ink); white-space: pre-wrap; word-break: break-all; }
.err { color: var(--dim); }
.help { margin-top: 0; display: grid; grid-template-columns: max-content 1fr; column-gap: 2ch; }
.help dt { color: var(--ink); }
.help dd { margin: 0; color: var(--dim); }
[data-history] > .out:last-child { margin-bottom: 1.2em; }
[data-history] .out { margin-bottom: 0.6em; }

@media (prefers-reduced-motion: no-preference) {
  .cmd { width: calc(var(--n) * 1ch); animation: type calc(var(--n) * 55ms) steps(var(--n)) var(--at) both; }
  .out, .l2, .l3, .l4, .l5, .l6, .l7 { animation: show 0s var(--at) both; }
  .l1 .cmd { --at: 0.4s; }
  .o1 { --at: 0.9s; }
  .l2 { --at: 1.05s; }
  .l2 .cmd { --at: 1.25s; }
  .o2 { --at: 1.95s; }
  .l3 { --at: 2.1s; }
  .l3 .cmd { --at: 2.3s; }
  .o3 { --at: 2.95s; }
  .l4 { --at: 3.1s; }
  .l4 .cmd { --at: 3.3s; }
  .o4 { --at: 3.8s; }
  .l5 { --at: 3.95s; }
  .l5 .cmd { --at: 4.15s; }
  .o5 { --at: 4.8s; }
  .l6 { --at: 4.95s; }
  .l6 .cmd { --at: 5.15s; }
  .o6 { --at: 5.4s; }
  .l7 { --at: 5.55s; }
  [data-history] .out { animation: none; }
  .cursor { animation: blink 1.1s steps(1) infinite; }
  @keyframes type { from { width: 0; } }
  @keyframes show { from { visibility: hidden; } }
  @keyframes blink { 50% { opacity: 0; } }
}

/* Asteroids */
.asteroids-on, .asteroids-on body { overflow: hidden; }
.asteroids-on body > header, .asteroids-on body > main, .asteroids-on body > footer { visibility: hidden; }
.asteroids {
  position: fixed; inset: 0; z-index: 100;
  color: var(--ink); font-family: var(--font);
  transition: background-color 0.6s, color 0.6s;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.asteroids.is-dark { background: #000; color: #fff; }
.asteroids canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.asteroids button { font: 600 var(--step--1) var(--font); color: #fff; background: #000; border: 1px solid #fff; border-radius: 999px; padding: 0.5rem 1rem; cursor: pointer; }
@media (hover: hover) { .asteroids button:hover { background: #fff; color: #000; } }
.asteroids button { -webkit-tap-highlight-color: transparent; }
.asteroids-pad button:active { background: #fff; color: #000; }
.asteroids :focus-visible { outline-color: #fff; }
.asteroids-exit { position: absolute; top: 1rem; right: 1rem; }
.asteroids-help {
  position: absolute; left: 1rem; right: 1rem; bottom: 1.25rem;
  text-align: center; font-size: var(--step--1); opacity: 0.7;
  animation: asteroids-help 0.8s 7s forwards;
}
@keyframes asteroids-help { to { opacity: 0; visibility: hidden; } }
.asteroids-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(24rem, calc(100% - 2rem)); padding: 2rem;
  background: #000; border: 1px solid #fff; text-align: center;
}
.asteroids-panel h2 { font-size: var(--step-2); }
.asteroids-panel p { margin-top: 0.75rem; }
.asteroids-panel p:last-child { margin-top: 1.5rem; display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.asteroids-pad { display: none; }
@media (pointer: coarse) {
  .asteroids-help { display: none; }
  .asteroids-pad { display: block; }
  .asteroids-pad button {
    position: absolute; bottom: calc(1.25rem + env(safe-area-inset-bottom)); width: 4rem; height: 4rem;
    padding: 0; border-radius: 50%; font-size: 1.25rem; opacity: 0.75;
  }
  .asteroids-pad [data-key=left] { left: 1rem; }
  .asteroids-pad [data-key=right] { left: 5.75rem; }
  .asteroids-pad [data-key=thrust] { right: 5.75rem; }
  .asteroids-pad [data-key=fire] { right: 1rem; }
}
