/* ── Three.js Particle Mindmap v2 ──────────────────── */

/* ── Container & Canvas ───────────────────────────── */
.mindmap-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  background: #000;
  overflow: hidden;
  z-index: 100;
}

#mindmap-canvas {
  width: 100%;
  height: 100vh;
  display: block;
}

#mindmap-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Loading ───────────────────────────────────────── */
.mindmap-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 5;
  pointer-events: none;
  transition: opacity 1s ease;
}

.mindmap-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.mindmap-loading-spinner {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(255, 255, 255, 0.06);
  border-top-color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: mindmap-spin 1s linear infinite;
}

@keyframes mindmap-spin {
  to { transform: rotate(360deg); }
}

/* ── Category Filter (left, vertically centered) ──── */
#mindmap-filters {
  position: absolute;
  top: 50%;
  left: 24px;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(10, 10, 14, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 20px 18px;
  min-width: 180px;
  color: #fff;
}

#mindmap-filters h3 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.3);
  margin: 0 0 16px;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

.mindmap-filter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  transition: color 0.25s ease, opacity 0.25s ease;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

.mindmap-filter-item:hover {
  color: #fff;
}

.mindmap-filter-item.is-off {
  color: rgba(255, 255, 255, 0.2);
}

.mindmap-filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 0 6px currentColor;
}

.mindmap-filter-item.is-off .mindmap-filter-dot {
  opacity: 0.2;
  transform: scale(0.7);
}

.mindmap-filter-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.mindmap-filter-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.2);
  min-width: 16px;
  text-align: right;
}

/* ── Search Bar (top center) ──────────────────────── */
#mindmap-search {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

#mindmap-search-input {
  width: 280px;
  padding: 11px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background: rgba(10, 10, 14, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  font-size: 13px;
  font-weight: 400;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  outline: none;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s ease,
              background 0.3s ease;
}

#mindmap-search-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
  font-weight: 400;
}

#mindmap-search-input:focus {
  width: 360px;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(10, 10, 14, 0.65);
}

/* ── Tooltip (glassmorphism) ──────────────────────── */
#mindmap-tooltip {
  position: absolute;
  z-index: 15;
  padding: 10px 16px;
  background: rgba(10, 10, 14, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #fff;
  font-size: 12px;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  max-width: 280px;
  line-height: 1.5;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#mindmap-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

#mindmap-tooltip strong {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}

#mindmap-tooltip .tooltip-cat {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Detail Panel (floating card, same style as category filter) */
#mindmap-detail {
  position: absolute;
  top: 50%;
  right: 24px;
  transform: translateY(-50%) scale(0.95);
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  background: rgba(10, 10, 14, 0.55);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 0;
  z-index: 20;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

#mindmap-detail.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

#mindmap-detail::-webkit-scrollbar {
  width: 4px;
}

#mindmap-detail::-webkit-scrollbar-track {
  background: transparent;
}

#mindmap-detail::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Detail inner content */
.detail-content {
  padding: 80px 28px 32px;
}

/* Close button as circle */
#detail-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

#detail-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: scale(1.1);
}

#detail-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 16px;
  line-height: 1.4;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  letter-spacing: -0.02em;
}

/* Category badge with dynamic color (set via JS) */
#detail-category {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

#detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.detail-tag {
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

.detail-tag:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

#detail-summary {
  font-size: 13.5px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 28px;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

#detail-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

#detail-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── View Toggle ──────────────────────────────────── */
#view-toggle {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 10px 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: rgba(10, 10, 14, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

#view-toggle:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(10, 10, 14, 0.7);
}

/* ── Mobile ────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Filters: horizontal bar at bottom */
  #mindmap-filters {
    position: absolute;
    top: auto;
    bottom: 72px;
    left: 0;
    right: 0;
    transform: none;
    min-width: auto;
    border-radius: 0;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 12px;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #mindmap-filters::-webkit-scrollbar {
    display: none;
  }

  #mindmap-filters h3 {
    display: none;
  }

  .mindmap-filter-item {
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    gap: 6px;
  }

  .mindmap-filter-item:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  .mindmap-filter-label {
    max-width: 100px;
  }

  .mindmap-filter-count {
    display: none;
  }

  /* Search */
  #mindmap-search-input {
    width: 220px;
    font-size: 12px;
    padding: 10px 16px;
  }

  #mindmap-search-input:focus {
    width: 280px;
  }

  /* Detail panel: bottom sheet */
  #mindmap-detail {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 65vh;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  }

  #mindmap-detail.is-open {
    transform: translateY(0);
  }

  .detail-content {
    padding: 24px 20px 32px;
  }

  /* Bottom sheet handle */
  #mindmap-detail::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin: 12px auto 0;
  }

  #detail-close {
    top: 12px;
    right: 16px;
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  #detail-title {
    font-size: 18px;
  }

  #detail-summary {
    font-size: 13px;
    line-height: 1.7;
  }

  #view-toggle {
    bottom: 16px;
    font-size: 11px;
    padding: 8px 18px;
  }

  /* Tooltip: hide on mobile (touch devices) */
  #mindmap-tooltip {
    display: none;
  }
}

/* ── Extra small screens ──────────────────────────── */
@media (max-width: 420px) {
  #mindmap-search-input {
    width: 180px;
  }

  #mindmap-search-input:focus {
    width: 240px;
  }

  .mindmap-filter-item {
    font-size: 10px;
    padding: 4px 8px;
  }
}
