/* The external client's page, in the console's look: its colours, Geist for
   words and Geist Mono for figures, white panels with hairline borders. */

@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --background: #f4f4f6;
  --foreground: #111114;
  --card: #ffffff;
  --muted: #efeff2;
  --muted-foreground: #5d5f67;
  --border: #e3e3e8;
  --input: #d6d6dc;
  --ok: #1f7a4d;
  --destructive: #be202f;
  /* the series, checked for colour-blind separation; the green is under 3:1
     on white, so every mark of it carries a value label or sits in a table */
  --rest: #2a78d6;
  --grpc: #eb6834;
  --wire: #1baf7a;
  /* springs: smooth, with no bounce, for what arrives or moves; snappy for a press */
  --spring-smooth: linear(
    0,
    0.0037,
    0.0142,
    0.031,
    0.0534,
    0.0804,
    0.1108,
    0.1438,
    0.1784,
    0.2135,
    0.2484,
    0.3145,
    0.3746,
    0.4283,
    0.4755,
    0.5562,
    0.6215,
    0.6726,
    0.7112,
    0.7735,
    0.8196,
    0.854,
    0.8793,
    0.9185,
    0.9458,
    0.9647,
    0.9779,
    0.9921,
    1
  );
  --spring-snappy: linear(
    0,
    0.012,
    0.049,
    0.107,
    0.185,
    0.278,
    0.383,
    0.493,
    0.601,
    0.702,
    0.791,
    0.865,
    0.924,
    0.967,
    0.995,
    1.013,
    1.019,
    1.016,
    1.009,
    1.003,
    1
  );
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--input) transparent;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
ul {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

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

/* ---- the top bar ---- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 24px;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
}

.brand svg {
  width: 20px;
  height: 20px;
}

.bar-title {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  color: var(--muted-foreground);
}

.pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.pill[data-state="running"]::before {
  background: var(--foreground);
  animation: pulse 1.2s ease-in-out infinite;
}

.pill[data-state="waiting"]::before {
  background: var(--input);
}

.pill[data-state="down"]::before {
  background: var(--destructive);
}

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

/* ---- the page ---- */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sub {
  margin-top: 6px;
  color: var(--muted-foreground);
}

.message {
  min-height: 21px;
  margin: 8px 0 12px;
  color: var(--muted-foreground);
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--foreground);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition:
    transform 180ms var(--spring-snappy),
    background-color 120ms;
}

.button svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.button:hover {
  background: #2b2b31;
}

/* feedback on press, before the click completes */
.button.pressed {
  transform: scale(0.97);
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

.button.ghost {
  height: 28px;
  padding: 0 10px;
  background: transparent;
  color: var(--foreground);
  font-size: 13px;
}

.button.ghost:hover {
  background: var(--muted);
}

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

.panel {
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgb(17 17 20 / 4%);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  font-size: 14px;
  font-weight: 600;
}

.panel-head p {
  font-size: 12px;
  color: var(--muted-foreground);
}

.panel-head .legend,
.panel-head .button {
  margin-left: auto;
}

.panel-body {
  padding: 16px 20px;
}

.charts {
  display: grid;
  gap: 24px;
}

@media (min-width: 900px) {
  .charts {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
  }
}

/* a chart drawn at another width never holds its column open */
.charts > div {
  min-width: 0;
}

.charts h3 {
  font-size: 13px;
  font-weight: 500;
}

.error {
  margin: 16px 20px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fbeaec;
  color: var(--destructive);
  font-size: 13px;
}

/* ---- the headline figures: one card, cells divided by hairlines ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgb(17 17 20 / 4%);
}

@media (min-width: 900px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  padding: 16px 20px;
  background: var(--card);
}

.stat-label {
  font-size: 13px;
  color: var(--muted-foreground);
}

.stat-value {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-value span {
  margin-left: 3px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.stat-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted-foreground);
}

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

.table {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

.panel-head + .table,
.panel-head + .facts,
.panel-body[hidden] + .table {
  border-top: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  height: 36px;
  background: rgb(239 239 242 / 60%);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
}

td {
  height: 44px;
  border-top: 1px solid var(--border);
}

th:first-child,
td:first-child {
  padding-left: 20px;
}

th:last-child,
td:last-child {
  padding-right: 20px;
}

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

td.num {
  font: 12px var(--mono);
  font-variant-numeric: tabular-nums;
}

td.soft {
  color: var(--muted-foreground);
}

td small {
  display: block;
  font: 12px var(--mono);
  color: var(--muted-foreground);
}

tbody tr:hover {
  background: rgb(239 239 242 / 50%);
}

tr[aria-current="true"] {
  background: rgb(239 239 242 / 70%);
}

.pick {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.pick:hover {
  text-decoration: underline;
}

/* on a phone, the columns that matter least wait for a wider screen, and the
   rest fit: tighter cells, and names and headings wrap */
@media (max-width: 760px) {
  .wide {
    display: none;
  }

  th,
  td {
    padding: 0 6px;
  }

  th,
  td:first-child {
    white-space: normal;
    line-height: 1.3;
  }

  td {
    height: auto;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* ---- the live run ---- */

.phase h3 {
  padding: 12px 20px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.step {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr 56px 84px;
  align-items: center;
  gap: 16px;
  padding: 6px 20px;
}

.step-name small {
  margin-left: 8px;
  font: 12px var(--mono);
  color: var(--muted-foreground);
}

.step svg {
  width: 100%;
  overflow: visible;
}

.step-count,
.step-median {
  text-align: right;
  font: 12px var(--mono);
  font-variant-numeric: tabular-nums;
}

.step-count {
  color: var(--muted-foreground);
}

.step.done .step-count {
  color: var(--foreground);
}

#live-steps {
  padding-bottom: 12px;
}

@media (max-width: 640px) {
  .step {
    grid-template-columns: 1fr auto auto;
    gap: 4px 12px;
  }

  .step svg {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* ---- charts ---- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 4px 0 8px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
  background: var(--rest);
}

.legend .grpc::before {
  background: var(--grpc);
}

/* the handshake line is dashed, so it does not rest on colour alone */
.legend .wire::before {
  height: 0;
  border-top: 2px dashed var(--wire);
  border-radius: 0;
  background: none;
  vertical-align: 3px;
}

svg text {
  font-family: var(--sans);
}

.axis text {
  font: 11px var(--mono);
  fill: var(--muted-foreground);
}

/* a halo of the surface, so a line behind a label never runs through it */
.label {
  font-size: 13px;
  fill: var(--foreground);
  paint-order: stroke;
  stroke: var(--card);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.label-2 {
  font: 11px var(--mono);
  fill: var(--muted-foreground);
}

.value {
  font: 12px var(--mono);
  fill: var(--foreground);
  font-variant-numeric: tabular-nums;
}

.grid line {
  stroke: var(--border);
  stroke-width: 1;
}

.baseline {
  stroke: var(--input);
  stroke-width: 1;
}

.ref line {
  stroke: var(--muted-foreground);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.ref text {
  font: 11px var(--mono);
  fill: var(--muted-foreground);
}

.mark {
  stroke: var(--foreground);
  stroke-width: 2;
  stroke-linecap: round;
}

.fill-rest {
  fill: var(--rest);
}

.fill-grpc {
  fill: var(--grpc);
}

.fill-wire {
  fill: var(--wire);
}

.line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.line.rest {
  stroke: var(--rest);
}

.line.grpc {
  stroke: var(--grpc);
}

.line.wire {
  stroke: var(--wire);
  stroke-dasharray: 5 4;
}

/* a 2px ring of the surface around overlapping marks */
.ring {
  stroke: var(--card);
  stroke-width: 2;
}

.hit {
  fill: transparent;
  cursor: pointer;
}

.crosshair {
  stroke: var(--input);
  stroke-width: 1;
}

.dot {
  transition: transform 500ms var(--spring-smooth);
  animation: dot-in 200ms ease-out;
}

/* the running median in a live strip follows its samples */
.step .mark {
  transition:
    transform 500ms var(--spring-smooth),
    opacity 200ms;
}

.step-count {
  transition: color 200ms;
}

.pill::before {
  transition: background-color 200ms;
}

tbody tr {
  transition: background-color 120ms;
}

/* a panel that arrives: up from just below, with the smooth spring */
.enter {
  animation: enter 500ms var(--spring-smooth) both;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes dot-in {
  from {
    opacity: 0;
  }
}

.tip {
  position: fixed;
  z-index: 20;
  max-width: 280px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--foreground);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
  pointer-events: none;
}

/* ---- this client ---- */

.facts {
  display: grid;
  gap: 12px 24px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 760px) {
  .facts {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

.facts dd {
  overflow-wrap: anywhere;
}

.checks {
  padding: 0;
  list-style: none;
}

.check {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 2px 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.check:first-child {
  border-top: 0;
}

.check-icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  fill: none;
  stroke: var(--ok);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.check.bad .check-icon {
  stroke: var(--destructive);
}

.check-name {
  font-weight: 500;
}

.check-ms {
  font: 12px var(--mono);
  color: var(--muted-foreground);
}

.check-detail {
  grid-column: 2 / -1;
  font-size: 12px;
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 32px;
  font-size: 12px;
  color: var(--muted-foreground);
}

@media (max-width: 640px) {
  .bar {
    padding: 0 16px;
  }

  .bar-title {
    display: none;
  }

  main {
    padding: 24px 16px 40px;
  }

  footer {
    padding: 0 16px 24px;
  }

  .panel-head,
  .panel-body,
  .facts,
  .check {
    padding-left: 16px;
    padding-right: 16px;
  }

  th:first-child,
  td:first-child {
    padding-left: 16px;
  }

  th:last-child,
  td:last-child {
    padding-right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button,
  .dot,
  .step .mark {
    transition: none;
    animation: none;
  }

  /* arrivals fade instead of moving */
  .enter {
    animation: fade 200ms ease-out both;
  }

  @keyframes fade {
    from {
      opacity: 0;
    }
  }

  .button.pressed {
    transform: none;
  }

  .pill[data-state="running"]::before {
    animation: none;
  }
}
