/* ============================================================
   THEMES BRAIN GRAPH — fiftylunches.com home
   A live, drifting network of the show's recurring themes.
   ============================================================ */

.themes-graph {
  background: var(--grad-forest);
  color: var(--linen);
  padding-top: var(--space-4xl);
  padding-bottom: var(--space-4xl);
  position: relative;
  overflow: hidden;
}

.themes-graph::before {
  /* Subtle radial glow so the canvas doesn't feel flat */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 30%, rgba(240, 200, 138, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 70%, rgba(157, 212, 192, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.themes-graph .container {
  position: relative;
  z-index: 1;
}

.themes-head {
  max-width: 680px;
  margin: 0 auto var(--space-2xl);
  text-align: center;
}

.themes-head .section-label {
  color: var(--copper-glow);
}

.themes-head h2 {
  color: var(--linen);
  margin-bottom: var(--space-md);
}

.themes-head h2 em {
  color: var(--copper-glow);
  font-style: italic;
  font-weight: 700;
}

.themes-head p {
  color: rgba(250, 248, 244, 0.75);
  font-size: 1.05rem;
  line-height: 1.55;
}

/* Legend ---------------------------------------------------- */

.themes-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  justify-content: center;
  margin-bottom: var(--space-xl);
  font-size: 0.85rem;
  color: rgba(250, 248, 244, 0.70);
}

.themes-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.themes-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 12px currentColor;
}

/* Canvas stage ---------------------------------------------- */

.themes-stage {
  position: relative;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  min-height: 380px;
  border-radius: var(--r-xl);
  background: rgba(20, 36, 31, 0.55);
  border: 1px solid rgba(157, 212, 192, 0.15);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  cursor: grab;
}

.themes-stage:active { cursor: grabbing; }

.themes-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Tooltip card --------------------------------------------- */

.themes-tooltip {
  position: absolute;
  min-width: 260px;
  max-width: 320px;
  background: var(--linen);
  color: var(--text-rich);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.06);
  padding: var(--space-md) var(--space-md) var(--space-md);
  font-size: 0.9rem;
  line-height: 1.45;
  transform: translate(-50%, calc(-100% - 16px));
  pointer-events: auto;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.themes-tooltip.is-open { opacity: 1; }

.themes-tooltip[hidden] { display: none; }

.themes-tooltip-cluster {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-quiet);
  margin-bottom: 4px;
}

.themes-tooltip-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--forest);
  margin: 0 0 8px;
  line-height: 1.2;
}

.themes-tooltip-blurb {
  margin: 0 0 12px;
  color: var(--text-warm);
  font-size: 0.88rem;
}

.themes-tooltip-heading {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-quiet);
  margin: 8px 0 4px;
}

.themes-tooltip-list {
  list-style: none;
  padding: 0;
  margin: 0 0 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.themes-tooltip-list a {
  display: block;
  color: var(--forest);
  text-decoration: none;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 1px solid rgba(43, 76, 66, 0.08);
  font-size: 0.88rem;
  transition: color 0.15s, padding-left 0.15s;
}

.themes-tooltip-list a:hover {
  color: var(--copper-deep);
  padding-left: 4px;
}

.themes-tooltip-list a:last-child { border-bottom: none; }

.themes-tooltip-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--text-quiet);
  font-size: 14px;
  line-height: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.themes-tooltip-close:hover {
  color: var(--forest);
  background: rgba(43, 76, 66, 0.08);
}

/* Tooltip pointer arrow (default: arrow at the bottom, card sits above node) */
.themes-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 14px;
  height: 14px;
  background: var(--linen);
  transform: translateX(-50%) rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.04);
}

/* Flipped: render BELOW the node when there isn't room above. */
.themes-tooltip.is-below {
  transform: translate(-50%, 16px);
}

.themes-tooltip.is-below::after {
  bottom: auto;
  top: -8px;
  box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
}

/* Footer note under graph ---------------------------------- */

.themes-foot {
  text-align: center;
  margin-top: var(--space-lg);
  color: rgba(250, 248, 244, 0.55);
  font-size: 0.82rem;
  font-style: italic;
}

/* Mobile --------------------------------------------------- */

@media (max-width: 720px) {
  .themes-graph { padding-top: var(--space-3xl); padding-bottom: var(--space-3xl); }
  .themes-stage { aspect-ratio: 4 / 5; min-height: 420px; }
  .themes-legend { gap: var(--space-md); font-size: 0.75rem; }
  .themes-tooltip { min-width: 220px; max-width: 85vw; }
}

/* Reduced motion ------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .themes-stage { /* JS reads this via getComputedStyle on the root to pause motion */ }
}
