/* ====================  Map Mind  ==================== */
:root {
  --bg-0: #07060f;
  --bg-1: #0d0b1f;
  --glass: rgba(22, 19, 43, 0.55);
  --glass-strong: rgba(28, 24, 54, 0.82);
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-soft: rgba(255, 255, 255, 0.06);
  --text: #ece9ff;
  --text-dim: #a7a2cc;
  --text-faint: #6f6a93;
  --accent: #b487ff;
  --accent-2: #58e6e0;
  --accent-3: #ff7ab8;
  --gold: #ffce5c;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-head: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(1200px 800px at 78% -10%, #1a1340 0%, transparent 55%),
              radial-gradient(1000px 700px at 8% 110%, #15233f 0%, transparent 55%),
              linear-gradient(160deg, var(--bg-1), var(--bg-0));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- animated background ---------- */
.bg-aurora {
  position: fixed; inset: -20% -10% auto -10%; height: 80vh; z-index: 0;
  background:
    radial-gradient(40% 50% at 25% 30%, rgba(180, 135, 255, 0.22), transparent 70%),
    radial-gradient(38% 45% at 75% 25%, rgba(88, 230, 224, 0.16), transparent 70%),
    radial-gradient(35% 40% at 55% 60%, rgba(255, 122, 184, 0.14), transparent 70%);
  filter: blur(20px);
  animation: drift 26s var(--ease) infinite alternate;
  pointer-events: none;
}
@keyframes drift {
  0%   { transform: translate3d(-3%, -2%, 0) scale(1); }
  100% { transform: translate3d(4%, 3%, 0) scale(1.15); }
}
#starfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* ---------- topbar ---------- */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(13,11,31,0.85), rgba(13,11,31,0.35));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke-soft);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; flex-shrink: 0; }
.brand-mark svg { display: block; overflow: visible; }
.bm-core { fill: var(--gold); }
.bm-node { fill: var(--accent); }
.bm-edge { stroke: var(--accent-2); stroke-width: 1.4; opacity: 0.7; }
.brand-mark { filter: drop-shadow(0 0 10px rgba(180,135,255,0.5)); animation: spinmark 40s linear infinite; }
@keyframes spinmark { to { transform: rotate(360deg); } }
.brand-text {
  font-family: var(--font-head); font-weight: 700; font-size: 21px; letter-spacing: 0.2px;
  background: linear-gradient(92deg, #fff, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* search */
.search {
  position: relative; flex: 1; max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid var(--stroke);
  border-radius: 999px; padding: 6px 6px 6px 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 6px 22px rgba(0,0,0,0.3);
  transition: border-color .25s, box-shadow .25s;
}
.search:focus-within { border-color: rgba(180,135,255,0.55); box-shadow: 0 0 0 4px rgba(180,135,255,0.14), 0 6px 22px rgba(0,0,0,0.3); }
.search-icon { color: var(--text-faint); font-size: 19px; }
#searchInput {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 15px; font-family: var(--font-body); padding: 8px 4px;
}
#searchInput::placeholder { color: var(--text-faint); }
.search-go {
  border: none; cursor: pointer; color: #1a1030; font-weight: 700; font-size: 14px;
  padding: 9px 18px; border-radius: 999px;
  background: linear-gradient(96deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 16px rgba(180,135,255,0.4); transition: transform .2s var(--ease), filter .2s;
}
.search-go:hover { transform: translateY(-1px); filter: brightness(1.08); }
.search-go:active { transform: translateY(0); }

/* suggestions */
.suggest {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 30;
  margin: 0; padding: 6px; list-style: none;
  background: var(--glass-strong); border: 1px solid var(--stroke);
  border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(16px);
  max-height: 320px; overflow-y: auto;
}
.suggest li {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  cursor: pointer; transition: background .15s;
}
.suggest li:hover, .suggest li.active { background: rgba(180,135,255,0.16); }
.suggest .s-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.suggest .s-name { font-weight: 600; font-size: 14px; }
.suggest .s-disc { color: var(--text-faint); font-size: 12px; margin-left: auto; }
.suggest .s-empty { color: var(--text-dim); padding: 12px; font-size: 13px; }

/* destination */
.dest { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.dest-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--text-faint); }
#destSelect {
  background: var(--glass); color: var(--text); border: 1px solid var(--stroke);
  border-radius: 10px; padding: 7px 10px; font-family: var(--font-body); font-size: 13px; font-weight: 600; cursor: pointer;
}
#destSelect:focus { outline: none; border-color: rgba(180,135,255,0.5); }

/* ---------- stage ---------- */
.stage { position: relative; z-index: 2; display: flex; min-height: 0; }
.graph-wrap { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.graph { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.graph.dragging { cursor: grabbing; }

/* controls */
.controls {
  position: absolute; left: 16px; bottom: 16px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 14px; padding: 6px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.controls button {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text-dim); border: 1px solid transparent;
  font-size: 18px; line-height: 1; transition: all .18s;
}
.controls button:hover { background: rgba(180,135,255,0.16); color: var(--text); border-color: var(--stroke); }

/* legend */
.legend {
  position: absolute; right: 16px; top: 16px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px; max-width: 190px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 14px;
  padding: 12px 14px; backdrop-filter: blur(12px); box-shadow: var(--shadow);
  font-size: 12px; max-height: 60%; overflow-y: auto;
  transition: opacity .3s, transform .3s;
}
.legend.hidden { opacity: 0; pointer-events: none; transform: translateX(12px); }
.legend h4 { margin: 0 0 4px; font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }
.legend .lg-item { display: flex; align-items: center; gap: 8px; color: var(--text-dim); cursor: default; }
.legend .lg-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }

/* empty hint */
.empty-hint {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  transition: opacity .5s, transform .5s; gap: 6px;
}
.empty-hint.gone { opacity: 0; pointer-events: none; transform: scale(0.96); }
.eh-orbit { position: relative; width: 96px; height: 96px; margin-bottom: 14px; }
.eh-orbit span {
  position: absolute; inset: 0; border: 1.5px dashed rgba(180,135,255,0.35); border-radius: 50%;
  animation: orbit 14s linear infinite;
}
.eh-orbit span:nth-child(2) { inset: 16px; border-color: rgba(88,230,224,0.32); animation-duration: 9s; animation-direction: reverse; }
.eh-orbit span:nth-child(3) { inset: 32px; border-color: rgba(255,122,184,0.34); animation-duration: 6s; }
.eh-orbit::after {
  content: ""; position: absolute; inset: 40px; border-radius: 50%;
  background: radial-gradient(circle, var(--gold), #ff9d3c); box-shadow: 0 0 26px var(--gold);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.empty-hint h1 {
  font-family: var(--font-head); font-weight: 600; font-size: clamp(28px, 4vw, 44px);
  margin: 6px 0 2px; letter-spacing: -0.5px;
  background: linear-gradient(96deg, #fff, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.empty-hint p { color: var(--text-dim); max-width: 460px; font-size: 15.5px; line-height: 1.55; margin: 0 0 8px; }
.empty-hint strong { color: var(--gold); font-weight: 600; }
.seed-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; margin-top: 6px; }
.seed {
  cursor: pointer; border: 1px solid var(--stroke); background: var(--glass);
  color: var(--text); padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  transition: all .2s var(--ease); backdrop-filter: blur(8px);
}
.seed:hover { transform: translateY(-2px); border-color: rgba(180,135,255,0.6); box-shadow: 0 8px 20px rgba(180,135,255,0.22); }
.seed .seed-emoji { margin-right: 7px; }
.surprise {
  margin-top: 16px; cursor: pointer; border: none; border-radius: 999px; padding: 11px 22px;
  font-weight: 700; font-size: 14px; color: #1a1030;
  background: linear-gradient(96deg, var(--gold), var(--accent-3));
  box-shadow: 0 8px 24px rgba(255,122,184,0.35); transition: transform .2s var(--ease), filter .2s;
}
.surprise:hover { transform: translateY(-2px); filter: brightness(1.06); }

/* ---------- detail panel ---------- */
.panel {
  position: relative; z-index: 5; width: 380px; flex-shrink: 0;
  border-left: 1px solid var(--stroke-soft);
  background: linear-gradient(180deg, rgba(16,13,34,0.7), rgba(11,9,26,0.78));
  backdrop-filter: blur(16px);
  transition: width .35s var(--ease), opacity .3s;
  overflow: hidden;
}
.panel.collapsed { width: 0; opacity: 0; border-left: none; }
.panel-inner { height: 100%; overflow-y: auto; padding: 22px; }
.panel-placeholder { color: var(--text-faint); font-size: 14px; line-height: 1.6; margin-top: 40px; text-align: center; }
.panel-placeholder em { color: var(--text-dim); font-style: normal; font-weight: 600; }

/* panel content */
.pc-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.pc-badge {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0; margin-top: 2px;
  display: grid; place-items: center; font-weight: 800; font-size: 19px; color: #100c22;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.pc-title { font-family: var(--font-head); font-weight: 600; font-size: 25px; line-height: 1.1; margin: 0; }
.pc-disc { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.pc-tag {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; letter-spacing: .2px;
}
.pc-desc { color: var(--text); font-size: 14.5px; line-height: 1.62; margin: 0 0 14px; }
.pc-fact {
  display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.55;
  color: var(--text-dim); background: rgba(255,206,92,0.07); border: 1px solid rgba(255,206,92,0.18);
  border-radius: 12px; padding: 11px 13px; margin-bottom: 18px;
}
.pc-fact .pf-icon { color: var(--gold); flex-shrink: 0; font-size: 15px; }

.pc-section-h {
  display: flex; align-items: center; gap: 8px; margin: 18px 0 10px;
  font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-faint); font-weight: 700;
}
.pc-section-h::after { content: ""; flex: 1; height: 1px; background: var(--stroke-soft); }

/* connection cards */
.conn {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: rgba(255,255,255,0.025); border: 1px solid var(--stroke-soft);
  border-radius: 13px; padding: 12px 13px; margin-bottom: 9px;
  transition: all .2s var(--ease);
}
.conn:hover { background: rgba(180,135,255,0.10); border-color: rgba(180,135,255,0.4); transform: translateX(3px); }
.conn-top { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.conn-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.conn-name { font-weight: 700; font-size: 14.5px; color: var(--text); }
.conn-rel {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: var(--accent-2); margin-left: auto; white-space: nowrap;
  background: rgba(88,230,224,0.10); padding: 2px 7px; border-radius: 6px;
}
.conn-why { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin: 0; }
.conn-arrow { color: var(--text-faint); font-size: 12px; margin-top: 4px; opacity: 0; transition: opacity .2s; }
.conn:hover .conn-arrow { opacity: 1; }

/* paths to destination */
.paths-box { margin-top: 4px; }
.path-card {
  background: rgba(88,230,224,0.05); border: 1px solid rgba(88,230,224,0.16);
  border-radius: 13px; padding: 11px 13px; margin-bottom: 9px; cursor: pointer; transition: all .2s var(--ease);
}
.path-card:hover { border-color: rgba(88,230,224,0.45); background: rgba(88,230,224,0.10); }
.path-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 4px; }
.path-step { font-size: 12.5px; font-weight: 600; }
.path-sep { color: var(--text-faint); font-size: 11px; }
.path-meta { font-size: 11px; color: var(--text-faint); margin-top: 6px; }

.pc-actions { display: flex; gap: 8px; margin: 18px 0 6px; }
.pc-btn {
  flex: 1; cursor: pointer; border-radius: 11px; padding: 11px; font-weight: 700; font-size: 13px;
  border: 1px solid var(--stroke); background: var(--glass); color: var(--text); transition: all .2s var(--ease);
}
.pc-btn:hover { border-color: rgba(180,135,255,0.5); background: rgba(180,135,255,0.12); }
.pc-btn.primary { border: none; color: #150f2c; background: linear-gradient(96deg, var(--accent-2), var(--accent)); }
.pc-btn.primary:hover { filter: brightness(1.08); }
.pc-ref {
  display: inline-flex; align-items: center; gap: 6px; color: var(--accent-2); text-decoration: none;
  font-size: 13px; font-weight: 600; margin-top: 8px;
}
.pc-ref:hover { text-decoration: underline; }
.pc-reflist { list-style: none; padding: 0; margin: 6px 0 0; }
.pc-reflist li { font-size: 13px; color: var(--text-dim); padding: 5px 0 5px 16px; position: relative; line-height: 1.45; }
.pc-reflist li::before { content: "›"; position: absolute; left: 0; color: var(--accent); }

/* ---------- trail ---------- */
.trail {
  position: relative; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 9px 18px; background: rgba(11,9,26,0.7); backdrop-filter: blur(12px);
  border-top: 1px solid var(--stroke-soft); min-height: 50px;
}
.trail-label { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-faint); font-weight: 700; flex-shrink: 0; }
.trail-track { display: flex; align-items: center; gap: 4px; overflow-x: auto; flex: 1; padding: 4px 0; }
.trail-track::-webkit-scrollbar { height: 0; }
.trail-chip {
  display: flex; align-items: center; gap: 7px; cursor: pointer; flex-shrink: 0;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; font-weight: 600; transition: all .2s var(--ease); white-space: nowrap;
}
.trail-chip:hover { border-color: rgba(180,135,255,0.55); transform: translateY(-1px); }
.trail-chip.current { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.trail-chip .tc-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.trail-sep { color: var(--text-faint); flex-shrink: 0; font-size: 13px; }
.trail-clear {
  flex-shrink: 0; cursor: pointer; background: transparent; border: 1px solid var(--stroke);
  color: var(--text-dim); border-radius: 9px; padding: 7px 13px; font-size: 12px; font-weight: 600; transition: all .2s;
}
.trail-clear:hover { color: var(--text); border-color: var(--accent-3); }

/* ---------- toast & celebration ---------- */
.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px);
  z-index: 50; background: var(--glass-strong); border: 1px solid var(--stroke);
  border-radius: 12px; padding: 12px 20px; font-size: 14px; font-weight: 600; color: var(--text);
  box-shadow: var(--shadow); backdrop-filter: blur(14px); opacity: 0; transition: opacity .3s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.celebrate { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; width: 10px; height: 14px; will-change: transform, opacity; border-radius: 2px; }
.cele-banner {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(0.8);
  z-index: 61; text-align: center; pointer-events: none; opacity: 0;
  transition: opacity .5s, transform .6s var(--ease);
}
.cele-banner.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.cele-banner .cb-card {
  background: var(--glass-strong); border: 1px solid rgba(255,206,92,0.4); border-radius: 22px;
  padding: 26px 38px; box-shadow: 0 30px 80px rgba(0,0,0,0.6); backdrop-filter: blur(18px);
}
.cele-banner h2 {
  font-family: var(--font-head); font-size: 30px; margin: 0 0 6px;
  background: linear-gradient(96deg, var(--gold), var(--accent-3)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cele-banner p { color: var(--text-dim); margin: 0; font-size: 14.5px; }

/* ---------- SVG graph elements ---------- */
.node-label {
  fill: var(--text); font: 600 12px var(--font-body);
  paint-order: stroke; stroke: rgba(7,6,15,0.92); stroke-width: 3.4px; stroke-linejoin: round;
  pointer-events: none; user-select: none;
}
.node-dest .node-label { fill: var(--gold); font-weight: 700; font-size: 13.5px; }
.node-halo { pointer-events: none; }
.node-dest .node-halo { animation: desthalo 2.8s ease-in-out infinite; }
@keyframes desthalo { 0%,100% { opacity: 0.18; } 50% { opacity: 0.42; } }
.node { transition: opacity .35s ease; }
.node circle { transition: stroke .2s, stroke-width .2s; }
.node:hover .node-halo { opacity: 0.3 !important; }
.edge { transition: stroke .25s, opacity .3s; }
.edge.flow { stroke-dasharray: 7 7; animation: dash 0.9s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -14; } }

/* traveling dotted line drawn during the reveal */
.reveal-connector {
  fill: none;
  stroke: rgba(120, 232, 226, 0.95);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 1 9;
  filter: drop-shadow(0 0 6px rgba(88, 230, 224, 0.55));
  animation: connector-move 0.55s linear infinite;
}
@keyframes connector-move { to { stroke-dashoffset: -20; } }

/* scrollbars */
.panel-inner::-webkit-scrollbar, .suggest::-webkit-scrollbar, .legend::-webkit-scrollbar { width: 8px; }
.panel-inner::-webkit-scrollbar-thumb, .suggest::-webkit-scrollbar-thumb, .legend::-webkit-scrollbar-thumb {
  background: rgba(180,135,255,0.25); border-radius: 8px;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .12s !important; }
}

/* responsive */
@media (max-width: 880px) {
  .stage { flex-direction: column; }
  .panel { width: 100% !important; max-height: 44%; border-left: none; border-top: 1px solid var(--stroke-soft); }
  .panel.collapsed { max-height: 0; }
  .dest { display: none; }
  .search { max-width: none; }
}

/* let flex items actually shrink below their content width */
.search, #searchInput { min-width: 0; }

@media (max-width: 560px) {
  .topbar { gap: 10px; padding: 10px 12px; }
  .brand { gap: 8px; }
  .brand-text { font-size: 18px; }
  .search { padding: 5px 5px 5px 12px; gap: 6px; }
  #searchInput { font-size: 14px; padding: 7px 2px; }
  .search-icon { font-size: 16px; }
  .search-go { padding: 8px 13px; font-size: 13px; }

  .controls { left: 10px; bottom: 10px; }
  .controls button { width: 34px; height: 34px; font-size: 16px; }
  .legend { right: 10px; top: 10px; max-width: 150px; padding: 10px 11px; }

  .empty-hint { padding: 18px; }
  .empty-hint p { font-size: 14px; }
  .seed-row { gap: 7px; }
  .seed { padding: 7px 12px; font-size: 12.5px; }

  .panel-inner { padding: 16px; }
  .pc-title { font-size: 22px; }

  .trail { padding: 8px 12px; gap: 8px; }
  .toast { bottom: 64px; left: 12px; right: 12px; transform: translateY(20px); text-align: center; }
  .toast.show { transform: translateY(0); }
}

/* hide the wordmark on very narrow screens so the search keeps room */
@media (max-width: 400px) {
  .brand-text { display: none; }
}
