/* HomePulse — 共享样式补充层。只用 ui.css 变量 + 本文件自有变量。 */
:root {
  --hp-ok: var(--green-dot);
  --hp-warn: var(--orange-dot);
  --hp-bad: var(--red-dot);
  --hp-idle: var(--gray-dot);
  --hp-link: var(--sep-strong);
  --hp-flow-a: .35;
}

/* ---------- 布局：桌面左拓扑右指标 + 底部时间线 ---------- */
.hp-layout {
  display: grid;
  grid-template-columns: minmax(320px, 5fr) minmax(360px, 7fr);
  gap: 20px;
  align-items: start;
}
.hp-bottom-stack { margin-top: 20px; }

/* ---------- 拓扑 ---------- */
.hp-topo-wrap { position: relative; }
.hp-topo { width: 100%; height: auto; display: block; }
.hp-topo .hp-node circle.hp-node-bg { fill: var(--surface-2); stroke: var(--sep-strong); }
.hp-topo .hp-node text { fill: var(--text); font-size: 10.5px; font-family: var(--font); letter-spacing: 0; }
.hp-topo .hp-node .hp-node-sub { fill: var(--text-3); font-size: 8.5px; }
.hp-topo .hp-node.external circle.hp-node-bg { stroke-dasharray: 3 2; }

.hp-edge { fill: none; stroke: var(--hp-link); stroke-linecap: round; }
.hp-edge.lv0 { stroke-width: 1.2; opacity: .35; }
.hp-edge.lv1 { stroke-width: 1.6; opacity: .55; }
.hp-edge.lv2 { stroke-width: 2.2; opacity: .8; }
.hp-edge.lv3 { stroke-width: 2.8; opacity: 1; }
.hp-edge-flow {
  fill: none; stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 3 9; stroke-dashoffset: 0; opacity: var(--hp-flow-a);
}
.hp-edge.lv0 + .hp-edge-flow, .hp-edge-flow[data-level="0"] { opacity: .12; }
.hp-edge-flow[data-level="1"] { opacity: .3; stroke-dasharray: 2 8; }
.hp-edge-flow[data-level="2"] { opacity: .55; }
.hp-edge-flow[data-level="3"] { opacity: .85; }
@media (prefers-reduced-motion: no-preference) {
  .hp-edge-flow[data-level="1"] { animation: hp-flow 2.6s linear infinite; }
  .hp-edge-flow[data-level="2"] { animation: hp-flow 1.6s linear infinite; }
  .hp-edge-flow[data-level="3"] { animation: hp-flow .9s linear infinite; }
}
@keyframes hp-flow { to { stroke-dashoffset: -24; } }

.hp-topo-legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  padding: 10px 16px; border-top: .5px solid var(--sep);
  font-size: 11.5px; color: var(--text-2);
}
.hp-topo-legend i {
  display: inline-block; width: 18px; height: 0; border-radius: 2px;
  background: var(--sep-strong); margin-right: 5px; vertical-align: 3px;
}
.hp-topo-legend .lg1 i { height: 1.5px; } .hp-topo-legend .lg2 i { height: 2.2px; } .hp-topo-legend .lg3 i { height: 3px; background: var(--accent); }

/* 链路列表（手机 / 色弱回退） */
.hp-links { list-style: none; margin: 0; padding: 0; }
.hp-links .row { grid-template-columns: minmax(0, 1fr) auto; }
.hp-link-lv { font-size: 11.5px; white-space: nowrap; }

/* ---------- 指标磁贴 ---------- */
.hp-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.hp-tile {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 14px 16px 10px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 2px;
  min-width: 0;
  cursor: default;
  transition: box-shadow .25s var(--ease);
}
.hp-tile.click { cursor: pointer; }
.hp-tile.click:hover { box-shadow: var(--shadow), 0 6px 18px -8px rgba(0, 0, 0, .18); }
.hp-tile .hp-tk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); min-width: 0; }
.hp-tile .hp-tk .hp-shape { font-size: 9px; }
.hp-tile .hp-tv {
  font-size: 24px; font-weight: 650; letter-spacing: -.03em; line-height: 1.2;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hp-tile .hp-tv small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.hp-tile .hp-ts { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-tile .hp-tspark { margin-top: 4px; width: 100%; height: 30px; display: block; color: var(--accent); }
.hp-tile.unavailable { opacity: .55; }
.hp-tile.unavailable .hp-tv { color: var(--text-3); font-size: 16px; font-weight: 500; }
.hp-tile.stale { box-shadow: var(--shadow), inset 0 0 0 1.5px var(--orange-dot); }
.hp-tile .hp-reason { font-size: 11px; color: var(--orange); margin-top: 2px; }
.hp-badge-stale {
  font-size: 10px; font-weight: 600; color: var(--orange);
  border: 1px solid var(--orange); border-radius: 99px; padding: 0 6px; margin-left: auto;
}

/* ---------- 时间线 ---------- */
.hp-tl-range { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hp-lanes {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 0;
  position: relative;
}
.hp-lane-label {
  font-size: 12px; color: var(--text-2); padding: 14px 0 14px 18px;
  border-right: .5px solid var(--sep);
  display: flex; align-items: center; gap: 6px;
}
.hp-lane {
  position: relative; min-height: 46px; padding: 8px 14px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.hp-lane + .hp-lane-label, .hp-lane + .hp-lane { border-top: .5px solid var(--sep); }
.hp-lane.pane { overflow-x: auto; scrollbar-width: thin; }

.hp-ev {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2); box-shadow: inset 0 0 0 .5px var(--sep-strong);
  border: 0; font-family: inherit; color: var(--text); cursor: pointer;
  white-space: nowrap; flex: none;
}
.hp-ev:hover { background: var(--accent-soft); }
.hp-ev .hp-shape { font-size: 9px; }
.hp-ev.sev-crit .hp-shape { color: var(--hp-bad); }
.hp-ev.sev-warn .hp-shape, .hp-ev.sev-notice .hp-shape { color: var(--hp-warn); }
.hp-ev.sev-info .hp-shape { color: var(--hp-ok); }
.hp-ev time { color: var(--text-3); font-variant-numeric: tabular-nums; }

.hp-sparklane { width: 100%; height: 44px; display: block; color: var(--accent); }

/* 时间轴刻度 */
.hp-axis {
  grid-column: 2; position: relative; height: 18px; margin-top: 2px;
  border-top: .5px solid var(--sep);
}
.hp-axis span {
  position: absolute; top: 3px; font-size: 10px; color: var(--text-3);
  transform: translateX(-50%); font-variant-numeric: tabular-nums;
}
.hp-axis-label { grid-column: 1; }

/* 泳道定位的事件 */
.hp-ev.abs { position: absolute; transform: translateX(-50%); }
.hp-lane.pane { position: relative; padding-left: 0; padding-right: 0; }
.hp-lane.pane .hp-inner { position: relative; height: 100%; min-height: 30px; }

/* 展开详情 */
.hp-ev-detail { padding: 14px 18px; border-top: .5px solid var(--sep); background: var(--surface-2); }
.hp-ev-detail .hp-kv { display: flex; gap: 14px; padding: 5px 0; font-size: 13px; }
.hp-ev-detail .hp-kv .k { color: var(--text-2); flex: none; width: 72px; }
.hp-ev-detail .hp-kv .v { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Ask 问答 ---------- */
.hp-ask .hp-ask-row { display: flex; gap: 10px; padding: 16px 18px 10px; }
.hp-ask input {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: .5px solid var(--sep-strong);
  border-radius: 999px; padding: 9px 16px; outline: none;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.hp-ask input:focus { border-color: var(--accent); background: var(--surface); }
.hp-ask input::placeholder { color: var(--text-3); }
.hp-ask .hp-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 18px 14px; }
.hp-chip {
  font-size: 12.5px; padding: 4px 12px; border-radius: 999px; border: 0;
  background: var(--track); color: var(--text-2); cursor: pointer; font-family: inherit;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.hp-chip:hover { background: var(--accent-soft); color: var(--text); }
.hp-ans { padding: 4px 18px 18px; }
.hp-ans .hp-q { font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.hp-ans .hp-a { font-size: 14.5px; line-height: 1.65; overflow-wrap: anywhere; }
.hp-ans .hp-a b { font-weight: 600; }
.hp-ans .hp-a .hp-ref {
  display: inline-flex; align-items: center; border: 0; cursor: pointer;
  font-family: inherit; font-size: 11px; padding: 1px 8px; margin: 0 2px;
  border-radius: 99px; background: var(--accent-soft); color: var(--accent);
  vertical-align: 1px; white-space: nowrap;
}
.hp-ans .hp-a .hp-ref:hover { text-decoration: underline; }
.hp-ans .hp-meta { margin-top: 10px; font-size: 11.5px; color: var(--text-3); }
.hp-ans .hp-unverified { color: var(--orange); font-weight: 600; }
.hp-ans .hp-err { color: var(--red); font-size: 13.5px; }
.hp-ans .hp-spin {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--track); border-top-color: var(--accent);
  animation: hp-spin .8s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes hp-spin { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { .hp-ans .hp-spin { animation-duration: 2.4s } }

/* ---------- 状态点 + 形状（色弱友好） ---------- */
.hp-shape { display: inline-block; font-size: 10px; line-height: 1; font-weight: 700; }
.hp-shape.ok { color: var(--hp-ok); }
.hp-shape.warn { color: var(--hp-warn); }
.hp-shape.bad { color: var(--hp-bad); }
.hp-shape.idle { color: var(--hp-idle); }

/* ---------- 响应式 ---------- */
.hp-scrim{position:fixed;inset:0;z-index:40;background:rgba(15,18,32,.22);opacity:0;pointer-events:none;transition:opacity .3s var(--ease)}
.hp-scrim.on{opacity:1;pointer-events:auto}
.hp-sheet.sheet{top:12px;right:12px;bottom:auto;left:auto;width:min(430px,calc(100vw - 24px));max-height:calc(100dvh - 24px);z-index:41;border-radius:var(--radius);transform:translateX(calc(100% + 24px));background:color-mix(in srgb,var(--bgc) 92%,var(--text) 8%);}
.hp-sheet.sheet.on{transform:none}
.hp-sheet.sheet[hidden]{display:none}
.hp-sheet-grip{display:none}
.hp-sheet-h{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:16px 18px 10px;border-bottom:.5px solid var(--sep)}
.hp-sheet-t{margin:0;font-size:17px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hp-sheet-b{overflow:auto;padding:14px 18px max(20px,env(safe-area-inset-bottom));}
.hp-sheet .hp-kv{display:flex;gap:12px;padding:8px 0;font-size:13px;overflow-wrap:anywhere}
.hp-sheet .hp-kv .k{color:var(--text-2);flex:none;width:48px}
.hp-sheet .hp-kv .v{min-width:0;overflow-wrap:anywhere}
.hp-node-detail{white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.6 var(--mono);max-width:100%;}
.hp-node{cursor:pointer}
.hp-node:hover .hp-node-bg,.hp-node:focus .hp-node-bg{stroke:var(--accent)!important;stroke-width:2}
.hp-lane.pane .hp-inner{width:100%;min-width:0;display:flex;flex-wrap:wrap;gap:8px;padding:10px 14px}
.hp-ev.abs{position:static;transform:none;max-width:100%;overflow:hidden;text-overflow:ellipsis}
.hp-axis span:first-child{transform:none}.hp-axis span:last-child{transform:translateX(-100%)}
.hp-topo .hp-node text{font-size:13px}
.hp-edge.lv0{opacity:.7;stroke-width:1.5;stroke:var(--text-2)}
.hp-edge.lv1{opacity:.8;stroke:var(--text-2)}
.hp-topo .hp-node circle.hp-node-bg{stroke:var(--text-3)}
.hp-tile.unavailable{opacity:1}
@media(max-width:719px){
.hp-sheet.sheet.hp-bottom{top:auto;right:0;bottom:0;left:0;width:100%;max-height:82dvh;border-radius:22px 22px 0 0;transform:translateY(105%)}
.hp-sheet.sheet.hp-bottom.on{transform:none}
.hp-sheet-grip{display:flex;justify-content:center;padding:10px 0 4px;touch-action:none}
.hp-grip{width:40px;height:5px;border-radius:3px;background:var(--sep-strong)}
}

@media (max-width: 1024px) {
  .hp-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .hp-layout { grid-template-columns: 1fr; }
}
@media (max-width: 719px) {
  .hp-tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hp-tile { padding: 12px 14px 8px; }
  .hp-tile .hp-tv { font-size: 20px; }
  .hp-tile .hp-tspark { height: 24px; }
  /* 时间线折叠：泳道标签收起，改为堆叠 */
  .hp-lanes { grid-template-columns: 1fr; }
  .hp-lane-label { border-right: 0; padding: 10px 16px 0; align-items: flex-start; }
  .hp-axis, .hp-axis-label { display: none; }
  .hp-lane.pane { overflow-x: hidden; }
  .hp-lane.pane .hp-inner { overflow-x: auto; padding: 0 14px 8px; }
}
