@charset "UTF-8";
/* ============================================================================
   AI 小工具手账 · stars.css
   首页扉页：夜空 / 星图 / 月亮 / 流星 / 撕纸过渡
   只在 index.html 引用。零图片、零外部字体；星星与月亮全部由 CSS 绘制。
   ============================================================================ */

.sky {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 540px;
  margin: 0 -20px;
  overflow: hidden;
  isolation: isolate;
  color: #e8ecff;
  background:
    radial-gradient(120% 85% at 50% 118%, #17224f 0%, #0b1026 46%, #06080f 100%);

  /* JS 会逐帧改写这几个变量；这里给初值，保证脚本未运行时也是确定的 */
  --par-x: 0px;
  --par-y: 0px;
  --pan-x: 0px;
  --pan-y: 0px;
  --par-far-x: 0px;
  --par-far-y: 0px;
  --par-moon-x: 0px;
}

/* 一层很淡的星云，让夜空不是死板的纯色 */
.sky-glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(46% 38% at 24% 30%, rgba(96, 124, 226, .22), transparent 70%),
    radial-gradient(38% 30% at 78% 22%, rgba(180, 148, 226, .16), transparent 72%),
    radial-gradient(50% 34% at 62% 84%, rgba(80, 118, 210, .14), transparent 74%);
}

/* --------------------------------------------------------------- 星空 ---- */

.sky-field {
  position: absolute;
  inset: -60px;
  z-index: 1;
  pointer-events: none;
  transform: translate3d(var(--par-far-x, 0px), var(--par-far-y, 0px), 0);
  will-change: transform;
}

.bg-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: twinkle 6s ease-in-out infinite;
}
.bg-star--far  { width: 1px;   height: 1px;   box-shadow: 0 0 3px rgba(200, 216, 255, .5); }
.bg-star--mid  { width: 1.6px; height: 1.6px; box-shadow: 0 0 5px rgba(200, 216, 255, .65); }
.bg-star--near { width: 2.6px; height: 2.6px; box-shadow: 0 0 9px rgba(214, 226, 255, .85); }

@keyframes twinkle {
  0%, 100% { opacity: .22; transform: scale(.86); }
  50%      { opacity: 1;   transform: scale(1.12); }
}

/* 流星：三条不同轨道 / 速度，从左上一直划出右下，横穿整片夜空。
   关键在 transform 顺序 —— rotate() 写在 translate3d() 前面，
   位移就沿着流星自身的方向走（而不是横着平移），所以一条尾巴能划过整屏。
   距离用 vmax，换任何屏幕比例都能穿出去。 */
.meteor {
  --meteor-w: min(50vw, 520px);   /* 尾巴长度 */
  --meteor-len: 150vmax;          /* 飞行距离（沿自身方向） */
  --meteor-angle: 18deg;          /* 下坠角度 */
  --meteor-dur: 11s;              /* 一个完整周期（含隐身等待） */
  --meteor-delay: 0s;
  position: absolute;
  left: -12vw;
  top: 3%;
  z-index: 1;
  width: var(--meteor-w);
  height: 2.5px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(196, 214, 255, .34) 38%,
    rgba(232, 241, 255, .95) 86%,
    #fff 100%);
  box-shadow: 0 0 8px rgba(198, 220, 255, .35);
  opacity: 0;
  pointer-events: none;
  transform-origin: 100% 50%;     /* 头在右端，left/top 就是流星的起点 */
  will-change: transform, opacity;
  animation: meteor var(--meteor-dur) var(--meteor-delay) linear infinite;
}

/* 流星头的一点强光，尾巴才不像一根白线 */
.meteor::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 34%, rgba(196, 220, 255, .45) 62%, transparent 72%);
  box-shadow: 0 0 12px 3px rgba(206, 226, 255, .55);
}

@keyframes meteor {
  0%, 84% { opacity: 0; transform: rotate(var(--meteor-angle)) translate3d(0, 0, 0); }
  86%     { opacity: .95; }
  97%     { opacity: 1; }
  100%    { opacity: 0; transform: rotate(var(--meteor-angle)) translate3d(var(--meteor-len), 0, 0); }
}

/* 三条流星错开时间，看起来像零星的流星群而不是机械循环 */
.meteor--1 {
  --meteor-angle: 17deg;
  --meteor-len: 150vmax;
  --meteor-dur: 11s;
  --meteor-delay: 0s;
  top: 2%;
  left: -16vw;
}
.meteor--2 {
  --meteor-angle: 26deg;
  --meteor-len: 168vmax;
  --meteor-dur: 15s;
  --meteor-delay: 4.6s;
  --meteor-w: min(42vw, 420px);
  top: -6%;
  left: 6vw;
}
.meteor--3 {
  --meteor-angle: 12deg;
  --meteor-len: 142vmax;
  --meteor-dur: 18.5s;
  --meteor-delay: 9.4s;
  --meteor-w: min(56vw, 560px);
  top: 14%;
  left: -24vw;
}

/* --------------------------------------------------------------- 月亮 ---- */

/* 大月亮低垂在纸的边缘，下半缘被撕纸压住 */
.moon {
  position: absolute;
  left: 50%;
  bottom: -38px;
  z-index: 2;
  width: 140px;
  height: 140px;
  margin-left: -70px;
  pointer-events: none;
  transform: translate3d(var(--par-moon-x, 0px), 0, 0);
  animation: moon-float 9s ease-in-out infinite;
}
/* 月面由内联 SVG 绘制：月海 + 固定撞击坑 + 边缘减光 + 月壤颗粒。
   随机小坑由 stars.js 的 buildMoonCraters() 每次刷新补进 #moonCratersRand。
   辉光改用 drop-shadow，跟着圆形轮廓走，不再是方形盒子。 */
.moon-svg {
  display: block;
  width: 100%;
  height: 100%;
  filter:
    drop-shadow(0 0 14px rgba(255, 244, 200, .32))
    drop-shadow(0 0 52px rgba(170, 186, 255, .18));
}

/* 月亮是纯装饰：整棵子树不吃指针；顺便保证 HTML 里的 class 都有样式 */
.moon-disc,
.moon-mare,
.moon-ray,
.moon-craters,
.moon-craters--rand,
.moon-crater,
.moon-ejecta,
.moon-rim { pointer-events: none; }

/* 小坑的坑缘压淡一点，否则一堆细亮环会显得发白 */
.moon-crater--sm ellipse:last-child { stroke-opacity: .78; }
@keyframes moon-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -8px; }
}

/* ------------------------------------------------------------- 撕纸边 ---- */

.torn {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  z-index: 4;
  height: 44px;
  pointer-events: none;
}
.torn svg { display: block; width: 100%; height: 100%; }

/* 纸的上缘被月光照亮一点点 */
.torn::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 520px;
  max-width: 92%;
  height: 96px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 240, 198, .5), transparent 72%);
  pointer-events: none;
}

/* ------------------------------------------------------------- 星图 ------ */

.sky-graph {
  position: absolute;
  inset: 0;
  z-index: 3;
  transform: translate3d(
    calc(var(--par-x, 0px) + var(--pan-x, 0px)),
    calc(var(--par-y, 0px) + var(--pan-y, 0px)),
    0
  );
  will-change: transform;
  touch-action: pan-y;
}

.sky-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.sky-links line {
  stroke: rgba(148, 174, 255, .28);
  stroke-width: 1;
  stroke-dasharray: 3 7;
  animation: flow 16s linear infinite;
}
@keyframes flow { to { stroke-dashoffset: -120; } }

/* 跨星系的桥：比星系内部的光丝更淡 */
.sky-links line.is-bridge {
  stroke: rgba(148, 174, 255, .16);
  stroke-dasharray: 2 11;
}

/* 悬停某颗星时，与它相连的线亮起（由 stars.js 加 class） */
.sky-links line.is-lit {
  stroke: rgba(206, 224, 255, .85);
  stroke-width: 1.5;
}

/* 节点被 hover / 聚焦时，与它相连的光丝亮起来 */
.sky-graph:has(#n-know:hover) .sky-links line[data-a="n-know"],
.sky-graph:has(#n-know:hover) .sky-links line[data-b="n-know"],
.sky-graph:has(#n-know:focus-visible) .sky-links line[data-a="n-know"],
.sky-graph:has(#n-know:focus-visible) .sky-links line[data-b="n-know"],
.sky-graph:has(#n-log1:hover) .sky-links line[data-a="n-log1"],
.sky-graph:has(#n-log1:hover) .sky-links line[data-b="n-log1"],
.sky-graph:has(#n-log2:hover) .sky-links line[data-a="n-log2"],
.sky-graph:has(#n-log2:hover) .sky-links line[data-b="n-log2"],
.sky-graph:has(#n-log3:hover) .sky-links line[data-a="n-log3"],
.sky-graph:has(#n-log3:hover) .sky-links line[data-b="n-log3"],
.sky-graph:has(#n-tag-t:hover) .sky-links line[data-a="n-tag-t"],
.sky-graph:has(#n-tag-t:hover) .sky-links line[data-b="n-tag-t"],
.sky-graph:has(#n-tag-p:hover) .sky-links line[data-a="n-tag-p"],
.sky-graph:has(#n-tag-p:hover) .sky-links line[data-b="n-tag-p"] {
  stroke: rgba(200, 219, 255, .82);
  stroke-width: 1.5;
}

/* 星系容器：铺满整张图，只做逻辑分组与名称定位 */
.galaxy {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.galaxy-name {
  position: absolute;
  transform: translate(-50%, 0);
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(200, 214, 255, .34);
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
  transition: color .5s ease, opacity .5s ease;
}
.galaxy.is-focus .galaxy-name { color: rgba(224, 234, 255, .8); }
.galaxy.is-dim .galaxy-name { opacity: .4; }

/* 聚焦的星系亮起来，另一个退到背景里 */
.galaxy .star {
  pointer-events: auto;
  transition: opacity .55s ease;
}
.galaxy.is-dim .star { opacity: .45; }
.galaxy.is-focus .star { opacity: 1; }

/* 一颗星
   盒子收缩到只有星点那么大：paint() 写的 left/top 就是星点圆心，
   而连线端点用的是同一组坐标 → 光丝一定打在星点上，不会再"星在交点上方"。
   星名改成绝对定位挂在下方，hover 时的 scale() 也只绕星点缩放，星点不位移。 */
.star {
  position: absolute;
  left: 50%;
  top: 46%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
  text-decoration: none;
  color: #dfe6ff;
  white-space: nowrap;
  cursor: pointer;
  transform: translate(-50%, -50%);
}

/* 点击 / 悬停热区：只影响命中，不影响布局与视觉尺寸 */
.star::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
}

.star:focus-visible { outline: none; }
.star:focus-visible::after {
  outline: 1px dashed rgba(190, 215, 255, .8);
  outline-offset: 2px;
}

.star-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 8px 2px rgba(178, 202, 255, .9),
    0 0 24px 7px rgba(96, 134, 255, .42);
  animation: twinkle 5s ease-in-out infinite;
}
.star--sun .star-dot {
  width: 12px;
  height: 12px;
  background: #fffbe8;
  box-shadow:
    0 0 14px 4px rgba(255, 238, 190, .95),
    0 0 48px 16px rgba(126, 156, 255, .5);
  animation-duration: 7s;
}

.star-label {
  /* 星名脱离文档流挂在星点下方：星点圆心 = 节点坐标，标签不再把盒子重心带偏 */
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  letter-spacing: .1em;
  color: rgba(219, 227, 255, .66);
  transition: color .2s ease;
  text-shadow: 0 0 10px rgba(6, 8, 15, .9), 0 1px 3px rgba(6, 8, 15, .9);
  pointer-events: auto;   /* 星名本身也点得开链接 */
}
.star--sun .star-label { font-size: 14px; letter-spacing: .2em; color: rgba(255, 250, 232, .92); }
.star:hover .star-label,
.star:focus-visible .star-label { color: #fff; }
.star:hover .star-dot { animation-play-state: paused; }

.star--dim { color: rgba(190, 202, 240, .45); cursor: default; }
.star--dim .star-dot {
  width: 4px;
  height: 4px;
  background: rgba(200, 214, 255, .6);
  box-shadow: 0 0 6px 1px rgba(150, 176, 255, .3);
  animation-duration: 11s;
}
.star--dim .star-label { color: rgba(190, 202, 240, .36); font-size: 10px; }

/* 被拖拽时的星 */
.star.is-dragging { cursor: grabbing; z-index: 9; }
.star.is-dragging .star-label { color: #fff; }

/* ------------------------------------------------------ 扉页上的字 ------ */

.sky-title {
  position: absolute;
  top: clamp(22px, 4.6vh, 50px);
  left: 0;
  right: 0;
  z-index: 6;
  margin: 0;
  text-align: center;
  font-family: "Songti SC", "Source Han Serif SC", "Noto Serif SC", SimSun, Georgia, serif;
  font-size: clamp(13px, 1.5vw, 15.5px);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: .4em;
  text-indent: .4em;
  color: rgba(232, 238, 255, .86);
  text-shadow: 0 1px 14px rgba(6, 8, 15, .8);
}

.sky-sub {
  position: absolute;
  top: calc(clamp(22px, 4.6vh, 50px) + 30px);
  left: 0;
  right: 0;
  z-index: 6;
  margin: 0;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: .26em;
  text-indent: .26em;
  color: rgba(196, 210, 255, .42);
}

.sky-hint {
  position: absolute;
  right: 22px;
  bottom: 62px;
  z-index: 6;
  margin: 0;
  font-size: 11px;
  letter-spacing: .1em;
  color: rgba(198, 212, 255, .48);
  animation: hint-breathe 5s ease-in-out infinite;
}
@keyframes hint-breathe {
  0%, 100% { opacity: .38; }
  50%      { opacity: .78; }
}

/* 无 JS 时的说明纸条 */
.sky-fallback { margin: 0 auto; max-width: var(--w-text); }

@media (max-width: 760px) {
  .sky { margin: 0 -14px; height: 92vh; height: 92svh; min-height: 500px; }
  .moon { width: 104px; height: 104px; margin-left: -52px; bottom: -28px; }
  .torn { height: 34px; }
  .sky-hint { right: 14px; bottom: 50px; font-size: 10px; }
  .star-label { font-size: 10px; }
  .star--sun .star-label { font-size: 12.5px; }
  .galaxy-name { font-size: 9px; letter-spacing: .1em; margin-top: 7px; }
  /* 窄屏不隐藏流星，只缩短尾巴、少一条，保留一点冲击力 */
  .meteor { --meteor-w: min(56vw, 280px); height: 1.6px; }
  .meteor--3 { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-star, .star-dot, .moon, .meteor, .sky-links line, .sky-hint { animation: none !important; }
  .meteor { display: none; }
  .bg-star { opacity: .55; }
}