/* ============================================================
 * bridge-hud.css · 协作舰桥双态 HUD
 * 闲态：雷达居中，视觉与原 bridge.html 一致
 * 工态：雷达缩左上角小框，主区域让位给赛博实时数据面板
 * 配置全部走 bridge-hud.js 的 window.BRIDGE_HUD_CONFIG
 * ============================================================ */

/* ---- 顶栏强制一行横排；#hudThread 调试串默认隐藏（data-debug=on 才显示） ---- */
.arena .hud { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
.arena .hud #hudThread { display: none; }
.arena .hud[data-debug="on"] #hudThread { display: inline; }

/* ---- 让 .orb 在两态之间可以平滑过渡（空闲态视觉不变） ---- */
.arena .orb-wrap { position: relative; }
.arena .orb {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  transition:
    left var(--hud-move-ms, 600ms) cubic-bezier(.6,.05,.2,1),
    top  var(--hud-move-ms, 600ms) cubic-bezier(.6,.05,.2,1),
    width var(--hud-move-ms, 600ms) cubic-bezier(.6,.05,.2,1),
    transform var(--hud-move-ms, 600ms) cubic-bezier(.6,.05,.2,1);
}

/* ---- 工态：雷达缩进左上角小框 ---- */
.arena.working .orb {
  left: var(--hud-orb-x, 14px);
  top:  var(--hud-orb-y, 14px);
  width: var(--hud-orb-size, 170px);
  transform: none;
  z-index: 6;
}
/* 小雷达里把 bot 节点缩成小点，名字藏掉；ticks/三环/sweep/core 保留识别度 */
.arena.working .orb .nodes .node { width: 14px; height: 14px; }
.arena.working .orb .nodes .node .av {
  width: 10px; height: 10px; border-width: 1px; box-shadow: 0 0 6px rgba(200,16,46,.6);
}
.arena.working .orb .nodes .node .nm { display: none; }
.arena.working .orb .core { inset: 38%; }
.arena.working .orb .core span { font-size: 9px; letter-spacing: 1.5px; text-shadow: 0 0 8px rgba(255,255,255,.6); }

/* 右上操作杆在工态缩到雷达小框正下方、左对齐，别挡 HUD */
.arena.working .stick-dock {
  left: var(--hud-orb-x, 14px); right: auto;
  top: calc(var(--hud-orb-y, 14px) + var(--hud-orb-size, 170px) + 10px);
  transform: scale(.72); transform-origin: top left;
  padding: 6px 6px 5px;
}
.arena.working .stick-dock .stick { width: 30px; height: 62px; }
.arena.working .stick-dock .stick .knob { height: 26px; }
.arena.working .stick-dock .stick.on .knob { top: 30px; }
.arena.working .stick-dock .tip { font-size: 9px; margin-top: 3px; }

/* 工作态：把 hud 栏里超长 modules 文字藏掉（它撑高了 hud 栏），并压扁 stream-wrap，
   让 orb-wrap 拿到足够高度放 HUD 面板。闲态不动。 */
.arena.working .hud #hudThread { display: none; }
.arena.working .stream-wrap { height: 72px; min-height: 72px; margin-bottom: 8px; }
.arena.working .stream-wrap .stream { padding: 6px 10px; gap: 4px; }
.arena.working .stream-wrap .line .bub { padding: 4px 9px; font-size: 11.5px; }

/* ============================================================
 * HUD 数据面板
 * ============================================================ */
.hud-panel {
  position: absolute;
  top: 14px; right: 14px; bottom: 14px;
  left: calc(var(--hud-orb-size, 170px) + var(--hud-orb-x, 14px) + 14px);
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(200,16,46,.22);
  background:
    linear-gradient(180deg, rgba(18,21,27,.86), rgba(8,10,14,.92));
  box-shadow:
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 28px rgba(200,16,46,.10) inset,
    0 12px 40px rgba(0,0,0,.5);
  overflow: hidden;
  z-index: 4;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--hud-move-ms, 600ms) ease, transform var(--hud-move-ms, 600ms) ease;
}
.arena.working .hud-panel { display: flex; opacity: 1; transform: none; }

/* 扫描线（可关） */
.hud-panel.fx-scan::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(53,224,255,.55), transparent);
  animation: hudScan 4.2s linear infinite;
  pointer-events: none;
}
@keyframes hudScan { 0% { top: 0; opacity: 0; } 8% { opacity: 1; } 92% { opacity: 1; } 100% { top: 100%; opacity: 0; } }

/* ---- KPI 排 ---- */
.hud-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 8px;
}
.hud-kpi {
  position: relative;
  padding: 8px 10px 8px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.025);
  overflow: hidden;
}
.hud-kpi .k-lab { font-size: 10.5px; color: #8b909c; letter-spacing: .5px; }
.hud-kpi .k-val {
  font-size: 22px; font-weight: 800; color: #fff; line-height: 1.1;
  font-variant-numeric: tabular-nums; margin-top: 2px;
  text-shadow: 0 0 12px rgba(200,16,46,.35);
}
.hud-kpi .k-sub { font-size: 10.5px; color: #6b7280; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-kpi.is-live .k-val { color: #ff5468; }
.hud-kpi.is-idle .k-val { color: #cfd3dc; }

/* ---- 状态锚点横条：KPI 排下面、事件流/机组上面，大字号填满中间 ---- */
.hud-anchor {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid rgba(200,16,46,.25);
  background: linear-gradient(90deg, rgba(200,16,46,.10), rgba(53,224,255,.05) 60%, rgba(200,16,46,.10));
  font-size: 14px; letter-spacing: 1px;
}
.hud-anchor .a-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff5468; box-shadow: 0 0 10px #ff5468; animation: hudBlink 1.2s infinite; }
.hud-anchor .a-main { color: #fff; font-weight: 800; font-size: 15px; text-shadow: 0 0 14px rgba(200,16,46,.5); }
.hud-anchor .a-sub { color: #8b909c; font-size: 12px; flex: 1; }
.hud-anchor .a-tag { font-size: 11px; padding: 2px 10px; border-radius: 999px; background: rgba(200,16,46,.2); color: #ff9aa8; font-weight: 700; }
.hud-anchor.idle { border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.02); }
.hud-anchor.idle .a-dot { background: #3a3f4a; box-shadow: none; animation: none; }
.hud-anchor.idle .a-main { color: #8b909c; text-shadow: none; }
.hud-anchor.idle .a-tag { background: rgba(255,255,255,.06); color: #8b909c; }

/* ---- 主体：左事件流 / 右机组（吃满面板剩余高度） ---- */
.hud-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0,1fr) 280px;
  gap: 10px;
}
.hud-col {
  display: flex; flex-direction: column; min-height: 0;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.07);
  background: rgba(6,7,10,.55);
}
.hud-col-hd {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px; font-size: 11px; color: #8b909c; letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.hud-col-hd .tx { color: #35e0ff; }
.hud-col-hd .grow { flex: 1; }
.hud-col-hd .st { font-size: 10px; padding: 1px 7px; border-radius: 999px; }
.hud-col-hd .st.live { background: rgba(200,16,46,.18); color: #ff9aa8; }
.hud-col-hd .st.idle { background: rgba(255,255,255,.06); color: #8b909c; }

/* 事件流：贴底生长，空处铺底纹+等待字 */
.hud-feed {
  flex: 1; overflow: auto; padding: 10px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  font-size: 12px; line-height: 1.45;
  position: relative;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 26px);
}
.hud-feed::after {
  content: 'AWAITING EVENT · 等待舰桥指令';
  position: absolute; left: 50%; top: 38%; transform: translate(-50%,-50%);
  font-size: 11px; letter-spacing: 3px; color: rgba(139,144,156,.35);
  pointer-events: none; white-space: nowrap;
}
.hud-feed.has-events::after { content: 'AWAITING NEXT · 等待新事件'; }
.hud-feed .ev {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 8px; border-radius: 7px;
  background: rgba(255,255,255,.025);
  border-left: 2px solid var(--ev-color, #35e0ff);
  animation: evIn .25s ease-out both;
}
@keyframes evIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.hud-feed .ev .t { color: #6b7280; font-size: 10.5px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.hud-feed .ev .who { color: var(--ev-color, #35e0ff); font-weight: 700; flex: 0 0 auto; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-feed .ev .txt { color: #d8dbe2; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-feed .ev.user { --ev-color: #ff5468; }
.hud-feed .ev.bot { --ev-color: #35e0ff; }
.hud-feed .ev.sys  { --ev-color: #ffc857; }
.hud-feed .ev.warn { --ev-color: #ff8a8a; }
.hud-feed .empty {
  color: #6b7280; font-size: 11.5px; text-align: center; padding: 24px 10px;
}
/* 事件流底部状态条：跟在事件流后面，不推到底 */
.hud-feed-foot {
  flex: 0 0 auto;
  padding: 7px 10px; font-size: 10.5px; color: #6b7280;
  border-top: 1px dashed rgba(255,255,255,.07);
  display: flex; justify-content: space-between; align-items: center;
}
.hud-feed-foot .live { color: #ff9aa8; }
.hud-feed-foot .idle { color: #6b7280; }

/* 机组列表：卡均分高度，不挤顶 */
.hud-crew {
  flex: 1; overflow: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  justify-content: space-evenly;
}
.hud-mbr {
  display: grid;
  grid-template-columns: 26px minmax(0,1fr) auto;
  gap: 8px; align-items: center;
  padding: 7px 9px; border-radius: 8px;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.05);
}
.hud-mbr .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #3a3f4a;
  justify-self: center;
}
.hud-mbr.run .dot { background: #ff5468; box-shadow: 0 0 8px #ff5468; animation: hudBlink 1.2s infinite; }
.hud-mbr.onduty .dot { background: #35e0ff; box-shadow: 0 0 8px #35e0ff; }
.hud-mbr.idle .dot { background: #3a3f4a; }
@keyframes hudBlink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.hud-mbr .mid .nm { font-size: 12px; font-weight: 700; color: #e7e9ee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-mbr .mid .id-sub { font-size: 10px; color: #6b7280; margin-top: 1px; font-family: ui-monospace, monospace; }
.hud-mbr .mid .doing { font-size: 10.5px; color: #8b909c; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-mbr .mid .prog { font-size: 10.5px; color: #9be9ff; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-mbr .sttag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,.06); color: #8b909c; }
.hud-mbr.run .sttag { background: rgba(200,16,46,.18); color: #ff9aa8; }
.hud-mbr.onduty .sttag { background: rgba(53,224,255,.12); color: #9be9ff; }

/* 数据缺席占位 */
.hud-na { color: #6b7280; font-size: 11px; font-style: italic; }

/* 窄屏：HUD 面板让宽，字和格子收到自己的框里 */
@media (max-width: 1180px) {
  .hud-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .hud-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud-anchor { flex-wrap: wrap; min-width: 0; }
  .hud-anchor .a-main, .hud-anchor .a-sub { min-width: 0; overflow-wrap: anywhere; }
  .hud-feed::after { white-space: normal; letter-spacing: 1px; max-width: 92%; text-align: center; }
  .hud-panel { min-width: 0; max-width: 100%; }
}
