@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:              #020810;
  --color-domain:    #00e5ff;
  --color-blanket:   #4d8fff;
  --color-specific:  #a855f7;
  --color-entity:    #f59e0b;
  --color-conflict:  rgba(255, 55, 95, 0.7);
  --glass-bg:        rgba(4, 12, 32, 0.82);
  --glass-border:    rgba(255, 255, 255, 0.07);
  --text:            rgba(255, 255, 255, 0.85);
  --text-muted:      rgba(255, 255, 255, 0.4);
}

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Syne', sans-serif;
  color: var(--text);
}

/* Atmospheric depth layers */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 55% at 18% 22%, rgba(0, 80, 255, 0.09)  0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 82% 78%, rgba(130, 0, 220, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 35% 40% at 55% 8%,  rgba(0, 200, 255, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 40% 35% at 90% 10%, rgba(0, 100, 200, 0.05) 0%, transparent 55%);
  pointer-events: none;
  animation: atmo 14s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes atmo {
  0%   { opacity: 0.65; transform: scale(1);    }
  100% { opacity: 1;    transform: scale(1.04); }
}

/* Subtle grid */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(50, 100, 220, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50, 100, 220, 0.032) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(ellipse 88% 88% at 50% 50%, black 30%, transparent 100%);
  mask-image:         radial-gradient(ellipse 88% 88% at 50% 50%, black 30%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* Star particle canvas */
#bg-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.45;
}

/* Graph SVG */
#graph-container {
  position: fixed;
  inset: 0;
  z-index: 2;
}

#graph-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graph-svg:active {
  cursor: grabbing;
}

/* ── Tooltip ─────────────────────────────────────────── */
#tooltip {
  position: fixed;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
  width: 290px;
  padding: 16px 20px;
  background: rgba(3, 10, 28, 0.9);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.025) inset,
    0 1px 0 rgba(255, 255, 255, 0.07) inset;
}

#tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tt-type {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 6px;
  opacity: 0.75;
}

.tt-label {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.tt-desc {
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.52);
  margin-bottom: 0;
}

.tt-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 11px 0;
}

.tt-section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.28);
  margin-bottom: 7px;
}

.tt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tt-tag {
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.04em;
}

.tt-edge-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 4px;
}

.tt-edge-source { color: rgba(255, 255, 255, 0.6); }
.tt-edge-target { color: rgba(255, 255, 255, 0.6); }
.tt-arrow { opacity: 0.3; }

/* ── Legend — node types ─────────────────────────────── */
#legend {
  position: fixed;
  bottom: 28px;
  left: 28px;
  padding: 14px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

/* ── Legend — edge types ─────────────────────────────── */
#edge-legend {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 14px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.legend-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.22);
  margin-bottom: 3px;
}

.legend-item, .edge-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Edge legend lines */
.edge-sample {
  width: 26px;
  height: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.edge-sample svg {
  width: 100%;
  height: 2px;
  overflow: visible;
}

/* Title watermark */
#title-watermark {
  position: fixed;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}