/*!
 * 友链星图 —— 页面样式
 *
 * 只负责「太空场景」这一块；申请友链表单、外链确认弹窗等沿用本页同时引入的 links.css。
 */

/* 这一页不要滚动：场景是全屏 fixed 的 */
html, body { overflow: hidden; background: #010206; }

#linksSpace {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #010206;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
#linksSpace:active { cursor: grabbing; }

#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
#sys { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#sys > * { pointer-events: auto; }

/* ---------- 中心地球 ---------- */
.globe {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 400; pointer-events: none;
}
.globe canvas {
  display: block; border-radius: 50%;
  box-shadow: inset 0 0 6px 1px rgba(128, 194, 255, .34);
}
.globe::before {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--gr, 20px) * 3.4);
  height: calc(var(--gr, 20px) * 3.4);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(140, 198, 255, .50) 0%,
    rgba(90, 164, 255, .20) 26%,
    rgba(52, 116, 236, .06) 52%,
    rgba(30, 80, 200, 0) 74%);
  animation: linksSpaceAtmo 9s ease-in-out infinite;
  pointer-events: none;
}
@keyframes linksSpaceAtmo { 0%, 100% { opacity: 1; } 50% { opacity: .8; } }

/* ---------- 友链节点 ---------- */
.link-node {
  position: absolute; left: 50%; top: 50%;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  text-decoration: none; color: inherit;
  will-change: transform, opacity;
  opacity: 0;
  pointer-events: none;
}
.link-node.node-ready { pointer-events: auto; }
.link-node .av, .link-node .nm { opacity: 0; }
.link-node.node-in .av,
.link-node.node-in .nm { animation: linksSpaceEnter .8s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes linksSpaceEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.link-node.dim { opacity: .05 !important; pointer-events: none; filter: saturate(.15); }

.link-node .av {
  position: relative; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; overflow: hidden;
  background: rgba(13, 23, 41, .8);
  box-shadow: 0 0 0 .5px rgba(158, 203, 255, .34), 0 0 14px 2px rgba(84, 148, 255, .26);
  transition: box-shadow .3s;
}
/* ⚠ em 是「图片加载中/失败」时的兜底，必须待在图片**下面**：
   两者都在 .av 里，em 用 absolute 铺满，靠 z-index 让 img 压在它上面。
   （2026-09-28 上线后踩过：漏了这条，em 的深色底把头像全盖成了「?」圆。） */
.link-node .av img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.link-node .av em {
  position: absolute; inset: 0; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  font-style: normal; font-weight: 500; color: #7ea6d6;
  background: rgba(13, 23, 41, .94);
}

.link-node .nm {
  font-size: 9px; line-height: 1.15;
  white-space: nowrap; max-width: 88px; overflow: hidden; text-overflow: ellipsis;
  color: #8ba3c4;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .98), 0 0 14px rgba(0, 0, 0, .9);
  transition: color .2s;
}
.link-node:hover { z-index: 900 !important; }
.link-node:hover .av { box-shadow: 0 0 0 1px rgba(185, 224, 255, .75), 0 0 26px 6px rgba(120, 180, 255, .6); }
.link-node:hover .nm { color: #fff; }

.link-node .ds {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 6px;
  font-size: 10.5px; line-height: 1.4; color: #8fa8c8;
  white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .22s; pointer-events: none;
  text-shadow: 0 1px 6px #000;
}
.link-node:hover .ds { opacity: 1; }

/* ---------- 底部中间工具条（原在右上，2026-09-28 按站长要求下移居中） ----------
   ⚠ z-index 必须高于头像：头像的 z-index 由 JS 逐帧写在行内（280~520，命中时 +300，
   hover 时 900），而工具条原来只有 6 ⇒ 头像会压在工具条和搜索结果面板上面。
   2026-09-29 提到 1000，顺带让毛玻璃工具条盖在飘过的头像上（更好看）。 */
.space-top {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 1000;
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 32px);
}
.space-top .search {
  display: flex; align-items: center; gap: 8px;
  border: .5px solid rgba(140, 180, 240, .24);
  background: rgba(10, 18, 34, .55);
  border-radius: 999px; padding: 6px 15px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.space-top .search svg { width: 13px; height: 13px; stroke: #5f779b; fill: none; stroke-width: 2; }
.space-top .search input {
  background: none; border: 0; outline: 0;
  color: #dce9ff; font-size: 12px; width: 158px; font-family: inherit;
}
.space-top .search input::placeholder { color: #5a7195; }

.space-top button {
  font-family: inherit; font-size: 12px; cursor: pointer;
  border-radius: 999px; padding: 7px 16px;
  transition: background .2s, border-color .2s, color .2s;
}
.space-top .links-apply-trigger {
  color: #06121f; background: #9ecdf8; border: 0; font-weight: 500;
}
.space-top .links-apply-trigger:hover { background: #bcdffb; }
.space-top .links-random-btn {
  color: #a8bedb; background: rgba(10, 18, 34, .55);
  border: .5px solid rgba(140, 180, 240, .26);
  display: inline-flex; align-items: center; gap: 6px;
}
.space-top .links-random-btn:hover { color: #eaf2ff; border-color: rgba(160, 200, 250, .5); }
.space-top .links-random-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---------- 搜索命中：对应头像高亮（2026-09-29） ----------
   搜索时未命中的头像由 JS 加 .dim 压到 opacity .05，命中的加 .hit 亮起来。
   ⚠ 关键帧里必须同时写 opacity:1 —— 基线样式 `.link-node .av { opacity: 0 }`，
   平时可见是靠入场动画（`.node-in .av`）的 `both` 保持末帧；这里把 .av 的 animation
   换成了另一个，不写 opacity 就会把命中的头像打回透明（等于「搜索后头像消失」）。 */
.link-node.hit .av { animation: linksSpaceHit 1.9s ease-in-out infinite; }
/* 名字必须一起点亮：入场是「转进视野才点亮」（.node-in 逐步加），
   还没轮到入场的节点 .nm 停在 opacity 0 ⇒ 只强制 .av 会出现「有头像没名字」的怪东西。
   `!important` 是为了压过 .node-in 的链接动画填充值。 */
.link-node.hit .nm { color: #fff; opacity: 1 !important; }

@keyframes linksSpaceHit {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 1.5px rgba(186, 226, 255, .92), 0 0 22px 5px rgba(118, 178, 255, .58);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 0 1.5px rgba(216, 240, 255, 1), 0 0 34px 11px rgba(142, 196, 255, .82);
  }
}

/* ---------- 搜索结果面板（搜索框正上方弹出，2026-09-29） ----------
   挂在 .space-top 里（它是 position:absolute，天然当定位祖先），left:0 与搜索框左缘对齐。
   配色写死深空色值、不用主题变量 —— 本页背景永远是深色。 */
.space-results {
  position: absolute;
  left: 0; bottom: calc(100% + 10px);
  width: 322px; max-width: calc(100vw - 32px);
  max-height: 272px; overflow-y: auto; overscroll-behavior: contain;
  padding: 7px;
  border: .5px solid rgba(140, 180, 240, .22);
  border-radius: 14px;
  background: rgba(7, 13, 26, .84);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .68);
  z-index: 2;
  opacity: 0; transform: translateY(7px) scale(.985); transform-origin: bottom left;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.space-results.show { opacity: 1; transform: none; pointer-events: auto; }
.space-results::-webkit-scrollbar { width: 6px; }
.space-results::-webkit-scrollbar-track { background: transparent; }
.space-results::-webkit-scrollbar-thumb { background: rgba(120, 170, 240, .26); border-radius: 3px; }

.space-results-head { padding: 5px 9px 7px; font-size: 10.5px; letter-spacing: .05em; color: #6f88ab; }
.space-results-head b { color: #a9c8ee; font-weight: 600; }

.space-results-list { display: flex; flex-direction: column; gap: 1px; }

.space-result {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: 9px;
  text-decoration: none; color: #cfe0f6; font-size: 12px;
  transition: background .16s, color .16s;
}
.space-result:hover { background: rgba(124, 176, 255, .14); color: #fff; }
.space-result .r-av {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-size: 10px; color: #8fb4e2; background: rgba(13, 23, 41, .92);
  box-shadow: 0 0 0 .5px rgba(158, 203, 255, .3), 0 0 10px 1px rgba(84, 148, 255, .22);
}
.space-result .r-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.space-result .r-main { flex: 1 1 auto; min-width: 0; }
.space-result .r-nm { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.space-result .r-ds {
  display: block; margin-top: 1px; font-size: 10px; color: #6f88ab;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.space-result .r-go {
  flex: 0 0 auto; font-size: 10.5px; color: #7ba6d8;
  opacity: 0; transform: translateX(-3px); transition: opacity .16s, transform .16s;
}
.space-result:hover .r-go { opacity: 1; transform: none; }

.space-results-empty { padding: 16px 9px; font-size: 11.5px; color: #6f88ab; text-align: center; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

@media (max-width: 640px) {
  .space-top { bottom: 18px; gap: 7px; max-width: calc(100% - 20px); }
  .space-top .search { padding: 5px 11px; }
  .space-top .search input { width: 74px; font-size: 11px; }
  .space-top .links-apply-trigger { padding: 6px 12px; font-size: 11px; }
  .space-top .links-random-btn { padding: 6px 11px; font-size: 11px; }
  .space-top .links-random-btn span { display: none; }
  /* 面板在窄屏改成「铺满工具条宽度」——工具条是居中的（左右各留 ~10px），
     固定 322px 会从右边溢出去；left/right 都贴 0 就永远不越界。 */
  .space-results { left: 0; right: 0; width: auto; max-width: none; max-height: 216px; }
  .space-result .r-ds { display: none; }
  .link-node .nm { font-size: 7.5px; max-width: 46px; }
  .link-node .ds { display: none; }
}

/* ---------- 外链确认弹层：深空半透明风 ----------
   覆盖 links.css 里的同名规则（那边用主题 CSS 变量，亮色主题下是白底，放进深空场景很突兀）。
   用 ID 选择器保证优先级压过 links.css 的类选择器。2026-09-28 按站长要求做。 */
#linkConfirmModal.link-confirm-modal.active {
  background: rgba(2, 5, 12, .5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
#linkConfirmModal .link-confirm-content {
  background: rgba(11, 19, 35, .78);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  backdrop-filter: blur(18px) saturate(1.25);
  border: .5px solid rgba(150, 195, 255, .26);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .62), inset 0 0 0 .5px rgba(130, 180, 255, .1);
}
#linkConfirmModal .link-confirm-header {
  border-bottom: .5px solid rgba(150, 195, 255, .15);
  color: #9fb6d6;
}
#linkConfirmModal .link-target-name { color: #eaf2ff; font-weight: 500; }
#linkConfirmModal .link-confirm-close { color: #7f97b8; }
#linkConfirmModal .link-confirm-close:hover { color: #eaf2ff; }
#linkConfirmModal .link-warning-text { color: #8ba3c4; }
#linkConfirmModal .link-confirm-cta {
  color: #06121f;
  background: linear-gradient(135deg, #a9d5fb, #7cb6ef);
  border: 0;
}
#linkConfirmModal .link-confirm-cta:hover { background: linear-gradient(135deg, #c3e1fd, #93c7f6); }
#linkConfirmModal .link-confirm-arrow { stroke: #06121f; }

@media (prefers-reduced-motion: reduce) {
  .link-node.node-in .av,
  .link-node.node-in .nm { animation: none; opacity: 1; }
  .globe::before { animation: none; }
}
