/* vivi 数据艺术页 · 暗底终端风
   配色变量由 site/palette.js 注入（真源 tools/palette.mjs，改色必须重跑校验）
   字体：系统 mono（macOS 上是 SF Mono）＝参考图的终端质感；中文回落 PingFang SC。
   ⛔ 这里不用她字体库里的展示体：那些是海报字，信息密集页会糊。 */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink-primary);
}

body {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
               "PingFang SC", "Heiti SC", monospace;
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 96px;
}

/* ── 页头 ───────────────────────────────────────────── */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink-line);
  flex-wrap: wrap;
}
.masthead h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.06em;
}
.masthead .meta {
  font-size: 11px;
  color: var(--ink-muted);
}

/* ── 区块 ───────────────────────────────────────────── */
section { margin-top: 64px; }

.sec-head { margin-bottom: 6px; }
.sec-num {
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.14em;
}
.sec-head h2 {
  font-size: 19px;
  font-weight: 600;
  margin: 4px 0 0;
  letter-spacing: 0.01em;
}
.sec-head p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-secondary);
  max-width: 66ch;
  line-height: 1.7;
}
.sec-head p b { color: var(--ink-primary); font-weight: 600; }

/* ── 卡片框（参考图2 的细白描边框）───────────────────── */
.panel {
  border: 1px solid var(--ink-line);
  padding: 20px 22px 18px;
  margin-top: 22px;
  position: relative;
}
.panel-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-title h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}
.panel-title .note { font-size: 11px; color: var(--ink-muted); }

/* ── hero 数字（一个数字就是一张图的场合）───────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--ink-line);
  border: 1px solid var(--ink-line);
  margin-top: 24px;
}
.stat {
  background: var(--surface);
  padding: 16px 18px 14px;
}
.stat .v {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat .v small { font-size: 14px; font-weight: 400; color: var(--ink-secondary); }
.stat .k { font-size: 11px; color: var(--ink-secondary); margin-top: 4px; }
.stat .sub { font-size: 10.5px; color: var(--ink-muted); margin-top: 3px; }

/* ── 筛选器（一行，在图之上；dataviz: filters in one row above）── */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 20px;
  padding-bottom: 4px;
}
.filters .lab {
  font-size: 11px;
  color: var(--ink-muted);
  margin-right: 2px;
  letter-spacing: 0.06em;
}
.chip {
  font: inherit;
  font-size: 11.5px;
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid var(--ink-line);
  padding: 5px 11px;
  cursor: pointer;
  letter-spacing: 0.02em;
  /* 触摸目标 ≥ 视觉尺寸：dataviz 要求 hit target 大于 mark */
  min-height: 28px;
}
.chip:hover { color: var(--ink-primary); border-color: #3a3a3a; }
.chip[aria-pressed="true"] {
  color: var(--surface);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── canvas 容器 ────────────────────────────────────── */
/* 171 列 × 最小 2px 格 ＝ 565px：手机上压不下去了（再压格子就没了）。
   ⛔ 不许让它把整页顶出横向滚动（全站每一屏都跟着歪）：
   只让这一个容器自己横向滚，页面照旧竖着读。 */
.cv-holder { position: relative; width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.cv-holder canvas { display: block; }

/* ── tooltip（值在前、标签在后；用 textContent 填）───── */
.tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: #141414;
  border: 1px solid #333;
  padding: 8px 11px;
  font-size: 11.5px;
  line-height: 1.5;
  max-width: 280px;
  opacity: 0;
  transition: opacity .1s;
}
.tip[data-on="1"] { opacity: 1; }
.tip .t-v { font-size: 14px; font-weight: 600; color: var(--ink-primary); font-variant-numeric: tabular-nums; }
.tip .t-k { color: var(--ink-secondary); }
.tip .t-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.tip .t-key { width: 14px; height: 2px; flex: none; } /* 线形色键，不用填充方块 */

/* ── 图例 ───────────────────────────────────────────── */
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 11px;
  color: var(--ink-secondary);
}
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; flex: none; }
.legend .sw.line { height: 2px; width: 14px; }

/* ── 表格视图（可访问性兜底：tooltip 里的值必须也能不 hover 拿到）── */
details.tbl { margin-top: 16px; }
details.tbl summary {
  font-size: 11px;
  color: var(--ink-muted);
  cursor: pointer;
  letter-spacing: 0.04em;
}
details.tbl summary:hover { color: var(--ink-secondary); }
details.tbl table {
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 11.5px;
  width: 100%;
}
details.tbl th, details.tbl td {
  border-bottom: 1px solid var(--ink-line);
  padding: 5px 10px 5px 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
details.tbl th { color: var(--ink-muted); font-weight: 400; }
details.tbl th:first-child, details.tbl td:first-child { text-align: left; }

/* ── 「怎么读」说明（她看不出颜色含义时的那条 callout）── */
.howto {
  margin-top: 14px;
  padding: 9px 12px;
  border-left: 2px solid var(--accent);
  background: #0e0e0e;
  font-size: 11.5px;
  color: var(--ink-secondary);
  line-height: 1.65;
}

/* ── 点阵网格（参考图2）───────────────────────────── */
.matrix-row { margin-top: 18px; }
.matrix-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--ink-secondary);
  margin-bottom: 7px;
  flex-wrap: wrap;
}
.matrix-head .name { color: var(--ink-primary); font-weight: 600; min-width: 92px; }
.matrix-head .num { color: var(--accent); font-variant-numeric: tabular-nums; }

/* waffle 格子：一个 <i> ＝ 一个真实单位（一个人 / 一场 / 一份问卷）
   ⛔ 别给格子加 border-radius：参考图2 是硬边方块，圆角一缩小就糊成点 */
.wf { display: grid; }
.wf i {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

/* 小多图容器（产品线身份靠标题+直接标签，不靠颜色）*/
.facets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 20px 26px;
  margin-top: 20px;
}
.facet .fname {
  font-size: 11.5px;
  color: var(--ink-primary);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.facet .fname .n { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
.facet .fsub { font-size: 10.5px; color: var(--ink-muted); margin-top: 5px; }

/* ── 页脚 ───────────────────────────────────────────── */
footer {
  margin-top: 80px;
  padding-top: 16px;
  border-top: 1px solid var(--ink-line);
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.8;
}

/* ── 移动端降级 ─────────────────────────────────────── */
@media (max-width: 720px) {
  .wrap { padding: 28px 16px 64px; }
  section { margin-top: 46px; }
  .sec-head h2 { font-size: 16.5px; }
  .stat .v { font-size: 22px; }
  .panel { padding: 16px 14px; }
}

/* 减少动效偏好：粒子过渡直接落位，不做补间 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
