/*
  nostrsearch node console
  ------------------------
  Direction: a mono-first instrument panel printed on cold pressed paper.
  Everything on this screen is a hash, a URL, a count or a timestamp, so the
  interface is set in mono by default and the display face appears only twice:
  the wordmark and the four corpus readouts. Colour is oxidised copper on
  grey-green stock — signal colours (rust, brass) are reserved for state, never
  decoration.
*/

@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --paper: #dfe3dc;
  --panel: #eef0ea;
  --ink: #14181a;
  --slate: #6b746e;
  --patina: #1f6f5c;
  --rust: #a8371f;
  --brass: #9a7220;

  --rule: color-mix(in srgb, var(--ink) 14%, transparent);
  --rule-strong: color-mix(in srgb, var(--ink) 32%, transparent);
  --wash: color-mix(in srgb, var(--ink) 5%, transparent);

  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  --display: "Archivo", "Helvetica Neue", Inter, system-ui, sans-serif;

  --rail: 232px;
  --gap: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font: 400 13px/1.5 var(--mono);
  font-feature-settings: "zero" 1;
  -webkit-font-smoothing: antialiased;
  /* Faint machine ruling; the paper this console is printed on. */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 27px,
    color-mix(in srgb, var(--ink) 2%, transparent) 27px 28px
  );
}

a {
  color: var(--patina);
}

::selection {
  background: var(--patina);
  color: var(--panel);
}

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

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

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100%;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--rule-strong);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  backdrop-filter: blur(2px);
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.03em;
  line-height: 1;
}

.wordmark span {
  color: var(--patina);
}

.wordmark small {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--slate);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  color: var(--ink);
  text-decoration: none;
  border-left: 2px solid transparent;
  font-size: 12px;
}

.nav a:hover {
  background: var(--wash);
}

.nav a[aria-current="true"] {
  border-left-color: var(--patina);
  background: var(--wash);
  font-weight: 600;
}

.nav a b {
  font-weight: 500;
  color: var(--slate);
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.main {
  padding: 40px 40px 96px;
  max-width: 1180px;
  display: flex;
  flex-direction: column;
  gap: 52px;
}

/* --------------------------------------------------------------- panels -- */

.panel {
  position: relative;
  border: 1px solid var(--rule-strong);
  background: var(--panel);
  padding: 28px 24px 24px;
}

/* The bezel plate: a section's label sits on its top edge, not above it. */
.panel > .plate {
  position: absolute;
  top: -9px;
  left: 16px;
  padding: 0 8px;
  background: var(--panel);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--slate);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel > .plate em {
  font-style: normal;
  color: var(--patina);
  letter-spacing: 0.06em;
  text-transform: none;
}

.panel-note {
  margin: 0 0 16px;
  color: var(--slate);
  max-width: 68ch;
}

.subhead {
  margin: 26px 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--slate);
}

.gap-note {
  margin-top: 4px;
  font-size: 11px;
}

/* ------------------------------------------------------------- readouts -- */

.readouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-top: 1px solid var(--rule);
}

.readout {
  padding: 16px 18px;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.readout:last-child {
  border-right: 0;
}

.readout.compact {
  padding: 14px 16px;
}

.readout.compact .v {
  font-size: clamp(20px, 2vw, 26px);
}

.readout .v {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(26px, 3.2vw, 38px);
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.readout .k {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--slate);
}

.readout .s {
  margin-top: 3px;
  font-size: 11px;
  color: var(--slate);
}

/* ---------------------------------------------- signature: corpus ribbon -- */

.ribbon {
  border: 1px solid var(--rule-strong);
  background: linear-gradient(to bottom, var(--panel), color-mix(in srgb, var(--panel) 82%, var(--paper)));
  padding: 18px 18px 0;
}

.ribbon-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 11px;
  color: var(--slate);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ribbon-head b {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
}

.bars {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 2px;
  height: 132px;
  margin-top: 14px;
  padding-bottom: 1px;
  overflow: hidden;
}

.bar {
  flex: 1 1 0;
  min-width: 2px;
  /* A young node has one or two buckets; without a cap each becomes a
     full-width slab that says nothing. */
  max-width: 26px;
  position: relative;
  background: color-mix(in srgb, var(--patina) 22%, transparent);
  transform-origin: bottom;
  animation: raise 620ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

/* The new-events share, drawn as solid patina rising from the baseline. */
.bar i {
  position: absolute;
  inset: auto 0 0 0;
  background: var(--patina);
  display: block;
}

.bar.gap {
  background: repeating-linear-gradient(
    135deg,
    color-mix(in srgb, var(--rust) 30%, transparent) 0 3px,
    transparent 3px 6px
  );
}

.bar.gap i {
  background: color-mix(in srgb, var(--rust) 55%, var(--patina));
}

.range {
  display: inline-flex;
  gap: 4px;
}

.range button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--panel);
}

.bar:hover {
  background: color-mix(in srgb, var(--patina) 40%, transparent);
  outline: 1px solid var(--ink);
}

@keyframes raise {
  from {
    transform: scaleY(0.02);
  }
}

.scale {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--rule-strong);
  padding: 6px 0 12px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--slate);
}

.ribbon-empty {
  height: 132px;
  display: grid;
  place-items: center;
  color: var(--slate);
  border-top: 1px solid var(--rule);
  margin-top: 14px;
}

/* ---------------------------------------------------- composition bar -- */

.composition {
  display: flex;
  height: 68px;
  margin-top: 14px;
  border: 1px solid var(--rule-strong);
  overflow: hidden;
}

.composition .seg {
  min-width: 1px;
  border-right: 1px solid color-mix(in srgb, var(--panel) 60%, transparent);
  animation: widen 640ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.composition .seg:last-child {
  border-right: 0;
}

@keyframes widen {
  from {
    transform: scaleX(0.01);
    transform-origin: left;
  }
}

.legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 4px 20px;
}

.legend li {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.legend i {
  width: 10px;
  height: 10px;
  border: 1px solid var(--rule-strong);
}

.legend .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.legend .pc {
  color: var(--slate);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
}

/* --------------------------------------------------------------- tables -- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

th {
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--slate);
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}

td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

td.num,
th.num {
  text-align: right;
  padding-right: 16px;
}

tbody tr:hover {
  background: var(--wash);
}

.trunc {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

button {
  font: 500 12px/1 var(--mono);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 8px 12px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover:not(:disabled) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--panel);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  border-color: var(--patina);
  color: var(--patina);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: var(--patina);
  border-color: var(--patina);
  color: var(--panel);
}

button.danger {
  border-color: color-mix(in srgb, var(--rust) 45%, transparent);
  color: var(--rust);
}

button.danger:hover:not(:disabled) {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--panel);
}

button.tiny {
  padding: 4px 8px;
  font-size: 11px;
}

input,
select {
  font: 400 12px/1 var(--mono);
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 60%, var(--panel));
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 8px 10px;
}

input::placeholder {
  color: color-mix(in srgb, var(--slate) 70%, transparent);
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--slate);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.row.tight {
  gap: 8px;
  align-items: center;
}

/* ---------------------------------------------------------------- chips -- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip.ok {
  color: var(--patina);
  border-color: color-mix(in srgb, var(--patina) 45%, transparent);
}

.chip.warn {
  color: var(--brass);
  border-color: color-mix(in srgb, var(--brass) 45%, transparent);
}

.chip.bad {
  color: var(--rust);
  border-color: color-mix(in srgb, var(--rust) 45%, transparent);
}

.chip.mute {
  color: var(--slate);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.dot.live {
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* ----------------------------------------------------------------- meter -- */

.meter {
  height: 6px;
  background: var(--wash);
  border: 1px solid var(--rule);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  background: var(--patina);
  transition: width 400ms ease;
}

.meter.brass i {
  background: var(--brass);
}

.meter.rust i {
  background: var(--rust);
}

/* ---------------------------------------------------------------- ranks -- */

.ranks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.ranks li {
  display: grid;
  grid-template-columns: 26px minmax(90px, 200px) 1fr 72px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
}

.ranks .rank {
  font-size: 10px;
  color: var(--slate);
  font-variant-numeric: tabular-nums;
}

.ranks .tag {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranks .count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--slate);
}

/* -------------------------------------------------------------- replay -- */

.current {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--rule-strong);
  background: color-mix(in srgb, var(--paper) 45%, var(--panel));
}

.current .pct {
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.current .meter {
  height: 10px;
}

.finished summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate);
  padding: 6px 0;
}

.finished summary:hover {
  color: var(--ink);
}

.finished[open] summary {
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------- files -- */

.filelist {
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-size: 12px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  padding: 4px;
}

.filerow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  cursor: pointer;
}

.filerow:hover {
  background: var(--wash);
}

.filerow input {
  accent-color: var(--patina);
  padding: 0;
}

.filerow .nm {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filerow .sz {
  color: var(--slate);
  font-size: 11px;
}

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

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  max-width: 380px;
}

.toast {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--panel);
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: slide 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast.err {
  background: var(--rust);
  border-color: var(--rust);
}

.toast b {
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 10px;
  padding-top: 1px;
}

@keyframes slide {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ----------------------------------------------------------------- misc -- */

.empty {
  padding: 4px 0 2px;
  color: var(--slate);
}

td.empty {
  padding: 18px 0;
}

.gate {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  padding: 6px 0 2px;
  color: var(--slate);
}

.mono-key {
  font-size: 11px;
  color: var(--slate);
  word-break: break-all;
}

.flash {
  animation: flash 900ms ease-out;
}

@keyframes flash {
  from {
    background: color-mix(in srgb, var(--patina) 30%, transparent);
  }
}

.hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 22px 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--rule-strong);
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .main {
    padding: 24px 16px 72px;
    gap: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* --------------------------------------------------- server-rendered pages -- */
/*
  The archive listing and the ingest status page are plain HTML served by the
  node, not this app — but they are the same instrument, so they load this
  stylesheet and set `class="page"` on the body. The app never uses these
  rules; anything specific to one of those pages lives inline in that page.
*/

body.page {
  padding: 40px 20px;
  display: flex;
  justify-content: center;
}

body.page main {
  width: 100%;
  max-width: 720px;
}

body.page .wordmark {
  margin-bottom: 26px;
}

body.page .panel {
  padding: 30px 24px 24px;
}

/* Few readouts and no dashboard around them, so the fluid display size the
   console uses is oversized here. */
body.page .readout .v {
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: -0.02em;
}

/* A readout with no number still takes a value's worth of height, so the
   labels beneath stay on one line with the rest. */
body.page .readout .v.mute {
  display: flex;
  align-items: center;
  min-height: clamp(18px, 2vw, 24px);
  color: var(--slate);
  font: 400 13px var(--mono);
  letter-spacing: 0;
}

/* Relay list pager. The scraper can discover thousands of relays, so the
   table is a window onto them rather than the whole set. */
.pager { display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-top: 10px; }
.pager-at { font-size: 11px; letter-spacing: .08em; color: var(--slate);
  font-variant-numeric: tabular-nums; }
.pager .btn[disabled] { opacity: .35; cursor: default; }

/* Rank rows: avatar + name, falling back to a colour block and the short key
   when a profile has no picture or the URL is dead. */
.avatar { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  object-fit: cover; background: var(--ink2); }
.avatar-fb { display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; }
.who { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-sub { font-size: 10px; color: var(--slate); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.ranks li { display: flex; align-items: center; gap: 8px; }

/* Live feed of recently scraped relay-days. Work is sampled at random, so
   this is how you see which relay is actually being hit. */
.feed { list-style: none; margin: 0; padding: 0;
  font-variant-numeric: tabular-nums; }
.feed li { display: flex; align-items: baseline; gap: 10px; padding: 3px 0;
  font-size: 12px; border-bottom: 1px solid var(--rule);
  flex-wrap: nowrap; }
.feed li:last-child { border-bottom: 0; }
.feed-when { flex: 0 0 68px; color: var(--slate); font-size: 11px;
  white-space: nowrap; }
.feed-what { flex: 1 1 auto; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.feed-day { flex: 0 0 auto; color: var(--slate); font-size: 11px;
  white-space: nowrap; }
/* Wide enough for "seen +new" together (e.g. 8.4k +2.1k); nowrap so a busy
   relay-day cannot push the count onto a second line. */
.feed-num { flex: 0 0 104px; text-align: right; white-space: nowrap; }
.feed-new { font-style: normal; color: var(--patina); }
.sub-note { font-weight: 400; font-size: 11px; color: var(--slate);
  margin-left: 8px; letter-spacing: 0; }

/* Horizon completion bar: how much of the scrape range is done. */
.hbar { display: block; height: 6px; background: var(--wash);
  border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.hbar > span { display: block; height: 100%; background: var(--patina);
  transition: width .4s ease; }

/* ------------------------------------------------------------ upload page -- */

.upload-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.upload-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.upload-head .wordmark {
  text-decoration: none;
  color: inherit;
}

.lede {
  font-size: 14px;
  line-height: 1.6;
  max-width: 72ch;
  margin: 0 0 8px;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 8px 32px;
  margin-bottom: 22px;
}

ul.plain {
  margin: 0;
  padding-left: 18px;
  color: var(--slate);
  line-height: 1.6;
}

ul.plain code {
  color: var(--ink);
}

.upload-form {
  border-top: 1px solid var(--rule-strong);
  padding-top: 18px;
}
