/* ============================================================
   Power AI — 能量实验室（技术页专用）
   覆盖两个区块：
   .rh-*  可玩预演（P&ID 能流图 + 控制面板 + 实时计算）
   .sm-*  121 站能量地图（canvas 星座图 + 聚合统计）
   设计 token 一律取 main.css 的 :root 变量，不另立色值体系。
   ============================================================ */

/* ================= 可玩预演 · REHEARSE ================= */

.rh-lab {
  margin-top: 8px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #0B2B45 0%, #0E3D60 60%, #0A4A5E 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 70px rgba(11, 43, 69, 0.28);
  padding: clamp(20px, 3.4vw, 36px);
  position: relative;
  overflow: hidden;
}
.rh-lab::before {
  content: '';
  position: absolute;
  top: -140px; right: -120px;
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(0, 194, 209, 0.16), transparent 65%);
  pointer-events: none;
}

.rh-top {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: clamp(18px, 2.6vw, 30px);
  position: relative;
}

/* ---- P&ID 舞台 ---- */
.rh-stage {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
}
.rh-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.rh-stage-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #7FE9F2;
  text-transform: uppercase;
}
.rh-stage svg { width: 100%; height: auto; display: block; }
.rh-stage-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.16);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}
.rh-stage-foot span { display: inline-flex; align-items: center; gap: 7px; }
.rh-lg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.rh-lg-dot.hot { background: #F59E0B; box-shadow: 0 0 8px rgba(245, 158, 11, 0.7); }
.rh-lg-dot.cold { background: #00C2D1; box-shadow: 0 0 8px rgba(0, 194, 209, 0.7); }
.rh-lg-dot.ink { background: #9FB9CC; }

/* P&ID 管线：底色管 + 流动虚线两层 */
.rh-pipe { stroke-linecap: round; fill: none; }
.rh-pipe.supply { stroke: rgba(245, 158, 11, 0.32); }
.rh-pipe.return { stroke: rgba(0, 194, 209, 0.3); }
.rh-pipe.air { stroke: rgba(0, 194, 209, 0.22); stroke-dasharray: 5 6; stroke-width: 2.5; }
.rh-pipe.elec { stroke: rgba(159, 185, 204, 0.4); stroke-width: 3; }
.rh-flow {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 3 13;
  animation: rhDash linear infinite;
}
.rh-flow.supply { stroke: #FBBF24; }
.rh-flow.return { stroke: #39E6F5; }
.rh-flow.air { stroke: #39E6F5; stroke-width: 2; stroke-dasharray: 2 10; }
.rh-flow.elec { stroke: #D8E6F0; stroke-width: 2; stroke-dasharray: 2 10; }
@keyframes rhDash { to { stroke-dashoffset: -160; } }

/* P&ID 节点 */
.rh-box { fill: rgba(255, 255, 255, 0.07); stroke: rgba(255, 255, 255, 0.22); stroke-width: 1.2; }
.rh-box.hp { fill: rgba(0, 194, 209, 0.1); stroke: rgba(57, 230, 245, 0.55); }
.rh-box.bld { fill: rgba(245, 158, 11, 0.08); stroke: rgba(245, 158, 11, 0.4); }
.rh-ntitle { fill: rgba(255, 255, 255, 0.85); font-size: 12.5px; font-weight: 600; font-family: var(--font-sans); }
.rh-ntitle.lg { font-size: 15px; font-weight: 800; }
.rh-nsub { fill: rgba(255, 255, 255, 0.55); font-size: 11px; font-family: var(--font-mono); }
.rh-nsub.above { font-size: 10.5px; letter-spacing: 0.08em; }
.rh-nval { fill: #FFFFFF; font-size: 13px; font-weight: 700; font-family: var(--font-mono); }
.rh-nval.cop { fill: #39E6F5; font-size: 14px; }
.rh-bld-line { fill: none; stroke: rgba(255, 255, 255, 0.4); stroke-width: 1.6; stroke-linejoin: round; }
.rh-pill { stroke-width: 1; }
.rh-pill.supply { fill: rgba(245, 158, 11, 0.16); stroke: rgba(245, 158, 11, 0.5); }
.rh-pill.return { fill: rgba(0, 194, 209, 0.14); stroke: rgba(0, 194, 209, 0.5); }
.rh-pill-t { fill: #FFFFFF; font-size: 11.5px; font-weight: 700; font-family: var(--font-mono); }

/* ---- 控制面板 ---- */
.rh-panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.rh-panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #7FE9F2;
}
.rh-ctl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.rh-ctl-head label { font-size: 13.5px; font-weight: 600; color: rgba(255, 255, 255, 0.85); }
.rh-ctl-val b {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
}
.rh-ctl-val small {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #7FE9F2;
  margin-left: 4px;
}
.rh-ctl-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.4);
}

/* 滑块（WebKit + Firefox） */
.rh-ctl input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #00C2D1 var(--fill, 50%), rgba(255, 255, 255, 0.18) var(--fill, 50%));
  outline: none;
  cursor: pointer;
}
.rh-ctl input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid #00C2D1;
  box-shadow: 0 0 0 4px rgba(0, 194, 209, 0.18), 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s var(--ease-out);
}
.rh-ctl input[type='range']::-webkit-slider-thumb:hover { transform: scale(1.15); }
.rh-ctl input[type='range']::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid #00C2D1;
  box-shadow: 0 0 0 4px rgba(0, 194, 209, 0.18);
}
.rh-ctl input[type='range']:focus-visible {
  outline: 2px solid #39E6F5;
  outline-offset: 6px;
}

/* 场景选择 */
.rh-scenes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rh-scene {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  transition: border-color 0.25s var(--ease-out), background 0.25s var(--ease-out), color 0.25s var(--ease-out);
}
.rh-scene small { font-family: var(--font-mono); font-size: 10px; color: rgba(255, 255, 255, 0.45); font-weight: 400; }
.rh-scene:hover { border-color: rgba(57, 230, 245, 0.5); color: #FFFFFF; }
.rh-scene.active {
  border-color: #00C2D1;
  background: rgba(0, 194, 209, 0.14);
  color: #FFFFFF;
}
.rh-scene.active small { color: #7FE9F2; }
.rh-scene:focus-visible { outline: 2px solid #39E6F5; outline-offset: 2px; }

/* ---- 预演结果大卡 ---- */
.rh-out {
  margin-top: clamp(18px, 2.6vw, 28px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.rh-metric {
  background: rgba(11, 43, 69, 0.55);
  padding: 18px 16px 14px;
}
.rh-m-num {
  font-family: var(--font-mono);
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 700;
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
}
.rh-m-num.save { color: #34D399; }
.rh-m-unit {
  font-size: 0.38em;
  font-weight: 600;
  color: #7FE9F2;
  margin-left: 5px;
  letter-spacing: 0.04em;
}
.rh-m-label {
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rh-m-note { font-size: 10.5px; color: rgba(255, 255, 255, 0.4); font-weight: 400; }
.rh-foot {
  margin-top: 16px;
  font-size: 12px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.5);
  position: relative;
}

/* ================= 121 站能量地图 · STATION MAP ================= */

.sm-block {
  margin-top: clamp(36px, 5vw, 56px);
  background: var(--bg-pure);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: clamp(20px, 3.2vw, 34px);
}
.sm-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.sm-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--energy-deep);
  margin-bottom: 10px;
}
.sm-title { font-size: clamp(20px, 2.6vw, 27px); font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.sm-desc { margin-top: 8px; font-size: 14px; line-height: 1.8; color: var(--ink-soft); max-width: 640px; }

.sm-stats {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.sm-stat { background: #FAFDFE; padding: 14px 18px; }
.sm-stat .k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.sm-stat .v {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: clamp(20px, 2.2vw, 27px);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.sm-stat .v small { font-size: 0.42em; font-weight: 600; color: var(--energy-deep); margin-left: 4px; }
.sm-stat .v .ok { color: var(--save); }

.sm-viewport {
  margin-top: 18px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(ellipse 90% 80% at 50% 40%, #F4FBFC 0%, #FAFBFD 70%);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.sm-viewport canvas { display: block; width: 100%; min-width: 720px; height: auto; }

/* 站点工况悬浮卡 */
.sm-tip {
  position: absolute;
  z-index: 5;
  min-width: 218px;
  background: var(--bg-pure);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  padding: 13px 15px 11px;
  pointer-events: none;
  font-size: 12.5px;
}
.sm-tip .t-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.sm-tip .t-id { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--ink); letter-spacing: 0.06em; }
.sm-tip .t-st { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; }
.sm-tip .t-st-on { color: var(--save); }
.sm-tip .t-st-high { color: #B45309; }
.sm-tip .t-st-alarm { color: var(--danger); }
.sm-tip .t-st-off { color: var(--ink-faint); }
.sm-tip .t-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 3px 0;
  color: var(--ink-soft);
}
.sm-tip .t-row b { font-family: var(--font-mono); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.sm-tip .t-row b.hot { color: #B45309; }
.sm-tip .t-row b.cold { color: var(--energy-deep); }
.sm-tip .t-row b.save { color: var(--save); }
.sm-tip .t-foot {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--line-strong);
}

.sm-legend {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 12px;
  color: var(--ink-faint);
}
.sm-lg { display: inline-flex; align-items: center; gap: 7px; }
.sm-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sm-dot.on { background: #00C2D1; box-shadow: 0 0 7px rgba(0, 194, 209, 0.7); }
.sm-dot.high { background: #F59E0B; box-shadow: 0 0 7px rgba(245, 158, 11, 0.7); }
.sm-dot.alarm { background: #F43F5E; box-shadow: 0 0 7px rgba(244, 63, 94, 0.7); }
.sm-dot.off { background: #B9C9D6; }
.sm-pulse-line {
  width: 26px; height: 2px;
  background: linear-gradient(90deg, transparent, #00C2D1, transparent);
  display: inline-block;
}

/* 深色叙事卡内的胶囊标签对比度修正（浅底三态规范不变，此处仅适配墨蓝底） */
.rh-lab .tag-sim {
  color: #7FE9F2;
  background: rgba(0, 194, 209, 0.12);
  border-color: rgba(57, 230, 245, 0.35);
}

/* ================= 响应式 ================= */
@media (max-width: 960px) {
  .rh-top { grid-template-columns: 1fr; }
  .rh-out { grid-template-columns: repeat(3, 1fr); }
  .sm-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .rh-out { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .rh-scenes { grid-template-columns: 1fr; }
  .rh-scene { flex-direction: row; justify-content: space-between; padding: 12px 14px; }
}
@media (max-width: 560px) {
  .rh-out { grid-template-columns: 1fr; }
  .sm-stats { grid-template-columns: 1fr 1fr; }
  .sm-head { flex-direction: column; }
}
@media (max-width: 480px) {
  .rh-lab { padding: 16px 12px; }
  .rh-panel { padding: 16px 14px; }
}

/* ================= 动效降级 ================= */
@media (prefers-reduced-motion: reduce) {
  .rh-flow { animation: none; }
}
