/* NodeBook — node detail, CLI console, regions, channels, the ⋯ menu, fleet dashboard, map. */

/* ---------- detail ---------- */

.detail-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6) 0;
}

.detail-title {
  flex: 1;
  min-width: 0;
}

.detail-title h1 {
  font-size: var(--text-xl);
  overflow-wrap: anywhere;
}

.detail-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: 6px;
}

.tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-6) 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  margin-bottom: -1px;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .tab:hover {
    color: var(--text);
    border-bottom-color: var(--border-strong);
  }
}

/* The open tab: in the text colour and bold, over a gold line (aria-current, never colour alone). */
.tab[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

/* A strip wider than its pane fades out at the end(s) with more tabs past them. */
.tabs[data-more="end"] {
  mask-image: linear-gradient(to right, black calc(100% - 40px), transparent);
}

.tabs[data-more="start"] {
  mask-image: linear-gradient(to left, black calc(100% - 40px), transparent);
}

.tabs[data-more="both"] {
  mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent);
}

.tab .tab-flag {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
}

.detail-body {
  padding: var(--space-5) var(--space-6) calc(var(--space-8) + 72px);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 980px;
}

.key-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  min-width: 0;
}

.key-field code {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-all;
  color: var(--text-2);
}

.byte-meter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.byte-meter .bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}

.byte-meter .bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--ok);
  border-radius: 2px;
}

.byte-meter .bar > i {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text-3);
}

.byte-meter[data-status="warning"] .bar > span {
  background: var(--warn);
}

.byte-meter[data-status="error"] .bar > span {
  background: var(--danger);
}

.issues {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.issue {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.issue .icon {
  margin-top: 1px;
}

.issue--warn .icon {
  color: var(--warn);
}

.issue--error .icon {
  color: var(--danger);
}

.issue--info .icon {
  color: var(--info);
}

.issue--ok .icon {
  color: var(--ok);
}

.callout {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--info-soft);
  font-size: var(--text-sm);
}

.callout .icon {
  color: var(--info);
  margin-top: 1px;
}

.callout--warn {
  background: var(--warn-soft);
}

.callout--warn .icon {
  color: var(--warn);
}

/* On a tinted callout the muted text colour is too light to read. */
.callout .kv dt {
  color: var(--text);
}

.callout--accent {
  background: var(--accent-soft);
}

.callout--accent .icon {
  color: var(--accent-strong);
}

.callout-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

/* Node Settings / Regions: how the node relates to the Fleet defaults, one line plus a disclosure. */
.layers-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.layers-line > span {
  flex: 1 1 16rem;
}

.layers-line a {
  color: var(--link);
}

.callout-more > summary {
  width: fit-content;
  color: var(--text-2);
  font-size: var(--text-xs);
  cursor: pointer;
}

.callout-more > p {
  margin-top: var(--space-2);
  color: var(--text-2);
}

.mini-map {
  height: 240px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

.mini-map.is-picking {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mini-map.is-picking .leaflet-container {
  cursor: crosshair;
}

.coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--space-3);
  align-items: end;
}

.flag-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-2) var(--space-5);
}

.check {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  cursor: pointer;
  padding: var(--space-1) 0;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 2px 0 0;
  flex: none;
}

.check small {
  display: block;
  color: var(--text-3);
  font-size: var(--text-xs);
}

/* ---------- CLI / console ---------- */

.code-block {
  margin: 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  max-height: 420px;
  overflow: auto;
  white-space: pre;
}

.code-block .ln-over {
  color: var(--code-bad);
}

.console[hidden] {
  display: none;
}

.console {
  height: 220px;
  overflow: auto;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.55;
}

.console .ok {
  color: var(--code-ok);
}

.console .err {
  color: var(--code-bad);
}

.console .muted {
  color: var(--code-mut);
}

.console .cmd {
  color: var(--code-warn);
}

.usb-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-2);
}

/* ---------- regions ---------- */

.region-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.region-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2) 6px calc(var(--space-3) + var(--depth, 0) * 22px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-height: 48px;
}

.region-row:last-child {
  border-bottom: 0;
}

.region-code {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.region-code .elbow {
  color: var(--text-3);
}

.region-row select {
  width: auto;
  min-height: 32px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  max-width: 130px;
}

.flood-btn {
  min-width: 76px;
  height: 30px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  color: var(--text-3);
}

.flood-btn[data-flood="allow"] {
  background: var(--ok-soft);
  border-color: transparent;
  color: var(--ok);
}

.flood-btn[data-flood="deny"] {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.home-mark {
  font-size: var(--text-xs);
  color: var(--accent-strong);
  font-family: var(--font-sans);
  font-weight: 600;
}

/* ---------- channels ---------- */

.channel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-3) var(--space-4);
  align-items: center;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.channel-slot {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
}

.channel-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.channel-secret {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-3);
  word-break: break-all;
}

.channel-secret--locked {
  display: inline-flex;
  gap: var(--space-1);
  align-items: center;
  font-family: inherit;
}

.channel-actions,
.channel-more-actions {
  display: flex;
  gap: 2px;
}

/* ---------- ⋯ menu ---------- */

.more-menu {
  position: relative;
}

.more-menu-list {
  position: absolute;
  z-index: 700;
  top: calc(100% + 4px);
  right: 0;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: var(--space-1);
  border-radius: var(--radius-md);
  /* glass, as the tools' menus; on glass the muted text takes its glass shade */
  border: 1px solid var(--glass-line);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-glass);
  --text-2: var(--glass-mut);
  --text-3: var(--glass-mut);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .more-menu-list {
    background: var(--surface);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .more-menu-list {
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.more-menu-list[hidden] {
  display: none;
}

.more-menu-item {
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.more-menu-item:focus-visible {
  background: var(--accent-soft);
  outline-offset: -2px;
}

@media (hover: hover) {
  .more-menu-item:hover:not(:disabled) {
    background: var(--accent-soft);
  }
}

.more-menu-item:disabled {
  color: var(--text-3);
  cursor: not-allowed;
}

.channel-issues {
  grid-column: 2 / -1;
}

/* ---------- fleet dashboard ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: var(--space-3);
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

button.stat--button {
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
}

/* The tile that filters the list: pale gold with a gold rim, its label in bold. */
button.stat--button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

button.stat--button[aria-pressed="true"] .stat-label {
  font-weight: 700;
  color: var(--text);
}

@media (hover: hover) {
  button.stat--button:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
}

/* tool-cijfer: 24/28 bold, table figures */
.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 28px;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stat-label .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--type-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-3);
  font-size: var(--text-xs);
  padding: 0 var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.table a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

@media (hover: hover) {
  .table a:hover {
    color: var(--link-hover);
    text-decoration: underline;
  }
}

.table-wrap {
  overflow-x: auto;
  margin: 0 calc(-1 * var(--space-2));
}

/* ---------- map page ---------- */

.map-view {
  position: relative;
  flex: 1;
  min-height: 0;
}

.map-canvas {
  position: absolute;
  inset: 0;
}

.map-toolbar {
  position: absolute;
  z-index: 500;
  top: var(--space-3);
  left: var(--space-3);
  right: var(--space-3);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  pointer-events: none;
}

.map-toolbar > * {
  pointer-events: auto;
}

/* Over the map: glass panels with the low shadow of what floats. */
.map-toolbar .chip,
.map-toolbar .btn {
  background: var(--glass);
  border-color: var(--glass-line);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-float);
}

.map-toolbar .chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.leaflet-container {
  background: var(--surface-2);
  font-family: var(--font-sans);
}

.leaflet-tile-pane {
  filter: var(--map-filter);
}

.leaflet-control-zoom a,
.leaflet-bar a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 80%, transparent) !important;
  color: var(--text-3) !important;
}

.leaflet-control-attribution a {
  color: var(--text-2) !important;
}

/* Popups float over the map: glass, with the glass shades of muted text and links. */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--text);
  box-shadow: var(--shadow-glass);
  --text-2: var(--glass-mut);
  --text-3: var(--glass-mut);
  --link: var(--glass-link);
}

.leaflet-popup-content-wrapper {
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-md);
}

.leaflet-popup-content {
  margin: 12px 14px;
}

.map-popup {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 180px;
}

.map-popup strong {
  font-size: var(--text-md);
}

.map-popup a.btn {
  color: var(--text);
}

.map-popup--list {
  max-height: min(320px, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  gap: 0;
}

.map-popup--list a {
  padding: var(--space-1) 0;
}

@media (pointer: coarse) {
  .map-popup--list a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

.pin {
  width: 26px;
  height: 26px;
  position: relative;
}

.pin::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--type-color);
  /* a single node: a 2 px rim, dark on light and light in dark, so it reads on any tile */
  border: 2px solid var(--node-rim);
}

.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--plate);
}

.pin--owned {
  width: 32px;
  height: 32px;
}

.pin--owned::before {
  box-shadow: 0 0 0 3px var(--accent);
}

.pin--owned::after {
  background: var(--accent);
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  box-shadow: 0 0 0 2px var(--plate);
}

.pin--selected::before {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--node-rim);
}

.pin--draft::before {
  opacity: 0.6;
  border-style: dashed;
}

.pin-cluster {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  /* map clusters: gold with an ink rim, in both themes */
  background: var(--accent);
  color: var(--accent-ink);
  border: 2px solid var(--ink);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.legend {
  position: absolute;
  z-index: 500;
  left: var(--space-3);
  bottom: var(--space-6);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--glass-mut);
  box-shadow: var(--shadow-float);
  flex-wrap: wrap;
}

.legend[hidden] {
  display: none;
}

.map-empty {
  position: absolute;
  z-index: 500;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 32px));
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-line);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-float);
  color: var(--glass-mut);
  text-align: center;
  pointer-events: none;
}

.map-empty[hidden] {
  display: none;
}

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

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--type-color);
}

/* Node Overview: what the device had when last read or applied to. */
.observed {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.observed-line {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  font-weight: 600;
}

.observed-line .icon {
  margin-top: 2px;
  flex: none;
}

.observed-line.is-same .icon,
.sync-yes {
  color: var(--ok);
}

.observed-line.is-diff .icon {
  color: var(--warn);
}

.sync-yes {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.observed-diff > summary {
  width: fit-content;
  color: var(--text-2);
  font-size: var(--text-sm);
  cursor: pointer;
}

.observed-diff > ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
  font-size: var(--text-sm);
}

/* Repeater Apply: what differs before, and each line's outcome after. */
.apply-diff,
.apply-result {
  margin: 0;
  padding-left: var(--space-5);
  font-size: var(--text-sm);
}

.apply-diff--plain {
  color: var(--text-2);
}

/* Settings from the configurator (#/handoff). */
.handoff-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  margin: 0;
}

.handoff-facts dt {
  color: var(--text-2);
}

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

.handoff-list li {
  overflow-wrap: anywhere;
}

.handoff-list--skipped {
  color: var(--text-3);
}

.apply-result {
  max-height: 50vh;
  overflow-y: auto;
}

.apply-result li {
  overflow-wrap: anywhere;
}

.apply-result code {
  margin-right: var(--space-2);
}

.apply-result .is-ok > span {
  color: var(--ok);
}

.apply-result .is-skip > span {
  color: var(--text-2);
}

.apply-result .is-err > span {
  color: var(--danger);
}

/* A short second line in a table cell (the phone's radio table: firmware, nodes not read). */
.cell-sub {
  display: block;
  color: var(--text-2);
  font-size: var(--text-xs);
}

/* New repeater: next steps (node.js newRepeaterCard). */
.steps {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.steps li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.steps li.is-done > span:not(.sr-only) {
  color: var(--text-2);
  text-decoration: line-through;
}
