/* ============================================================
   LEGUME LAB — Styles
   ============================================================ */

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

:root {
  --bg-deep:       #060f08;
  --bg-card:       #0d1a0f;
  --bg-elevated:   #152018;
  --bg-panel:      #091309;
  --text-primary:  #eae8d6;
  --text-secondary:#9ab888;
  --text-muted:    #72906a;
  --gold:          #e0b838;
  --gold-light:    #eecf70;
  --gold-dim:      #c8a030;
  --green:         #5a8a4a;
  --green-light:   #7aaa6a;
  --rust:          #b8512e;
  --rust-light:    #d4724e;
  --border:        #1c3020;
  --border-light:  #274030;
  --shadow:        0 4px 24px rgba(0,0,0,0.6);
  --shadow-lg:     0 8px 48px rgba(0,0,0,0.8);
  --radius:        8px;
  --radius-lg:     14px;
  --transition:    300ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.65;
  overflow: hidden;
  height: 100vh;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.screen { width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; }
.screen.active { z-index: 10; }

em, i { font-style: italic; }
strong { font-weight: 600; color: var(--text-primary); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 32px;
  background: var(--gold);
  color: #0d0a06;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none; border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 0 0 0 rgba(212,168,50,0.4);
}
.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(212,168,50,0.35);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); border-color: var(--text-muted); }
.btn-ghost:disabled { opacity: 0.3; cursor: default; }

/* ═════════════════════════════════════════════════════════════
   LANDING SCREEN
═════════════════════════════════════════════════════════════ */
#landing {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-deep);
  overflow: hidden;
}

.landing-bg {
  position: absolute; inset: 0; overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 70% 40%, rgba(100,60,10,0.25) 0%, transparent 70%),
    radial-gradient(ellipse 50% 80% at 20% 80%, rgba(60,100,30,0.15) 0%, transparent 70%);
}

.landing-bean-grid {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 0;
  opacity: 0.07;
  pointer-events: none;
}

.bean-item {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  animation: float linear infinite;
  transform-origin: center;
}

@keyframes float {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(8deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

.landing-content {
  position: relative; z-index: 2;
  text-align: center;
  max-width: 720px;
  padding: 40px 24px;
  animation: fadeInUp 0.8s ease both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.landing-eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: 20px;
}

.landing-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.title-line-1 {
  display: block;
  color: var(--gold-light);
}

.title-divider {
  display: block;
  font-size: 0.4em;
  color: var(--text-muted);
  margin: 4px 0;
  font-weight: 400;
}

.title-line-2 {
  display: block;
  font-size: 0.55em;
  font-style: italic;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.landing-tagline {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 40px;
}

.landing-stats {
  display: flex; align-items: center; justify-content: center; gap: 0;
  margin-bottom: 48px;
}

.stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 0 32px;
}

.stat-number {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.stat-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-div {
  width: 1px;
  height: 40px;
  background: var(--border-light);
}


/* ═════════════════════════════════════════════════════════════
   ONBOARDING OVERLAY
═════════════════════════════════════════════════════════════ */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}

.onboarding-backdrop {
  position: absolute; inset: 0;
  background: rgba(8,6,3,0.88);
  backdrop-filter: blur(4px);
}

.onboarding-card {
  position: relative; z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 48px;
  max-width: 580px;
  width: calc(100% - 40px);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.4s ease both;
}

.onboarding-skip {
  position: absolute; top: 20px; right: 20px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: color var(--transition);
}
.onboarding-skip:hover { color: var(--text-secondary); }

.onboarding-step { display: none; }
.onboarding-step.active { display: block; animation: fadeInUp 0.3s ease both; }

.step-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.step-number {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 16px;
}

.onboarding-step h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.7rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.onboarding-step p {
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.7;
}

.onboarding-preview {
  margin-top: 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 20px;
  height: 100px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-preview {
  background: linear-gradient(135deg, var(--bg-deep) 0%, #081a0a 100%);
}

.preview-dot {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px currentColor;
}

.preview-label {
  position: absolute;
  transform: translateX(-50%);
  top: calc(100% - 22px);
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.onboarding-tree-preview {
  margin-top: 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 10px;
  border: 1px solid var(--border);
}

.onboarding-tree-preview svg {
  width: 100%; height: auto;
}

.onboarding-food-strip {
  margin: 18px 0;
  border-radius: var(--radius);
  overflow: hidden;
  height: 108px;
}
.onboarding-food-strip img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 60%;
  display: block;
}

.onboarding-step em {
  font-style: italic;
  color: var(--text-primary);
}

.onboarding-views-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.onboarding-view-block {
  flex: 1;
  min-width: 0;
}
.onboarding-view-block .onboarding-preview,
.onboarding-view-block .onboarding-tree-preview {
  margin-top: 0;
}
.view-block-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.onboarding-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 36px;
}

.onboarding-dots {
  display: flex; gap: 8px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  transition: background var(--transition);
  cursor: pointer;
}
.dot.active { background: var(--gold); }

/* ═════════════════════════════════════════════════════════════
   EXPLORER LAYOUT
═════════════════════════════════════════════════════════════ */
#explorer {
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

.explorer-header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 56px;
}

.btn-home {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}
.btn-home:hover { color: var(--text-primary); background: var(--bg-elevated); }

.view-toggle {
  display: flex;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-btn:hover { color: var(--text-secondary); }
.toggle-btn.active {
  background: var(--bg-elevated);
  color: var(--gold);
}

.explorer-hint {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.explorer-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Visualization Panel ──────────────────────────────────── */
.viz-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
}

.viz-view {
  position: absolute; inset: 0;
}

#mapContainer, #treeContainer {
  width: 100%; height: 100%;
}

/* ── Detail Panel ─────────────────────────────────────────── */
.detail-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  transition: width var(--transition);
}

.detail-panel::-webkit-scrollbar { width: 6px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* Overview (no crop selected) */
.detail-overview {
  padding: 32px 24px;
  animation: fadeInUp 0.4s ease both;
}

.detail-overview h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.detail-overview > p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
  line-height: 1.7;
}

/* Crop grid in overview */
.crop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.crop-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; gap: 4px;
}

.crop-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.crop-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.crop-card-sci {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--text-muted);
}

.crop-card-origin {
  font-size: 0.7rem;
  color: var(--gold-dim);
  margin-top: 2px;
}

/* Detail back button */
.detail-back {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: left;
  transition: color var(--transition);
}
.detail-back:hover { color: var(--text-secondary); }

/* ── Crop Detail Content ───────────────────────────────────── */
.detail-content {
  padding: 0 0 60px 0;
  animation: fadeInUp 0.35s ease both;
}

/* Hero section */
.crop-hero {
  position: relative;
}

.crop-hero-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}

.crop-hero-img-fallback {
  width: 100%;
  height: 220px;
}

/* ── Image placeholders ──────────────────────────────────── */
.img-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.hero-placeholder   { width: 100%; height: 220px; border-radius: 0; border-left: none; border-right: none; }
.dish-placeholder   { width: 100%; height: 200px; }
.recipe-placeholder { width: 100%; height: 180px; }
.placeholder-label {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.placeholder-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.crop-hero-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 40px 24px 20px;
  background: linear-gradient(transparent, rgba(13,10,6,0.95));
}

.crop-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.crop-altnames {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Badges row */
.crop-badges {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.badge-sci {
  background: rgba(90,138,74,0.15);
  color: var(--green-light);
  border: 1px solid rgba(90,138,74,0.25);
  font-style: italic;
}

.badge-origin {
  background: rgba(212,168,50,0.12);
  color: var(--gold);
  border: 1px solid rgba(212,168,50,0.2);
}

.badge-age {
  background: rgba(184,81,46,0.12);
  color: var(--rust-light);
  border: 1px solid rgba(184,81,46,0.2);
}

/* Detail body sections */
.detail-section {
  padding: 24px 24px 0;
}

.section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 12px;
}

.detail-section p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.75;
  margin-bottom: 12px;
}

.detail-section p:last-child { margin-bottom: 0; }

/* Short description pull quote */
.crop-short-desc {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.65;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--gold-dim);
  margin: 0 0 0 0;
  background: rgba(212,168,50,0.04);
}

/* Spread list */
.spread-list {
  list-style: none;
  margin-top: 10px;
}

.spread-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.spread-item:last-child { border-bottom: none; }

.spread-arrow {
  flex-shrink: 0;
  width: 20px; height: 20px;
  background: rgba(212,168,50,0.12);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-dim);
  font-size: 0.7rem;
  margin-top: 1px;
}

.spread-region {
  font-weight: 500;
  color: var(--text-primary);
}

.spread-years {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Varieties */
.varieties-list {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 10px;
}

.variety-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.variety-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}

.variety-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.heirloom-badge {
  padding: 2px 8px;
  background: rgba(90,138,74,0.2);
  color: var(--green-light);
  border: 1px solid rgba(90,138,74,0.3);
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.variety-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.variety-image {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 10px;
  display: block;
  background: var(--bg-elevated);
}

/* Dish / Recipe images */
.detail-image-block {
  margin: 24px 0 0;
  padding: 0 24px;
}

.detail-image-block img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  background: var(--bg-elevated);
}

.img-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
  padding: 0 2px;
}

/* Recipe card */
.recipe-card {
  margin: 24px 24px 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.recipe-image {
  width: 100%; height: 180px;
  object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}

.recipe-body {
  padding: 20px;
}

.recipe-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

.recipe-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.recipe-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.recipe-intro {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--gold-dim);
  margin-bottom: 14px;
  line-height: 1.5;
}

.recipe-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Section divider */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 24px 0;
}

/* ═════════════════════════════════════════════════════════════
   MAP VISUALIZATION
═════════════════════════════════════════════════════════════ */
#mapContainer svg {
  width: 100%; height: 100%;
}

.country-path {
  fill: #162814;
  stroke: #2a4224;
  stroke-width: 0.5;
}

.graticule {
  fill: none;
  stroke: #0d160d;
  stroke-width: 0.3;
}

.sphere { fill: #070d09; }

.origin-circle {
  cursor: pointer;
  transition: opacity 0.2s;
}

.origin-circle circle {
  transition: r 0.2s, filter 0.2s;
}

.origin-circle:hover circle {
  filter: brightness(1.4);
}

.origin-circle.active circle {
  stroke: var(--text-primary);
  stroke-width: 2;
}

.origin-pulse {
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; r: var(--base-r); }
  100% { opacity: 0; r: calc(var(--base-r) * 2.5); }
}

.spread-arc {
  fill: none;
  stroke-width: 1;
  opacity: 0;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawArc 1.2s ease forwards;
}

@keyframes drawArc {
  to { stroke-dashoffset: 0; opacity: 0.5; }
}

.spread-dot {
  opacity: 0;
  animation: fadeInDot 0.3s ease forwards;
}

@keyframes fadeInDot { to { opacity: 0.7; } }

.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 200px;
  z-index: 10;
}

.map-tooltip.visible { opacity: 1; }

.tooltip-name { font-weight: 600; margin-bottom: 2px; }
.tooltip-sci { font-style: italic; color: var(--text-muted); font-size: 0.72rem; }
.tooltip-age { color: var(--gold-dim); font-size: 0.72rem; margin-top: 4px; }
.tooltip-hint { color: var(--text-muted); font-size: 0.7rem; margin-top: 4px; }

.map-legend {
  position: absolute; bottom: 24px; left: 24px;
  background: rgba(26,20,14,0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 220px;
}

.legend-title {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.legend-gradient { margin-bottom: 12px; }

.legend-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #c8783c, #d4a832, #e8c870);
  margin-bottom: 4px;
}

.legend-labels {
  display: flex; justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.legend-items { display: flex; flex-direction: column; gap: 5px; }

.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
}

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

/* ═════════════════════════════════════════════════════════════
   TREE VISUALIZATION
═════════════════════════════════════════════════════════════ */
#treeContainer svg { width: 100%; height: 100%; }

.tree-link {
  fill: none;
  stroke: #332510;
  stroke-width: 1.5;
  transition: stroke 0.3s;
}

.tree-link.highlighted { stroke: #8a6e20; }

.tree-node circle {
  transition: r 0.2s, fill 0.2s, stroke 0.2s;
}

.tree-node.family circle { fill: var(--gold); r: 8; }
.tree-node.subfamily circle { fill: var(--gold-dim); }
.tree-node.tribe circle { fill: #8a6020; }
.tree-node.genus circle { fill: #6b5030; }
.tree-node.crop circle {
  fill: var(--green);
  cursor: pointer;
}
.tree-node.crop:hover circle { fill: var(--green-light); }
.tree-node.crop.active circle {
  fill: var(--gold-light);
  stroke: var(--gold);
  stroke-width: 2;
}

.tree-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  fill: var(--text-secondary);
  pointer-events: none;
  user-select: none;
}

.tree-label.crop-label {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
}

.tree-label.root-label {
  fill: var(--gold);
  font-weight: 600;
  font-size: 13px;
}

.tree-label.tribe-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-style: italic;
}

.tree-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 200px;
  z-index: 10;
}
.tree-tooltip.visible { opacity: 1; }

.tree-legend {
  position: absolute; bottom: 24px; left: 24px;
  background: rgba(26,20,14,0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}

.tree-legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

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

.legend-swatch.root { background: var(--gold); }
.legend-swatch.tribe { background: #8a6020; }
.legend-swatch.genus { background: #6b5030; }
.legend-swatch.crop { background: var(--green); }

/* ═════════════════════════════════════════════════════════════
   TRANSITIONS
═════════════════════════════════════════════════════════════ */
.screen { transition: opacity 0.4s ease; }
.screen.fading-out { opacity: 0; pointer-events: none; }

/* ═════════════════════════════════════════════════════════════
   CREDITS BUTTON + MODAL
═════════════════════════════════════════════════════════════ */
.btn-credits {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.btn-credits:hover {
  color: var(--text-secondary);
  border-color: var(--text-muted);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(680px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--text-primary);
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
  overflow-y: auto;
  padding: 20px 24px 24px;
}
.modal-intro {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 20px;
  line-height: 1.6;
}
.modal-intro a {
  color: var(--gold);
  text-decoration: none;
}
.modal-intro a:hover { text-decoration: underline; }

/* Credits table rows */
.credit-row {
  display: grid;
  grid-template-columns: 1fr 80px 120px 1fr;
  gap: 8px 16px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.credit-row:last-child { border-bottom: none; }
.credit-row:hover { background: var(--bg-elevated); }
.credit-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}
.credit-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}
.credit-license {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 500;
}
.credit-artist {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.credits-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 0;
}

/* ═════════════════════════════════════════════════════════════
   TAXON DETAIL PANEL
═════════════════════════════════════════════════════════════ */

.badge-level {
  background: rgba(100,140,200,0.14);
  color: #7eaadf;
  border: 1px solid rgba(100,140,200,0.25);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}

.taxon-detail-header {
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.taxon-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.taxon-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px;
  line-height: 1.2;
}

.taxon-origin {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.taxon-species-count {
  padding: 10px 24px 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.taxon-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.taxon-link {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--gold);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.taxon-link:hover {
  background: rgba(212,168,50,0.1);
  border-color: rgba(212,168,50,0.35);
}

/* ═════════════════════════════════════════════════════════════
   SCROLLBAR STYLING
═════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ═════════════════════════════════════════════════════════════
   RESPONSIVE — minimal, focus on desktop
═════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .detail-panel { width: 340px; }
}

@media (max-width: 700px) {
  .explorer-body { flex-direction: column; }
  .viz-panel { height: 50vh; }
  .detail-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); height: 50vh; }
  .explorer-hint { display: none; }
}
