/* ═══════════════════════════════════════════════════════════════════════════
   🎨 STYLES: The Phylogenetic Tree of Political Thought
   All visual styling for the political tree visualization
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   Base Reset & Body
   ───────────────────────────────────────────────────────────────────────────── */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  background: linear-gradient(to bottom, #e0f2fe, #f0f9ff, #fef3c7);
  padding: 8px;
  overflow-x: hidden;
}

.container {
  max-width: 1152px;
  margin: 0 auto;
  position: relative;
}

/* ─────────────────────────────────────────────────────────────────────────────
   🏷️ Header
   ───────────────────────────────────────────────────────────────────────────── */

.header {
  text-align: center;
  margin-bottom: 8px;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: bold;
  color: #1f2937;
}

.header p {
  font-size: 0.75rem;
  color: #6b7280;
}

/* ─────────────────────────────────────────────────────────────────────────────
   📋 Info Panel
   ───────────────────────────────────────────────────────────────────────────── */

.info-panel {
  background: rgba(255,255,255,0.95);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 12px;
  margin-bottom: 8px;
  border-left: 4px solid #888;
  display: none;
}

.info-panel.visible {
  display: block;
}

.info-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.info-content {
  flex: 1;
}

.info-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.info-title {
  font-weight: bold;
  font-size: 1rem;
}

.info-subtitle {
  font-size: 0.75rem;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
}

.info-description {
  font-size: 0.875rem;
  color: #374151;
}

.info-thinkers,
.info-count {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 4px;
}

.info-dna {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.info-dna-tag {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  color: white;
}

.close-btn {
  color: #9ca3af;
  font-size: 1.25rem;
  cursor: pointer;
  background: none;
  border: none;
  margin-left: 8px;
}

.close-btn:hover {
  color: #4b5563;
}

/* ─────────────────────────────────────────────────────────────────────────────
   🌳 Tree Container
   ───────────────────────────────────────────────────────────────────────────── */

.tree-container {
  position: relative;
}

/* ─────────────────────────────────────────────────────────────────────────────
   🔗 SVG Layer (Paths)
   ───────────────────────────────────────────────────────────────────────────── */

.svg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ─────────────────────────────────────────────────────────────────────────────
   🍃 Canopy (Ideologies)
   ───────────────────────────────────────────────────────────────────────────── */

.canopy {
  background: rgba(240, 253, 244, 0.7);
  border-radius: 16px 16px 0 0;
  padding: 8px 12px 12px;
  border: 2px solid #86efac;
  border-bottom: none;
  position: relative;
  z-index: 1;
}

.canopy-title {
  text-align: center;
  font-size: 0.75rem;
  color: #166534;
  font-weight: 600;
  margin-bottom: 8px;
}

.canopy-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.family-column {}

.family-header {
  font-size: 0.75rem;
  font-weight: bold;
  text-align: center;
  padding: 4px;
  border-radius: 4px 4px 0 0;
  color: white;
  margin-bottom: 4px;
}

.ideology-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ideology-card {
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 4px;
  padding: 6px 4px;
  border: 2px solid;
  text-align: center;
  background: white;
}

.ideology-card:hover {
  transform: scale(1.02);
}

.ideology-name {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
}

/* ─────────────────────────────────────────────────────────────────────────────
   🪵 Trunk (Families)
   ───────────────────────────────────────────────────────────────────────────── */

.trunk {
  background: rgba(254, 243, 199, 0.9);
  padding: 12px 16px;
  border-left: 4px solid #d97706;
  border-right: 4px solid #d97706;
  position: relative;
  z-index: 1;
  transition: opacity 0.5s;
}

.trunk.faded {
  opacity: 0.3;
}

.trunk-title {
  text-align: center;
  font-size: 0.75rem;
  color: #92400e;
  font-weight: 600;
  margin-bottom: 8px;
}

.trunk-families {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.family-badge {
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 12px;
  padding: 6px 16px;
  font-weight: bold;
  font-size: 0.875rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  color: white;
}

.family-badge:hover {
  transform: scale(1.05);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Ground (Divider)
   ───────────────────────────────────────────────────────────────────────────── */

.ground {
  background: linear-gradient(to right, #d97706, #b45309, #d97706);
  height: 8px;
  position: relative;
}

.ground-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -8px;
  background: #fffbeb;
  padding: 0 16px;
  font-size: 0.75rem;
  color: #78350f;
  font-weight: bold;
  border-radius: 4px;
  border: 2px solid #f59e0b;
}

/* ─────────────────────────────────────────────────────────────────────────────
   🌱 Roots (Dimensions)
   ───────────────────────────────────────────────────────────────────────────── */

.roots {
  background: linear-gradient(to bottom, #fffbeb, rgba(254, 243, 199, 0.8));
  border-radius: 0 0 16px 16px;
  padding: 16px 12px 12px;
  border: 2px solid #fbbf24;
  border-top: none;
  position: relative;
  z-index: 1;
}

.roots-title {
  text-align: center;
  font-size: 0.75rem;
  color: #78350f;
  font-weight: 600;
  margin-bottom: 12px;
}

.roots-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.roots-row:last-child {
  margin-bottom: 0;
}

.dimension-card {
  background: rgba(255,255,255,0.8);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* UPDATED HEADER: Flex layout for title and button */
.dimension-header {
  font-size: 0.75rem;
  font-weight: bold;
  margin-bottom: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  color: white;
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* NEW: Toggle Button */
.info-toggle-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  margin-left: 4px;
}

.info-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* NEW: Info Drawer */
.dimension-info-drawer {
  background-color: #f3f4f6;
  color: #4b5563;
  font-size: 0.7rem;
  line-height: 1.3;
  overflow: hidden;
  max-height: 0; /* Closed state */
  padding: 0 8px;
  margin-bottom: 0;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.3s ease-in-out;
  border-left: 3px solid #9ca3af;
}

.dimension-info-drawer.open {
  max-height: 120px; /* Open state */
  padding: 6px 8px;
  margin-bottom: 8px;
  opacity: 1;
}

.poles-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pole-card {
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 4px;
  padding: 6px 8px;
  border: 2px solid;
  text-align: center;
  background: white;
}

.pole-card:hover {
  transform: scale(1.02);
}

.pole-label {
  font-size: 0.75rem;
  font-weight: 500;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Legend
   ───────────────────────────────────────────────────────────────────────────── */

.legend {
  margin-top: 8px;
  background: rgba(255,255,255,0.8);
  border-radius: 12px;
  padding: 8px;
  font-size: 0.75rem;
  color: #4b5563;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-item b {
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Visual States (Faded, Highlighted, Selected)
   ───────────────────────────────────────────────────────────────────────────── */

.faded-out {
  background: #f3f4f6 !important;
  color: #9ca3af !important;
  border-color: #e5e7eb !important;
  opacity: 0.5;
}

.highlighted {
  color: white !important;
}

.selected {
  color: white !important;
  transform: scale(1.08);
  border-color: white !important;
  z-index: 10;
  position: relative;
}