/* ============================================================
   starmap.css — 魔法星图（Pages/Nonaction/MagicSystem）
   ------------------------------------------------------------
   Comic Style: 视觉（颜色 / 边框 / 阴影 / 圆角）一律由 .cshtml 的
   工具类承担，本文件只保留工具类表达不了的机制：
     · SVG 铺满容器的绝对定位
     · 覆盖层的层叠与鼠标穿透（否则会挡住节点拖拽）
     · details 折叠机制与自绘三角标记
     · 星尘闪烁（CSS 动画，替代原 300 条 d3.transition 链）
     · 由 JS 挂上的状态类与 CSS 变量
     · 响应式尺寸（星图高度用 vh，断点切换）

   ★ 为什么星尘闪烁要写成 CSS 动画 ★
   原实现给每颗背景星跑一条 duration 1000~3000ms 的 d3 过渡，
   过渡结束后在 on('end') 里再起一条 —— 300 条互不相干的链永不停止，
   每个都占着一个 d3 定时器，而视觉效果只是「透明度上下浮动」。
   CSS 动画能做同样的事，走合成器线程、不掉帧、也不占主线程。
   每颗星的周期与相位由 JS 通过 --sm-twinkle-* 变量注入（见 engine）。
   ============================================================ */

/* ---------------- 容器 ---------------- */
.starry-sky-container {
    position: relative;
    width: 100%;
    height: 72vh;
    min-height: 460px;
    margin: 0;
    background: #0f1626;
    border-radius: 0;
    box-shadow: none;   /* 硬阴影由页面的工具类给，这里显式取消圆角与柔光 */
}

/* SVG 必须铺满并压在覆盖层之下 */
#starSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------------- 星尘 ----------------
   闪烁 = 透明度在两个极值之间往复，节奏由变量注入。 */
.sm-star {
    animation: sm-twinkle var(--sm-twinkle-duration, 4s) ease-in-out infinite alternate;
    animation-delay: var(--sm-twinkle-delay, 0s);
}
.sm-star-static { animation: none; }   /* prefers-reduced-motion 下静态呈现 */

@keyframes sm-twinkle {
    from { opacity: 1; }
    to   { opacity: var(--sm-twinkle-min, .2); }
}

/* ---------------- 节点与连线 ----------------
   指针形状属于「机制」，交给这里；放大 / 发光由 d3 与 SVG 属性控制。 */
.sm-node { cursor: grab; }
.sm-node:active { cursor: grabbing; }
.sm-node:focus { outline: none; }
/* 键盘聚焦的可见反馈：focused 节点外圈加一道墨线光环。
   箭头用 offset 而不是描边，避免放大时圆点被"吃掉"一圈。 */
.sm-node:focus-visible .sm-node-circle {
    stroke: #fffef0;
    stroke-width: 2;
    paint-order: stroke;
}
.sm-node-label {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    font-weight: 700;
    pointer-events: none;   /* 标签不吃事件，否则拖拽会从文字上漏掉 */
    user-select: none;
}
.sm-link { stroke-linecap: round; }

/* ---------------- 覆盖层 ----------------
   pointer-events:none 是关键 —— 覆盖层压在 SVG 之上，
   不穿透的话它下面那一片节点永远拖不动。
   交互控件（将来若加按钮）单独把 pointer-events 打开即可。 */
.magic-system-overlay {
    position: relative;
    z-index: 10;
    padding: 14px;
    pointer-events: none;
}
.magic-overlay-card {
    display: inline-block;
    max-width: min(520px, 92%);
    padding: 10px 16px;
    background: #fffef0;
    border: 4px solid #1a1a1a;
    box-shadow: 4px 4px 0 0 rgba(26, 26, 26, 1);
}
.magic-system-overlay h2 {
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: .04em;
    margin: 0 0 .3rem;
    /* JS 注入节点主题色；取值失败时退回墨色，保证始终可读。
       白色 / 近白色节点（核心魔系、光系）在纸白底上不可见，
       故以 color-mix 压向墨色，只保留节点颜色的「色相提示」。 */
    color: color-mix(in srgb, var(--sm-node-color, #1a1a1a) 55%, #1a1a1a);
}
.magic-system-overlay p {
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.7;
    margin: 0;
    color: #4a4a4a;
}
/* 派生关系行：比描述低一档的辅助信息 */
.magic-overlay-meta {
    margin-top: .35rem !important;
    padding-top: .35rem;
    border-top: 2px dashed #1a1a1a;
    font-size: .7rem !important;
    letter-spacing: .02em;
    color: #4a4a4a;
}
/* 未选中任何节点时该行不占位 */
.magic-overlay-meta:empty { display: none; }

/* ---------------- 图例 ---------------- */
.magic-legend-item {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .04em;
    color: #1a1a1a;
}

/* ---------------- 文字版体系清单 ----------------
   details 的折叠机制 + 自绘三角标记（原生 marker 无法对齐风格包的字重） */
.magic-textual-summary {
    display: flex;
    align-items: center;
    cursor: pointer;
    list-style: none;
    padding: .75rem 1rem;
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .06em;
    color: #1a1a1a;
}
.magic-textual-summary::-webkit-details-marker { display: none; }
.magic-textual-summary::after {
    content: '+';
    margin-left: auto;
    font-size: 1rem;
    line-height: 1;
}
.magic-textual[open] .magic-textual-summary::after { content: '\2212'; }  /* − */
.magic-textual[open] .magic-textual-summary {
    border-bottom: 4px solid #1a1a1a;
    background: #facc15;
}
.magic-textual-body { padding: 1rem 1.15rem; }
.magic-glossary { display: grid; gap: .9rem; margin: 0; }
.magic-term {
    display: grid;
    grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
    gap: .6rem 1rem;
    padding-bottom: .9rem;
    border-bottom: 4px dashed #1a1a1a;
}
.magic-term:last-child { border-bottom: 0; padding-bottom: 0; }
.magic-term dt { font-weight: 900; font-size: .82rem; color: #1a1a1a; }
.magic-term dd { margin: 0; font-weight: 700; font-size: .82rem; line-height: 1.75; color: #4a4a4a; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 768px) {
    .starry-sky-container { height: 82vh; }
    .magic-system-overlay h2 { font-size: 1rem; }
    .magic-system-overlay p { font-size: .78rem; }
}
@media (max-width: 480px) {
    .starry-sky-container { height: 78vh; min-height: 380px; }
    .magic-system-overlay { padding: 8px; }
    .magic-system-overlay h2 { font-size: .9rem; }
    .magic-system-overlay p { font-size: .72rem; }
    .magic-term { grid-template-columns: 1fr; gap: .2rem; }
}

/* ---------------- 减少动态效果 ----------------
   这里只关掉「装饰性」的 CSS 动画：星尘闪烁、悬停缩放过渡。
   星图本体（力布局持续模拟 + 缓慢自转）属于内容本身，保留不关；
   模拟器以非零待机热度常驻（starmap.js 的 idleAlpha），自转由 startSpin 驱动。 */
@media (prefers-reduced-motion: reduce) {
    .sm-star { animation: none; }
    .sm-node-circle { transition: none; }
}
