/* ── TOKENS ── */
:root {
  --bg:        #efeeee;
  --black:     #000000;
  --white:     #ffffff;
  --rust:      #BF7665;
  --font-head: 'Borna', sans-serif;
  --font-body: 'Silka', sans-serif;
  --font-mono: 'NudicaMono', 'Courier New', monospace;
  --ease:      cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html { height: 100%; background: var(--bg); overflow: hidden; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--black);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── SWISS BACKGROUND LETTER ── */
.bg-letter {
  position: absolute;
  top: -120px;
  left: -60px;
  font-family: var(--font-head, 'Borna', sans-serif);
  font-size: 1000px;
  font-weight: 700;
  line-height: 1;
  color: #000;
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
  user-select: none;
}
.bg-letter--2 {
  top: -60px;
  left: auto;
  right: -100px;
  font-size: 900px;
}
.bg-letter--3 {
  top: 80px;
  left: 40%;
  font-size: 750px;
}

/* ── NAVBAR (shared via nav.css) ── */
.nav-active {
  opacity: 0.4;
}

/* ── PAGE HEADER ── */
.rel-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--black);
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.rel-header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 40px;
}

.rel-header-folio {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.folio-mark { opacity: 0.4; }
.vb-sep     { opacity: 0.25; margin: 0 2px; }
.vb-total   { opacity: 0.35; }

.rel-header-title {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 5px;
}

.rel-header-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.4;
}

.rel-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rel-leg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.7;
}

.rel-leg-dot {
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.25);
}

/* ── GRAPH CANVAS ── */
.rel-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#rel-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

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

/* Arrow markers on all edges */
#rel-svg path[data-from]              { marker-end: url(#rel-arrow); }
#rel-svg path[data-from].edge-focused { marker-end: url(#rel-arrow-focused); }
#rel-svg path[data-from].edge-cross   { marker-end: url(#rel-arrow-cross); }
#rel-svg path[data-from].edge-entity  { marker-end: url(#rel-arrow-entity); }

/* Edge label text — primary */
#edge-labels text {
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  fill: rgba(0,0,0,0.28);
  transition: opacity 0.2s;
}

/* Edge label text — entity-to-entity (rust tint) */
#edge-labels text.edge-label-entity {
  fill: rgba(191,118,101,0.55);
  font-size: 8px;
}

/* Legend for entity-level edges */
.rel-leg-dash {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.rel-leg-dash span {
  display: inline-block;
  width: 16px;
  height: 1.5px;
  background: rgba(191,118,101,0.5);
}

/* ── NODE INTERACTIONS ── */
.node-clickable circle {
  transition: fill 0.2s var(--ease), stroke-width 0.2s var(--ease);
  cursor: pointer;
}

.node-clickable text {
  transition: fill 0.2s var(--ease);
  pointer-events: none;
  user-select: none;
}

.node-clickable:hover circle {
  fill: var(--black) !important;
  stroke-width: 2 !important;
}

.node-clickable:hover text { fill: #ffffff !important; }

/* Focus / dim states (set by JS) */
.node-dimmed   { opacity: 0.1; transition: opacity 0.3s var(--ease); pointer-events: none; }
.node-focused circle { filter: brightness(1.15) drop-shadow(0 0 8px rgba(0,0,0,0.3)); stroke-width: 2.5 !important; }
.node-active circle  { filter: brightness(1.3)  drop-shadow(0 0 16px rgba(191,118,101,0.5)); stroke-width: 3.5 !important; }

.edge-dimmed  { opacity: 0.04 !important; transition: opacity 0.3s var(--ease); }
.edge-focused { opacity: 1 !important;    stroke: rgba(0,0,0,0.35) !important; stroke-width: 2 !important; transition: opacity 0.3s var(--ease); }

/* Selected node ring */
.node-clickable.selected circle {
  filter: drop-shadow(0 0 12px rgba(191,118,101,0.6));
  stroke: var(--rust) !important;
  stroke-width: 3 !important;
}

/* ── SIDE PANEL ── */
.rp {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 360px;
  background: var(--white);
  border-left: 1px solid var(--black);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transform: translateX(0);
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
  overflow: hidden;
}

.rp.hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* Panel top bar */
.rp-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 18px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.rp-top-folio {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
}

.rp-close {
  background: none;
  border: 1px solid rgba(0,0,0,0.2);
  color: var(--black);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease), border-color 0.2s;
  flex-shrink: 0;
}

.rp-close:hover { background: var(--black); color: var(--white); border-color: var(--black); }

/* Panel body (content injected by JS) */
.rp-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}

/* Panel content styles (used by JS-injected HTML) */
.rel-panel-prop {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.45;
  margin-bottom: 8px;
}

.rel-panel-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.rel-panel-type {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  opacity: 0.5;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.rel-panel-desc {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.8;
  margin-bottom: 24px;
}

.rel-panel-list-title {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.4;
  margin-bottom: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.rel-panel-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rel-panel-list li {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 12px;
  border: 1px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: baseline;
  gap: 10px;
  transition: background 0.15s var(--ease), border-color 0.15s;
}

.rel-panel-list li::before {
  content: "→";
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.3;
  flex-shrink: 0;
}

.rel-panel-list li:hover {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.15);
}

.rel-panel-cover {
  width: 100%;
  margin-bottom: 20px;
  border: 1px solid rgba(0,0,0,0.1);
  display: block;
}

/* Panel footer */
.rp-foot {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid rgba(0,0,0,0.1);
}

.rp-geo-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--black);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--black);
  text-decoration: none;
  transition: background 0.2s var(--ease), color 0.2s;
}

.rp-geo-btn:hover { background: var(--black); color: var(--white); }
.rp-geo-btn .arr { transition: transform 0.3s var(--ease); }
.rp-geo-btn:hover .arr { transform: translateX(4px); }

/* ── CONTEXTUAL LAYER NODE STATES ── */
[data-ctx] { cursor: pointer; transition: opacity 0.3s var(--ease); }
[data-ctx].ctx-dimmed  { opacity: 0.08; pointer-events: none; }
[data-ctx].ctx-active  circle { stroke: var(--rust) !important; stroke-width: 2.5 !important; }
[data-ctx].ctx-focused circle { stroke-width: 2 !important; opacity: 1; }
