/* ==========================================================================
   Lineage Garden (계보원) - 2D Tree SVG Canvas Stylesheet
   Path: /linea/css/tree_canvas.css
   ========================================================================== */

.tree-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.tree-canvas {
  height: 100%;
  width: 100%;
  touch-action: none;
  cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, var(--bg-dots) 1px, transparent 1.2px);
  background-size: 22px 22px;
  user-select: none;
}

.tree-canvas:active {
  cursor: grabbing;
}

/* Connectors */
.tree-canvas .link {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
  transition: stroke 0.15s, stroke-width 0.15s;
}

.tree-canvas .link:hover {
  stroke: var(--accent);
  stroke-width: 2.2;
}

/* Node Rectangles */
.tree-canvas .node {
  cursor: pointer;
}

.tree-canvas .node rect {
  fill: var(--panel-card);
  stroke: var(--line-strong);
  stroke-width: 1.2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.04));
  transition: all 0.15s ease;
}

.tree-canvas .node:hover rect {
  stroke: var(--accent);
  stroke-width: 1.8;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.08));
}

.tree-canvas .node.sel rect {
  stroke: var(--accent);
  stroke-width: 2.4;
  fill: var(--accent-soft);
  filter: drop-shadow(0 4px 12px rgba(46, 120, 69, 0.15));
}

.tree-canvas .node.root rect {
  stroke: var(--ochre);
  stroke-width: 2.2;
}

/* Node Typography inside SVG */
.tree-canvas .node text {
  fill: var(--fg);
  font-family: var(--body);
  pointer-events: none;
}

.tree-canvas .node .ttl {
  fill: var(--ochre);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.tree-canvas .node .nm {
  font-weight: 600;
  font-size: 13.5px;
}

.tree-canvas .node .hj {
  font-family: var(--display);
  fill: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
}

.tree-canvas .node .sub {
  fill: var(--muted);
  font-size: 11px;
}

/* Toggle (+ / -) Buttons on Parents */
.tree-canvas .tog {
  cursor: pointer;
}

.tree-canvas .tog circle {
  fill: var(--panel-card);
  stroke: var(--accent);
  stroke-width: 1.5;
  transition: transform 0.15s, fill 0.15s;
}

.tree-canvas .tog:hover circle {
  fill: var(--accent-soft);
  stroke-width: 2;
}

.tree-canvas .tog text {
  fill: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.tree-canvas .cnt {
  fill: var(--muted);
  font-size: 10px;
  text-anchor: middle;
  font-weight: 600;
  pointer-events: none;
}

/* Floating HUD Controls */
.tree-hud {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

:root[data-theme="dark"] .tree-hud,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tree-hud {
    background: rgba(26, 35, 31, 0.85);
  }
}

.tree-legend {
  position: absolute;
  right: 14px;
  top: 12px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  z-index: 10;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
