@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;800;900&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-deep: #030712;
  --hud-bg: rgba(15, 23, 42, 0.72);
  --hud-border: rgba(56, 189, 248, 0.25);
  --hud-glow: rgba(56, 189, 248, 0.15);
  --neon-cyan: #38bdf8;
  --neon-purple: #c084fc;
  --neon-amber: #fbbf24;
  --neon-pink: #f472b6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-display: 'Orbitron', monospace, sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

html {
  font-size: 16.5px;
  transition: font-size 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-text-size-adjust: 100%;
}

html[data-font-scale="medium"] {
  font-size: 17px;
}

html[data-font-scale="large"] {
  font-size: 19.5px;
}

html[data-font-scale="huge"] {
  font-size: 22px;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#cosmos-canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ================= HUD UI Layer ================= */
.hud-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
}

.hud-interactive {
  pointer-events: auto;
}

/* Top Header Bar */
.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hud-border);
  padding: 0.6rem 1.25rem;
  border-radius: 9999px;
  box-shadow: 0 0 20px var(--hud-glow);
}

.logo-icon {
  font-size: 1.4rem;
  animation: pulse-spin 8s linear infinite;
}

@keyframes pulse-spin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, #38bdf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Search and Sector Filter */
.search-filter-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hud-border);
  border-radius: 9999px;
  padding: 0.4rem 0.75rem 0.4rem 1.15rem;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.98rem;
  width: 250px;
  font-family: var(--font-body);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.hud-btn-group {
  display: flex;
  gap: 0.5rem;
}

.hud-btn {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--hud-border);
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.hud-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px var(--neon-cyan);
  transform: translateY(-1px);
}

.hud-btn.primary {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.4), rgba(192, 132, 252, 0.4));
  border-color: var(--neon-cyan);
}

/* Sector Filter Pills (Top / Bottom) */
.sector-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  max-width: 100%;
}

.sector-pill {
  padding: 0.45rem 0.95rem;
  background: var(--hud-bg);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.sector-pill:hover, .sector-pill.active {
  color: var(--text-main);
  border-color: var(--neon-cyan);
  background: rgba(56, 189, 248, 0.2);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Bottom Navigation / Controls */
.hud-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

.stats-card {
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hud-border);
  padding: 0.85rem 1.4rem;
  border-radius: 1rem;
  display: flex;
  gap: 1.6rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--neon-cyan);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tooltip on Hover */
.star-tooltip {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--neon-cyan);
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
  transform: translate(-50%, -120%);
  transition: opacity 0.15s ease;
  opacity: 0;
}

.star-tooltip.visible {
  opacity: 1;
}

.star-tooltip-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}

.star-tooltip-sector {
  font-size: 0.82rem;
  color: var(--neon-cyan);
}

/* Modals & Dialogs */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--neon-cyan);
  border-radius: 1.5rem;
  width: 90%;
  max-width: 580px;
  padding: 2.2rem;
  position: relative;
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.25);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-card {
  transform: scale(1);
}

.close-btn {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #fff;
}

.card-badge {
  display: inline-block;
  font-size: 0.8rem;
  text-transform: uppercase;
  font-family: var(--font-display);
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  margin-bottom: 0.6rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
}

.card-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: #fff;
}

.card-repo {
  font-size: 0.98rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.card-desc {
  font-size: 1.1rem;
  line-height: 1.7;
  color: #cbd5e1;
  margin-bottom: 1.4rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.6rem;
}

.tag-pill {
  font-size: 0.82rem;
  padding: 0.25rem 0.65rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 0.4rem;
  color: #cbd5e1;
}

.card-actions {
  display: flex;
  gap: 0.85rem;
  margin-top: 1.2rem;
}

.action-btn {
  flex: 1;
  padding: 0.85rem;
  border-radius: 0.75rem;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-align: center;
  text-decoration: none;
}

.btn-visit {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  box-shadow: 0 0 15px rgba(2, 132, 199, 0.4);
}

.btn-visit:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.btn-bookmark {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-bookmark:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--neon-amber);
}

.btn-bookmark.bookmarked {
  background: var(--neon-amber);
  color: #000;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

/* Black Hole Gravitational Gacha View */
.black-hole-vortex {
  width: 140px;
  height: 140px;
  margin: 1.5rem auto;
  border-radius: 50%;
  background: radial-gradient(circle, #000000 60%, #a855f7 90%, #38bdf8 100%);
  box-shadow: 0 0 50px #9333ea, inset 0 0 30px #000;
  animation: spin-vortex 4s linear infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes spin-vortex {
  from { transform: rotate(0deg) scale(0.95); }
  50% { transform: rotate(180deg) scale(1.05); }
  to { transform: rotate(360deg) scale(0.95); }
}

/* Constellation Drawer */
.constellation-drawer {
  position: fixed;
  right: -400px;
  top: 0;
  width: 380px;
  max-width: 90vw;
  height: 100%;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--hud-border);
  z-index: 90;
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.constellation-drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neon-cyan);
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.3rem;
}

.drawer-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  padding: 0.75rem 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-item-title {
  font-weight: 600;
  font-size: 1rem;
}

.drawer-item-repo {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.drawer-remove-btn {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .hud-top-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-input {
    width: 100%;
  }
  .stats-card {
    display: none;
  }
  .hud-bottom-bar {
    justify-content: center;
  }
}
