/* mqtt.pskreporter.info: one stylesheet for the documentation pages.
   Two colours carry meaning throughout: "sent by" (the transmitting station)
   and "heard by" (the receiving station). Everything else is ink on paper. */

@font-face {
  font-family: "Atkinson Next";
  src: url("fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Mono";
  src: url("fonts/atkinson-hyperlegible-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --ink: #17202b;
  --soft: #55616f;
  --rule: #d5dbe2;
  --wash: #f2f4f7;
  --link: #1746c4;
  --tx: #9a1c61;
  --tx-wash: #fbedf4;
  --rx: #086569;
  --rx-wash: #e6f4f4;
  --warn: #8a4b00;
  --sans: "Atkinson Next", system-ui, sans-serif;
  --mono: "Atkinson Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181d;
    --ink: #e7eaee;
    --soft: #a3adb8;
    --rule: #333c47;
    --wash: #1d232b;
    --link: #8fb0ff;
    --tx: #f291c4;
    --tx-wash: #33202b;
    --rx: #6fd3d3;
    --rx-wash: #17302f;
    --warn: #f0b060;
  }
}

* { box-sizing: border-box; }

html {
  font-size: 112.5%;
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
}

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 2px; }

/* ---------- page frame ---------- */

.frame {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 3.5rem;
  max-width: 68rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.side {
  position: sticky;
  top: 2.5rem;
  align-self: start;
  font-size: 0.89rem;
}
.side .site {
  display: block;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 1.25rem;
  overflow-wrap: anywhere;
}
.side ul { list-style: none; margin: 0; padding: 0; }
.side li { margin: 0; }
.side li a {
  display: block;
  padding: 0.28rem 0 0.28rem 0.75rem;
  border-left: 2px solid var(--rule);
  color: var(--soft);
  text-decoration: none;
}
.side li a:hover { color: var(--ink); border-left-color: var(--soft); }
.side li a[aria-current] { color: var(--ink); border-left-color: var(--ink); font-weight: 600; }
.side .elsewhere { margin-top: 1.25rem; }

main { min-width: 0; }
main > section { margin-top: 3.5rem; }
main > section > *, main > header > * { max-width: 41rem; }
main > section > .wide { max-width: none; }
main > section > .cmd, main > section > pre, main > section > h2 { max-width: 47rem; }

@media (max-width: 54rem) {
  .frame { display: block; padding-top: 1.25rem; }
  .side { position: static; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
  .side .site { margin-bottom: 0.6rem; }
  .side ul { display: flex; flex-wrap: wrap; gap: 0.1rem 1.1rem; }
  .side li a { border-left: 0; padding: 0.2rem 0; text-decoration: underline; }
  .side .elsewhere { margin-top: 0.4rem; }
}

/* ---------- type ---------- */

h1 {
  font-size: 2.35rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 750;
  margin: 0 0 1rem;
  text-wrap: balance;
}
h2 {
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 700;
  margin: 0 0 0.9rem;
  padding-top: 1.1rem;
  border-top: 2px solid var(--ink);
}
h3 { font-size: 1.06rem; font-weight: 700; margin: 1.9rem 0 0.4rem; }
p, ul, ol, dl, table, pre, blockquote { margin: 0 0 1rem; }
ul, ol { padding-left: 1.3rem; }
li { margin-bottom: 0.4rem; }
.lede { font-size: 1.17rem; line-height: 1.5; }
.note { color: var(--soft); font-size: 0.92rem; }

code, pre, kbd, .mono { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--wash); padding: 0.08em 0.3em; border-radius: 3px; overflow-wrap: anywhere; }
pre {
  background: var(--wash);
  padding: 0.85rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.5;
  font-size: 0.84rem;
}
pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }

blockquote { margin-left: 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--soft); }
blockquote .who { display: block; margin-top: 0.3rem; font-size: 0.9rem; }

.tx { color: var(--tx); }
.rx { color: var(--rx); }

/* ---------- command line with a copy button ---------- */

.cmd {
  display: flex;
  align-items: stretch;
  background: var(--wash);
  border-radius: 4px;
  margin: 0 0 1rem;
}
.cmd pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  background: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cmd button { border: 0; border-left: 1px solid var(--rule); border-radius: 0 4px 4px 0; background: none; }

button {
  font: inherit;
  font-size: 0.89rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--soft);
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}
button:hover { background: var(--wash); }
.cmd button:hover { background: var(--rule); }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
button.primary:hover { opacity: 0.88; background: var(--ink); }

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

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; vertical-align: top; padding: 0.42rem 1rem 0.42rem 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 700; border-bottom-color: var(--ink); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td code { white-space: nowrap; }

/* ---------- the topic: anatomy and builder in one ---------- */

.topic {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.1rem 1.1rem 0.4rem;
  margin-bottom: 1rem;
}
.topic-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem 0.75rem;
  margin-bottom: 1rem;
}
.seg label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.seg .pos { color: var(--soft); font-weight: 400; font-variant-numeric: tabular-nums; }
.seg input, .opts select {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.89rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--soft);
  border-radius: 4px;
  padding: 0.42rem 0.5rem;
}
.seg input::placeholder { color: var(--soft); opacity: 0.75; }
.seg.is-tx label { color: var(--tx); }
.seg.is-rx label { color: var(--rx); }
.seg.is-tx input { border-color: var(--tx); background: var(--tx-wash); }
.seg.is-rx input { border-color: var(--rx); background: var(--rx-wash); }
.seg input[aria-invalid="true"] { border-color: var(--warn); border-style: dashed; }
.seg .hint { font-size: 0.78rem; color: var(--warn); min-height: 1.1em; margin-top: 0.15rem; }

.opts { display: flex; flex-wrap: wrap; gap: 0.6rem 1.5rem; align-items: center; font-size: 0.89rem; margin-bottom: 1rem; }
.opts label { display: flex; align-items: center; gap: 0.4rem; }
.opts select { width: auto; font-family: var(--sans); }

.built {
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  margin-bottom: 0.8rem;
}
.built .w { color: var(--soft); }
.built .tx, .built .rx { font-weight: 650; }
.built .k { font-weight: 650; }

@media (max-width: 40rem) {
  .topic-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- live sample ---------- */

.live { margin-bottom: 1rem; }
.live-bar { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: baseline; justify-content: space-between; margin-bottom: 0.4rem; }
.live-status { font-size: 0.92rem; }
.live-status strong { font-variant-numeric: tabular-nums; }
.live table { font-family: var(--mono); font-size: 0.8rem; table-layout: fixed; }
.live th { font-family: var(--sans); font-size: 0.8rem; }
.live td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.live tbody:empty::after { content: "Waiting for spots."; display: block; padding: 0.6rem 0; color: var(--soft); font-family: var(--sans); }
.live .c-time { width: 5.6rem; }
.live .c-band { width: 4rem; }
.live .c-mode { width: 4.2rem; }
.live .c-db { width: 3.4rem; }
@media (max-width: 40rem) {
  .live .c-grid { display: none; }
}

/* ---------- terms ---------- */

.terms { counter-reset: term; list-style: none; padding: 0; }
.terms li { counter-increment: term; position: relative; padding-left: 2.2rem; margin-bottom: 1rem; }
.terms li::before {
  content: counter(term);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.5rem;
  height: 1.5rem;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}
.terms strong { display: block; }

footer { margin-top: 4rem; padding-top: 1.1rem; border-top: 1px solid var(--rule); font-size: 0.89rem; color: var(--soft); max-width: 41rem; }
footer p { margin-bottom: 0.5rem; }

/* ---------- status ---------- */

:root { --ok: #1c7a43; --bad: #c22f1d; }
@media (prefers-color-scheme: dark) {
  :root { --ok: #5fcf8a; --bad: #ff7b66; }
}

.verdict { font-size: 1.35rem; line-height: 1.35; font-weight: 650; padding-left: 0.9rem; border-left: 6px solid var(--rule); }
.verdict.is-ok { border-left-color: var(--ok); }
.verdict.is-bad { border-left-color: var(--bad); }

.statusline { font-size: 0.95rem; }
.statusline .dot, .chain .state::before, .legend i {
  display: inline-block; width: 0.7em; height: 0.7em; margin-right: 0.45em; background: var(--rule);
}
.statusline .dot { border-radius: 50%; }
.statusline.is-ok .dot { background: var(--ok); }
.statusline.is-bad .dot { background: var(--bad); border-radius: 0; }

.chain { list-style: none; padding: 0; display: flex; gap: 1.6rem; align-items: stretch; }
.chain > li, .chain .pair > div {
  position: relative; flex: 1; margin: 0; padding: 0.7rem 0.8rem;
  border: 1.5px solid var(--rule); border-radius: 6px; display: flex; flex-direction: column;
}
.chain > li.pair { border: 0; padding: 0; gap: 0.5rem; }
.chain > li + li::before {
  content: ""; position: absolute; left: -1.25rem; top: 50%; width: 0.9rem; height: 2px; background: var(--soft);
}
.chain .what { font-size: 0.82rem; color: var(--soft); margin-bottom: 0.6rem; }
.chain .state { margin-top: auto; font-size: 0.89rem; font-weight: 650; }
.chain .state::before { content: ""; border-radius: 50%; }
.chain > li.is-ok, .chain .pair > div.is-ok { border-color: var(--ok); }
.chain .is-ok .state::before { background: var(--ok); }
.chain > li.is-bad, .chain .pair > div.is-bad { border-color: var(--bad); border-width: 3px; }
.chain .is-bad .state::before { background: var(--bad); border-radius: 0; }
@media (max-width: 54rem) {
  .chain { flex-direction: column; gap: 1.1rem; }
  .chain > li + li::before { left: 1.2rem; top: -0.85rem; width: 2px; height: 0.6rem; }
  .chain > li.pair { flex-direction: row; }
}

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--sans); font-size: 12px; fill: var(--soft); }
.chart text.lane { fill: var(--ink); font-size: 13px; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .area { fill: var(--link); opacity: 0.14; }
.chart .line { fill: none; stroke: var(--link); stroke-width: 2; stroke-linejoin: round; }
.chart .c-ok { fill: var(--ok); }
.chart .c-bad { fill: var(--bad); }
.chart .c-idle { fill: var(--rule); }
.chart .cross { stroke: var(--ink); stroke-width: 1; }
.chart .tip {
  position: absolute; top: 0; pointer-events: none; background: var(--paper); border: 1px solid var(--soft);
  border-radius: 4px; padding: 0.35rem 0.55rem; font-size: 0.8rem; line-height: 1.4; white-space: nowrap;
}
.legend { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.3rem 1.3rem; font-size: 0.85rem; color: var(--soft); }
.legend .k-ok { background: var(--ok); height: 0.3em; vertical-align: middle; }
.legend .k-bad { background: var(--bad); }
.legend .k-idle { background: var(--rule); height: 0.3em; vertical-align: middle; }
.legend .k-none { background: none; border-bottom: 1px dashed var(--soft); height: 0.35em; }

.statusline { margin-bottom: 1rem; }
.statusline p { margin-bottom: 0.35rem; }
.spark-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.7rem; min-height: 30px; }
#spark { display: inline-flex; }
#spark svg { display: block; touch-action: none; }
#spark .line { fill: none; stroke: var(--link); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
#spark .pt { fill: var(--link); }
#spark .base { stroke: var(--rule); stroke-width: 1; }
#spark .mark { stroke: var(--ink); stroke-width: 1; }
.spark-range { display: inline-flex; }
.spark-range button { padding: 0.1rem 0.5rem; font-size: 0.78rem; border-radius: 0; border-color: var(--rule); color: var(--soft); }
.spark-range button:first-child { border-radius: 4px 0 0 4px; }
.spark-range button:last-child { border-radius: 0 4px 4px 0; margin-left: -1px; }
.spark-range button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); position: relative; }
#spark-read { font-variant-numeric: tabular-nums; }
