/* ═══════════════════════════════════════════════════════
   WADHWA FAMILY TREE — Elegant Warm Heritage Theme
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────── */
:root {
  /* Palette */
  --cream:        #fcfaf6;
  --cream-dark:   #f0ece4;
  --parchment:    #e8e2d6;
  --charcoal:     #2a2a2a;
  --charcoal-mid: #4a4a4a;
  --charcoal-light:#7a7a7a;
  --forest:       #1b3a24;
  --forest-light: #2d5a3a;
  --forest-muted: #3d6e4e;
  --gold:         #c5a059;
  --gold-light:   #d4b87a;
  --gold-dark:    #9e7d3e;
  --branch-a:     #2d6a4f;
  --branch-b:     #7b5b3a;
  --branch-c:     #5a3e6f;
  --branch-root:  #8b7355;
  --white:        #ffffff;
  --danger:       #a0422a;

  /* Typography */
  --font-serif:  'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --sidebar-width: 280px;
  --detail-width:  340px;
  --header-height: 72px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--charcoal);
  background: var(--cream);
}

/* subtle parchment texture via radial gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(197,160,89,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(27,58,36,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

::selection {
  background: var(--gold-light);
  color: var(--forest);
}

/* ── Header ────────────────────────────────────────── */
#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--forest);
  color: var(--cream);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.header-icon path[fill="#1b3a24"] { fill: var(--cream); }
.header-icon rect { fill: var(--gold); }
.header-icon path[stroke="#c5a059"],
.header-icon path[stroke="#c5a059"] { stroke: var(--gold-light); }

.header-brand h1 {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.78rem;
  opacity: 0.7;
  font-weight: 300;
  letter-spacing: 0.03em;
}

.header-stats {
  display: flex;
  gap: 12px;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(197,160,89,0.3);
  border-radius: 8px;
  padding: 6px 16px;
  min-width: 70px;
}

.stat-num {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold-light);
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

/* ── Main Layout ───────────────────────────────────── */
#app-main {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  z-index: 1;
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--cream-dark);
  border-right: 1px solid var(--parchment);
  padding: 20px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 10;
}

.sidebar-section { }

.sidebar-label {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--forest);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Search */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--charcoal-light);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 9px 32px 9px 32px;
  border: 1px solid var(--parchment);
  border-radius: 6px;
  background: var(--white);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--charcoal);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

#search-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197,160,89,0.2);
}

#search-input::placeholder {
  color: var(--charcoal-light);
}

.search-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--charcoal-light);
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  display: none;
}
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--danger); }

.search-hint {
  font-size: 0.75rem;
  color: var(--charcoal-light);
  margin-top: 4px;
  min-height: 1.2em;
}

/* Filter Chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--parchment);
  border-radius: 20px;
  background: var(--white);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--charcoal-mid);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.chip:hover {
  border-color: var(--gold);
  color: var(--charcoal);
}

.chip.active {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}

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

.chip-dot.branch-a { background: var(--branch-a); }
.chip-dot.branch-b { background: var(--branch-b); }
.chip-dot.branch-c { background: var(--branch-c); }

/* Generation slider */
.gen-slider-wrap { padding: 0 2px; }

#gen-slider {
  width: 100%;
  accent-color: var(--forest);
  cursor: pointer;
}

.gen-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--charcoal-light);
  margin-top: 4px;
}

/* Zoom Controls */
.zoom-controls {
  display: flex;
  gap: 6px;
}

.zoom-btn {
  flex: 1;
  padding: 7px 0;
  border: 1px solid var(--parchment);
  border-radius: 6px;
  background: var(--white);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--charcoal-mid);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.zoom-btn:hover {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}

.zoom-fit { font-size: 0.78rem; }

/* Legend */
.sidebar-legend {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--parchment);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--charcoal-mid);
  padding: 3px 0;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-swatch.branch-a { background: var(--branch-a); }
.legend-swatch.branch-b { background: var(--branch-b); }
.legend-swatch.branch-c { background: var(--branch-c); }
.legend-swatch.branch-root { background: var(--branch-root); }

.legend-deceased {
  width: 12px;
  text-align: center;
  font-weight: 700;
  color: var(--charcoal-light);
  font-size: 0.9rem;
}

/* ── Tree Container ────────────────────────────────── */
#tree-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(circle at 50% 50%, rgba(197,160,89,0.03) 0%, transparent 70%);
}

#tree-container:active { cursor: grabbing; }

#tree-svg {
  width: 100%;
  height: 100%;
}

/* ── Tree Nodes (SVG styled via CSS) ───────────────── */
.node-group { cursor: pointer; }

.node-card {
  fill: var(--white);
  stroke: var(--parchment);
  stroke-width: 1.5;
  rx: 4;
  ry: 4;
  transition: stroke 0.2s var(--ease), filter 0.2s var(--ease);
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.08));
}

.node-group:hover .node-card {
  stroke: var(--gold);
  filter: drop-shadow(0 2px 8px rgba(197,160,89,0.25));
}

.node-group.selected .node-card {
  stroke: var(--gold);
  stroke-width: 2.5;
  filter: drop-shadow(0 3px 12px rgba(197,160,89,0.35));
}

.node-group.faded {
  opacity: 0.2;
  transition: opacity 0.4s var(--ease);
}

.node-group.highlighted {
  opacity: 1;
}

.node-name {
  font-family: 'Playfair Display', serif;
  font-size: 9.5px;
  font-weight: 600;
  fill: var(--charcoal);
}

.node-gen {
  font-family: 'Inter', sans-serif;
  font-size: 7.5px;
  fill: var(--charcoal-light);
}

.node-deceased {
  font-size: 10px;
  fill: var(--charcoal-light);
}

.node-branch-indicator {
  stroke-width: 0;
}

/* Links */
.tree-link {
  fill: none;
  stroke: var(--parchment);
  stroke-width: 1.5;
  transition: stroke 0.3s var(--ease), opacity 0.4s var(--ease);
}

.tree-link.faded {
  opacity: 0.1;
}

.tree-link.highlighted {
  opacity: 1;
  stroke-width: 2.5;
}

.tree-link.branch-a { stroke: var(--branch-a); }
.tree-link.branch-b { stroke: var(--branch-b); }
.tree-link.branch-c { stroke: var(--branch-c); }
.tree-link.branch-Root { stroke: var(--branch-root); }

/* ── Detail Panel ──────────────────────────────────── */
.detail-panel {
  width: var(--detail-width);
  flex-shrink: 0;
  background: var(--cream-dark);
  border-left: 1px solid var(--parchment);
  padding: 24px 20px;
  overflow-y: auto;
  z-index: 10;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

.detail-panel.hidden {
  display: none;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--charcoal-light);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s var(--ease);
}

.detail-close:hover {
  background: var(--parchment);
  color: var(--charcoal);
}

/* Detail Content Styles */
.detail-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--gold);
}

.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--forest);
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 auto 12px;
  border: 2px solid var(--gold);
}

.detail-name {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--forest);
  margin-bottom: 4px;
}

.detail-gen-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-gen-badge.branch-a { background: rgba(45,106,79,0.12); color: var(--branch-a); }
.detail-gen-badge.branch-b { background: rgba(123,91,58,0.12); color: var(--branch-b); }
.detail-gen-badge.branch-c { background: rgba(90,62,111,0.12); color: var(--branch-c); }
.detail-gen-badge.branch-Root { background: rgba(139,115,85,0.12); color: var(--branch-root); }

.detail-section {
  margin-bottom: 18px;
}

.detail-section-title {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--forest);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--parchment);
}

.detail-row {
  display: flex;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.82rem;
}

.detail-row-label {
  color: var(--charcoal-light);
  min-width: 72px;
  flex-shrink: 0;
  font-weight: 500;
}

.detail-row-value {
  color: var(--charcoal);
  word-break: break-word;
}

.detail-row-value a {
  color: var(--forest-light);
  text-decoration: underline;
  text-decoration-color: var(--gold-light);
  text-underline-offset: 2px;
}

.detail-row-value a:hover {
  color: var(--gold-dark);
}

.detail-children-list {
  list-style: none;
  padding: 0;
}

.detail-children-list li {
  padding: 4px 8px;
  margin-bottom: 3px;
  font-size: 0.82rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.detail-children-list li:hover {
  background: var(--parchment);
}

.detail-children-list li::before {
  content: '↳ ';
  color: var(--gold);
}

.detail-deceased-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(0,0,0,0.06);
  color: var(--charcoal-light);
  margin-left: 6px;
}

/* ── Scrollbar ─────────────────────────────────────── */
.sidebar::-webkit-scrollbar,
.detail-panel::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.detail-panel::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.detail-panel::-webkit-scrollbar-thumb {
  background: var(--parchment);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.detail-panel::-webkit-scrollbar-thumb:hover {
  background: var(--gold-light);
}

/* Lineage Timeline Styles */
.lineage-timeline {
  position: relative;
  padding-left: 16px;
  margin: 10px 0 10px 4px;
  border-left: 1.5px solid var(--gold-light);
}

.timeline-item {
  position: relative;
  margin-bottom: 12px;
}

.timeline-item:last-child {
  margin-bottom: 4px;
}

.timeline-marker {
  position: absolute;
  left: -21px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  border: 1.5px solid var(--cream-dark);
}

.timeline-item:hover .timeline-marker {
  background: var(--forest);
  transform: scale(1.2);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.timeline-content {
  display: flex;
  flex-direction: column;
}

.timeline-gen {
  font-size: 0.68rem;
  color: var(--charcoal-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.timeline-content a {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--forest-light);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

.timeline-content a:hover {
  color: var(--gold-dark);
  text-decoration: underline;
}

/* Child count badges in lists */
.detail-child-count {
  font-size: 0.72rem;
  color: var(--charcoal-light);
  font-style: italic;
  margin-left: 4px;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 220px;
    --detail-width: 280px;
  }

  .header-stats { display: none; }

  .header-brand h1 { font-size: 1.2rem; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .detail-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 340px;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  }
}
