/* Custom fonts */
.font-display {
  font-family: 'Playfair Display', serif;
}

body {
  font-family: 'Inter', sans-serif;
}

/* Tree structure */
.tree-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.node-card {
  background: white;
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 180px;
  border: 2px solid transparent;
}

.node-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.node-card.expanded {
  border-color: #171717;
}

.node-card.root {
  min-width: 220px;
  padding: 1rem 1.5rem;
}

.node-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e5e5e5;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.node-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.node-avatar svg {
  width: 24px;
  height: 24px;
  color: #a3a3a3;
}

.node-info {
  flex: 1;
  min-width: 0;
}

.node-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: #171717;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-subtitle {
  font-size: 0.75rem;
  color: rgba(23, 23, 23, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-party {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.expand-indicator {
  font-size: 0.75rem;
  color: #a3a3a3;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.node-card.expanded .expand-indicator {
  transform: rotate(180deg);
}

/* Children container - horizontal by default */
.node-children {
  display: none;
  flex-wrap: nowrap;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  margin-top: 2.5rem;
  position: relative;
}

.node-children.visible {
  display: flex;
  animation: fadeIn 0.3s ease;
}

/* Vertical layout for >5 children */
.node-children.vertical {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin-left: 2rem;
}

/* ========== CONNECTOR LINES ========== */

/* Vertical line down from parent to children */
.tree-node:has(> .node-children.visible) > .node-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2px;
  height: 1.5rem;
  background: #d4d4d4;
  transform: translateX(-50%) translateY(100%);
}

/* === HORIZONTAL LAYOUT CONNECTORS === */

/* Horizontal bar connecting all children */
.node-children:not(.vertical).visible::before {
  content: '';
  position: absolute;
  top: 0;
  height: 2px;
  background: #d4d4d4;
  /* Will span from first child center to last child center */
  left: calc(0.75rem + 90px);
  right: calc(0.75rem + 90px);
}

/* Vertical drop line from horizontal bar to each child */
.node-children:not(.vertical) > .tree-node::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 1rem;
  background: #d4d4d4;
  transform: translateX(-50%) translateY(-100%);
}

/* Spacing for horizontal children */
.node-children:not(.vertical) > .tree-node {
  padding: 0 0.75rem;
}

/* === VERTICAL LAYOUT CONNECTORS === */

/* Vertical line running down the left side */
.node-children.vertical.visible::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: calc(100% - 1.5rem);
  background: #d4d4d4;
}

/* Horizontal line from vertical bar to each child */
.node-children.vertical > .tree-node {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.node-children.vertical > .tree-node::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -2rem;
  width: 1.5rem;
  height: 2px;
  background: #d4d4d4;
  transform: translateY(-50%);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Region grouping */
.region-group {
  background: white;
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.region-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: #171717;
  margin-bottom: 1rem;
  text-align: center;
}

/* Canvas scrollbar styling */
#canvas::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#canvas::-webkit-scrollbar-track {
  background: transparent;
}

#canvas::-webkit-scrollbar-thumb {
  background: #d4d4d4;
  border-radius: 5px;
}

#canvas::-webkit-scrollbar-thumb:hover {
  background: #a3a3a3;
}

#canvas::-webkit-scrollbar-corner {
  background: transparent;
}

/* Zoom controls */
.zoom-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 500;
  color: #171717;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: scale(1.05);
}

.zoom-btn:active {
  transform: scale(0.95);
}

.zoom-btn-small {
  width: 32px;
  height: 32px;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.zoom-label {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(23, 23, 23, 0.6);
  font-weight: 500;
}

/* Canvas inner - positioned for transform-based pan/zoom */
#canvas-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  padding: 100px;
}

/* Pan cursors */
#canvas.panning {
  cursor: grabbing;
}
