/* Sim collection portal.
   Color means state: signal green is a tunnel that is up or a host that is ready, amber is
   waiting, the tally red is a live session. Everything else is ink on mist.
   Atkinson Hyperlegible keeps 0/O and 1/l/I apart in the addresses, keys and tokens people
   read off these pages; its mono cut is used only for those machine values. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/static/fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("/static/fonts/atkinson-hyperlegible-mono.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --mist: #eef1f4;
  --paper: #ffffff;
  --ink: #15212c;
  --slate: #5a6673;
  --rule: #d4dae0;
  --rule-strong: #b3bdc7;
  --signal: #0a7b5b;
  --signal-soft: #d6ede4;
  --amber: #9a5f00;
  --amber-soft: #f6ead3;
  --tally: #c9302c;
  --error: #b42318;
  --error-soft: #fbe6e3;
  --focus: #2f6fde;
  --sans: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  /* A 1.25 scale from 16px. */
  --t-sm: 0.8125rem;
  --t-md: 1.25rem;
  --t-lg: 1.5625rem;
  --t-xl: 1.953rem;
  --t-xxl: 2.441rem;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --mist: #10171d;
    --paper: #18222b;
    --ink: #e5eaee;
    --slate: #9ba7b2;
    --rule: #2a3641;
    --rule-strong: #43515e;
    --signal: #3fbf8f;
    --signal-soft: #173a2e;
    --amber: #e0a33a;
    --amber-soft: #3a2c12;
    --tally: #e5483f;
    --error: #f0766b;
    --error-soft: #3d1c19;
    --focus: #7aa7ff;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--mist);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: var(--t-xxl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--t-md);
  font-weight: 700;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
}

p {
  margin: 0 0 1rem;
  max-width: 68ch;
  text-wrap: pretty;
}

code,
pre,
.mono {
  font-family: var(--mono);
  font-size: 0.9375em;
}

pre {
  margin: 0;
  padding: 0.875rem 1rem;
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  line-height: 1.55;
}

.muted,
.sub {
  color: var(--slate);
}

.sub {
  display: block;
  font-size: var(--t-sm);
}

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--paper);
  z-index: 2;
}

.skip:focus {
  top: 0.5rem;
}

/* --- Frame ------------------------------------------------------------ */

.wrap {
  width: min(100% - 2.5rem, 60rem);
  margin-inline: auto;
}

body.admin .wrap {
  width: min(100% - 2.5rem, 78rem);
}

.top {
  border-bottom: 1px solid var(--rule);
}

.top-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 2rem;
  min-height: 3.5rem;
  padding-block: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 700;
  text-decoration: none;
}

.brand svg {
  flex: none;
}

.sections {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  align-self: stretch;
}

.sections a {
  display: flex;
  align-items: center;
  color: var(--slate);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.sections a:hover {
  color: var(--ink);
}

.sections a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}

.account {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
  font-size: 0.9375rem;
}

.account .who {
  color: var(--slate);
}

main {
  padding: 2.5rem 0 5rem;
}

.page-head {
  margin-bottom: 2.25rem;
}

.page-head.split {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-head p {
  margin: 0.5rem 0 0;
  color: var(--slate);
}

.crumb {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--slate);
  font-size: 0.9375rem;
}

/* A host name is a machine value, set like a nameplate. */
h1.ident {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 1.5rem;
  margin: 0.875rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--slate);
}

section {
  margin-top: 3rem;
}

section > h2 {
  margin-bottom: 1rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.count {
  color: var(--slate);
  font-weight: 400;
}

/* --- State ------------------------------------------------------------ */

.lamp {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-weight: 600;
  color: var(--slate);
  white-space: nowrap;
}

.lamp::before {
  content: "";
  width: 0.625em;
  height: 0.625em;
  border-radius: 50%;
  border: 2px solid currentColor;
}

.lamp[data-state="up"] {
  color: var(--signal);
}

.lamp[data-state="up"]::before,
.lamp[data-state="down"]::before {
  background: currentColor;
}

/* `wait` is a host whose VM is being created, set up, stopped, started or deleted. */
.lamp[data-state="waiting"],
.lamp[data-state="wait"] {
  color: var(--amber);
}

.lamp[data-state="down"] {
  color: var(--error);
}

/* A live session, lit like a studio's on-air light. */
.onair {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 3px;
  background: var(--tally);
  color: #fff;
  font-weight: 700;
  font-size: var(--t-sm);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.notice {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  max-width: none;
  border-left: 4px solid;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.notice.error {
  background: var(--error-soft);
  border-color: var(--error);
}

/* `wait` is a host in the middle of a change, amber like its lamp. */
.notice.warning,
.notice.wait {
  background: var(--amber-soft);
  border-color: var(--amber);
}

.notice.ok {
  background: var(--signal-soft);
  border-color: var(--signal);
}

/* --- The tunnel line ---------------------------------------------------
   A device (round node) reaches its host (square node) through a tunnel: solid green when up,
   dashed amber while waiting, dotted grey once it has dropped. */

.tunnel {
  display: flex;
  align-items: center;
  min-width: 5rem;
  color: var(--rule-strong);
}

.tunnel .node {
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: var(--mist);
}

.tunnel .node.host {
  border-radius: 2px;
  background: var(--ink);
  border-color: var(--ink);
}

.tunnel .pipe {
  position: relative;
  flex: 1;
  border-top: 3px dotted currentColor;
}

[data-state="up"] .tunnel {
  color: var(--signal);
}

[data-state="up"] .tunnel .node {
  background: currentColor;
}

[data-state="up"] .tunnel .pipe {
  border-top-style: solid;
}

[data-state="waiting"] .tunnel,
[data-state="pending"] .tunnel {
  color: var(--amber);
}

[data-state="waiting"] .tunnel .pipe,
[data-state="pending"] .tunnel .pipe {
  border-top-style: dashed;
}

[data-state="revoked"] .tunnel {
  opacity: 0.4;
}

/* Traffic: one slow pulse from the device to the host, only while the tunnel is up. */
[data-state="up"] .tunnel .pipe::after {
  content: "";
  position: absolute;
  top: -5.5px;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
  animation: traffic 3.2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes traffic {
  from {
    left: 0;
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  to {
    left: calc(100% - 8px);
    opacity: 0;
  }
}

/* A state that changed while the page was open flashes once. */
.changed [data-link-label] {
  animation: changed 1.2s ease-out;
}

@keyframes changed {
  from {
    background: var(--signal-soft);
  }
  to {
    background: transparent;
  }
}

.link-label {
  font-weight: 600;
}

[data-state="up"] .link-label {
  color: var(--signal);
}

[data-state="waiting"] .link-label,
[data-state="pending"] .link-label {
  color: var(--amber);
}

[data-state="stale"] .link-label,
[data-state="revoked"] .link-label {
  color: var(--slate);
}

/* --- Devices ------------------------------------------------------------ */

.devices {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.device {
  display: grid;
  grid-template-columns: minmax(9rem, 1.1fr) minmax(6rem, 1fr) minmax(11rem, 1.2fr) 6.5rem 5.5rem;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--rule);
}

.device-name strong {
  font-family: var(--mono);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.device-addr {
  color: var(--slate);
}

.device-action {
  justify-self: end;
}

@media (max-width: 44rem) {
  .device {
    grid-template-columns: 1fr auto;
  }

  .device .tunnel {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .device-state {
    grid-row: 3;
  }

  .device-addr {
    grid-row: 3;
    justify-self: end;
  }

  .device-action {
    grid-column: 2;
    grid-row: 1;
  }
}

/* --- Surfaces --------------------------------------------------------- */

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.75rem;
}

.panel.result {
  margin: 0 0 2.5rem;
}

.panel.result .notice {
  margin-top: 1rem;
}

.connect {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem 3rem;
  margin-top: 0;
}

.connect > h2 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: var(--t-lg);
}

@media (max-width: 44rem) {
  .connect {
    grid-template-columns: 1fr;
    padding: 1.25rem;
  }
}

/* A stopped host's page leads with the way to start it, where the connect panel would be: one
   action, so the panel is only as wide as its words. */
.panel.stopped {
  max-width: 40rem;
  margin-top: 0;
}

.panel.stopped > h2 {
  margin-bottom: 0.75rem;
  font-size: var(--t-lg);
}

.panel.stopped .form-note {
  margin: 1rem 0 0;
}

@media (max-width: 44rem) {
  .panel.stopped {
    padding: 1.25rem;
  }
}

/* Why the page offers no config while the host is not running. */
.held {
  margin: 1.25rem 0 0;
  color: var(--slate);
}

.steps {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  counter-increment: step;
  padding: 0 0 0.875rem 2.25rem;
  min-height: 1.75rem;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.05rem;
  width: 1.5rem;
  height: 1.5rem;
  border: 1.5px solid var(--rule-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--t-sm);
  font-weight: 700;
  color: var(--slate);
}

/* The value a step asks someone to type or open: large enough to read across a room. */
.value {
  display: block;
  width: fit-content;
  margin-top: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-family: var(--mono);
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.also {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 2rem;
  margin-top: 1.5rem;
  padding: 0 0.25rem;
}

.also > div {
  flex: 1 1 18rem;
}

.also p {
  margin: 0.25rem 0 0;
  color: var(--slate);
}

.also input {
  width: 15rem;
}

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

/* The one-time config: QR code on white whatever the theme, steps beside it. */
.once {
  display: grid;
  grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
  gap: 2rem 3rem;
  align-items: start;
}

@media (max-width: 44rem) {
  .once {
    grid-template-columns: 1fr;
  }
}

.qr {
  margin: 0;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 10px;
  color: #15212c;
}

.qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.qr figcaption {
  margin-top: 0.5rem;
  text-align: center;
  font-size: var(--t-sm);
  color: #5a6673;
}

.watch {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.watch .tunnel {
  margin: 0.75rem 0;
}

.watch .ends {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.9375rem;
}

details {
  margin-top: 1rem;
}

summary {
  cursor: pointer;
  width: fit-content;
  font-weight: 600;
}

details[open] summary {
  margin-bottom: 0.75rem;
}

/* A secret or a command, with its copy button. */
.copyable {
  position: relative;
  margin: 0.5rem 0 1.25rem;
}

/* Wrapped, so a long command stays whole beside its button instead of scrolling under it. */
.copyable pre,
.copyable .token-once {
  padding-right: 5.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.copyable [data-copy] {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.token-once {
  margin: 0;
  max-width: none;
  padding: 0.875rem 1rem;
  font-family: var(--mono);
  font-size: 1.0625rem;
  word-break: break-all;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.paths {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  gap: 1.5rem 2.5rem;
}

.paths section {
  margin: 0;
}

.paths h2 {
  margin-bottom: 0.5rem;
}

/* --- Tables ----------------------------------------------------------- */

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

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

th {
  text-align: left;
  font-weight: 600;
  font-size: var(--t-sm);
  color: var(--slate);
  padding: 0 1rem 0.5rem 0;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem 0.75rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

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

td.end,
th.end {
  text-align: right;
  padding-right: 0;
}

td .row-title {
  font-weight: 700;
}

td.nowrap {
  white-space: nowrap;
}

td.details {
  font-size: var(--t-sm);
  overflow-wrap: anywhere;
}

td .row-title.mono {
  font-weight: 600;
}

.empty {
  max-width: none;
  padding: 1.5rem 0;
  color: var(--slate);
  border-top: 1px solid var(--rule);
}

.meter {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  white-space: nowrap;
}

.meter-bar {
  display: inline-flex;
  gap: 3px;
}

.meter-bar i {
  width: 0.625rem;
  height: 0.875rem;
  border: 1.5px solid var(--rule-strong);
  border-radius: 2px;
}

.meter-bar i.used {
  background: var(--ink);
  border-color: var(--ink);
}

.meter.full {
  color: var(--amber);
}

dl.summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1rem 2rem;
  margin: 1.75rem 0 0;
  padding: 1.25rem 0;
  border-block: 1px solid var(--rule);
}

dl.summary div {
  min-width: 0;
}

dl.summary dt {
  font-size: var(--t-sm);
  color: var(--slate);
}

dl.summary dd {
  margin: 0.125rem 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* A summary under a section's heading has the rule every heading's content starts with, and
   none below: the action groups under it carry their own. */
section > dl.summary {
  margin-top: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

section > dl.summary ~ .consequences {
  margin-top: 1.75rem;
}

.stops {
  margin: 1.25rem 0 0;
}

/* --- Forms ------------------------------------------------------------ */

form {
  margin: 0;
}

form.inline {
  display: inline;
}

.field {
  display: block;
  margin: 0 0 1.125rem;
}

.field > span:first-child {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

.field .hint {
  display: block;
  margin-top: 0.375rem;
  font-size: var(--t-sm);
  color: var(--slate);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}

input::placeholder {
  color: var(--slate);
  opacity: 0.8;
}

input:user-invalid {
  border-color: var(--error);
}

fieldset {
  margin: 0 0 1.125rem;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.375rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin: 0.375rem 0;
}

.choice input {
  margin: 0.3rem 0 0;
  accent-color: var(--ink);
}

.form-narrow {
  max-width: 28rem;
}

/* What happens after a form is sent, under its button. */
.form-note {
  max-width: 28rem;
  margin-top: 1.5rem;
  color: var(--slate);
  font-size: 0.9375rem;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
}

button:hover,
.button:hover {
  box-shadow: inset 0 0 0 100vmax rgb(255 255 255 / 0.12);
}

button.quiet,
.button.quiet {
  color: var(--ink);
  background: transparent;
  border-color: var(--rule-strong);
}

button.quiet:hover,
.button.quiet:hover {
  box-shadow: none;
  border-color: var(--ink);
}

button.danger {
  color: var(--error);
  background: transparent;
  border-color: currentColor;
}

button.danger:hover {
  box-shadow: none;
  background: var(--error-soft);
}

button.small {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

button.text {
  padding: 0;
  font-weight: 400;
  color: inherit;
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 0.2em;
}

button.text:hover {
  box-shadow: none;
  text-decoration-color: currentColor;
}

button:disabled {
  cursor: default;
  opacity: 0.7;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 0.25rem;
}

.actions select {
  width: auto;
  min-width: 10rem;
}

.actions input[type="text"] {
  width: 14rem;
}

.actions input[type="number"] {
  width: 7rem;
}

/* Actions grouped by what they cost: settings, then things that cut a host off. */
.consequences {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.5rem 2.5rem;
}

.consequences > div {
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.consequences h3 {
  margin-bottom: 0.375rem;
}

.consequences p {
  color: var(--slate);
  font-size: 0.9375rem;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 2.5rem 3.5rem;
  align-items: start;
}

@media (max-width: 60rem) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.side h2 {
  margin-bottom: 1rem;
}

/* --- Sign-in ---------------------------------------------------------- */

.gate {
  max-width: 26rem;
  padding-top: 2.5rem;
}

.gate h1 {
  font-size: var(--t-xl);
}

.gate .lede {
  margin: 0.625rem 0 2rem;
  color: var(--slate);
}

.gate button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
}

.staff-door {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--slate);
}

.staff-door .button {
  margin-top: 0.75rem;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
