/*
 * 包依赖图实验页。
 *
 * 基础外壳（token、排版、卡片、按钮、读数、oracle 列表、证据边界、表格、页脚）
 * 由 study-lab-shell.css 统一提供，本文件只剩这一页的表单、图表、3D 场景和
 * 联动/缩放/排序控件。数据色的验证记录见 code-mode-evidence-lab.css 的文件头：
 * 分类色 --brand / --signal 在两种模式下六项检查全过；状态色的绿红对在色盲下
 * 无法靠色相区分，所以状态一律带字形和文字标签。
 */

#graph-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
}

#graph-form label { display: flex; min-width: 220px; flex: 1 1 220px; flex-direction: column; gap: 6px; }
#graph-form label > span { font-weight: 700; font-size: 0.9rem; }
#graph-form small { color: var(--muted); font-size: 0.78rem; }

select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-strong);
}

.scatter-scroll, .bar-scroll, .table-scroll {
  overflow-x: auto;
  /* 滚到头就停，不把横向滑动连带成整页滚动。 */
  overscroll-behavior-x: contain;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.scatter-scroll, .bar-scroll { padding: 14px; }
/*
 * 图宽由脚本按容器算出并写进 viewBox，所以缩放恒为 1，SVG 里的字号就是屏幕上的
 * 字号。这里不设 min-width：设了只会在窄屏强制出现一条本不需要的横向滚动条。
 * 宽度下限由脚本负责（760，保证坐标轴标签不互相压住），到不了才滚动。
 */
.scatter-scroll svg, .bar-scroll svg { display: block; width: 100%; }

.axis, .axis-title, .bar-label, .bar-value, .bar-degree, .point-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.point-label { fill: var(--ink); font-size: 14px; font-weight: 750; }
.bar-value { fill: var(--ink); font-weight: 750; }
.bar-degree { fill: var(--brand); font-weight: 750; }

/*
 * 点的几何（cx/cy/r）由脚本的键控补间驱动：CSS transition 会和补间叠加成二次
 * 缓动，所以这里不给几何属性挂 transition。悬停反馈改用描边加粗表达。
 */
.point {
  fill: color-mix(in srgb, var(--brand) 55%, transparent);
  stroke: var(--brand);
  stroke-width: 2;
}

/* 枢纽只是同一序列里的一个状态，不是第二个序列；形状加粗描边，名字仍由标签给出。 */
.point.is-hub { fill: var(--signal); stroke: var(--signal); }
.point:hover { stroke-width: 3.5; }

.bar {
  fill: color-mix(in srgb, var(--brand) 26%, transparent);
  stroke: var(--brand);
}

.bar.is-hub { fill: color-mix(in srgb, var(--signal) 26%, transparent); stroke: var(--signal); }

/*
 * 联动高亮：指针停在散点、柱或表格行的任何一处，三处同时亮起。用 --signal
 * 而不是新的颜色——它已经在「枢纽」语义里出现过，这里复用同一个强调通道。
 */
tr.is-linked td { background: color-mix(in srgb, var(--signal) 14%, transparent); }
.point.is-linked { stroke-width: 3.5; fill: color-mix(in srgb, var(--signal) 45%, transparent); }
.bar.is-linked { stroke-width: 3px; }

/* 参数变化时新建的标记淡入一次；既有标记的位置移动走脚本补间，不经这里。 */
@keyframes mark-enter { from { opacity: 0; } }
.is-entering { animation: mark-enter var(--dur-enter, 200ms) ease-out; }

/*
 * 自绘数值提示。原生 <title> 延迟约一秒且触屏基本不可用；提示是 fixed 定位的
 * 便签，pointer-events 关掉避免遮挡指针路径，信息本体仍在表格里逐行可查。
 */
.plot-tooltip {
  position: fixed;
  z-index: 30;
  max-width: 300px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: var(--shadow-md);
  font-family: var(--mono);
  font-size: var(--text-xs, 0.78rem);
  line-height: 1.5;
  pointer-events: none;
}

.plot-tooltip[hidden] { display: none; }

/* 排序表头：按钮继承表头的 mono 小字风格，激活列加品牌色和方向箭头。 */
thead th button.sort-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

th[aria-sort]:not([aria-sort="none"]) { color: var(--brand); }
thead th button.sort-key:hover { color: var(--brand); }
th[aria-sort="ascending"] button.sort-key::after { content: "▲"; font-size: 9px; }
th[aria-sort="descending"] button.sort-key::after { content: "▼"; font-size: 9px; }

/* 缩放控件组：紧凑版按钮，键盘与触屏的缩放等价物。 */
.zoom-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.button.button-compact {
  min-height: 34px;
  padding: 6px 13px;
  border-color: var(--line-strong);
  color: var(--ink);
  background: color-mix(in srgb, var(--surface-strong) 65%, transparent);
  font-weight: 700;
  font-size: 0.85rem;
}

.scatter-scroll svg.is-magnified { cursor: grab; }
.scatter-scroll svg.is-panning { cursor: grabbing; user-select: none; }

.evidence-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.evidence-grid > * { min-width: 0; margin-top: 20px; }

@media (max-width: 1080px) {
  .hero-panel, .evidence-grid, .boundary-columns { grid-template-columns: minmax(0, 1fr); }
}

/* 进场淡入与按钮过渡都只是动效，去掉不损失信息；补间在脚本里自行尊重偏好。 */
@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
  .is-entering { animation: none; }
}

@media (forced-colors: active) {
  .card, .hero-panel, .scatter-scroll, .bar-scroll, .table-scroll { border: 1px solid CanvasText; }
  .button, select { border: 1px solid ButtonText; }
  .plot-tooltip { border: 1px solid CanvasText; }
}

/*
 * 四个角上的包承载本页结论（最大的包不是最被依赖的包），所以它们比其他 215 个点
 * 多一个圆环和一条引导线。219 个点里找一个 7px 的点做不到，加了环就做得到。
 * 环和线都不编码数值，去掉后图仍然完整。
 */
.point-ring {
  fill: none;
  stroke: var(--signal);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.point-leader {
  stroke: var(--signal);
  stroke-width: 1.25;
}

/*
 * 3D 场景。默认不启动，所以这里的样式在按钮点下之前都不影响布局。
 * 场景不承载精确数值——数值在散点图和表格里，那两个都不需要先交互。
 */
.scene-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--space-2xs);
  margin: var(--space-sm) 0 0;
}

.scene-legend > div {
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.scene-legend dt {
  margin: 0 0 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--text-2xs);
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scene-legend dd { margin: 0; font-size: var(--text-sm); }

.scene-launch { margin-top: var(--space-sm); }

.scene-launch-note {
  margin: var(--space-2xs) 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.scene-stage { margin-top: var(--space-sm); position: relative; }

/*
 * model-viewer 式锚定标签：按钮钉在分组柱顶的投影坐标上，
 * 每帧由 onFrame 写 left/top；层本身不接指针，只有按钮可点。
 */
.dsh3d-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.dsh3d-hotspot {
  pointer-events: auto;
  position: absolute;
  transform: translate(-50%, -100%);
  font: inherit;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.dsh3d-hotspot:hover { border-color: var(--brand); }
.dsh3d-hotspot:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

#scene-canvas {
  display: block;
  width: 100%;
  height: clamp(320px, 46vh, 560px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
  cursor: grab;
  touch-action: none;
}

#scene-canvas:active { cursor: grabbing; }

.scene-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs);
  margin-top: var(--space-xs);
}

.scene-toggle {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: var(--text-sm);
}

#scene-spin[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); }

@media (forced-colors: active) {
  #scene-canvas { border: 1px solid CanvasText; }
}

/* 正文术语联动：说明文字里的包名按钮，视觉上像链接但可聚焦。 */
.term-ref {
  font: inherit;
  padding: 0;
  border: none;
  background: none;
  color: var(--vp-c-brand-1, #3aa2ff);
  text-decoration: underline dotted;
  cursor: pointer;
}
