/* THE PAPER
 *
 * Light, warm, and quiet, with the colour arriving as soft light from the corners rather than as a
 * flat field. The composition is the opposite of the previous one and stronger for it: on a loud
 * orange field the dark town was a panel sitting on a poster, and here it is the single heavy
 * object on a sheet of paper. Everything else gets out of its way.
 *
 * Square corners throughout, not pills. An old-style serif set very tight for anything that
 * speaks, and the mono kept for anything that counts — a serif and a monospace together read as a
 * document and a readout, which is exactly what this is.
 */

:root {
  --paper-1: #FBFAF3;
  --paper-2: #F6F4EA;
  --paper-3: #E9F4E9;
  --glow-a:  rgba(184, 255, 220, 0.85);   /* the near corner */
  --glow-b:  rgba(17, 182, 111, 0.20);    /* the far one */

  --ink:     #07110D;
  --ink-2:   rgba(7, 17, 13, 0.62);
  --ink-3:   rgba(7, 17, 13, 0.34);
  --rule:    rgba(7, 17, 13, 0.12);

  --accent:  #11B66F;
  --deepest: #0C2118;

  --night:   #0B0E17;
  --cream:   #FFF3E2;
  --good:    #0E8F53;
  --bad:     #C42A40;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 4%, var(--glow-a), rgba(0,0,0,0) 448px),
    radial-gradient(circle at 92% 18%, var(--glow-b), rgba(0,0,0,0) 384px),
    linear-gradient(135deg, var(--paper-1) 0%, var(--paper-2) 52%, var(--paper-3) 100%);
  background-attachment: fixed;
}

/* A grid so faint it reads as paper tooth rather than as a grid. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(7,17,13,.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(7,17,13,.035) 1px, transparent 1px);
  background-size: 62px 62px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 62%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 62%);
}
body > * { position: relative; z-index: 1; }

h1, h2, h3, .serif {
  font-family: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 1.02;
  text-wrap: balance;
  margin: 0;
}

.wrap { width: min(1180px, 100% - 44px); margin-inline: auto; }

/* ---------------------------------------------------------------------- top */

.top { display: flex; align-items: center; gap: 14px; padding: 26px 0 8px; }
.mark { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.mark canvas { display: block; image-rendering: pixelated; }
.mark b { font-family: "Newsreader", Georgia, serif; font-weight: 500; font-size: 20px; letter-spacing: -0.04em; }

.nav { display: flex; gap: 8px; align-items: center; }
.link {
  padding: 8px 14px;
  color: var(--ink-2); text-decoration: none;
  font-size: 12.5px;
  border: 1px solid transparent;
  transition: color .14s ease, border-color .14s ease;
}
.link:hover { color: var(--ink); border-color: var(--rule); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 0;
  background: var(--deepest); color: #FFFDF5;
  border: 1px solid var(--deepest);
  font: 500 12.5px/1 "IBM Plex Mono", monospace;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: transparent; color: var(--deepest); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: #FFFDF5; }

/* --------------------------------------------------------------------- hero */

.hero { padding: 40px 0 26px; max-width: 940px; }
.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 11.5px; letter-spacing: 0.18em; text-transform: uppercase;
  margin-bottom: 18px;
}
h1 { font-size: clamp(42px, 7.4vw, 92px); }
.lede { margin: 22px 0 0; max-width: 62ch; font-size: clamp(14px, 1.5vw, 16.5px); color: var(--ink-2); }
.lede b { font-weight: 600; color: var(--ink); }
.acts { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }

/* ------------------------------------------------------------- the window */

.window { margin-top: 38px; }
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--night);
  border: 1px solid var(--deepest);
  overflow: hidden;
  display: grid; place-items: center;
  /* The one heavy thing on the page, so it is allowed one real shadow. */
  box-shadow: 0 26px 60px -28px rgba(7,17,13,.55);
}
.stage canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; cursor: grab; touch-action: none; }
.stage canvas:active { cursor: grabbing; }

.controls { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; }
.ctl {
  width: 30px; height: 30px; border-radius: 0;
  border: 1px solid rgba(255,253,245,.26);
  background: rgba(11,14,23,.66); color: #FFFDF5;
  font: 500 14px/1 "IBM Plex Mono", monospace; cursor: pointer;
  display: grid; place-items: center;
}
.ctl:hover { background: #FFFDF5; color: var(--night); }
.hint {
  position: absolute; left: 12px; bottom: 13px;
  font-size: 10.5px; letter-spacing: .07em; color: rgba(255,253,245,.36);
  pointer-events: none;
}
.crier {
  position: absolute; left: 12px; top: 12px;
  max-width: min(60%, calc(100% - 250px));
  padding: 7px 12px;
  background: rgba(11,14,23,.8);
  border: 1px solid rgba(255,253,245,.18);
  color: #FFFDF5; font-size: 11.5px;
  pointer-events: none; transition: opacity .5s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crier.is-idle { opacity: .3; }
.crier.is-buy   { border-color: rgba(17,182,111,.62); }
.crier.is-sell  { border-color: rgba(255,129,147,.55); }
.crier.is-climb { border-color: rgba(240,195,92,.6); }
.crier.is-stone { border-color: rgba(200,190,255,.65); }

.who {
  position: absolute; right: 10px; top: 12px;
  width: min(212px, 46%); padding: 12px 14px;
  background: #FFFDF5; color: var(--ink);
  border: 1px solid var(--deepest);
  font-size: 11px; line-height: 1.5;
  display: flex; flex-direction: column; gap: 1px;
}
.who.is-off { display: none; }
.who b { font-family: "Newsreader", Georgia, serif; font-weight: 500; font-size: 16px; letter-spacing: -0.03em; }
.who .addr { font-size: 10px; color: var(--ink-3); margin-top: -1px; }
.who span { color: var(--ink-2); }
.who .follow {
  margin-top: 9px; padding: 6px 10px; border-radius: 0;
  border: 1px solid var(--deepest); background: var(--deepest); color: #FFFDF5;
  font: 500 10.5px/1 "IBM Plex Mono", monospace; cursor: pointer;
}
.who .follow:hover { background: transparent; color: var(--deepest); }
.who a { margin-top: 7px; color: var(--accent); font-weight: 600; }

/* The readings live on the paper, not in the dark — they are for reading, not for atmosphere. */
.readout { display: flex; flex-wrap: wrap; gap: 0; margin-top: 0; border: 1px solid var(--rule); border-top: 0; }
.chip {
  flex: 1 1 0; min-width: 132px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px;
  border-right: 1px solid var(--rule);
}
.chip:last-child { border-right: 0; }
.chip i { font-style: normal; color: var(--ink-3); letter-spacing: .14em; text-transform: uppercase; font-size: 9.5px; }
.chip b { font-weight: 500; font-variant-numeric: tabular-nums; font-size: 19px; font-family: "Newsreader", Georgia, serif; letter-spacing: -0.03em; }
.chip--bad b  { color: var(--bad); }
.chip--good b { color: var(--good); }
.chip--slot b { color: var(--ink); }
.chip--quiet b { color: var(--ink-3); }

.ticker {
  margin-top: 14px; padding: 11px 2px;
  border-top: 1px solid var(--rule);
  font-size: 11.5px; color: var(--ink-3);
  display: flex; gap: 28px; white-space: nowrap; overflow: hidden;
}
.ticker i { font-style: normal; }
.ticker i.buy  { color: var(--good); }
.ticker i.sell { color: var(--bad); }

/* ----------------------------------------------------------------- sections */

section { padding: 84px 0 0; }
h2 { font-size: clamp(28px, 4vw, 46px); margin-bottom: 30px; }
/* 258px was wide enough that four cards only fit on a very wide screen, so they wrapped 3 + 1 and
   the fourth sat alone beside dead space. auto-fit collapses tracks it does not use, so a smaller
   minimum gives four-in-a-row here and still gives two-in-a-row to the sections that have two. */
.cards { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(206px, 1fr)); border: 1px solid var(--rule); }
.card { padding: 26px 24px; border-right: 1px solid var(--rule); }
.card:last-child { border-right: 0; }
.card h3 { font-size: 20px; margin-bottom: 10px; }
.card p { margin: 0; font-size: 13px; color: var(--ink-2); }
.card code { font-family: "IBM Plex Mono", monospace; font-size: 15px; }

.tag {
  display: inline-block; margin-bottom: 12px;
  padding: 3px 9px;
  background: rgba(17,182,111,.14); color: #0A7A49;
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
.scroller { overflow-x: auto; border: 1px solid var(--rule); }
th, td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 400; }
tr:last-child td { border-bottom: 0; }
td b { font-weight: 500; font-variant-numeric: tabular-nums; font-family: "Newsreader", Georgia, serif; font-size: 16px; }

.note { margin-top: 20px; font-size: 12.5px; color: var(--ink-2); max-width: 74ch; }
footer { padding: 80px 0 48px; font-size: 12px; color: var(--ink-3); }

/* The stream wants none of the paper — just the town, edge to edge. */
body.is-stream { background: var(--night); }
body.is-stream::before { display: none; }
body.is-stream .top, body.is-stream .hero, body.is-stream section, body.is-stream footer,
body.is-stream .readout { display: none; }
body.is-stream .wrap { width: 100%; }
body.is-stream .window { margin: 0; }
body.is-stream .stage { border: 0; box-shadow: none; aspect-ratio: auto; height: 100vh; }
body.is-stream .ticker {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0;
  padding: 10px 16px; background: rgba(7,17,13,.9); color: var(--cream); border-top: 0;
}

body.is-stale .crier { border-color: rgba(255,129,147,.7); }

@media (max-width: 620px) {
  .wrap { width: calc(100% - 28px); }
  .nav .hide-sm { display: none; }
  .who { display: none; }
  /* The hint wraps to two lines at this width and runs under the buttons. Touch users are not
     reading "drag to move" anyway — they are already dragging. */
  .hint { display: none; }
  .chip { min-width: 50%; border-bottom: 1px solid var(--rule); }
  .card { border-right: 0; border-bottom: 1px solid var(--rule); }
}

/* ------------------------------------------------------- trying the endpoints */

/* A card that is also a button. It has to reset the browser's button styling completely or it
   arrives centred, in the system font, with a border nobody asked for. */
.card--try {
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; border-right: 1px solid var(--rule);
  cursor: pointer; width: 100%;
  transition: background .14s ease;
}
.card--try:hover { background: rgba(17,182,111,.07); }
.card--try:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.card--try:last-child { border-right: 0; }

.apipanel { margin-top: 18px; border: 1px solid var(--deepest); background: var(--night); }
.apipanel.is-off { display: none; }

.apihead {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,253,245,.14);
  color: #FFFDF5; font-size: 12px;
}
.apihead b { font-family: "IBM Plex Mono", monospace; font-weight: 500; }
.apihead span { color: rgba(255,253,245,.5); margin-right: auto; font-variant-numeric: tabular-nums; }
.apihead a { color: var(--accent); text-decoration: none; }
.apihead a:hover { text-decoration: underline; }
.apihead button {
  background: none; border: 0; color: rgba(255,253,245,.55);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.apihead button:hover { color: #FFFDF5; }

#api-out {
  margin: 0; padding: 14px 16px;
  max-height: 380px; overflow: auto;
  color: #CFE3D6;
  font: 400 11.5px/1.65 "IBM Plex Mono", monospace;
  white-space: pre;
  tab-size: 2;
}

@media (max-width: 620px) {
  .card--try { border-right: 0; border-bottom: 1px solid var(--rule); }
  #api-out { font-size: 10.5px; max-height: 300px; }
}
