/* ============================================
   NONBINARY STARS — CELESTIAL NAMES
   v2.0 — Separated CSS + Mobile Responsive
   ============================================ */

/* ========== RESET & BASE ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: #000;
  font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

/* ========== VIEWPORT & UNIVERSE ========== */
.viewport {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.viewport.grabbing {
  cursor: grabbing;
}

.viewport.grabbing * {
  cursor: grabbing !important;
  user-select: none !important;
}

.universe-container {
  width: 6000px;
  height: 6000px;
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  transform-origin: 0 0;
}

/* ========== CANVAS LAYERS ========== */
.layer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 6000px;
  height: 6000px;
  pointer-events: none;
}

#activeCanvas { z-index: 6; }
#connBaseCanvas { z-index: 5; }
#starfieldCanvas { z-index: 2; }
#bgCanvas { z-index: 1; }

/* ========== TWINKLE STARS ========== */
.twinkle-star {
  position: absolute;
  background: white;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  animation: twinkle var(--dur) ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.85; }
}

/* ========== NAME ELEMENTS ========== */
.name {
  position: absolute;
  color: #e8d5b7;
  text-shadow: 0 0 15px rgba(255, 220, 180, 0.4);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.3s ease, opacity 0.4s ease;
  z-index: 10;
  contain: layout style;
}

.name:hover {
  color: #fff;
  text-shadow: 0 0 25px rgba(255, 255, 255, 0.8);
  transform: scale(1.15);
}

.name.selected {
  color: #fff !important;
  text-shadow: 0 0 40px rgba(255, 255, 255, 1),
               0 0 80px currentColor;
  z-index: 100;
  opacity: 1 !important;
}

.name.connected {
  color: #fff;
  text-shadow: 0 0 20px currentColor;
  opacity: 1 !important;
}

.name.culled {
  visibility: hidden;
}

.name.filtered-out {
  visibility: hidden;
}

/* ========== ZOOM-ADAPTIVE TEXT ========== */
[data-zoom-level="far"] .name.size-1 { opacity: 0; pointer-events: none; }
[data-zoom-level="far"] .name.size-2 { opacity: 0; pointer-events: none; }
[data-zoom-level="far"] .name.size-3 { opacity: 0.3; }

[data-zoom-level="mid-far"] .name.size-1 { opacity: 0; pointer-events: none; }
[data-zoom-level="mid-far"] .name.size-2 { opacity: 0.35; }

[data-zoom-level="mid"] .name.size-1 { opacity: 0.3; }

/* "near" and "close" show everything at normal opacity */

.size-1 { font-size: 0.85rem; opacity: 0.5; }
.size-2 { font-size: 1.1rem; opacity: 0.6; }
.size-3 { font-size: 1.4rem; opacity: 0.75; }
.size-4 { font-size: 1.9rem; opacity: 0.85; }
.size-5 { font-size: 2.5rem; opacity: 0.95; }
.size-6 { font-size: 3.2rem; opacity: 1; }

/* ========== COLOR CLASSES ========== */
.golden { color: #ffd700; }
.silver { color: #c9d4dc; }
.rose { color: #e8a0a8; }
.ice { color: #a8cce8; }
.amber { color: #e8c078; }
.violet { color: #c8a8e8; }
.seafoam { color: #a8e8d8; }

/* ========== TOOLTIP ========== */
.tooltip {
  position: fixed;
  background: rgba(5, 5, 15, 0.95);
  border: 1px solid rgba(255, 220, 180, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  max-width: 280px;
  color: #e8d5b7;
  font-size: 0.9rem;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 10000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-title {
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 4px;
}

.tooltip-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 220, 180, 0.6);
  margin-bottom: 8px;
}

/* ========== CONTROLS BAR ========== */
.controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 10000;
  opacity: 0.7;
  transition: opacity 0.3s;
}

.controls:hover {
  opacity: 1;
}

.control-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e8d5b7;
  padding: 10px 18px;
  border-radius: 25px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.3s;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.control-btn.active {
  background: rgba(255, 220, 180, 0.3);
  border-color: rgba(255, 220, 180, 0.5);
}

.control-btn.zoom-level {
  min-width: 60px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ========== LEGEND ========== */
.legend {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(5, 5, 15, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  z-index: 10000;
  backdrop-filter: blur(10px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-line {
  width: 24px;
  height: 2px;
}

.legend-line.system {
  background: rgba(100, 150, 255, 0.8);
}

.legend-line.relation {
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 180, 100, 0.8) 0px,
    rgba(255, 180, 100, 0.8) 5px,
    transparent 5px,
    transparent 10px
  );
}

/* ========== INFO PANEL ========== */
.info {
  position: fixed;
  top: 20px;
  left: 20px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  z-index: 10000;
  background: rgba(5, 5, 15, 0.85);
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.name-count {
  font-size: 2rem;
  color: rgba(255, 220, 180, 0.9);
}

.hint {
  margin-top: 10px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.4;
}

/* ========== SEARCH ========== */
.search-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  width: 280px;
}

.search-input {
  width: 100%;
  background: rgba(5, 5, 15, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  padding: 10px 18px 10px 36px;
  color: #e8d5b7;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  backdrop-filter: blur(10px);
  transition: border-color 0.3s;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.search-input:focus {
  border-color: rgba(255, 220, 180, 0.5);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.8rem;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(5, 5, 15, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  overflow: hidden;
  display: none;
  max-height: 320px;
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.search-results.open {
  display: block;
}

.search-result {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-result:hover,
.search-result.highlighted {
  background: rgba(255, 220, 180, 0.15);
}

.search-result-name {
  color: #e8d5b7;
  font-size: 0.9rem;
}

.search-result-type {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ========== FILTER PANEL (commented out for now — not useful enough yet) ==========
.filter-panel {
  position: fixed;
  top: 110px;
  right: 20px;
  background: rgba(5, 5, 15, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  z-index: 10000;
  backdrop-filter: blur(10px);
  max-height: calc(100vh - 240px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.filter-header {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.filter-header:hover {
  color: rgba(255, 255, 255, 0.8);
}

.filter-header .arrow {
  transition: transform 0.2s;
  font-size: 0.6rem;
}

.filter-panel.collapsed .arrow {
  transform: rotate(-90deg);
}

.filter-body {
  padding: 8px 14px 10px;
  overflow-y: auto;
  transition: max-height 0.3s ease;
}

.filter-panel.collapsed .filter-body {
  display: none;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  user-select: none;
}

.filter-item:hover {
  color: rgba(255, 255, 255, 0.85);
}

.filter-item input[type="checkbox"] {
  accent-color: rgba(255, 220, 180, 0.8);
  cursor: pointer;
}

.filter-actions {
  padding: 6px 14px 8px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.filter-action-btn {
  background: none;
  border: none;
  color: rgba(255, 220, 180, 0.6);
  font-family: inherit;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 2px 0;
}

.filter-action-btn:hover {
  color: rgba(255, 220, 180, 1);
}
========== END FILTER PANEL (commented out) ========== */

/* Hide filter panel (commented out feature) */
.filter-panel {
  display: none;
}

/* ========== MINIMAP ========== */
.minimap {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 150px;
  height: 150px;
  background: rgba(5, 5, 15, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  z-index: 10000;
  overflow: hidden;
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.minimap-viewport {
  position: absolute;
  border: 2px solid rgba(255, 220, 180, 0.8);
  background: rgba(255, 220, 180, 0.15);
  pointer-events: none;
}

.minimap-dot {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 220, 180, 0.5);
  border-radius: 50%;
}


/* ==============================================
   MOBILE RESPONSIVE
   ============================================== */

/* ---------- Tablets & small desktops ---------- */
@media (max-width: 900px) {
  .search-container {
    width: 240px;
  }

  .legend {
    padding: 10px 14px;
    font-size: 0.7rem;
  }

  .filter-panel {
    top: 100px;
  }

  .minimap {
    width: 120px;
    height: 120px;
    bottom: 75px;
  }

  .controls {
    gap: 8px;
    bottom: 16px;
  }

  .control-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }
}

/* ---------- Mobile landscape & small tablets ---------- */
@media (max-width: 680px) {
  /* Search bar: full width with side margins */
  .search-container {
    width: calc(100% - 32px);
    max-width: 400px;
    top: 14px;
  }

  .search-input {
    padding: 12px 18px 12px 36px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .search-results {
    max-height: 240px;
  }

  /* Hide legend on small screens to reduce clutter */
  .legend {
    display: none;
  }

  /* Info panel: hide by default (it's already display:none in HTML) */
  .info {
    top: auto;
    bottom: 80px;
    left: 16px;
    padding: 10px 14px;
    font-size: 0.75rem;
  }

  .info .hint {
    display: none;
  }

  .name-count {
    font-size: 1.4rem;
  }

  /* Filter panel: already hidden globally, but keep mobile override commented for later
  .filter-panel {
    top: 64px;
    right: 16px;
    left: auto;
    max-height: calc(100vh - 180px);
    font-size: 0.7rem;
  }

  .filter-body {
    max-height: 200px;
  }
  */

  /* Minimap: bottom-left on mobile */
  .minimap {
    width: 90px;
    height: 90px;
    bottom: 12px;
    right: auto;
    left: 12px;
  }

  /* Hide zoom controls and center view on mobile */
  #zoomIn,
  #zoomOut,
  #zoomLevel,
  #centerView {
    display: none;
  }

  /* Controls bar: compact, just the remaining buttons */
  .controls {
    bottom: 110px;
    left: 12px;
    flex-direction: column;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 24px);
    opacity: 0.85;
    transform: translateX(0);
  }

  .control-btn {
    padding: 8px 12px;
    font-size: 0.75rem;
    border-radius: 20px;
  }

  /* Tooltip: top of screen below search, compact inline header */
  .tooltip {
    left: 12px !important;
    right: 12px;
    top: 58px !important;
    bottom: auto;
    max-width: 380px;
    width: auto;
    border-radius: 12px;
    margin: 7px auto;
    padding: 10px 16px;
    z-index: 10001;
  }

  .tooltip-title {
    font-size: 1rem;
    display: inline;
    margin-bottom: 0;
  }

  .tooltip-category {
    display: inline;
    margin-left: 8px;
    margin-bottom: 0;
    font-size: 0.65rem;
    vertical-align: baseline;
  }

  .tooltip-desc {
    margin-top: 4px;
  }
}

/* ---------- Small phones (portrait) ---------- */
@media (max-width: 420px) {
  .search-container {
    width: calc(100% - 24px);
    top: 10px;
  }

  .minimap {
    width: 70px;
    height: 70px;
    bottom: 56px;
    left: 10px;
    right: auto;
    border-radius: 8px;
  }

  .controls {
    bottom: 8px;
    gap: 5px;
    padding: 0 8px;
  }

  .control-btn {
    padding: 7px 10px;
    font-size: 0.7rem;
  }

  .tooltip {
    left: 8px !important;
    right: 8px;
    top: 54px !important;
    bottom: auto;
    padding: 10px 14px;
  }
}

/* ---------- Very short screens (landscape phones) ---------- */
@media (max-height: 500px) {
  .search-container {
    top: 8px;
  }

  .minimap {
    display: none;
  }

  .legend {
    display: none;
  }

  .controls {
    bottom: 6px;
  }

  .control-btn {
    padding: 6px 10px;
    font-size: 0.7rem;
  }

  .tooltip {
    top: 50px !important;
    bottom: auto;
  }
}

/* ---------- Touch device refinements ---------- */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets for names */
  .name {
    padding: 4px 2px;
  }

  /* Search results need bigger tap targets */
  .search-result {
    padding: 14px 16px;
  }

  /* Controls always visible on touch */
  .controls {
    opacity: 0.9;
  }
}
