/* Nitara's Family Tree — enchanted night sky theme */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Baloo 2', 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(1200px 700px at 18% -8%, rgba(255, 158, 100, 0.14), transparent 60%),
    radial-gradient(1000px 800px at 85% 12%, rgba(224, 123, 255, 0.12), transparent 60%),
    radial-gradient(900px 900px at 55% 110%, rgba(90, 169, 255, 0.13), transparent 60%),
    radial-gradient(ellipse at 50% 32%, #33306b 0%, #1d1b46 52%, #0d0c24 100%);
  color: #eef0ff;
}

#stage {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: none; cursor: grab;
}
#stage.panning { cursor: grabbing; }

/* ---- background stars ---- */
.star { animation: twinkle var(--d) ease-in-out var(--dl) infinite alternate; opacity: var(--o); }
@keyframes twinkle {
  from { opacity: calc(var(--o) * 0.25); }
  to   { opacity: var(--o); }
}

/* ---- fireflies ---- */
.firefly {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: radial-gradient(circle, #ffe9ad 0%, rgba(255, 233, 173, 0) 70%);
  filter: blur(0.5px); pointer-events: none;
  animation: drift var(--t) ease-in-out var(--dl) infinite alternate;
  opacity: 0.8;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); opacity: 0.25; }
  50%  { opacity: 0.9; }
  to   { transform: translate(var(--dx), var(--dy)) scale(1.6); opacity: 0.3; }
}

/* ---- nodes ---- */
.node { cursor: grab; }
.node.dragging { cursor: grabbing; }
.node .pop { transform-box: fill-box; transform-origin: center; transition: transform 0.25s cubic-bezier(.3,1.4,.5,1); }
.node:hover .pop { transform: scale(1.08); }
.node .bob {
  transform-box: fill-box; transform-origin: center;
  animation-name: bob; animation-timing-function: ease-in-out;
  animation-iteration-count: infinite; animation-direction: alternate;
}
@keyframes bob { from { transform: translateY(-3.5px); } to { transform: translateY(3.5px); } }

.node text { user-select: none; pointer-events: none; }
.node image { pointer-events: none; }

/* Nitara flourishes */
.focus-spin {
  transform-box: fill-box; transform-origin: center;
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.focus-halo {
  transform-box: fill-box; transform-origin: center;
  animation: haloPulse 3.2s ease-in-out infinite;
}
@keyframes haloPulse {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50%      { transform: scale(1.12); opacity: 1; }
}
.sparkle {
  transform-box: fill-box; transform-origin: center;
  animation: sparkle 2.6s ease-in-out infinite;
}
@keyframes sparkle {
  0%, 100% { opacity: 0.15; scale: 0.5; }
  50%      { opacity: 1; scale: 1.25; }
}

/* ---- edges ---- */
.edge, .heart { transition: opacity 0.3s ease, stroke-opacity 0.3s ease; }

/* ---- hover dimming ---- */
#stage.dimmed .node { opacity: 0.22; transition: opacity 0.3s ease; }
#stage.dimmed .node.lit { opacity: 1; }
#stage.dimmed .edge { opacity: 0.12; }
#stage.dimmed .edge.lit { opacity: 1; stroke-opacity: 1; }
#stage.dimmed .heart { opacity: 0.15; }
#stage.dimmed .heart.lit { opacity: 1; }
.node { transition: opacity 0.3s ease; }

/* ---- header ---- */
#header {
  position: absolute; top: 18px; left: 22px; z-index: 5;
  pointer-events: none;
}
#header h1 {
  font-size: 30px; font-weight: 700; letter-spacing: 0.3px;
  background: linear-gradient(100deg, #ffe9ad 10%, #ff9ecf 55%, #9ecbff 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 3px 24px rgba(255, 210, 140, 0.25);
}
#header p { font-size: 13.5px; color: rgba(224, 229, 255, 0.66); margin-top: 2px; }

/* ---- toolbar ---- */
#toolbar {
  position: absolute; top: 18px; right: 22px; z-index: 5;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
}
.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  color: #eef0ff; background: rgba(38, 35, 84, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px; padding: 9px 14px; cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 18px rgba(5, 4, 15, 0.35);
}
.btn:hover { background: rgba(66, 60, 130, 0.85); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(5, 4, 15, 0.5); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(120deg, #ff9e64, #e07bff);
  border-color: rgba(255, 255, 255, 0.35); color: #1c1436;
}
.btn.primary:hover { background: linear-gradient(120deg, #ffb277, #e995ff); }
.btn.icon { padding: 9px 12px; font-size: 15px; line-height: 1; }

/* ---- legend ---- */
#legend {
  position: absolute; left: 22px; bottom: 52px; z-index: 5;
  display: flex; gap: 8px; flex-wrap: wrap; max-width: 46vw;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: rgba(238, 240, 255, 0.85);
  background: rgba(38, 35, 84, 0.6); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px; padding: 5px 12px 5px 6px; backdrop-filter: blur(8px);
}
.chip i { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }

/* ---- hint bar ---- */
#hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 5; font-size: 12.5px; color: rgba(224, 229, 255, 0.55);
  background: rgba(20, 18, 51, 0.55); border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 7px 16px; border-radius: 999px; backdrop-filter: blur(8px);
  white-space: nowrap;
}
#hint b { color: rgba(255, 233, 173, 0.9); font-weight: 600; }

/* ---- busy overlay ---- */
#busy {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 20; display: none; font-size: 16px; font-weight: 600;
  color: #ffe9ad; background: rgba(20, 18, 51, 0.92);
  border: 1px solid rgba(255, 233, 173, 0.3); border-radius: 16px;
  padding: 22px 34px; box-shadow: 0 12px 60px rgba(5, 4, 15, 0.7);
}
#busy.show { display: block; animation: busyPulse 1.4s ease-in-out infinite; }
@keyframes busyPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }

@media (max-width: 900px) {
  #header h1 { font-size: 22px; }
  #hint { display: none; }
  #legend { max-width: 90vw; bottom: 14px; }
}
