/* /terminal — aterm running in the page. Same palette + type rules as the
   rest of the site (serif for prose, mono for identifiers, no webfonts for
   PAGE text — the .ttf under this directory is engine data: the wasm
   rasterizer's font, fetched like an image, never a CSS font). */

:root {
  --bg: #F5F3EC;
  --fg: #1B1D18;
  --fg-dim: #4D4F47;
  --muted: #64665D;
  --rule: #847E72;
  --accent: #0F6A78;
  --term-bg: #0C0D0C;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --serif: ui-serif, Charter, "Bitstream Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C0D0C;
    --fg: #E6E4DD;
    --fg-dim: #A3A199;
    --muted: #8A8983;
    --rule: #6A6C64;
    --accent: #5BB8C4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

header.bar {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.85rem;
}
header.bar .brand {
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
}
header.bar .title { color: var(--fg-dim); }
header.bar .get {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
header.bar .get:hover { text-decoration: underline; }
/* Two links in the bar now. The auto margin belongs to the FIRST of the pair,
   not to every .get — otherwise both absorb free space and a gap opens between
   them. Anchoring it to .register (rather than to the title) keeps the pair at
   the right edge on narrow screens too, where the title is display:none. */
header.bar .get { margin-left: 0; }
header.bar .register { margin-left: auto; }
header.bar .get + .get { margin-left: 0.6rem; }

main {
  flex: 1;
  min-height: 0;
  padding: clamp(0.5rem, 2vw, 1.25rem);
  display: flex;
}

#term-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  background: var(--term-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  padding: 10px; /* boot.js subtracts this when fitting the grid (--term-pad) */
}

#term {
  display: block;
  opacity: 0;
  transition: opacity 160ms ease-out;
}
#term.live { opacity: 1; }

#boot,
.noscript-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #8A8983;
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* the keyboard sink: focusable, invisible, still IME-capable */
#kbd {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2px;
  height: 2px;
  padding: 0;
  border: none;
  opacity: 0;
  font-size: 16px; /* keeps iOS from zooming on focus */
  resize: none;
}

@media (max-width: 40rem) {
  header.bar .title { display: none; }
}
/* Below ~26rem even brand + the two nowrap buttons exceed the bar: let the
   pair drop to its own line (still right-aligned by .register's auto margin).
   overflow-x: auto is the same safety net footer.by has — the bar may scroll,
   the page never does. */
@media (max-width: 26rem) {
  header.bar { flex-wrap: wrap; row-gap: 0.5rem; overflow-x: auto; }
  /* whichever button wraps to the second line keeps the right edge too */
  header.bar .get.download { margin-left: auto; }
}

/* the header's install link is /aterm's download button, sized for the bar */
header.bar .get.download {
  display: inline-block;
  font: 600 0.8125rem var(--mono);
  color: var(--bg);
  background: var(--accent);
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  white-space: nowrap;
}
/* the OS mark after "Download aterm" — the label's size and ink; the sprite it
   draws from is a zero-size <svg> at the top of the body */
header.bar .get.download .os { width: 1em; height: 1em; vertical-align: -0.15em; margin-left: 0.4em; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
/* visually hidden, still read by assistive tech (" for macOS" completes the button's name) */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
header.bar .get.download:hover, header.bar .get.download:focus-visible {
  color: var(--bg);
  text-decoration: none;
  background: color-mix(in srgb, var(--accent) 85%, var(--fg));
}
/* platform.js aims this button like /aterm's; when the visitor's platform has
   no published build (or cannot be told) it turns hollow, says so, and leads to
   /aterm#install (the picker). Inset ring so the bar's height never changes. */
header.bar .get.download.download-none {
  color: var(--fg-dim);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--fg-dim);
}
header.bar .get.download.download-none:hover, header.bar .get.download.download-none:focus-visible {
  color: var(--fg);
  background: color-mix(in srgb, var(--fg-dim) 12%, transparent);
}

/* Register: a real <button> (it opens the dialog below), outlined — the
   download stays the primary call. Only the UA look is reset; its margins are
   left alone so the .register auto margin above still anchors the pair. */
header.bar .get.register {
  display: inline-block;
  appearance: none;
  -webkit-appearance: none;
  font: 600 0.8125rem var(--mono);
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
header.bar .get.register:hover, header.bar .get.register:focus-visible {
  text-decoration: none;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
header.bar .get:focus-visible,
#register-dialog :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── the Register dialog ──
   Same vocabulary as the card pages: an accent rail on the left, mono for the
   heading, labels and fields, serif for the two lines of prose. The inset is
   PADDING on #register-dialog (a child's margin would hit-test as the dialog);
   register.js decides "backdrop" by geometry anyway, so a tap in the gutter
   never dismisses. */
#register-dialog {
  width: min(26rem, calc(100vw - 2rem));
  margin: auto;
  padding: 1.25rem 1.4rem 1.25rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.4);
}
#register-dialog::backdrop { background: rgb(12 13 12 / 0.6); }
#register-dialog .panel {
  margin: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
}
#register-dialog h2 {
  margin: 0 0 0.6rem;
  font: 700 0.95rem var(--mono);
  letter-spacing: 0.04em;
}
#register-dialog .what {
  margin: 0;
  font: 400 0.9375rem/1.5 var(--serif);
  color: var(--fg);
}
#register-dialog label {
  display: block;
  margin: 0.9rem 0 0.3rem;
  font: 600 0.75rem var(--mono);
  letter-spacing: 0.04em;
  color: var(--fg-dim);
}
#register-dialog input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  font: 400 1rem var(--mono); /* 16px: iOS does not zoom the field on focus */
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg-dim);
  border-radius: 4px;
}
#register-dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.1rem;
}
#register-dialog .actions button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0.5rem 0.9rem;
  font: 600 0.8125rem var(--mono);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
#register-dialog .go {
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
}
#register-dialog .go:hover, #register-dialog .go:focus-visible {
  background: color-mix(in srgb, var(--accent) 85%, var(--fg));
  border-color: color-mix(in srgb, var(--accent) 85%, var(--fg));
}
#register-dialog .cancel {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
}
#register-dialog .cancel:hover, #register-dialog .cancel:focus-visible {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
#register-dialog .note {
  margin: 1rem 0 0;
  font: 400 0.8125rem/1.55 var(--serif);
  color: var(--muted);
}
#register-dialog code { font: 400 0.9em var(--mono); }
#register-dialog .note a { color: var(--muted); }
#register-dialog .note a:hover, #register-dialog .note a:focus-visible { color: var(--accent); }
#register-done .note { margin-top: 0.75rem; }
/* the typed address has no break opportunity: wrap it rather than overflow */
#register-done-email { overflow-wrap: anywhere; }
/* the done panel takes focus programmatically (so it is read aloud); it is
   not interactive, so no ring on the whole panel */
#register-done:focus { outline: none; }

/* the site footer, one line, in the header bar's voice */
footer.by {
  border-top: 1px solid var(--rule);
  padding: 0.5rem 1.25rem;
  font: 400 0.8125rem var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow-x: auto;
}
footer.by p { margin: 0; }
/* the ALab mark that opens the by-line — the header brand's weight and tracking */
footer.by .mark { font-weight: 700; letter-spacing: 0.04em; color: var(--fg); }
footer.by a { color: var(--muted); text-decoration: none; }
footer.by a:hover, footer.by a:focus-visible { color: var(--accent); }
footer.by .soc { display: inline-block; vertical-align: -0.15em; margin-left: 0.1em; }
footer.by .soc svg { width: 1em; height: 1em; }
