*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-2);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
}

#graph { position: absolute; inset: 0; }
#graph canvas { display: block; }

/* soft vignette so nodes near the edge recede instead of getting clipped */
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 42%, rgba(4, 6, 10, 0.62) 100%);
}

/* --- node labels --------------------------------------------------------- */
/* Every node keeps its name, all the time. They are plain text by default so
   150 of them do not turn into 150 competing chips; only the ones taking part
   in the current hover get a chip drawn around them. */
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.label {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--fg-2);
  text-shadow:
    0 0 3px var(--bg-2),
    0 0 6px var(--bg-2),
    0 1px 2px rgba(0, 0, 0, 0.9);
}

.label[data-rel="self"],
.label[data-rel="from"],
.label[data-rel="to"],
.label[data-rel="hit"] {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 3px;
  background: rgba(9, 12, 18, 0.9);
  border: 1px solid var(--line-2);
  text-shadow: none;
  z-index: 2;
}

.label[data-rel="self"] {
  color: #0d1017;
  background: var(--focus);
  border-color: var(--focus);
  font-weight: 600;
}

.label[data-rel="from"] { color: var(--from); border-color: rgba(77, 157, 255, 0.55); }
.label[data-rel="to"]   { color: var(--to);   border-color: rgba(49, 214, 155, 0.55); }
.label[data-rel="hit"]  { color: var(--hit);  border-color: rgba(255, 255, 255, 0.35); }

/* --- HUD ------------------------------------------------------------------ */
.hud {
  position: absolute;
  background: rgba(14, 18, 26, 0.9);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  font-family: var(--mono);
  font-size: 11.5px;
}

.hud-card {
  top: 12px;
  left: 12px;
  width: 216px;
  padding: 10px 12px 11px;
}

.hud-card__id {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-card__meta {
  color: var(--fg-3);
  font-size: 10.5px;
  margin-top: 3px;
}

.hud-card__rel {
  display: flex;
  gap: 14px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--fg-2);
}

.hud-card__rel b { font-weight: 600; }
.hud-card__rel .from b { color: var(--from); }
.hud-card__rel .to b { color: var(--to); }

.hud-card__cta { margin-top: 8px; color: var(--fg-3); font-size: 10.5px; }

.hud-card[data-empty="true"] .hud-card__rel,
.hud-card[data-empty="true"] .hud-card__cta { display: none; }

.hud-legend {
  bottom: 12px;
  left: 12px;
  padding: 9px 12px 10px;
  color: var(--fg-2);
}

.hud-legend div { display: flex; align-items: center; gap: 8px; padding: 2px 0; }

.hud-legend i {
  width: 16px;
  height: 2px;
  border-radius: 2px;
  flex: none;
  background: currentColor;
}

.hud-legend .from { color: var(--from); }
.hud-legend .to { color: var(--to); }
.hud-legend .self { color: var(--focus); }
.hud-legend .rest { color: var(--node); }
.hud-legend span { color: var(--fg-2); }
.hud-legend .from span, .hud-legend .to span,
.hud-legend .self span, .hud-legend .rest span { color: var(--fg-2); }

.hud-tools {
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 2px;
  padding: 3px;
}

.hud-tools button {
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--fg-2);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 9px;
  cursor: pointer;
}

.hud-tools button:hover { background: var(--panel-2); color: var(--fg); }
.hud-tools button[aria-pressed="true"] { color: var(--from); }

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

/* --- boot / error --------------------------------------------------------- */
.boot {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-3);
  background: var(--bg-2);
  transition: opacity 0.4s ease;
}

.boot[hidden] { display: none; }
.boot__bar { width: 150px; height: 2px; background: var(--line-2); overflow: hidden; border-radius: 2px; }
.boot__bar i { display: block; width: 40%; height: 100%; background: var(--from); animation: slide 1.1s ease-in-out infinite; }

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
  .boot__bar i { animation: none; width: 100%; }
}

@media (max-width: 620px) {
  .hud-card { width: 178px; }
  .hud-legend { font-size: 10.5px; }
}
