/*
 * groove_map.css — Lacuna Engine Groove Map
 * ------------------------------------------------------------------
 * Three-column shell: sidebar (legend + search) · canvas stage ·
 * detail panel. Each panel is a floating semi-transparent card on
 * top of the full-bleed canvas so the scatter plot always fills the
 * viewport. Colours mirror the rest of the app (Ableton-dark).
 */

:root {
  --bg: #1A1A1A;
  --panel: #242424;
  --panel-border: #2E2E2E;
  --panel-nested: #1E1E1E;
  --accent: #FF6B2B;
  --text: rgba(255,255,255,0.87);
  --text-sec: rgba(255,255,255,0.54);
  --text-dis: rgba(255,255,255,0.30);
  --text-faint: rgba(255,255,255,0.15);
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --sans: 'Helvetica Neue', -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== top nav ================================================= */
.map-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: #1B1B1B;
  border-bottom: 1px solid var(--panel-border);
  z-index: 30;
}
.map-nav-back {
  color: var(--text-sec);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid var(--panel-border);
  transition: color 150ms, border-color 150ms;
}
.map-nav-back:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.map-nav-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.20em;
  color: var(--text);
}
.map-nav-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dis);
  letter-spacing: 0.05em;
}

/* ===== empty state ============================================ */
.map-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 80vw);
  padding: 24px 28px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  text-align: center;
}
.map-empty-title {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.10em;
  margin-bottom: 10px;
}
.map-empty-body {
  font-size: 13px;
  color: var(--text-sec);
  line-height: 1.6;
}
.map-empty-body code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-nested);
  padding: 2px 6px;
  border-radius: 2px;
  color: var(--text);
}

/* ===== sidebar (search + legend) =============================== */
.map-sidebar {
  position: fixed;
  top: 56px; left: 16px;
  width: 220px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  background: rgba(36, 36, 36, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 12px;
  z-index: 20;
  font-size: 12px;
}
.map-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.map-search {
  flex: 1;
  background: var(--panel-nested);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 11px;
  border-radius: 3px;
  outline: none;
}
.map-search:focus { border-color: var(--accent); }
.map-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dis);
  white-space: nowrap;
}
.map-legend-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-sec);
  margin-top: 4px;
  margin-bottom: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--panel-border);
}
.legend-all {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-dis);
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  cursor: pointer;
}
.legend-all:hover { color: var(--accent); border-color: var(--accent); }
.map-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 120ms;
}
.legend-row:hover { background: rgba(255,255,255,0.04); }
.legend-row.off { opacity: 0.35; }
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex: 0 0 10px;
}
.legend-name {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  text-transform: capitalize;
}
.legend-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dis);
}
.map-hint {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.map-hint-row {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dis);
  display: flex;
  align-items: center;
  gap: 8px;
}
.kbd {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-sec);
  background: var(--panel-nested);
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  padding: 1px 5px;
  min-width: 36px;
  text-align: center;
}

/* ===== stage (canvas fills the rest) =========================== */
.map-stage {
  position: fixed;
  top: 40px; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  /* cursor style: set by JS (grab vs grabbing) */
}
#map-canvas {
  display: block;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: grab;
}
#map-canvas:active { cursor: grabbing; }

.map-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(20, 20, 20, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  z-index: 25;
  max-width: 240px;
  line-height: 1.45;
}
.map-tooltip .tt-name {
  color: var(--text);
  margin-bottom: 4px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.map-tooltip .tt-meta {
  color: var(--text-sec);
  font-size: 10px;
}
.map-loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dis);
  letter-spacing: 0.10em;
}

/* ===== detail panel ============================================ */
.map-detail {
  position: fixed;
  top: 56px; right: 16px;
  width: 280px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  background: rgba(36, 36, 36, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 16px 16px 14px;
  z-index: 20;
}
.detail-close {
  position: absolute;
  top: 6px; right: 8px;
  background: none;
  border: none;
  color: var(--text-dis);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.detail-close:hover { color: var(--accent); }
.detail-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  margin-bottom: 10px;
}
.detail-name {
  font-size: 14px;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
  margin-bottom: 3px;
}
.detail-genre {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-sec);
  margin-bottom: 12px;
}
.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.detail-stat {
  background: var(--panel-nested);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 6px 8px;
}
.detail-stat-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dis);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.detail-stat-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}
.detail-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.detail-btn {
  flex: 1;
  background: var(--panel-nested);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 120ms, color 120ms;
}
.detail-btn:hover { border-color: var(--accent); color: var(--accent); }
.detail-btn-primary {
  background: var(--accent);
  color: #1A1A1A;
  border-color: var(--accent);
}
.detail-btn-primary:hover {
  background: #FF8754;
  border-color: #FF8754;
  color: #1A1A1A;
}
.detail-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.detail-neighbors-hdr {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-sec);
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
  margin-bottom: 6px;
}
.detail-neighbors {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.neighbor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 120ms;
}
.neighbor-row:hover { background: rgba(255,255,255,0.04); }
.neighbor-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex: 0 0 8px;
}
.neighbor-name {
  flex: 1;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.neighbor-sim {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
}

/* ===== responsive (mobile) ===================================== */
@media (max-width: 720px) {
  .map-sidebar {
    top: 48px;
    left: 8px; right: 8px;
    width: auto;
    max-height: 40vh;
  }
  .map-detail {
    top: auto;
    bottom: 8px;
    left: 8px; right: 8px;
    width: auto;
    max-height: 50vh;
  }
  .map-nav-sub { display: none; }
}
