/* SandOS Hub — additions to the shared design system.
 * Only classes that don't exist in base.css / components.css go here. */

/* --border-subtle not in tokens.css — define it here */
:root { --border-subtle: rgba(255,255,255,.055); }

/* Hub pages all use .view-inner for padding — strip the default from .view */
.view { padding: 0; }

/* Active nav item (BEM modifier used in Hub's app.js) */
.nav-item--active {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item--active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}
.nav-item--active svg { color: var(--accent); }

/* Inner wrapper that constrains content width with consistent padding */
.view-inner {
  padding: var(--s6) var(--s6) var(--s12);
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 1023px) {
  .view-inner { padding: var(--s5) var(--s4) var(--s10); }
}

/* Card footer */
.card__footer {
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-0);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Persistent pairing-request banner (below topbar, above view) */
.pairing-banner {
  background: color-mix(in srgb, var(--yellow, #e3b341) 12%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--yellow, #e3b341) 35%, transparent);
  padding: var(--s3) var(--s4);
  flex-shrink: 0;
}
.pairing-banner__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s2);
}
.pairing-banner__title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--yellow, #e3b341);
}
.pairing-banner__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.pairing-banner__close:hover { color: var(--text); background: var(--surface-2); }
.pairing-banner__row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  padding: var(--s2) 0;
  border-top: 1px solid color-mix(in srgb, var(--yellow, #e3b341) 15%, transparent);
  font-size: var(--fs-sm);
}
.pairing-banner__row:first-child { border-top: none; }

/* Full-page spinner (centered in the view area) */
.spinner--page {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-width: 2.5px;
}

/* ---- Tab bar (used in node detail page) ---- */
.tab-bar {
  display: flex;
  gap: var(--s1);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: var(--s2) var(--s4);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab-btn:hover { color: var(--text); }
.tab-btn--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- Fullscreen layout (SSH terminal) ---- */
/* Hides the sidebar + collapses topbar so the terminal gets the whole viewport */
.layout--fullscreen .sidebar { display: none; }
.layout--fullscreen { grid-template-columns: 1fr; }
.layout--fullscreen .topbar { display: none; }
.layout--fullscreen .view { height: 100dvh; }

.feature-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}
.feature-chip--off {
  opacity: 0.35;
  text-decoration: line-through;
}

/* ---- Topology HUD ----
 * The map's toolbar + legend as a floating overlay instead of stacked boxed
 * bars around a fixed-height canvas — desktop docks it to the bottom, mobile
 * flips it to the top (below the app topbar) and collapses everything but the
 * primary row behind a toggle so it doesn't eat the screen. */
.topo-hud {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3) var(--s4);
  padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-top: 1px solid var(--border);
}
.topo-hud__row {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
}
.topo-hud__toggle { display: inline-flex; margin-left: auto; }
.topo-legend {
  display: flex; gap: var(--s5); flex-wrap: wrap; align-items: center;
}

/* Collapsed by default on EVERY size — the legend is reference material, and
 * at desktop width it was eating a third of the map. Expanded height is
 * user-set (--topo-more-h, dragged via the grip below and persisted); the
 * transition is on max-height so the collapse animates from any height. */
.topo-hud__more {
  max-height: 0; overflow: hidden;
  transition: max-height var(--dur) var(--ease);
}
.topo-hud.is-expanded .topo-hud__more {
  max-height: var(--topo-more-h, 40vh); overflow-y: auto;
}

/* Drag-to-resize grip along the HUD's top edge — only meaningful while
 * expanded, so it's hidden (and non-interactive) when collapsed. */
.topo-hud__grip {
  display: none;
  position: absolute; left: 0; right: 0; top: -3px; height: 9px;
  cursor: ns-resize; z-index: 26;
}
.topo-hud.is-expanded .topo-hud__grip { display: block; }
.topo-hud__grip::after {
  content: ""; position: absolute; left: 50%; top: 3px;
  width: 46px; height: 3px; margin-left: -23px; border-radius: 2px;
  background: var(--border); transition: background var(--dur) var(--ease);
}
.topo-hud__grip:hover::after { background: var(--text-faint); }
/* While dragging, the whole document keeps the resize cursor and stops
 * selecting text under the pointer. */
body.topo-resizing { cursor: ns-resize; user-select: none; }

/* Collapsed, the HUD shrinks to just its toolbar row; the caret is the only
 * affordance for the legend. */
.topo-hud__caret {
  display: inline-block; transition: transform var(--dur) var(--ease);
  font-size: 11px; line-height: 1;
}
.topo-hud.is-expanded .topo-hud__caret { transform: rotate(180deg); }

@media (max-width: 720px) {
  .topo-hud {
    top: 0; bottom: auto; border-top: none; border-bottom: 1px solid var(--border);
    padding-bottom: var(--s3);
  }
  .topo-hud.is-expanded .topo-hud__more { max-height: 60vh; }
  /* Dragging a bottom-edge grip makes no sense when the HUD is docked to the
   * top — mobile keeps the plain toggle it already had. */
  .topo-hud.is-expanded .topo-hud__grip { display: none; }
}
