@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

:root {
  --bg: #050510;
  --bg-panel: rgba(8, 10, 24, 0.94);
  --text: #d0d4e0;
  --text-dim: #606880;
  --text-bright: #f0f4ff;
  --gold: #ffe070;
  --gold-glow: rgba(255, 224, 112, 0.3);
  --teal: #64f0e0;
  --teal-glow: rgba(100, 240, 224, 0.3);
  --purple: #c49cff;
  --purple-glow: rgba(196, 156, 255, 0.3);
  --coral: #ffaa60;
  --coral-glow: rgba(255, 170, 96, 0.3);
  --green: #80e8a0;
  --green-glow: rgba(128, 232, 160, 0.3);
  --link: rgba(140, 170, 220, 0.06);
  --link-hover: rgba(180, 210, 255, 0.25);
  --border: rgba(140, 170, 220, 0.08);
  --search-bg: rgba(140, 170, 220, 0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* noise overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px;
  pointer-events: none;
  z-index: 0;
}

canvas#graph {
  position: fixed;
  inset: 0;
  z-index: 1;
  cursor: grab;
}
canvas#graph:active { cursor: grabbing; }

#search-container {
  position: fixed;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: 420px;
  max-width: calc(100vw - 40px);
}

#search-wrap {
  position: relative;
  background: var(--search-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
#search-wrap:focus-within {
  border-color: rgba(232, 184, 75, 0.25);
  box-shadow: 0 0 40px rgba(232, 184, 75, 0.06);
}

#search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 15px;
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 14px 16px 14px 42px;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  letter-spacing: 0.01em;
}
#search::placeholder { color: var(--text-dim); }

/* search type removed - unified search */

#results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  overflow: hidden;
  display: none;
  max-height: 340px;
  overflow-y: auto;
}
#results.active { display: block; }

.result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: rgba(255,255,255,0.04); }
.result-title {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-bright);
}
.result-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Search loading bar (bottom edge of search box) --- */
#search-loading-bar {
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s;
}
#search-loading-bar.active {
  opacity: 1;
}
#search-loading-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--gold), var(--teal));
  border-radius: 2px;
  transition: width 0.4s ease-out;
}

#search-loading-text {
  position: absolute;
  bottom: -22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#search-loading-text.active {
  opacity: 1;
}

/* --- Filter legend (left side, vertical) --- */
#filter-legend {
  position: fixed;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
#filter-legend.visible {
  opacity: 1;
  pointer-events: auto;
}
#filter-legend:hover {
  opacity: 1 !important;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s, background 0.15s;
  font-family: 'DM Sans', sans-serif;
}
.legend-item:hover {
  background: rgba(255,255,255,0.05);
}
.legend-item.off {
  opacity: 0.25;
}
.legend-item .legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-item .legend-label {
  font-size: 11px;
  color: var(--text);
  letter-spacing: 0.02em;
  font-weight: 400;
}
.legend-item .legend-count {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
  min-width: 16px;
  text-align: right;
}

#detail-panel {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 300px;
  max-height: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 100;
  display: none;
  overflow: hidden;
}
#detail-panel.active { display: flex; flex-direction: column; }

#detail-header {
  padding: 20px 20px 0;
  flex-shrink: 0;
}

#detail-panel h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--text-bright);
  margin-bottom: 2px;
  line-height: 1.3;
}
#detail-panel .detail-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  margin-bottom: 0;
}
#detail-panel .detail-info {
  font-size: 11px;
  color: var(--text-dim);
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#detail-panel .detail-works-wrap {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
#detail-panel .detail-works {
  list-style: none;
  padding: 4px 0;
}
#detail-panel .detail-works li {
  padding: 7px 20px;
  font-size: 12px;
  color: var(--text-dim);
  transition: background 0.1s;
  line-height: 1.4;
}
#detail-panel .detail-works li:hover {
  background: rgba(255,255,255,0.03);
}
#detail-panel .detail-works .work-title {
  color: var(--text);
}
#detail-panel .detail-works .work-role {
  color: var(--text-dim);
  font-size: 11px;
  opacity: 0.7;
}

/* (loading indicator integrated into search bar) */

/* --- Origin tags (top-right) --- */
#origins {
  position: fixed;
  top: 28px;
  right: 28px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#origins.visible {
  opacity: 1;
  pointer-events: auto;
}
.origin-tag {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  padding: 5px 11px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: default;
  transition: opacity 0.2s, background 0.15s;
}
.origin-tag:hover {
  background: rgba(255,255,255,0.06);
}
.origin-tag .origin-dot {
  display: inline-block;
  font-size: 10px;
  line-height: 1;
  margin-right: 0;
  flex-shrink: 0;
}
.origin-spinner {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: origin-spin 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
@keyframes origin-spin {
  to { transform: rotate(360deg); }
}
.origin-tag .origin-name {
  color: var(--text);
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}
.origin-tag.selected {
  border-color: rgba(255,224,112,0.3);
  background: rgba(255,224,112,0.06);
}
.origin-tag.selected .origin-dot {
  color: var(--gold) !important;
}
.origin-tag.selected .origin-name {
  color: var(--gold);
}

#link-panel {
  position: fixed;
  bottom: 60px;
  right: 28px;
  width: 280px;
  max-height: 320px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(20px);
  padding: 18px 20px;
  z-index: 100;
  display: none;
  overflow-y: auto;
}
#link-panel.active { display: block; }
#link-panel h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-bright);
  margin-bottom: 12px;
  line-height: 1.4;
}
#link-panel-works {
  list-style: none;
  padding: 0;
  margin: 0;
}
#link-panel-works li {
  padding: 5px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
  font-family: 'DM Sans', sans-serif;
}
#link-panel-works li:first-child { border-top: none; }

#hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.35;
  transition: opacity 0.3s;
  white-space: nowrap;
}
#hint:hover { opacity: 0.7; }
.hint-item {
  display: inline;
}
.hint-item .hint-key {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 3px;
}
.hint-item .hint-label {
  margin-left: 3px;
}
.hint-sep {
  width: 1px;
  height: 10px;
  background: rgba(255,255,255,0.08);
  flex-shrink: 0;
}
@media (max-width: 700px) {
  #hint { display: none; }
}

/* --- Spotify player --- */
.spotify-player {
  display: none;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.spotify-player.active { display: block; }
.spotify-player iframe {
  display: block;
  border-radius: 0 0 14px 14px;
}

/* Play button next to work titles */
.work-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  font-size: 7px;
  cursor: pointer;
  margin-right: 8px;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
}
.work-play-btn:hover {
  background: rgba(100, 240, 224, 0.15);
  color: var(--teal);
}
.work-play-btn.loading {
  opacity: 0.4;
  pointer-events: none;
}
.work-play-btn.no-preview {
  opacity: 0.15;
  pointer-events: none;
}

#detail-panel .detail-works li {
  display: flex;
  align-items: flex-start;
}

/* scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
