/* One sheet for both pages: the front page, which shows the cluster,
   and the page a tab joins from. */
:root {
  --ground: #f6f6f3;
  --panel: #ffffff;
  --ink: #1c1d21;
  --muted: #666a73;
  --line: #dcdde0;
  --accent: #3b6fd4;
  --good: #1f8a4c;
  --bad: #b3382c;
  --bar: #7ea6f4;

  /* The hero is the night sky whatever the page's theme. */
  --space: #070b16;
  --space-ink: #edf1ff;
  --space-muted: #9aa6c8;
  --space-line: #1d2742;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #101116;
    --panel: #181a20;
    --ink: #ececec;
    --muted: #9a9ea8;
    --line: #2b2e36;
    --accent: #7ea6f4;
    --good: #55c98a;
    --bad: #f08a7e;
  }
}

* {
  box-sizing: border-box;
}

/* An element the page has hidden stays hidden, whatever a class says
   about how the element is laid out. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font:
    16px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}

code,
pre,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 72px;
}

header.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 4px 0 18px;
}

/* The site's name, which is a link to the front page and reads as the
   name it is. */
header.brand .name {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

header.brand img {
  width: 44px;
  height: 44px;
}

header.brand a:not(.name) {
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0;
}

/* The link to the source, which is GitHub's mark and no words. The
   padding makes the mark large enough for a thumb. */
header.brand .source {
  display: flex;
  padding: 8px;
  margin-right: -8px;
  color: var(--muted);
}

header.brand .source:hover {
  color: var(--ink);
}

header.brand .source svg {
  width: 26px;
  height: 26px;
}

h1 {
  font-size: clamp(28px, 4.2vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

h2 {
  font-size: 17px;
  margin: 0 0 6px;
}

main > h2 {
  margin: 36px 0 10px;
}

.small {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  min-width: 0;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button.quiet {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 500;
}

.empty {
  color: var(--muted);
  margin: 10px 0 0;
  font-size: 14px;
}

/* The hero: the invitation, beside the world. */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 8px 24px;
  align-items: center;
  background: radial-gradient(1200px 500px at 85% 40%, #101a36 0%, transparent 60%), var(--space);
  color: var(--space-ink);
  border-radius: 16px;
  padding: 32px;
}

.hero .lede {
  color: var(--space-muted);
  font-size: 17px;
  margin: 0 0 22px;
  max-width: 52ch;
}

.hero .small {
  color: var(--space-muted);
}

.hero .invite {
  display: flex;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--space-line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.hero .invite img {
  width: 132px;
  height: 132px;
  border-radius: 6px;
  background: #fff;
  flex: none;
}

.hero .invite p {
  margin: 0 0 10px;
}

.hero .invite p:last-child {
  margin: 0;
}

.hero .button {
  background: #7ea6f4;
  color: #071022;
}

.world {
  position: relative;
  text-align: center;
  min-width: 0;
}

/* The card of the dot that was picked, over a corner of the globe. */
.picked {
  position: absolute;
  top: 0;
  left: 0;
  width: min(270px, 78%);
  text-align: left;
  background: rgba(10, 16, 34, 0.92);
  border: 1px solid var(--space-line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  backdrop-filter: blur(4px);
}

.picked-name {
  font-weight: 600;
  font-size: 14px;
  margin: 0 22px 8px 0;
  overflow-wrap: anywhere;
}

.picked dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  margin: 0;
}

.picked dt {
  color: var(--space-muted);
}

.picked dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.picked .close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: 0;
  color: var(--space-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.world canvas {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  touch-action: none;
  cursor: grab;
}

.world canvas:active {
  cursor: grabbing;
}

.world .small {
  margin: -8px 0 0;
}

/* The numbers. */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}

.tile .number {
  font-size: 30px;
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.tile .label {
  font-size: 13px;
  margin-top: 2px;
}

.tile .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  min-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A line that has more to say is underlined with dots: pointing at the
   line, or touching it, shows what. */
.tile .sub:has(.tip) {
  overflow: visible;
}

.tip {
  position: relative;
  cursor: default;
  outline: none;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.tip:hover,
.tip:focus {
  color: var(--ink);
}

.tip:hover::after,
.tip:focus::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 2;
  top: calc(100% + 6px);
  left: 0;
  width: min(300px, 70vw);
  white-space: normal;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

/* Panels side by side. */
/* Two columns of panels. Both columns are as tall as the taller one,
   and the panels of the shorter column share what is over between
   them, so that the two columns end on one line. */
.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.pair.wide-left {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

.stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* The topology. */
#topology {
  width: 100%;
  height: auto;
  display: block;
  color: var(--muted);
  overflow: visible;
}

#topology .spokes line {
  stroke: var(--line);
  stroke-width: 1;
}

#topology .links line {
  stroke-width: 1.4;
}

#topology .links line.trunk {
  stroke-width: 2.2;
  opacity: 0.8;
}

#topology .pulses circle {
  fill: var(--accent);
}

#topology .nodes rect {
  stroke-width: 1.6;
}

#topology .nodes rect.idle {
  stroke: var(--muted);
  opacity: 0.7;
}

#topology .nodes .flash rect {
  animation: flash 1.2s ease-out 1;
}

@keyframes flash {
  0% {
    stroke: #ffd27a;
    stroke-width: 7;
  }
  100% {
    stroke-width: 1.6;
  }
}

#topology .service text,
#topology .labels text {
  font-size: 11px;
  fill: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#topology .labels text {
  fill: var(--muted);
  font-size: 11.5px;
}

#topology .hub circle {
  fill: var(--panel);
  stroke: var(--accent);
  stroke-width: 2;
}

#topology .hub text {
  font-size: 10.5px;
  fill: var(--ink);
  font-weight: 600;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
  margin-top: 8px;
}

.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.legend .swatch.idle {
  border: 1.5px solid var(--muted);
}

/* Lists of things that happened, and of records. */
.feed,
.ranks {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 13.5px;
}

.feed li,
.ranks li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.feed li:first-child,
.ranks li:first-child {
  border-top: 0;
}

.feed .what,
.ranks .what {
  min-width: 0;
  overflow-wrap: anywhere;
}

.feed .when,
.ranks .when {
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.ranks .when {
  white-space: normal;
}

.feed .event::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--muted);
  flex: none;
  align-self: center;
}

.feed .event.join::before {
  background: var(--accent);
}

.feed .event.start::before {
  background: var(--good);
}

.feed .event.leave::before,
.feed .event.move::before {
  background: var(--bad);
}

.feed .event .what {
  flex: 1;
}

.feed .address {
  color: var(--muted);
}

/* A Service: its name and address on one line, and the nodes its pods
   are on under them. */
#services li {
  flex-direction: column;
  gap: 2px;
}

#services .when {
  text-align: left;
  white-space: normal;
}

/* Bars lying down. */
.bars .bar-row {
  display: grid;
  grid-template-columns: minmax(80px, 30%) 1fr 36px;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
  padding: 4px 0;
}

.bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: var(--ground);
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
}

.bar-track .bar {
  display: block;
  height: 100%;
  background: var(--bar);
  border-radius: 4px;
}

.bar-value {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Bars standing up. */
.bars.upright {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  height: 150px;
  align-items: end;
  margin: 12px 0 4px;
}

.bars.upright .column {
  display: grid;
  grid-template-rows: 16px 1fr 18px;
  height: 100%;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

.bars.upright .bar {
  align-self: end;
  background: var(--bar);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}

.bars.upright .column-name {
  padding-top: 4px;
}

/* The table of nodes. */
.scroll {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

/* A long table scrolls inside its own box, under headings that stay. */
.scroll.tall {
  max-height: 440px;
  overflow-y: auto;
  padding-top: 0;
}

/* The row of the node that was picked. */
tr.lit td {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* A node's name where it is a link to the node, and a button that
   reads as a link. Both are underlined with dots, as everything on the
   page that answers to a pointer is. */
a.node-link {
  color: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

button.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

#topology .nodes g {
  cursor: pointer;
}

.scroll.tall th {
  position: sticky;
  top: 0;
  background: var(--panel);
}

th,
td {
  text-align: left;
  padding: 7px 12px 7px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prose {
  max-width: 70ch;
}

/* How it works: three steps side by side. */
.steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
}

.steps li {
  counter-increment: step;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14.5px;
}

.steps li::before {
  content: counter(step);
  display: block;
  color: var(--accent);
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 4px;
}

/* A listing of YAML, coloured by site.js. */
pre.yaml .key {
  color: var(--accent);
}

pre.yaml .value {
  color: var(--ink);
}

pre.yaml .comment {
  color: var(--muted);
}

pre.yaml .line {
  display: block;
  margin: 0 -12px;
  padding: 0 12px;
}

pre.yaml .line.mark {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* The foot of the front page. */
footer.foot {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

footer.foot p {
  margin: 0 0 8px;
}

footer.foot code {
  font-size: 12px;
  overflow-wrap: anywhere;
}

pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-size: 13px;
}

/* Narrow screens: one column. */
@media (max-width: 860px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    padding: 22px 18px;
  }

  .world canvas {
    max-width: 340px;
  }

  /* Someone reading on a phone is holding the thing the QR code is
     for, so the code goes, the line that says to scan the code goes
     with it, and the button takes their place. */
  .hero .invite img,
  .hero .invite .scan {
    display: none;
  }

  .hero .invite .button {
    display: block;
    text-align: center;
  }

  .hero .invite > div {
    width: 100%;
  }

  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pair,
  .pair.wide-left,
  .steps {
    grid-template-columns: minmax(0, 1fr);
  }

  header.brand {
    font-size: 24px;
  }

  header.brand img {
    width: 38px;
    height: 38px;
  }

  .hero .invite {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* The join page: a tab that is a node. */
body.node main {
  max-width: 720px;
  padding-bottom: 24px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.node-name {
  font-size: 26px;
  font-weight: 650;
  word-break: break-all;
  margin: 4px 0 0;
}

.status {
  margin: 6px 0 16px;
  color: var(--muted);
}

.status[data-state="running"] {
  color: var(--good);
}

.status[data-state="refused"],
.status[data-state="unsupported"],
.status[data-state="left"] {
  color: var(--bad);
}

.pods {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* With no pod to show, the list takes no room, and the foot of the page
   comes up under the status line: a tab that has left has nothing to
   keep a screen's height open for. */
.pods:empty {
  display: none;
}

.pod {
  /* As tall as what the card holds, and taller when the page has room:
     a card that could shrink would hide its top under an open shell. */
  flex: 1 0 auto;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}

.pod .title {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.pod .title .image {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.pod iframe {
  flex: 1 1 auto;
  width: 100%;
  min-height: 300px;
  border: 0;
}

/* A pod's two parts: what the program prints, and a shell beside it. */
.pod .part {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.pod .part + .part {
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}

.pod .label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}

.pod .label b {
  color: var(--ink);
  font-weight: 600;
}

.pod .label .button {
  margin-left: auto;
  padding: 5px 12px;
  font-size: 13px;
}

.pod .terminal {
  height: 300px;
  padding: 6px 8px;
  background: #000;
}

.pod .note {
  margin: 0;
  padding: 0 12px 8px;
  font-size: 12px;
  color: var(--muted);
}

/* What this node has done, and under it the button that asks its own
   pod. The two are rows of their own, so that the button stays where
   it is when its answer is written beside it. */
.mine {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
}

.mine .tally {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0;
}

.mine .tally dt {
  font-size: 12px;
  color: var(--muted);
}

.mine .tally dd {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.mine .ask-mine {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

footer.node-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}
