/* node-editor.css - 노드 캔버스 전용 스타일 */
#editor-canvas {
  position: relative;
  height: min(68vh, 760px);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 1px 1px, rgba(151, 166, 191, 0.28) 1px, transparent 0) 0 0 / 24px 24px,
    linear-gradient(180deg, rgba(24, 34, 53, 0.92), rgba(11, 18, 32, 0.96));
  box-shadow: var(--shadow-card);
  touch-action: none;
}

#viewport {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

#wire-layer,
#node-layer {
  position: absolute;
  inset: 0;
  width: 3000px;
  height: 1800px;
}

#wire-layer {
  z-index: var(--z-wires);
  overflow: visible;
  pointer-events: none;
}

#node-layer {
  z-index: var(--z-nodes);
}

.canvas-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: var(--z-hint);
  transform: translate(-50%, -50%);
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: 18px 24px;
  background: rgba(8, 17, 29, 0.68);
  backdrop-filter: blur(8px);
  pointer-events: none;
  text-align: center;
  word-break: keep-all;
}

.canvas-hint.hidden {
  display: none;
}

.node {
  position: absolute;
  width: 248px;
  min-height: 118px;
  color: var(--text);
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-node);
  user-select: none;
  backdrop-filter: blur(10px);
}

.node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 167, 255, 0.22), var(--shadow-node);
}

.node.dragging {
  z-index: var(--z-node-drag);
  opacity: 0.92;
}

.node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  cursor: grab;
}

.node-header:active {
  cursor: grabbing;
}

.node-color {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--node-input);
  box-shadow: 0 0 10px currentColor;
}

.node[data-color="logic"] .node-color { background: var(--node-logic); }
.node[data-color="output"] .node-color { background: var(--node-output); }

.node-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-delete {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.node-delete:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.node-body {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
}

.node-param {
  display: grid;
  gap: 4px;
}

.node-param label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.node-param input,
.node-param select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: #0a101d;
  color: var(--text);
  padding: 6px 8px;
}

.port-row {
  display: flex;
  align-items: center;
  min-height: 24px;
  font-size: 12px;
  color: var(--muted);
}

.port-row.out {
  justify-content: flex-end;
}

.port {
  position: relative;
  width: 14px;
  height: 14px;
  border: 2px solid var(--kind-any);
  border-radius: 50%;
  background: #08111d;
  cursor: crosshair;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.port:hover {
  transform: scale(1.22);
  background: var(--panel-2);
}

.port-in { margin-right: 8px; }
.port-out { margin-left: 8px; }
.port[data-kind="number"] { border-color: var(--kind-number); }
.port[data-kind="bool"] { border-color: var(--kind-bool); }
.port[data-kind="string"] { border-color: var(--kind-string); }
.port[data-kind="any"] { border-color: var(--kind-any); }

.node-readout {
  min-height: 28px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  background: #070d18;
  color: #c8d6e9;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-warn {
  display: inline-flex;
  width: max-content;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: var(--r-pill);
  padding: 2px 7px;
  color: var(--warn);
  font-size: 11px;
  font-weight: 700;
}

.wire {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
  pointer-events: stroke;
  cursor: pointer;
}

.wire:hover,
.wire.selected {
  stroke-width: 5;
  stroke: var(--accent);
}

.wire.live {
  stroke: var(--accent);
  stroke-dasharray: 8 7;
  animation: wire-flow 0.8s linear infinite;
}

.wire.temp {
  stroke: var(--muted);
  stroke-dasharray: 6 6;
}

@keyframes wire-flow {
  to { stroke-dashoffset: -30; }
}

.palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-3);
}

.palette-group {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  background: rgba(17, 24, 39, 0.7);
}

.palette-title {
  margin-bottom: var(--sp-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.palette-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.palette .btn {
  padding: 7px 10px;
  font-size: 12px;
  border-radius: var(--r-sm);
}

@media (max-width: 900px) {
  #editor-canvas {
    min-height: 460px;
  }

  .palette {
    grid-template-columns: 1fr;
  }
}

/* 캔버스 우하단 컨트롤 버튼 그룹 */
#editor-canvas .canvas-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: flex;
  gap: 4px;
}

#editor-canvas .canvas-control-btn {
  height: 32px;
  box-sizing: border-box;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border);
  color: var(--text);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-node);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#editor-canvas .canvas-control-btn.zoom-btn {
  width: 32px;
  font-size: 16px;
  font-weight: bold;
}

#editor-canvas .canvas-control-btn:hover {
  background: var(--panel-2);
  border-color: var(--accent);
  color: var(--text);
}
