/* ==========================================================================
   tech.css — 首页交互舞台（只由 index.html 加载）
   --------------------------------------------------------------------------
   白底 + 蓝色科技未来风：多层氛围（光晕 / 极光 / 透视地网格 / 能量隧洞 /
   全息齿轮 / 反应堆核心 / 数据导管）+ 玻璃 HUD + 取景框 + 功能节点。
   硬约束（改动前先读 INTERFACES.md §1 / §4 / §8）：
     · 不引用任何远程资源，纯 CSS，无图片；
     · 所有绝对定位元素必须留在视口内 —— .dev/harness-overflow.js 会逐个量
       getBoundingClientRect()，overflow:hidden 的裁剪不算数；
     · 无 JS 时 .stage-nodes 退化成静态网格，节点仍然可点；
     · 文字不通过 CSS content 注入（i18n 断言读 textContent）；
     · prefers-reduced-motion 关掉全部动画与过渡。
   ========================================================================== */

/* ---------- 舞台容器 ---------- */

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 48fr) minmax(0, 52fr);
  align-content: center;
  align-items: center;
  min-height: var(--stage-min);
  overflow: hidden;
  isolation: isolate;
  cursor: grab;
  touch-action: pan-y;
  /* 白底 + 蓝色科技感的分层氛围底 */
  background:
    radial-gradient(112% 76% at 74% 34%, rgba(37, 99, 235, .13), rgba(37, 99, 235, 0) 62%),
    radial-gradient(72% 58% at 94% 4%, rgba(6, 182, 212, .10), rgba(6, 182, 212, 0) 66%),
    radial-gradient(64% 52% at 4% 96%, rgba(124, 58, 237, .07), rgba(124, 58, 237, 0) 68%),
    linear-gradient(180deg, #ffffff 0%, #fbfdff 54%, #f4f9ff 100%);
}

/* 复用 .hero 的字号与节奏，只覆盖纵向留白 */
.stage.hero { padding: 128px 0 96px; }

.stage.is-dragging { cursor: grabbing; }
.stage:focus { outline: none; }
.stage:focus-visible { outline: 2px solid var(--tech-blue); outline-offset: -5px; }

.stage-canvas {
  position: absolute; inset: 0; z-index: 1;
  display: block; width: 100%; height: 100%;
  pointer-events: none;
}

/* 蓝图网格底纹 */
.stage-grid {
  position: absolute; inset: 0; z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--tech-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--tech-grid) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(112% 92% at 72% 40%, #000 26%, transparent 80%);
          mask-image: radial-gradient(112% 92% at 72% 40%, #000 26%, transparent 80%);
}

/* 光晕层：叠在画布之上，给整幕加一层柔和的冷色空气感 */
.stage-aura {
  position: absolute; inset: 0; z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(56% 44% at 70% 47%, rgba(6, 182, 212, .15), rgba(6, 182, 212, 0) 70%),
    radial-gradient(44% 38% at 88% 10%, rgba(37, 99, 235, .13), rgba(37, 99, 235, 0) 72%),
    radial-gradient(38% 34% at 6% 90%, rgba(124, 58, 237, .09), rgba(124, 58, 237, 0) 74%),
    repeating-linear-gradient(180deg, rgba(10, 27, 61, .035) 0 1px, rgba(10, 27, 61, 0) 1px 3px);
}

/* ---------- 取景框（四角括号 / 扫掠光 / 刻度尺） ---------- */

.stage-frame {
  position: absolute; inset: 0; z-index: 5;
  pointer-events: none;
}

.stage-corner {
  position: absolute; width: 18px; height: 18px;
  border: 1px solid var(--tech-hair-2);
}
.stage-corner:nth-child(1) { left: 16px;  top: 16px;    border-right: 0; border-bottom: 0; }
.stage-corner:nth-child(2) { right: 16px; top: 16px;    border-left: 0;  border-bottom: 0; }
.stage-corner:nth-child(3) { left: 16px;  bottom: 16px; border-right: 0; border-top: 0; }
.stage-corner:nth-child(4) { right: 16px; bottom: 16px; border-left: 0;  border-top: 0; }

.stage-scan {
  position: absolute; left: 0; right: 0; top: 0; height: 132px;
  background: linear-gradient(180deg,
    rgba(37, 99, 235, 0) 0%,
    rgba(37, 99, 235, .05) 58%,
    rgba(6, 182, 212, .14) 96%,
    rgba(6, 182, 212, 0) 100%);
  animation: stage-scan-move 9s linear infinite;
}
@keyframes stage-scan-move {
  0%   { transform: translateY(-140px); }
  100% { transform: translateY(1180px); }
}

.stage-ruler {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 12px; height: 9px;
  background:
    repeating-linear-gradient(90deg, rgba(37, 99, 235, .30) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(90deg, rgba(37, 99, 235, .15) 0 1px, transparent 1px 16px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}

/* ---------- 文案栏 ---------- */

.stage-in {
  /* 与导航（.wrap-wide，1120 居中 + gutter 内边距）用同一套几何，
     所以首屏文案的左边界 = 品牌左边界，而不是在 48% 列里居中。 */
  grid-column: 1 / -1;
  width: 100%;
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
  position: relative; z-index: 7; pointer-events: none;
}
/* 文案右缘留出余量，避免压到轨道上的功能节点 */
.stage-in .lead { max-width: 46ch; }
.stage-in a, .stage-in button { pointer-events: auto; }
.stage-in .eyebrow { color: var(--tech-blue-deep); }
.stage-in h1 { text-shadow: 0 1px 0 rgba(255, 255, 255, .8); }
/* 标题第二行：渐变字（只在本浏览器支持 background-clip:text 时启用，否则保留墨色，绝不会变隐形） */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .stage-in h1 em {
    text-shadow: none;
    background-image: var(--tech-grad);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
            color: transparent;
  }
}

.stage-hint {
  margin: 26px 0 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.7;
  color: var(--tech-blue-deep);
  max-width: 52ch;
}
.stage-hint::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tech-cyan);
  margin-right: 9px; vertical-align: 2px;
  box-shadow: 0 0 0 4px rgba(8, 145, 178, .14);
}

/* ---------- 左下角状态行（纯 ASCII，由 hero.js 写入） ---------- */

.stage-status {
  position: absolute; z-index: 6;
  left: var(--gutter); bottom: 24px;
  margin: 0;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em;
  color: var(--muted); opacity: .85;
  pointer-events: none;
}
html:not(.js) .stage-status { display: none; }

/* ---------- 功能节点 ---------- */

.stage-nodes {
  grid-column: 2;
  position: relative; z-index: 4;
  display: flex; flex-wrap: wrap; gap: 10px;
  align-content: center;
  margin: 0;
}

.stage-node {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 100%;
  padding: 7px 14px 7px 12px;
  overflow: hidden;
  border: 1px solid var(--tech-hair-2);
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(244, 249, 255, .78));
  font-family: var(--font-mono); font-size: 12px; line-height: 1;
  color: #1e293b;
  text-decoration: none; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 10px 22px -20px rgba(37, 99, 235, .8);
  -webkit-backdrop-filter: blur(6px) saturate(130%);
          backdrop-filter: blur(6px) saturate(130%);
  transition: border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
/* 扫光：只动 transform，不改变任何布局尺寸 */
.stage-node::after {
  content: ""; position: absolute; inset: 0;
  background: var(--tech-sheen);
  transform: translateX(-132%);
  transition: transform .6s ease;
  pointer-events: none;
}
.stage-node:hover::after, .stage-node:focus-visible::after { transform: translateX(132%); }

.stage-node:hover, .stage-node:focus-visible {
  border-color: var(--tech-blue);
  color: var(--tech-blue-deep);
  box-shadow: var(--tech-glow-sm);
  outline: none;
}

.stage-node-idx {
  font-size: 10px; letter-spacing: .06em;
  color: var(--tech-blue); opacity: .75;
}
.stage-node-id { display: inline-block; }

.stage-node-ring {
  width: 7px; height: 7px; flex: 0 0 auto;
  border: 1px solid var(--tech-line-2);
  border-radius: 50%;
  background: #fff;
  transition: background .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.stage-node.is-lit { border-color: var(--tech-line-2); }
.stage-node.is-lit .stage-node-ring {
  background: var(--tech-blue);
  border-color: var(--tech-blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .14);
}
/* 指针正悬停（或键盘聚焦）在这个节点上：hero.js 会点亮通往它的数据导管 */
.stage-node.is-hot {
  border-color: var(--tech-cyan);
  color: var(--tech-deep);
  box-shadow: 0 0 0 1px rgba(6, 182, 212, .45), 0 16px 32px -20px rgba(6, 182, 212, .85);
}
.stage-node.is-hot .stage-node-ring { background: var(--tech-cyan); border-color: var(--tech-cyan); }

/* JS 起效（桌面宽屏）后节点脱离文档流，由 hero.js 定位到椭圆轨道 */
.stage.is-live .stage-nodes {
  /* 关键：它是 grid 子元素，绝对定位时以「所在网格区」为包含块，
     不写 grid-area 就会被自动放进第 2 列 → 节点整体右移一整列。
     这里让它的网格区横跨整张舞台。 */
  grid-area: 1 / 1 / -1 / -1;
  position: absolute; inset: 0; display: block; margin: 0; pointer-events: none;
}
.stage.is-live .stage-node { position: absolute; left: 0; top: 0; pointer-events: auto; will-change: transform; }

/* ---------- 右上角 HUD ---------- */

.stage-hud {
  position: absolute; z-index: 6;
  top: 24px; right: var(--gutter);
  display: grid; gap: 7px; min-width: 186px;
  padding: 12px 15px 13px;
  border: 1px solid var(--tech-hair-2);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .93), rgba(247, 251, 255, .84));
  -webkit-backdrop-filter: blur(10px) saturate(140%);
          backdrop-filter: blur(10px) saturate(140%);
  box-shadow: var(--tech-glow-sm);
  font-family: var(--font-mono); font-size: 11px; line-height: 1.2;
  color: var(--tech-ink);
  pointer-events: none;
}
/* 两个对角括号，营造仪表盘取景感 */
.stage-hud::before, .stage-hud::after {
  content: ""; position: absolute; width: 10px; height: 10px;
  border: 1px solid var(--tech-blue); opacity: .6;
}
.stage-hud::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.stage-hud::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
html:not(.js) .stage-hud { display: none; }

.hud-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-bottom: 5px; margin-bottom: 1px;
  border-bottom: 1px solid var(--tech-hair);
}
.hud-title { color: var(--tech-blue-deep); letter-spacing: .18em; font-size: 10.5px; }
.hud-pips { display: inline-flex; gap: 3px; }
.hud-pips i {
  width: 14px; height: 3px; border-radius: 2px;
  background: var(--tech-line);
  transition: background .2s ease, box-shadow .2s ease;
}
.hud-pips i.on { background: var(--tech-grad); box-shadow: 0 0 6px rgba(37, 99, 235, .5); }

.hud-row { display: flex; justify-content: space-between; gap: 14px; }
.hud-k { color: #8b93a3; letter-spacing: .14em; }
.hud-v { color: var(--tech-blue-deep); font-variant-numeric: tabular-nums; }
.hud-bar { height: 3px; border-radius: 2px; background: var(--tech-line); overflow: hidden; }
.hud-bar-fill {
  display: block; width: 0; height: 100%;
  background: linear-gradient(90deg, var(--tech-blue), var(--tech-cyan), var(--tech-violet));
  transition: width .12s linear;
}

/* ---------- 窄屏 / 降级 ---------- */

@media (max-width: 979px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    align-content: start;
  }
  .stage.hero { padding: 96px 0 68px; }
  .stage-in { padding-left: var(--gutter); justify-self: stretch; }
  .stage-in .lead { max-width: none; }
  .stage-canvas { opacity: .45; }
  .stage-aura { opacity: .5; }
  /* 窄屏正文压在画布之上：加一层白色径向遮罩保证可读性 */
  .stage-in::before {
    content: ""; position: absolute; inset: -14px -10px; z-index: -1;
    background: radial-gradient(62% 58% at 34% 44%, rgba(255, 255, 255, .94), rgba(255, 255, 255, .6) 58%, rgba(255, 255, 255, 0) 100%);
  }
  .stage-scan { display: none; }
  .stage-status { display: none; }
  .stage-nodes { grid-column: 1; margin-top: 30px; }
  .stage-hint { max-width: none; }
}

@media (max-width: 640px) {
  .stage.hero { padding: 84px 0 60px; }
  /* 窄屏：HUD 退出绝对定位，改成文档流里的状态条，避免压在大标题上 */
  .stage-hud {
    position: static; justify-self: start; width: max-content;
    margin: 16px var(--gutter) 0;
  }
  .stage-node { font-size: 11.5px; padding: 6px 11px 6px 10px; }
  .stage-hud { min-width: 168px; padding: 10px 12px 11px; }
  .stage-ruler { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-node, .stage-node-ring, .hud-bar-fill, .hud-pips i, .stage-node::after { transition: none; }
  .stage-scan { animation: none; opacity: 0; }
}

@media print {
  .stage-canvas, .stage-grid, .stage-aura, .stage-frame, .stage-hud, .stage-status { display: none; }
}
