/* Shared economy-graph explorer styles.
   Ported from the ai-economy explorer shell (reset, layout, header, sidebar,
   view-list, legend, graph canvas, inspector base); the domain-specific
   inspector sections (revenue, flows, HHI, FAQ, lens switcher) are dropped.
   New here: the bundle selector, node-type legend dots, and a plain-DOM
   hover tooltip (replacing ai-economy's Lit <chart-tooltip>). */

/* ── Reset ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
  padding: 0;
}
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  cursor: pointer;
}
ul,
ol {
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}

:root {
  --bg: #0b0c0f;
  --surface: #111318;
  --border: #1d1f28;
  --border-strong: #272a38;
  --text: #d0d4e0;
  --text-muted: #52576a;
  --text-dim: #2e3040;
  --accent: #4a9ef8;

  --header-h: 40px;
  --sidebar-w: 210px;
  --inspector-w: 340px;
  --font-sans: "Lexend Deca", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:
    "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --font: var(--font-mono);
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Color utilities ──────────────────────────────── */
.col-muted {
  color: var(--text-muted);
}

/* ── Badge variants ───────────────────────────────── */
.i-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid;
  margin-bottom: 6px;
}
.badge-entity {
  color: var(--text-muted);
  border-color: var(--text-muted);
}

/* ── Layout ───────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr var(--inspector-w);
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ── Sidebar resize handle ────────────────────────── */
#sidebar-resize {
  position: absolute;
  top: var(--header-h);
  bottom: 0;
  left: var(--sidebar-w);
  width: 9px;
  transform: translateX(-4px);
  cursor: col-resize;
  z-index: 40;
  background: transparent;
  transition: background 0.12s ease;
  touch-action: none;
}
#sidebar-resize:hover {
  background: var(--border-strong);
}
#sidebar-resize.dragging {
  background: var(--accent);
}

/* ── Header ───────────────────────────────────────── */
#header {
  grid-column: 1 / -1;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.h-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  flex-shrink: 0;
}
.h-brand b {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.h-bundle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  flex-shrink: 0;
}
.h-bundle select {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
}
.h-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border-right: 1px solid var(--border);
}
.h-search svg {
  color: var(--text-muted);
  flex-shrink: 0;
}
.h-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  width: 100%;
}
.h-search input::placeholder {
  color: var(--text-muted);
}
.h-stats {
  display: flex;
  align-items: stretch;
}
.h-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.h-stat b {
  color: var(--text);
}
.h-stat--live {
  color: #20c47a;
}

/* ── Sidebar ──────────────────────────────────────── */
#sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  transition: opacity 0.12s;
}
#sidebar.ready {
  opacity: 1;
}
.s-section {
  padding: 12px 14px 6px;
}
.s-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.s-rule {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.view-list {
  list-style: none;
}
.view-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.02em;
  transition:
    background 0.1s,
    color 0.1s;
}
.view-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}
.view-item.active {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.v-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.15s;
}
.view-item[data-view="all"].active .v-dot,
.view-item[data-view="all"]:hover .v-dot {
  background: var(--text);
}
.view-item.active .v-dot,
.view-item:hover .v-dot {
  background: var(--view-color, var(--text));
}

.filter-block {
  padding: 0 14px 6px;
}
.f-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 3px 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}
.f-item input[type="checkbox"] {
  appearance: none;
  width: 10px;
  height: 10px;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.f-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.f-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 2px;
  width: 4px;
  height: 2px;
  border-left: 1.5px solid #000;
  border-bottom: 1.5px solid #000;
  transform: rotate(-45deg);
}

/* Node-filter groups (ADR-004): one titled group per scheme, checkboxes reuse
   .f-item. The group accent rides on --view-color, set per group in app.ts. */
#node-filter-list {
  padding: 0 14px 6px;
}
.nf-group {
  margin-bottom: 8px;
}
.nf-title {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--view-color, var(--text-muted));
  padding: 2px 0 3px;
}
.f-count {
  margin-left: auto;
  color: var(--text-muted);
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.legend {
  padding: 0 14px 12px;
}
.l-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 0;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}
.l-line {
  width: 16px;
  height: 1.5px;
  flex-shrink: 0;
}
.n-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.layout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.layout-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* ── Graph canvas ─────────────────────────────────── */
#canvas {
  position: relative;
  overflow: hidden;
  background: var(--bg);
  cursor: default;
}
#canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.3;
}
#graph {
  width: 100%;
  height: 100%;
  display: block;
}
#graph canvas {
  outline: none;
}
#graph.is-grabbing {
  cursor: grabbing;
}
#graph.is-grab {
  cursor: grab;
}

/* ── Hover tooltip (plain DOM) ────────────────────── */
.graph-tooltip {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 6px 9px;
  max-width: 240px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.graph-tooltip .tt-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.graph-tooltip .tt-sub {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Inspector ────────────────────────────────────── */
#inspector {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  overflow-x: hidden;
}
.i-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 9px;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 32px;
}
.i-empty svg {
  opacity: 0.25;
  margin-bottom: 4px;
}
.i-empty.off {
  display: none;
}
.i-panel {
  display: none;
}
.i-panel.on {
  display: block;
}
.i-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.i-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.i-subtitle {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 3px;
  word-break: break-all;
}
.i-sec {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.i-sec-label {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.i-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 0;
  font-size: 10px;
  gap: 10px;
}
.i-key {
  color: var(--text-muted);
  flex-shrink: 0;
}
.i-val {
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}
.i-empty-note {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 18px 14px;
}

.party {
  margin-bottom: 7px;
}
.party-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.party-role {
  font-size: 9px;
  color: var(--text-muted);
  padding: 1px 0 1px 10px;
}

.edge-row {
  cursor: pointer;
  margin: 0 -6px;
  padding: 4px 6px;
  border-radius: 2px;
  transition: background 0.1s;
}
.edge-row:hover {
  background: rgba(255, 255, 255, 0.04);
}
.edge-row .edge-arrow {
  color: var(--text-muted);
  margin-right: 4px;
}
.edge-row .edge-cp {
  font-weight: 500;
  color: var(--text);
}
.edge-row .edge-type {
  font-size: 9px;
  letter-spacing: 0.04em;
  margin-top: 1px;
}
.actor-link {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  text-decoration-color: var(--text-muted);
}
.actor-link:hover {
  text-decoration-color: var(--text);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 3px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
}
