/* ============================================================
   star-db.css — 星空数据库独立展示页
   精简标题区 + 星空舞台（控制栏悬浮于星空上）
   ============================================================ */

/* ---------- 页面布局：全屏沉浸（无标题区/页脚，导航悬浮于星空之上） ---------- */
html,
body {
  overflow: hidden;
}
.star-db-main {
  display: block;
  min-height: 100vh;
}
/* 悬浮导航：毛玻璃浮条叠在星空上方，不占版心、不挤压舞台 */
.site-header.star-db-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  height: var(--header-h, 64px);
  background: linear-gradient(180deg, rgba(4, 7, 16, 0.78), rgba(4, 7, 16, 0.34) 62%, rgba(4, 7, 16, 0));
  border-bottom: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: none;
}

/* ---------- 悬浮控制条：融合于星空顶部，不破坏沉浸感 ---------- */
.star-db-controls {
  /* 移动端控制栏悬浮/正常流均覆盖星空画布上部，容器放行点击穿透，
     仅具体控件接收事件，保证星星可点、控件可操作 */
  pointer-events: none;
  position: absolute;
  top: calc(var(--header-h, 64px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 10px 14px;
  background: rgba(8, 12, 24, 0.52);
  border: 1px solid rgba(160, 180, 210, 0.14);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.32);
}
/* 控制栏容器 pointer-events:none 放行穿透后，具体交互控件重新接收事件 */
.star-db-search,
.star-db-search-clear,
.star-db-filter .filter-btn,
.filter-btn,
.star-db-sort,
.star-db-sort-select,
.star-db-count {
  pointer-events: auto;
}
.star-db-search-wrap {
  position: relative;
  width: min(320px, 100%);
}
.star-db-search {
  width: 100%;
  padding: 9px 76px 9px 40px;
  font-size: 0.9rem;
  color: #e8eaed;
  background: rgba(10, 14, 26, 0.6);
  border: 1px solid rgba(160, 180, 210, 0.16);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.star-db-search::placeholder { color: #8b929c; }
.star-db-search:focus {
  border-color: rgba(111, 179, 168, 0.65);
  box-shadow: 0 0 0 3px rgba(111, 179, 168, 0.18);
}
.star-db-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  stroke: #8b929c;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}
.star-db-search-clear {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #8b929c;
  cursor: pointer;
}
.star-db-search-clear:hover { color: #e8eaed; background: rgba(255, 255, 255, 0.08); }
.star-db-search-clear svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}
.star-db-search-hit {
  position: absolute;
  right: 42px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  color: #6fb3a8;
  pointer-events: none;
}
.star-db-filter {
  margin-bottom: 0;
  gap: 6px;
}
.star-db-filter .filter-btn {
  padding: 6px 14px;
  font-size: 0.84rem;
  color: #a7adb5;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.star-db-filter .filter-btn:hover { color: #e8eaed; background: rgba(255, 255, 255, 0.06); }
.star-db-filter .filter-btn.active {
  color: #ffffff;
  background: rgba(111, 179, 168, 0.92);
  box-shadow: 0 2px 12px rgba(111, 179, 168, 0.28);
}
.star-db-count {
  margin: 0;
  font-size: 0.82rem;
  color: #8b929c;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ---------- 工具栏：排序 + 计数（视图切换已移除） ---------- */
.star-db-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.star-db-sort {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: #8b929c;
}
.star-db-sort-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 30px 6px 12px;
  font-size: 0.84rem;
  font-family: inherit;
  color: #e8eaed;
  background: rgba(10, 14, 26, 0.6);
  border: 1px solid rgba(160, 180, 210, 0.16);
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b929c' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.star-db-sort-select option { color: #1a1d21; }
.star-db-sort-select:hover { border-color: rgba(111, 179, 168, 0.5); }
.star-db-sort-select:focus-visible {
  border-color: rgba(111, 179, 168, 0.65);
  box-shadow: 0 0 0 3px rgba(111, 179, 168, 0.18);
}

/* ---------- 粒子散射层：覆盖星空，不拦截交互 ---------- */
.star-particle-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none;
}

/* ---------- 空状态 ---------- */
.star-db-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}
#star-db-empty-3d {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: auto;
  background: rgba(4, 6, 16, 0.42);
  backdrop-filter: blur(2px);
}
.star-db-empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 340px;
}
.star-db-empty-icon {
  width: 42px;
  height: 42px;
  stroke: var(--brand, #6fb3a8);
  fill: none;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.star-db-empty-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.star-db-empty-reset {
  margin-top: 6px;
}
.star-db-empty[hidden] { display: none; }

/* ---------- 3D 星空舞台：铺满整个可视区（进入即沉浸） ---------- */
.star-db-stage {
  display: block;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  border-radius: 0;
  border: none;
  position: relative;
  overflow: hidden;
}
.star-db-stage #stars-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .star-db-stage {
    display: block;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
  }
  /* 控制栏保持悬浮于星空顶部：不占流、触控目标加大（页脚/标题已移除） */
  .star-db-controls {
    position: absolute;
    top: calc(var(--header-h, 64px) + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 16px);
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 16px;
    margin: 0;
    flex: none;
    z-index: 9;
  }
  .star-db-search-wrap { width: 100%; }
  .star-db-search { font-size: 16px; padding: 11px 76px 11px 40px; }
  .star-db-search-clear { width: 32px; height: 32px; }
  .star-db-filter { justify-content: center; flex-wrap: wrap; }
  .star-db-filter .filter-btn { min-height: 38px; padding: 8px 14px; }
  .star-db-sort-select { min-height: 40px; padding: 8px 32px 8px 12px; }
  .star-db-toolbar { justify-content: space-between; }
  .star-db-count { font-size: 0.78rem; }
}

/* ---------- 弱交互窄屏（手机全屏时让顶部浮层纵向排布） ---------- */
@media (max-width: 480px) {
  .star-db-controls {
    top: calc(var(--header-h, 64px) + 8px);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: calc(100% - 16px);
    max-width: none;
  }
  /* 筛选按钮在窄屏自动换行，宽度锁定在视口内，避免外层 overflow 裁切 */
  .star-db-filter {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 2px 0 6px;
    overflow: visible;
    gap: 6px 8px;
  }
  .star-db-filter .filter-btn { flex: 0 0 auto; white-space: nowrap; }
  .star-db-toolbar { flex-wrap: nowrap; gap: 6px; }
  .star-db-count { white-space: nowrap; min-width: 0; }
  .star-db-sort-select { max-width: 132px; }
}

/* ---------- WebGL 深空背景层（垫底，位于 #stars-canvas / 粒子层之下） ---------- */
#stars-bg-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
}
/* WebGL 不可用/初始化失败时隐藏背景画布，回到 2D fallback 或纯底色 */
#stars-bg-canvas.stars-bg-fallback {
  display: none;
}

/* ---------- 减弱动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  .star-db-controls { transition: none; }
}
