/* The device list page. Same colours and the same line of rings as the 远程 window (src\Ui.cs, Theme):
   a filled ring is a PC that answers, a hollow one on a dashed line is a PC that is off. */
:root {
  color-scheme: dark;
  --bg: #10252c;
  --raised: #1e3a43;
  --line: #3e626c;
  --text: #f3f1e8;
  --muted: #96afb5;
  --direct: #6ee7c8;
  --fault: #ff8f7a;
  --trunk-x: 23px;
  --ui: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  --data: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", var(--ui);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--ui);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.page {
  width: min(520px, 100%);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

/* --- header and the trunk line ------------------------------------------- */

.head {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 22px;
}

.ring {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 12px 0 0 calc(var(--trunk-x) - 10px);
  border: 2.5px solid var(--text);
  border-radius: 50%;
  position: relative;
}

.ring::after {
  content: "";
  position: absolute;
  inset: 3.5px;
  border-radius: 50%;
  background: var(--text);
}

/* The line runs from the header's ring down to the first PC. */
.head:has(+ .trunk:not([hidden]))::after {
  content: "";
  position: absolute;
  left: calc(var(--trunk-x) - 1px);
  top: 34px;
  bottom: 0;
  border-left: 2px solid var(--line);
}

h1 {
  margin: 0;
  font: 600 30px/1.3 var(--data);
  letter-spacing: 0.02em;
}

.sub {
  margin: 0;
  color: var(--muted);
}

/* --- the PCs ------------------------------------------------------------- */

#device-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.device {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 64px;
}

/* Each PC draws the stretch of line that leads to it. */
.device::before {
  content: "";
  position: absolute;
  left: calc(var(--trunk-x) - 1px);
  top: 0;
  height: 32px;
  border-left: 2px solid var(--line);
}

.device + .device::before {
  top: -8px;
  height: 40px;
}

.device.offline::before { border-left-style: dashed; }

.device-link {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: calc(var(--trunk-x) * 2) 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 10px 12px 10px 0;
  color: inherit;
  text-decoration: none;
  border-radius: 14px;
}

.node {
  grid-row: 1 / span 2;
  justify-self: center;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: var(--bg);
  position: relative;
  z-index: 1;
}

.online .node {
  border-color: var(--direct);
  background: radial-gradient(circle, var(--direct) 0 3px, var(--bg) 3.5px);
}

.name {
  font: 600 19px/1.25 var(--data);
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state {
  grid-column: 2;
  font-size: 14px;
  color: var(--muted);
}

.online .state { color: var(--direct); }

.go {
  grid-column: 3;
  grid-row: 1 / span 2;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--raised);
  font-size: 15px;
  font-weight: 600;
}

.online .go {
  background: var(--direct);
  color: var(--bg);
}

.offline .go { display: none; }

.device-link:hover { background: color-mix(in srgb, var(--raised) 55%, transparent); }

.device:not(.offline) .remove { display: none; }

.note {
  color: var(--muted);
  font-size: 14px;
  margin: 8px 0 0 calc(var(--trunk-x) * 2 + 10px);
}

/* --- cards, buttons, footer --------------------------------------------- */

.card {
  margin-top: 8px;
  padding: 20px;
  border-radius: 18px;
  background: var(--raised);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.card p { margin: 0 0 16px; color: var(--muted); }

.card ol { margin: 0; padding-left: 22px; }

.card li { margin-bottom: 8px; }

.card b { color: var(--direct); font-weight: 600; }

.actions { margin-top: 28px; }

.button {
  display: block;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font: 700 16px/1.2 var(--ui);
  cursor: pointer;
}

.button:hover { background: #fff; }

.link {
  padding: 6px 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 14px/1.4 var(--ui);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover { color: var(--text); }

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

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

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  margin-top: 40px;
  font-size: 13px;
  color: var(--muted);
}

.foot .link { padding: 0; }

/* --- the phone's QR code -------------------------------------------------- */

.sheet {
  width: min(400px, calc(100% - 32px));
  padding: 24px;
  border: 0;
  border-radius: 22px;
  background: var(--raised);
  color: var(--text);
}

.sheet::backdrop { background: rgb(6 16 20 / 0.72); }

.sheet h2 { margin: 0 0 4px; font-size: 20px; }

.sheet p { margin: 0 0 16px; color: var(--muted); }

.qr {
  width: min(280px, 72vw);
  aspect-ratio: 1;
  margin: 0 auto 12px;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

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

.qr.expired { opacity: 0.15; }

.sheet .note { margin: 0 0 18px; text-align: center; }

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.row .button { width: auto; padding: 12px 28px; }

@media (max-width: 380px) {
  .name { font-size: 17px; }
  .go { padding: 6px 12px; }
}
