/* 共享交互层的结构样式。颜色、字体、圆角通过各方案的 CSS 变量覆盖。 */
:root {
  --rc-pop-bg: #fff;
  --rc-pop-fg: #1d1d1f;
  --rc-pop-muted: #6b6b70;
  --rc-pop-line: rgba(0,0,0,.12);
  --rc-pop-accent: #1f5eff;
  --rc-pop-radius: 12px;
  --rc-pop-shadow: 0 18px 50px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.08);
  --rc-lb-bg: rgba(12,12,14,.94);
  --rc-hl: #ffb020;
}

html { scrollbar-gutter: stable; }
html.lb-lock, html.lb-lock body { overflow: hidden; }

/* ---------- 术语按钮（行内） ---------- */
button[data-term] {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: help; text-decoration: underline dotted; text-decoration-thickness: 1px;
  text-underline-offset: .28em; text-decoration-color: currentColor;
}
button[data-term]:focus-visible { outline: 2px solid var(--rc-pop-accent); outline-offset: 2px; border-radius: 2px; }
button[data-term][aria-expanded="true"] { text-decoration-style: solid; }

/* ---------- 术语浮层 ---------- */
.term-pop {
  position: absolute; z-index: 900; width: min(340px, calc(100vw - 24px));
  background: var(--rc-pop-bg); color: var(--rc-pop-fg);
  border: 1px solid var(--rc-pop-line); border-radius: var(--rc-pop-radius);
  box-shadow: var(--rc-pop-shadow);
  opacity: 0; transform: translateY(4px) scale(.985); transform-origin: top center;
  transition: opacity .14s ease, transform .14s ease;
  font-size: 14px; line-height: 1.7; text-align: left;
}
.term-pop.is-above { transform-origin: bottom center; transform: translateY(-4px) scale(.985); }
.term-pop.is-open { opacity: 1; transform: none; }
.term-pop__body { padding: 14px 16px 14px; }
.term-pop__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.term-pop__title { margin: 0; font-weight: 700; font-size: 15px; line-height: 1.4; }
.term-pop__en { display: block; font-weight: 400; font-size: 12px; color: var(--rc-pop-muted); letter-spacing: .02em; }
.term-pop__close {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center; margin: -4px -6px 0 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--rc-pop-muted); cursor: pointer;
}
.term-pop__close:hover, .term-pop__close:focus-visible { background: var(--rc-pop-line); color: var(--rc-pop-fg); outline: none; }
.term-pop__def { margin: 8px 0 0; }
.term-pop__fig { margin: 12px 0 0; padding: 10px; border: 1px solid var(--rc-pop-line); border-radius: calc(var(--rc-pop-radius) - 4px); }
.term-pop__fig svg { display: block; width: 100%; height: auto; }
.term-pop__fig figcaption { margin-top: 6px; font-size: 11px; color: var(--rc-pop-muted); }
.term-pop__link { display: inline-flex; gap: 6px; align-items: center; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--rc-pop-accent); text-decoration: none; }
.term-pop__link:hover { text-decoration: underline; }

/* ---------- 原图放大 ---------- */
.lb {
  position: fixed; inset: 0; z-index: 1000; display: none; flex-direction: column;
  background: var(--rc-lb-bg); color: #f2f2f2;
}
.lb.is-open { display: flex; animation: lb-in .16s ease; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lb__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 14px; border-bottom: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.lb__cap { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(255,255,255,.82); }
.lb__tools { display: flex; gap: 8px; flex: none; }
.lb__btn {
  font: inherit; font-size: 13px; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-flex; gap: 6px; align-items: center;
}
.lb__btn:hover, .lb__btn:focus-visible { background: rgba(255,255,255,.2); outline: none; }
.lb__btn kbd { font: inherit; font-size: 11px; opacity: .6; }
/* 单元格固定为舞台大小（minmax(0,1fr)），图片的 max-height:100% 才有参照，整图一屏内完整显示 */
.lb__stage { flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 10px; overflow: auto; outline: none; }
.lb__img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lb.is-actual .lb__stage { grid-template: none; place-items: start center; }
.lb.is-actual .lb__img { max-width: none; max-height: none; }
@media (max-width: 640px) {
  .lb__bar { flex-wrap: wrap; }
  .lb__cap { white-space: normal; flex-basis: 100%; }
  .lb__btn[data-lb="open"] { display: none; }
}

[data-zoom] { cursor: zoom-in; }
[data-zoom]:focus-visible { outline: 3px solid var(--rc-pop-accent); outline-offset: 3px; }

/* ---------- 编号联动的共性动效 ---------- */
@keyframes rc-pulse { 0% { box-shadow: 0 0 0 0 var(--rc-hl); } 100% { box-shadow: 0 0 0 10px transparent; } }
[data-pin].pulse { animation: rc-pulse .7s ease-out 1; }
.is-target { animation: rc-target 1.6s ease-out 1; }
@keyframes rc-target { 0%, 30% { background-color: color-mix(in srgb, var(--rc-hl) 22%, transparent); } 100% { background-color: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- 图表标记与引线（三套方案共用结构） ---------- */
.chart { position: relative; width: 100%; }
.chart > img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pin-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.pin-line { stroke: var(--pin, #1f5eff); stroke-width: 1.25; vector-effect: non-scaling-stroke; opacity: .7; transition: opacity .2s, stroke-width .2s; }
.pin-dot {
  position: absolute; width: 11px; height: 11px; transform: translate(-50%, -50%); pointer-events: none;
  border: 2px solid var(--pin, #1f5eff); border-radius: 50%; background: rgba(255,255,255,.55);
  transition: transform .2s, background-color .2s;
}
.pin-marker {
  position: absolute; transform: translate(-50%, -50%); z-index: 2;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: var(--pin, #1f5eff); color: var(--pin-ink, #fff); border: 2px solid var(--pin-ring, #fff);
  font: 700 12px/20px var(--pin-font, system-ui, sans-serif); cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.28); transition: transform .18s, background-color .18s, opacity .18s;
}
.pin-marker:hover { transform: translate(-50%, -50%) scale(1.1); }
.pin-marker:focus-visible { outline: 3px solid var(--rc-hl); outline-offset: 2px; }
.pin-marker.is-active { background: var(--rc-hl); color: #1a1200; transform: translate(-50%, -50%) scale(1.18); }
.pin-dot.is-active { background: var(--rc-hl); transform: translate(-50%, -50%) scale(1.35); border-color: #1a1200; }
.pin-line.is-active { opacity: 1; stroke: var(--rc-hl); stroke-width: 2.5; }
[data-active-pin]:not([data-active-pin=""]) .pin-marker:not(.is-active) { opacity: .5; }
[data-active-pin]:not([data-active-pin=""]) .pin-line:not(.is-active) { opacity: .25; }
.pin-marker.pulse { animation: rc-pulse .7s ease-out 1; }

.pin-ref {
  display: inline-grid; place-items: center; min-width: 1.45em; height: 1.45em; padding: 0 .3em; margin: 0 .2em;
  vertical-align: .08em; border-radius: .73em; border: 1.5px solid var(--pin, #1f5eff);
  background: transparent; color: var(--pin, #1f5eff); font: 700 .74em/1 var(--pin-font, system-ui, sans-serif); cursor: pointer;
  transition: background-color .18s, color .18s;
}
.pin-ref:hover { background: color-mix(in srgb, var(--pin, #1f5eff) 14%, transparent); }
.pin-ref.is-active { background: var(--rc-hl); border-color: var(--rc-hl); color: #1a1200; }
.pin-ref:focus-visible { outline: 2px solid var(--rc-hl); outline-offset: 2px; }
[data-pin-role="note"].is-active { background: color-mix(in srgb, var(--rc-hl) 18%, transparent); }

/* 「待补」统一样式：各方案可覆盖颜色 */
.missing { color: var(--missing, #9a5b00); }
.missing::before { content: "待补 · "; font-weight: 700; }
@media (max-width: 640px) { .pin-marker { min-width: 20px; height: 20px; font-size: 11px; line-height: 16px; padding: 0 4px; } .pin-dot { width: 8px; height: 8px; } }
