/* Stonk Tool.
 *
 * Two colours: graphite and acid. Nothing on this page is a bordered rectangle pretending
 * to be a surface - the structure is hairlines, whitespace and one pixel grid, which is
 * what a terminal is made of. Emphasis is inversion, never a second hue, so a dumped
 * position and a graduated pool shout without the palette growing.
 */

@font-face {
  font-family: "Departure Mono";
  src: url("/fonts/DepartureMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --ink: #141412;
  --ink-2: #1b1b18;
  --ink-3: #232320;
  --line: #2a2a25;
  --line-2: #3a3a33;
  --dim: #6e7064;
  --mid: #9a9c8d;
  --text: #cfd0c2;
  --acid: #c5f066;
  --acid-soft: #c5f06655;

  --t-micro: 10px;
  --t-small: 11px;
  --t-body: 13px;
  --t-mid: 16px;
  --t-big: 22px;

  --gap: 20px;
  --rule: 1px solid var(--line);

  --cols: minmax(150px, 1fr) 48px 60px 92px 116px 104px 168px 96px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: "Departure Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: var(--t-body);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  cursor: url("/cursor.png") 6 6, crosshair;
}

/* The ground is not flat black: the plates carry a soft fall-off from the middle. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 42%, #1a1a17 0%, #141412 58%, #0f0f0d 100%);
  z-index: -1;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: inherit;
}

:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 8px 12px;
  background: var(--acid);
  color: var(--ink);
  z-index: 40;
}
.skip:focus {
  left: 8px;
  top: 8px;
}

/* ---- shell ---------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
  height: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ---- masthead ------------------------------------------------------- */

.masthead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "lockup strap ident"
    "lockup strap contract";
  align-items: center;
  column-gap: 28px;
  padding: 18px 0 14px;
  border-bottom: var(--rule);
}

.lockup {
  grid-area: lockup;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--acid);
}

.lockup-traces {
  display: block;
  width: 92px;
  height: 34px;
  opacity: 0.75;
}

.lockup-traces svg {
  display: block;
  width: 100%;
  height: 100%;
}

.trace-line,
.band-line {
  fill: none;
  stroke: var(--acid);
  stroke-width: 1;
}

.trace-node {
  fill: var(--acid);
}

.lockup-mark {
  display: block;
  color: var(--acid);
}

.lockup-mark svg {
  display: block;
}

.wordmark {
  margin: 0;
  font-size: var(--t-big);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--acid);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.block {
  width: 11px;
  height: 11px;
  background: var(--acid);
  display: inline-block;
}

.strap {
  grid-area: strap;
  margin: 0;
  color: var(--dim);
  font-size: var(--t-small);
  max-width: 46ch;
}

.ident {
  grid-area: ident;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  font-size: var(--t-small);
}

.ticker {
  color: var(--acid);
  letter-spacing: 0.08em;
}

.links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--mid);
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
}

.link:hover,
.link:focus-visible {
  color: var(--acid);
  border-bottom-color: var(--acid);
}

.link[aria-disabled="true"] {
  color: var(--dim);
  cursor: not-allowed;
  text-decoration: line-through;
  text-decoration-color: var(--line-2);
}

.contract {
  grid-area: contract;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: var(--t-small);
  min-height: 26px;
}

.contract-label {
  color: var(--dim);
  letter-spacing: 0.1em;
}

.contract-value {
  font: inherit;
  color: var(--text);
  word-break: break-all;
  user-select: all;
}

.contract.is-empty .contract-value {
  color: var(--dim);
}

.copy {
  color: var(--ink);
  background: var(--acid);
  padding: 3px 8px;
  min-width: 54px;
  text-align: center;
}

.copy[disabled] {
  background: none;
  color: var(--dim);
  box-shadow: inset 0 0 0 1px var(--line-2);
}

.copy:not([disabled]):hover {
  background: #d7ff78;
}

/* ---- finder --------------------------------------------------------- */

.finder {
  position: relative;
  padding: 16px 0 14px;
  border-bottom: var(--rule);
}

.prompt {
  display: flex;
  align-items: center;
  gap: 10px;
}

.caret {
  color: var(--acid);
  font-size: var(--t-mid);
}

#q {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: var(--t-mid);
  color: var(--text);
  background: none;
  border: 0;
  padding: 6px 0;
  caret-color: var(--acid);
}

#q::placeholder {
  color: var(--dim);
}

#q:focus {
  outline: none;
}

.finder-note {
  color: var(--dim);
  font-size: var(--t-small);
  white-space: nowrap;
}

.results {
  position: absolute;
  z-index: 20;
  left: 26px;
  right: 0;
  top: 100%;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--ink-2);
  box-shadow: 0 0 0 1px var(--line), 0 18px 40px #0b0b09cc;
  max-height: 46vh;
  overflow: auto;
}

.results li {
  display: grid;
  grid-template-columns: 70px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 7px 12px;
  font-size: var(--t-small);
  color: var(--mid);
}

.results li[aria-selected="true"],
.results li:hover {
  background: var(--acid);
  color: var(--ink);
}

.results .r-sym {
  color: var(--text);
  letter-spacing: 0.06em;
}

.results li[aria-selected="true"] .r-sym,
.results li:hover .r-sym,
.results li[aria-selected="true"] .r-live,
.results li:hover .r-live {
  color: var(--ink);
}

.results .r-live {
  color: var(--acid);
}

.results .r-empty {
  padding: 10px 12px;
  color: var(--dim);
}

/* ---- subject -------------------------------------------------------- */

.subject {
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr;
  gap: 12px 28px;
  align-items: end;
  padding: 14px 0 12px;
  border-bottom: var(--rule);
}

.subject-name {
  margin: 0;
  font-size: var(--t-big);
  font-weight: 400;
  color: var(--acid);
  display: flex;
  align-items: baseline;
  gap: 10px;
  letter-spacing: 0.04em;
}

.subject-name small {
  font-size: var(--t-small);
  color: var(--mid);
  letter-spacing: 0;
}

.subject-book {
  margin: 2px 0 0;
  font-size: var(--t-small);
  color: var(--dim);
}

.tally {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 26px;
  margin: 0;
  justify-content: flex-end;
}

.tally div {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.tally dt {
  font-size: var(--t-micro);
  color: var(--dim);
  letter-spacing: 0.1em;
}

.tally dd {
  margin: 0;
  font-size: var(--t-mid);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tally dd small {
  font-size: var(--t-small);
  color: var(--dim);
  margin-left: 5px;
}

/* ---- controls ------------------------------------------------------- */

.controls {
  display: flex;
  align-items: center;
  gap: 8px 22px;
  flex-wrap: wrap;
  padding: 11px 0;
  border-bottom: var(--rule);
  font-size: var(--t-small);
}

.switch,
.group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.group-label {
  color: var(--dim);
  letter-spacing: 0.1em;
  margin-right: 4px;
}

.chip {
  padding: 5px 9px;
  color: var(--dim);
  letter-spacing: 0.04em;
  min-height: 26px;
}

.chip:hover {
  color: var(--text);
}

.chip.is-on {
  background: var(--acid);
  color: var(--ink);
}

.chip b {
  font-weight: 400;
  margin-left: 5px;
  color: var(--acid);
}

.chip.is-on b {
  color: var(--ink);
}

.watch {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 8px;
  color: var(--dim);
  min-height: 26px;
}

.watch:hover {
  color: var(--text);
}

.lamp {
  width: 7px;
  height: 7px;
  background: var(--line-2);
  display: block;
}

.watch[aria-pressed="true"] {
  background: var(--acid);
  color: var(--ink);
}

.watch[aria-pressed="true"] .lamp {
  background: var(--ink);
  animation: blink 1.6s steps(1) infinite;
}

@keyframes blink {
  0%,
  55% {
    opacity: 1;
  }
  56%,
  100% {
    opacity: 0.15;
  }
}

/* ---- table ---------------------------------------------------------- */

.head,
.row {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 14px;
  align-items: center;
}

.head {
  padding: 9px 10px 9px 8px;
  font-size: var(--t-micro);
  letter-spacing: 0.12em;
  color: var(--dim);
  border-bottom: var(--rule);
}

.head span:not(.c-token),
.row > *:not(.cell-token):not(.cell-flag) {
  text-align: right;
}

.board {
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.row {
  padding: 8px 10px 8px 8px;
  border-bottom: 1px solid #201f1c;
  border-left: 2px solid transparent;
  font-variant-numeric: tabular-nums;
  color: var(--mid);
}

.row:hover {
  background: var(--ink-2);
  border-left-color: var(--acid);
}

.cell-token {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.t-sym {
  color: var(--text);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 15ch;
}

.t-sym:hover {
  color: var(--acid);
  text-decoration: underline;
}

.t-name {
  color: var(--dim);
  font-size: var(--t-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-volume b,
.cell-liq b,
.cell-net b {
  font-weight: 400;
  color: var(--text);
}

.cell-volume small,
.cell-liq small {
  display: block;
  font-size: var(--t-micro);
  color: var(--dim);
}

.is-up {
  color: var(--acid);
}

.is-flat,
.is-none {
  color: #4d4e46;
}

/* Progress to graduation, as cells rather than as a smooth bar. */
.bar {
  margin-top: 4px;
  height: 4px;
  width: 100%;
  background: #262622;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px);
  mask-image: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px);
}

.bar i {
  display: block;
  height: 100%;
  background: var(--acid);
}

.cell-flag {
  display: flex;
  gap: 4px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.flag {
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  padding: 2px 5px;
  color: var(--dim);
  box-shadow: inset 0 0 0 1px var(--line-2);
}

/* Inversion is reserved for the one state that ends a curve's life on this board. */
.flag.is-hot {
  background: var(--acid);
  color: var(--ink);
  box-shadow: none;
}

.flag.is-warn {
  color: var(--acid);
  box-shadow: inset 0 0 0 1px var(--acid-soft);
}

.flag.is-quiet {
  box-shadow: none;
  padding-left: 0;
  color: #4d4e46;
}

/* ---- alerts view ---------------------------------------------------- */

.lab {
  display: none;
}

.event {
  display: grid;
  grid-template-columns: 84px 140px minmax(180px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 9px 10px 9px 8px;
  border-bottom: 1px solid #201f1c;
  border-left: 2px solid transparent;
  font-variant-numeric: tabular-nums;
  color: var(--mid);
}

.event:hover {
  background: var(--ink-2);
  border-left-color: var(--acid);
}

.event .e-kind {
  font-size: var(--t-micro);
  letter-spacing: 0.12em;
  padding: 2px 5px;
  background: var(--acid);
  color: var(--ink);
  justify-self: start;
}

.event .e-kind.is-soft {
  background: none;
  color: var(--acid);
  box-shadow: inset 0 0 0 1px var(--acid-soft);
}

.event .e-what {
  color: var(--text);
}

.event .e-age {
  text-align: right;
  color: var(--dim);
}

/* ---- states --------------------------------------------------------- */

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.loading svg.band {
  width: 100%;
  height: 100%;
  opacity: 0.5;
}

.band-line {
  stroke-dasharray: 8 1200;
  animation: run 1.9s linear infinite;
  animation-delay: calc(var(--i) * -0.24s);
}

@keyframes run {
  from {
    stroke-dashoffset: 1208;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.is-reading .trace-line {
  stroke-dasharray: 6 300;
  animation: run 1.4s linear infinite;
  animation-delay: calc(var(--i) * -0.2s);
}

.is-reading .trace-node {
  animation: blink 0.9s steps(1) infinite;
  animation-delay: calc(var(--i) * -0.3s);
}

.notice {
  padding: 40px 8px;
  color: var(--dim);
  max-width: 62ch;
}

.notice b {
  display: block;
  color: var(--text);
  font-weight: 400;
  margin-bottom: 6px;
}

.notice button {
  margin-top: 14px;
  background: var(--acid);
  color: var(--ink);
  padding: 5px 10px;
}

/* ---- toasts --------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 30;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  background: var(--acid);
  color: var(--ink);
  padding: 8px 10px;
  font-size: var(--t-small);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
  animation: pop 0.16s steps(2);
}

.toast.is-soft {
  background: var(--ink-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--acid-soft);
}

.toast b {
  font-weight: 400;
  letter-spacing: 0.1em;
  font-size: var(--t-micro);
}

@keyframes pop {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ---- narrow --------------------------------------------------------- */

@media (max-width: 1080px) {
  :root {
    --cols: minmax(120px, 1fr) 44px 56px 84px 100px 92px 132px 84px;
    --gap: 14px;
  }
  .strap {
    display: none;
  }
  .masthead {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "lockup ident"
      "lockup contract";
  }
}

@media (max-width: 780px) {
  :root {
    --t-body: 12px;
  }

  .shell {
    height: auto;
    min-height: 100%;
    grid-template-rows: auto auto auto auto auto 1fr;
  }

  .masthead {
    grid-template-columns: 1fr;
    grid-template-areas:
      "lockup"
      "ident"
      "contract";
    row-gap: 8px;
    justify-items: start;
  }

  .lockup-traces {
    width: 56px;
  }

  .ident,
  .contract {
    justify-content: flex-start;
    width: 100%;
    flex-wrap: wrap;
  }

  .finder-note {
    display: none;
  }

  .subject {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .tally {
    justify-content: flex-start;
    gap: 2px 20px;
  }

  .watch {
    margin-left: 0;
  }

  .head {
    display: none;
  }

  /* One row becomes a small block, and every figure carries its own label. */
  .row {
    grid-template-columns: 1fr 1fr auto;
    grid-template-areas:
      "token token age"
      "buyers trades volume"
      "net liq liq"
      "flags flags flags";
    gap: 8px 14px;
    padding: 12px 8px;
    align-items: start;
  }

  .row > *:not(.cell-token):not(.cell-flag) {
    text-align: left;
  }

  .cell-age {
    text-align: right !important;
  }

  .lab {
    display: block;
    font-style: normal;
    font-size: var(--t-micro);
    letter-spacing: 0.1em;
    color: var(--dim);
  }

  .cell-token { grid-area: token; }
  .cell-age { grid-area: age; }
  .cell-buyers { grid-area: buyers; }
  .cell-trades { grid-area: trades; }
  .cell-volume { grid-area: volume; }
  .cell-net { grid-area: net; }
  .cell-liq { grid-area: liq; }
  .cell-flag { grid-area: flags; }

  .board {
    overflow: visible;
  }

  .event {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "kind what age"
      "detail detail detail";
    gap: 4px 10px;
  }
  .event .e-kind {
    grid-area: kind;
  }
  .event .e-what {
    grid-area: what;
  }
  .event .e-age {
    grid-area: age;
  }
  .event .e-detail {
    grid-area: detail;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .band-line,
  .is-reading .trace-line,
  .is-reading .trace-node,
  .watch[aria-pressed="true"] .lamp,
  .toast {
    animation: none;
  }
  .band-line {
    stroke-dasharray: none;
    opacity: 0.35;
  }
}

/* Visible to a screen reader, not to the eye: the official mark carries the name. */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
