/* sublayer — the front door, and the deepest room in the constellation.
 *
 * The sibling owns a colour and an hour: hacklog is amber phosphor on
 * warm black. This is the layer under it, so it takes the third band of the
 * spectrum — violet — and the least light. Nothing here should look like
 * daylight.
 *
 * The rules it plays by, so a later edit doesn't drift:
 *   - Monospace everywhere. Family trait, and the page is full of hosts,
 *     berth numbers and a prompt; they should line up.
 *   - ONE accent (violet). Green and grey are not decoration here, they are
 *     the status lights, and they mean lit and sealed.
 *   - Motion is depth only: the strata drift, the cursor blinks. Both stop
 *     dead for anyone who asked for reduced motion.
 *   - No webfonts, no external requests of any kind.
 *
 * Light mode is not an inverted page. It is the same station drawn as a core
 * sample on paper — a geologic section, ink on stock. Every colour token
 * lives on bare :root; the dark block only overrides.
 */

:root {
  --ground:   #f3f2ef;
  --ground-2: #e8e6e1;
  --ink:      #16151c;
  --dim:      #615f70;
  --rule:     #d5d2cb;
  --hairline: #e0ddd6;
  --signal:   #5b3fd0;
  --signal-2: #7a63e4;
  --lit:      #167a4e;
  --sealed:   #a29fab;
  --glow:     transparent;
  --field-ink: 22, 21, 28;

  --measure: 72ch;
  --pad: clamp(1.25rem, 5vw, 3rem);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "DejaVu Sans Mono", "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:   #06060b;
    --ground-2: #0d0d16;
    --ink:      #d6d3e6;
    --dim:      #797690;
    --rule:     #201f30;
    --hairline: #16162170;
    --signal:   #9b8cff;
    --signal-2: #b6abff;
    --lit:      #4fd39a;
    --sealed:   #4a4860;
    --glow:     rgba(155, 140, 255, 0.35);
    --field-ink: 214, 211, 230;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  font-variant-ligatures: none;
}

@media (min-width: 40rem) { body { font-size: 16px; } }

/* The strata. Fixed behind the content, drawn by deck.js; it is decoration
   with no content, so it is aria-hidden and never takes a pointer event.
   
   NOT z-index: -1. body's background propagates to the viewport canvas (html
   sets none), which paints behind every negative layer — the field would be
   invisible and the CSS would look correct. It sits at 0 and the content is
   lifted to 1 instead. */
#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(3rem, 12vh, 7rem) var(--pad) 4rem;
}

::selection { background: var(--signal); color: var(--ground); }

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--rule);
}
a:hover { color: var(--signal); text-decoration-color: var(--signal); }
a:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }

/* ── masthead ─────────────────────────────────────────────────────────── */

.masthead { margin-bottom: 3rem; }

.wordmark {
  margin: 0;
  font-size: clamp(2rem, 11vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  color: var(--signal);
  text-shadow: 0 0 28px var(--glow);
}

.cursor {
  font-weight: 400;
  margin-left: 0.06em;
  animation: blink 1.25s steps(1) infinite;
}

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

.tagline {
  margin: 0.9rem 0 0;
  color: var(--dim);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

/* ── the lede ─────────────────────────────────────────────────────────── */

.lede { margin: 0 0 3.5rem; max-width: 62ch; }
.lede p { margin: 0 0 1rem; }
.lede-turn { color: var(--signal-2); }

/* ── section heads ────────────────────────────────────────────────────── */

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 1.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim);
}

.count { letter-spacing: 0.12em; text-transform: none; opacity: 0.85; }

kbd {
  font: inherit;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 0.35em;
  color: var(--ink);
}

/* ── the decks ────────────────────────────────────────────────────────── */

.manifest { margin-bottom: 3.5rem; }

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

.deck {
  border-left: 2px solid transparent;
  padding: 0.85rem 0 0.95rem 0.9rem;
  border-bottom: 1px solid var(--hairline);
  transition: border-color 120ms linear, background-color 120ms linear;
}

.deck.lit:hover, .deck.lit:focus-within {
  border-left-color: var(--signal);
  background: var(--ground-2);
}

.deck-head {
  display: grid;
  grid-template-columns: 3ch minmax(0, 14ch) 1.4ch auto 1fr;
  align-items: baseline;
  gap: 0 0.9ch;
  text-decoration: none;
  color: inherit;
}

.berth { color: var(--dim); font-size: 0.8rem; }

.deck-name {
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.deck.lit .deck-name { color: var(--ink); }
.deck.lit:hover .deck-name, .deck.lit:focus-within .deck-name { color: var(--signal); }
.deck.dark .deck-name { color: var(--sealed); letter-spacing: 0; }

/* The status light. It is the only round thing on the page, so it reads as a
   lamp rather than as punctuation. Lit decks glow; sealed ones are hollow. */
.light {
  justify-self: center;
  align-self: center;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}
.deck.lit .light { background: var(--lit); box-shadow: 0 0 9px var(--lit); }
.deck.dark .light { border: 1px solid var(--sealed); }

.status {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--dim);
}
.deck.dark .status { color: var(--sealed); }

.deck-tagline {
  color: var(--dim);
  font-size: 0.82rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-body {
  margin: 0.55rem 0 0;
  padding-left: 3ch;
  max-width: 60ch;
  color: var(--ink);
  font-size: 0.88rem;
}
.deck.dark .deck-body { color: var(--sealed); }

.deck-host {
  margin: 0.4rem 0 0;
  padding-left: 3ch;
  color: var(--dim);
  font-size: 0.76rem;
  letter-spacing: 0.05em;
}
.deck.lit .deck-host::before { content: "\2192\00a0"; color: var(--signal); }

/* Below the fold of a phone the five-column head has nowhere to go: the
   tagline drops under the name rather than being ellipsed into nothing. */
@media (max-width: 34rem) {
  .deck-head { grid-template-columns: 3ch 1fr 1.4ch auto; }
  .deck-tagline { grid-column: 2 / -1; white-space: normal; padding-top: 0.2rem; }
}

.transmission {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1ch;
  margin: 1.4rem 0 0;
  padding-left: 0.9rem;
  font-size: 0.8rem;
  color: var(--dim);
}
.transmission .label { letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.8; }
.transmission .when { color: var(--sealed); }
.transmission a { color: var(--ink); }

/* ── the activity strip ───────────────────────────────────────────────── */
/* Measured, not written: bin/collect fills it from the box, render only
   lays it out. Same furniture as the decks — the lamp means the same thing
   here (a worker up) as it does there (a deck lit). */

.activity { margin-bottom: 3.5rem; }

.workers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6ch;
  margin: 0 0 1rem;
  padding-left: 0.9rem;
  font-size: 0.82rem;
}
.worker { display: inline-flex; align-items: center; gap: 0.6ch; color: var(--ink); }
.worker .light { width: 0.5rem; height: 0.5rem; border-radius: 50%; flex: none; }
.worker.up .light { background: var(--lit); box-shadow: 0 0 9px var(--lit); }
.worker.down .light { border: 1px solid var(--sealed); }
.worker .state { color: var(--dim); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; }
.worker .since { color: var(--sealed); font-size: 0.76rem; }

.log { list-style: none; margin: 0; padding: 0; }
.ev {
  display: grid;
  grid-template-columns: 11ch 8ch 1fr;
  gap: 0 1.2ch;
  align-items: baseline;
  padding: 0.3rem 0 0.3rem 0.9rem;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.84rem;
}
.ev .when { color: var(--sealed); font-size: 0.76rem; letter-spacing: 0.04em; }
.ev .who { color: var(--signal-2); }
.ev .what { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.ev .obj { color: var(--dim); }
.ev .span { color: var(--sealed); font-size: 0.76rem; }
.ev.merge { border-left-color: var(--rule); }
.ev.review .what { color: var(--dim); }
.ev.todo .what { color: var(--dim); }

@media (max-width: 34rem) {
  .ev { grid-template-columns: 11ch 1fr; }
  .ev .what { grid-column: 1 / -1; padding-left: 0; }
}

.queue, .more, .nosignal {
  margin: 1rem 0 0;
  padding-left: 0.9rem;
  font-size: 0.8rem;
  color: var(--dim);
}
.nosignal { color: var(--sealed); max-width: 60ch; }
.queue a { color: var(--ink); }

/* ── /ops/ ───────────────────────────────────────────────────────────── */

.masthead.small .wordmark { font-size: clamp(1.4rem, 7vw, 2.2rem); letter-spacing: 0.1em; }
.crumb { margin: 0 0 0.8rem; font-size: 0.76rem; color: var(--dim); letter-spacing: 0.1em; }
.crumb a { color: var(--dim); }
.topology p { margin: 0 0 1rem; }
.upstream { color: var(--dim); font-size: 0.8rem; }
.upstream .label { letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.8; margin-right: 1ch; }
.upstream a { color: var(--ink); }
.workers-now { margin-bottom: 3rem; }
.decisions .note { margin: 0 0 1.4rem; max-width: 60ch; color: var(--dim); font-size: 0.84rem; }

.repo { margin: 0 0 2rem; }
.repo h3 {
  display: flex;
  align-items: center;
  gap: 0.8ch;
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.repo h3 .light { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--lit); box-shadow: 0 0 9px var(--lit); }
.repo.retired h3 { color: var(--sealed); }
.repo.retired h3 .light { background: none; box-shadow: none; border: 1px solid var(--sealed); }
.repo h3 .n { color: var(--dim); font-weight: 400; letter-spacing: 0; font-size: 0.76rem; }

.adrs { list-style: none; margin: 0; padding: 0; }
.adrs li {
  display: grid;
  grid-template-columns: 5ch 1fr auto;
  gap: 0 1.2ch;
  align-items: baseline;
  padding: 0.3rem 0 0.3rem 0.9rem;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.84rem;
}
.adr-id { color: var(--dim); font-size: 0.76rem; }
.adr-title { min-width: 0; overflow-wrap: anywhere; }
.repo.retired .adr-title { color: var(--sealed); }
.adr-status { color: var(--sealed); font-size: 0.74rem; letter-spacing: 0.06em; white-space: nowrap; }
@media (max-width: 34rem) {
  .adrs li { grid-template-columns: 5ch 1fr; }
  .adr-status { grid-column: 2; }
}

/* ── the console ──────────────────────────────────────────────────────── */

.console {
  background: var(--ground-2);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--signal);
  padding: 0.9rem 1rem;
  font-size: 0.85rem;
}

.console.focused { border-color: var(--signal); }

.readout {
  margin: 0;
  min-height: 7.5rem;
  max-height: 22rem;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.readout .out { color: var(--ink); }
.readout .muted { color: var(--dim); }
.readout .sig { color: var(--signal); }
.readout .ok { color: var(--lit); }
.readout .echo { color: var(--dim); }
.readout .echo b { color: var(--ink); font-weight: 400; }

.prompt {
  display: grid;
  grid-template-columns: 2ch 1fr;
  align-items: center;
  gap: 0 0.5ch;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--rule);
}

.ps1 { color: var(--signal); user-select: none; }

#cmd {
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  width: 100%;
  caret-color: var(--signal);
}
#cmd:focus { outline: none; }

.noscript { color: var(--dim); font-size: 0.8rem; margin: 0.8rem 0 0; }

/* ── footer ───────────────────────────────────────────────────────────── */

footer {
  margin-top: 4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  color: var(--dim);
  font-size: 0.76rem;
  max-width: 62ch;
}
footer p { margin: 0 0 0.4rem; }
.built { color: var(--sealed); letter-spacing: 0.05em; }

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  * { transition: none !important; }
}

/* ── the manual ───────────────────────────────────────────────────────── */
/* Prose pages under /manual/. Same furniture as ops: heads are small, spaced
   and dim; code and tables take the signature panel (ground-2, a rule, a 2px
   signal left border). Every colour is a token already defined above. */

.manual { max-width: var(--measure); }
.manual .page-body p { margin: 0 0 1rem; }
.manual .page-body h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 2.6rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim);
}
.manual .page-body h3 {
  margin: 1.8rem 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.manual .page-body ul, .manual .page-body ol { margin: 0 0 1.2rem; padding-left: 1.6rem; }
.manual .page-body li { margin: 0 0 0.45rem; }
.manual .page-body li::marker { color: var(--dim); }
.manual .page-body strong { color: var(--ink); font-weight: 700; }
.manual .page-body code {
  font: inherit;
  padding: 0 0.3em;
  background: var(--ground-2);
  border: 1px solid var(--hairline);
  border-radius: 3px;
}
.manual .page-body pre {
  margin: 0 0 1.4rem;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  background: var(--ground-2);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--signal);
  font-size: 0.86rem;
  line-height: 1.55;
}
.manual .page-body pre code { padding: 0; background: none; border: 0; }
.manual .page-body table {
  width: 100%;
  margin: 0 0 1.4rem;
  border-collapse: collapse;
  font-size: 0.86rem;
  border-left: 2px solid var(--signal);
}
.manual .page-body th, .manual .page-body td {
  padding: 0.45rem 0.8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
.manual .page-body th {
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}
.manual .page-body td:first-child { color: var(--ink); }
@media (max-width: 40rem) {
  .manual .page-body table { display: block; overflow-x: auto; }
}

.manual-pages { list-style: none; margin: 0; padding: 0; }
.manual-pages .page { border-bottom: 1px solid var(--hairline); }
.manual-pages .page a {
  display: grid;
  grid-template-columns: 3ch 1fr;
  gap: 0.2rem 1rem;
  padding: 0.9rem 0.6rem;
  color: inherit;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.manual-pages .page a:hover, .manual-pages .page a:focus-visible {
  background: var(--ground-2);
  border-left-color: var(--signal);
}
.manual-pages .n { color: var(--dim); font-size: 0.8rem; letter-spacing: 0.22em; }
.manual-pages .page-name { font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--signal); }
.manual-pages .page-summary { grid-column: 2; color: var(--dim); font-size: 0.86rem; }

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.86rem;
}
.page-nav .next { margin-left: auto; }

/* ── the crew ─────────────────────────────────────────────────────────── */
/* One row per crew member: the lamp and the name, the role and the queue,
   one line in the signal, then the sketch as prose. Same panel as the rest. */

.crew { max-width: var(--measure); }
.crew-list { list-style: none; margin: 0; padding: 0; }
.crew-member {
  margin: 0 0 2.4rem;
  padding: 1rem 1.2rem 0.4rem;
  background: var(--ground-2);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--sealed);
}
.crew-member.up { border-left-color: var(--signal); }
.crew-member h3 {
  display: flex;
  align-items: center;
  gap: 0.8ch;
  margin: 0 0 0.3rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.crew-member h3 .light { width: 0.5rem; height: 0.5rem; border-radius: 50%; flex: none; }
.crew-member.up h3 .light { background: var(--lit); box-shadow: 0 0 9px var(--lit); }
.crew-member.down h3 .light { border: 1px solid var(--sealed); }
.crew-member .worker-state { color: var(--dim); font-size: 0.72rem; letter-spacing: 0.18em; font-weight: 400; }
.crew-member .since { color: var(--sealed); font-size: 0.76rem; font-weight: 400; letter-spacing: 0; text-transform: none; }
.crew-meta { margin: 0 0 0.8rem; color: var(--dim); font-size: 0.76rem; letter-spacing: 0.22em; text-transform: uppercase; }
.crew-line { margin: 0 0 1rem; color: var(--signal-2); }
.crew-member .sketch p { margin: 0 0 1rem; }
.crew-member .nosignal { margin: 0 0 1rem; }
.how p { margin: 0 0 1rem; }
