/* zapla.net — ship's terminal, booting.
 *
 * Dark by design: there is no light theme and no theme switch, because the whole visual language
 * (phosphor glow, scanlines, a starfield behind everything) only reads on black. Every colour
 * below was checked against --bg for WCAG AA at body size; --dim is the floor, do not go quieter.
 *
 * Nothing here loads from a network other than this one. No @import, no font CDN, no icon set.
 * A landing page that a third party can break at any moment is a landing page that will be broken
 * on the day someone actually looks at it.
 */

:root {
  --bg:      #04060c;   /* the page under the starfield */
  --panel:   #080d17;   /* panel fill, sits just above the starfield */
  --panel-2: #0c1320;   /* table stripes and inset wells */
  --line:    #1d2a3d;   /* hairlines and panel borders */
  --ink:     #d8e4f2;   /* body text — 15.6:1 on --bg */
  --dim:     #8698ae;   /* labels and secondary text — 6.9:1 on --bg, the quietest allowed */
  --acc:     #5af0a8;   /* phosphor green: online, headings, the wordmark rule — 13.9:1 */
  --acc-dk:  #1d5f43;   /* accent at rest, for rules and inactive pips */
  --warn:    #ffc44d;   /* stale / rate limited — 11.6:1 */
  --bad:     #ff6f61;   /* offline / no signal — 6.5:1 */
  --info:    #7cc4ff;   /* links — 8.4:1 */

  /* Monospace everywhere. No webfont: the page must be correct the instant the HTML lands, and
     a self-hosted pixel face would still be one more thing to ship, version and cache-bust. */
  --mono: ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace;

  /* Spacing on an 8px grid so panel edges keep landing on whole pixels. */
  --u: 8px;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  /* Sub-pixel antialiasing fights the pixel look; keep glyph edges hard. */
  -webkit-font-smoothing: none;
  font-smooth: never;
  overflow-x: hidden;
}

/* The starfield is a fixed backdrop, not content. It is behind everything and never scrolls. */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  /* The canvas backing store is deliberately ~1/3 scale; this is what makes a star a chunky
     square instead of a soft dot when the browser scales it back up. */
  image-rendering: pixelated;
}

/* Scanlines + a vignette, drawn over the starfield but under the content. pointer-events:none
   or the whole page stops being clickable. */
#crt {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.30) 0px,
      rgba(0, 0, 0, 0.30) 1px,
      rgba(0, 0, 0, 0) 1px,
      rgba(0, 0, 0, 0) 3px
    );
  opacity: 0.55;
}
#crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0) 45%, rgba(0,0,0,0.55) 100%);
}
@media (prefers-reduced-motion: reduce) {
  /* Scanlines are static, so they stay — but drop them to where they cannot shimmer on scroll
     for anyone who asked the OS to calm things down. */
  #crt { opacity: 0.30; }
}

.shell {
  position: relative;
  z-index: 2;
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(var(--u) * 4) calc(var(--u) * 2) calc(var(--u) * 8);
}

/* ─── Panels ──────────────────────────────────────────────────────────────── */

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: calc(var(--u) * 2);
  margin: 0 0 calc(var(--u) * 3);
}

/* Corner brackets: four 10px L's drawn with borders on two pseudo-elements. Hard edges, no
   border-radius anywhere on this page. */
.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
  border-color: var(--acc);
  border-style: solid;
}
.panel::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.panel::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.panel > h2 {
  margin: 0 0 calc(var(--u) * 2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--acc);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--u);
}
.panel > h2 .idx { color: var(--acc-dk); margin-right: var(--u); }

/* ─── Hero ────────────────────────────────────────────────────────────────── */

.hero { padding-top: calc(var(--u) * 4); }

.wordmark {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  fill: var(--ink);
  /* The glow is the only soft thing on the page and it is behind hard-edged pixels, which is
     what a phosphor tube actually looks like. */
  filter: drop-shadow(0 0 6px rgba(90, 240, 168, 0.35));
}

.tagline {
  margin: calc(var(--u) * 3) 0 0;
  font-size: 17px;
  max-width: 62ch;
}

.subline {
  margin: var(--u) 0 0;
  color: var(--dim);
  max-width: 62ch;
}

.phase {
  display: inline-block;
  margin-top: calc(var(--u) * 2);
  padding: 2px var(--u);
  border: 1px solid var(--warn);
  color: var(--warn);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Click-to-copy address. */
.address {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  margin-top: calc(var(--u) * 3);
  max-width: 460px;
}
.address code {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--u) calc(var(--u) * 1.5);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-right: 0;
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--ink);
  overflow-x: auto;
}
.address button {
  flex: 0 0 auto;
  padding: var(--u) calc(var(--u) * 2);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--acc);
  border: 1px solid var(--acc);
  cursor: pointer;
}
.address button:hover { background: #7ff7bd; }
.address button[data-state="copied"] { background: var(--warn); border-color: var(--warn); }
.address button[data-state="failed"] { background: var(--bad); border-color: var(--bad); }

/* ─── Status panel ────────────────────────────────────────────────────────── */

.status-head {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
  flex-wrap: wrap;
}

/* The state light: a hard square, not a circle, and it does not pulse. */
.light {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background: var(--dim);
  box-shadow: 0 0 10px rgba(134, 152, 174, 0.5);
}
.state-online   .light { background: var(--acc);  box-shadow: 0 0 12px rgba(90, 240, 168, 0.7); }
.state-offline  .light { background: var(--bad);  box-shadow: 0 0 12px rgba(255, 111, 97, 0.6); }
.state-nosignal .light { background: var(--bad);  box-shadow: none; opacity: 0.55; }
.state-limited  .light { background: var(--warn); box-shadow: 0 0 12px rgba(255, 196, 77, 0.55); }

.state-word {
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.1;
  color: var(--dim);
}
.state-online   .state-word { color: var(--acc); }
.state-offline  .state-word,
.state-nosignal .state-word { color: var(--bad); }
.state-limited  .state-word { color: var(--warn); }

.badge {
  padding: 1px 6px;
  border: 1px solid currentColor;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--warn);
}
.badge[hidden] { display: none; }

/* Telemetry readout: label on the left, value on the right, dotted leader between. */
.readout {
  margin: calc(var(--u) * 2) 0 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px calc(var(--u) * 2);
}
.readout dt {
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow: hidden;
  white-space: nowrap;
}
.readout dt::after {
  content: " ································································································";
  color: var(--acc-dk);
}
.readout dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.readout dd.motd { text-align: right; max-width: 40ch; justify-self: end; }

.foot-note {
  margin: calc(var(--u) * 2) 0 0;
  padding-top: var(--u);
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: var(--u);
  flex-wrap: wrap;
}

/* ─── Market ──────────────────────────────────────────────────────────────── */

.station { margin-top: calc(var(--u) * 3); }
.station:first-of-type { margin-top: 0; }

.station h3 {
  margin: 0 0 var(--u);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.station h3 .sid { color: var(--dim); font-weight: 400; letter-spacing: 0.08em; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
caption { text-align: left; color: var(--dim); font-size: 12px; padding-bottom: 4px; }
th, td {
  padding: 5px var(--u);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
thead th {
  color: var(--dim);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
tbody tr:nth-child(even) { background: var(--panel-2); }
th.bid { text-align: right; }
td.bid {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--acc);
  white-space: nowrap;
}
td.bid .unit { color: var(--dim); font-size: 12px; margin-left: 4px; }
td.spark { width: 108px; padding-right: 0; }

/* Sparkline: hard-edged divs, one column per history point. No charting library — it would be
   larger than the rest of the site put together. */
.spark-cols {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 22px;
}
.spark-cols i {
  display: block;
  width: 3px;
  min-height: 1px;
  background: var(--acc-dk);
}
.spark-cols i:last-child { background: var(--acc); }
.spark-none { color: var(--dim); font-size: 11px; }
/* The market panel with no data in it. Same size as body text: "the feed is down" is the
   panel's content in that state, not a footnote to it. */
.feed-note { margin: 0; color: var(--dim); }

/* ─── "What this is" ──────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: calc(var(--u) * 2);
}
.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--acc-dk);
  padding: calc(var(--u) * 2);
}
.card h3 {
  margin: 0 0 var(--u);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acc);
}
.card p { margin: 0; color: var(--ink); font-size: 14px; }

/* ─── Footer ──────────────────────────────────────────────────────────────── */

footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--line);
  padding: calc(var(--u) * 3) calc(var(--u) * 2) calc(var(--u) * 6);
  max-width: 1040px;
  margin: 0 auto;
  color: var(--dim);
  font-size: 13px;
}
footer ul { list-style: none; margin: 0 0 calc(var(--u) * 2); padding: 0; display: flex; flex-wrap: wrap; gap: 0 calc(var(--u) * 3); }
footer p { margin: 0 0 var(--u); max-width: 78ch; }

a { color: var(--info); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--acc); }

/* Keyboard focus must be obvious on a page this dark. Never remove this without a replacement. */
:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

/* Skip link — present for keyboard users, out of the way for everyone else. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  background: var(--acc);
  color: var(--bg);
  padding: var(--u) calc(var(--u) * 2);
}
.skip:focus { left: var(--u); top: var(--u); }

/* Announced to screen readers, invisible on screen. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

noscript .panel { border-color: var(--warn); }

/* ─── 404 ─────────────────────────────────────────────────────────────────── */

.lost {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.lost .code {
  /* margin: 0 is load-bearing. A <p> keeps its 1em margins, and at a 120px font size that is a
     120px gap above and below the number — the page looks like it failed to load. */
  margin: 0;
  font-size: clamp(48px, 18vw, 120px);
  line-height: 1;
  font-weight: 700;
  color: var(--bad);
  letter-spacing: 0.06em;
}

/* ─── Narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  body { font-size: 14px; }
  .shell { padding: calc(var(--u) * 2) calc(var(--u) * 1.5) calc(var(--u) * 6); }
  /* Stacking the readout rows is what keeps a long MOTD from forcing a horizontal scrollbar at
     360px, which is the width this page is most often opened at. */
  .readout { grid-template-columns: 1fr; }
  .readout dt::after { content: ""; }
  .readout dd { text-align: left; }
  .readout dd.motd { max-width: none; justify-self: start; text-align: left; }
  .readout dd + dt { margin-top: var(--u); }
  /* Both the header cell and the body cells, or the table keeps a column for a chart that is
     not there and the two remaining headings sit over the wrong columns. */
  th.spark, td.spark { display: none; }
  .address { max-width: none; }
  .address code { border-right: 1px solid var(--line); }
  .address button { width: 100%; margin-top: -1px; }
}
