/* ============================================================
   05 · 为什么用中转 / WHY RELAY
   ------------------------------------------------------------
   白底 · 居中标题 + 左右两张对比卡（直连 / WhereRelay 中转）
   + 下方白卡三格点阵数据。
   动画：CSS offset-path 沿 SVG 路径运行数据包（无动画库）
     · 直连失败 2.4s：红点沿虚线走到丢包点后消失，× 处扩散环闪烁
     · 中转流光 2.2s：绿点 + 小拖尾沿短路径持续流动，到达目标服务器
   prefers-reduced-motion：数据包隐藏（静止不可见），其余内容完整可读。
   依赖 base.css token；类名统一 .bt- 前缀
   ============================================================ */

/* ---------- 对比卡容器 ---------- */
.bt-cmp{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px;margin-top:56px}
.bt-card{display:flex;flex-direction:column;min-width:0;overflow:hidden;background:var(--white);border:1px solid var(--line);border-radius:var(--r)}
.bt-card-relay{background:var(--tint);border-color:var(--brand-line)}
.bt-card-hd{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:24px 24px 0}
.bt-card-title{font-family:var(--f-h);font-size:18px;line-height:28px;font-weight:700;letter-spacing:-.01em;color:var(--ink)}
.bt-map-wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:8px 24px 12px}
.bt-map{display:block;width:100%;max-width:360px;height:auto}

/* ---------- SVG 路径图 ---------- */
.bt-path{fill:none;stroke-linecap:round}
.bt-path-fail{stroke:var(--line-2);stroke-width:3;stroke-dasharray:2 7}
.bt-path-direct{stroke:var(--off);stroke-width:3}
.bt-path-backup{stroke:var(--line-2);stroke-width:2;stroke-dasharray:4 6}
.bt-path-good{stroke:var(--brand);stroke-width:4}

.bt-map text{font-family:var(--f);font-size:11px;font-weight:500;fill:var(--ink-3)}
.bt-hop circle{fill:var(--white);stroke:var(--line-2);stroke-width:2}
.bt-node-bg{fill:var(--tint)}
.bt-node-bg-muted{fill:var(--soft)}
.bt-node-dot{fill:var(--brand)}
.bt-node-dot-muted{fill:var(--ink-4)}
.bt-node-lbl{fill:var(--ink-3)}

/* 丢包 / 断线标注 */
.bt-x-bg{fill:#FEF3F2;stroke:#FDDCD9;stroke-width:1}
.bt-x-line{fill:none;stroke:var(--off);stroke-width:2.4;stroke-linecap:round}
.bt-map .bt-x-txt{fill:var(--off);font-weight:600}
.bt-x-ring{fill:none;stroke:var(--off);stroke-width:1.5;opacity:0;transform-box:fill-box;transform-origin:center;animation:bt-x-ring 2.4s ease-out infinite}
.bt-x2 .bt-x-ring{animation-delay:.8s}
@keyframes bt-x-ring{
  0%,50%{opacity:0;transform:scale(.7)}
  54%{opacity:.55;transform:scale(1)}
  86%,100%{opacity:0;transform:scale(2.2)}
}

/* 中转节点：绿色圆 + 脉冲外环 + 盾牌 */
.bt-relay-core{fill:var(--brand)}
.bt-relay-ring{fill:none;stroke:var(--brand);stroke-width:6;opacity:.14;transform-box:fill-box;transform-origin:center;animation:bt-node-pulse 2.2s ease-out infinite}
.bt-relay-shield{fill:none;stroke:#fff;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
@keyframes bt-node-pulse{
  0%,100%{opacity:.12;transform:scale(.94)}
  45%{opacity:.22;transform:scale(1.02)}
}

/* 备用自动切换标注 */
.bt-switch rect{fill:var(--white);stroke:var(--brand-line);stroke-width:1}
.bt-map .bt-switch text{fill:var(--brand);font-size:11px;font-weight:600}

/* 目标服务器到达波纹 */
.bt-arrive-ring{fill:none;stroke:var(--brand);stroke-width:2;opacity:0;transform-box:fill-box;transform-origin:center;animation:bt-arrive 2.2s ease-out infinite}
@keyframes bt-arrive{
  0%,84%{opacity:0;transform:scale(.9)}
  88%{opacity:.5;transform:scale(1)}
  100%{opacity:0;transform:scale(1.7)}
}

/* ---------- 数据包（CSS 动画沿 SVG 路径移动） ---------- */
.bt-pkt{opacity:0}

/* 直连：红点在丢包点（路径 35% 处）消失 */
.bt-pkt-bad{
  fill:var(--off);stroke:#fff;stroke-width:1.5;
  offset-path:path("M36 200 C70 205 64 150 100 150 S128 70 150 92 S196 196 222 160 S236 60 264 44");
  offset-rotate:auto;
  animation:bt-pkt-bad 2.4s cubic-bezier(.55,.05,.85,.5) infinite;
}
@keyframes bt-pkt-bad{
  0%{offset-distance:0%;opacity:0}
  6%{opacity:1}
  48%{offset-distance:34.6%;opacity:1}
  54%{offset-distance:36.6%;opacity:0}
  100%{offset-distance:36.6%;opacity:0}
}

/* 中转：绿点 + 拖尾持续流动，第二组负延迟错开半个周期 */
.bt-pkt-good{
  fill:var(--brand);
  offset-path:path("M36 200 Q90 150 150 120 T264 44");
  offset-rotate:auto;
  animation:bt-pkt-flow 2.2s linear infinite;
}
.bt-pkt-late{animation-delay:-1.1s}
.bt-pkt-tail{
  fill:var(--brand);
  offset-path:path("M36 200 Q90 150 150 120 T264 44");
  offset-rotate:auto;
  animation:bt-pkt-tail 2.2s linear infinite;
  animation-delay:.14s;
}
.bt-pkt-tail-late{animation-delay:-.96s}
@keyframes bt-pkt-flow{
  0%{offset-distance:0%;opacity:0}
  5%{opacity:1}
  94%{opacity:1}
  100%{offset-distance:100%;opacity:0}
}
@keyframes bt-pkt-tail{
  0%{offset-distance:0%;opacity:0}
  6%{opacity:.32}
  94%{opacity:.32}
  100%{offset-distance:100%;opacity:0}
}

/* ---------- 卡底三列数据 ---------- */
.bt-foot{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-top:auto;padding:20px 24px 24px;border-top:1px solid var(--line)}
.bt-card-relay .bt-foot{border-top-color:var(--brand-line)}
.bt-metric{min-width:0}
.bt-metric b{display:block;font-family:var(--f-mono);font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.01em;font-feature-settings:"zero" 1;color:var(--ink);white-space:nowrap}
.bt-metric span{display:block;margin-top:4px;font-size:13px;line-height:20px;color:var(--ink-3)}

/* ---------- 汇总点阵数据卡 ---------- */
.bt-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));margin-top:24px;background:var(--white);border:1px solid var(--line);border-radius:var(--r)}
.bt-stat{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-width:0;padding:32px 24px}
.bt-stat + .bt-stat{border-left:1px solid var(--line)}
.bt-stat .dm{--dm-on:var(--brand);--dm-off:var(--tint-2);display:inline-flex;line-height:0}
.bt-stat .dm svg{display:block;height:54px;width:auto}
.bt-stat .dm .on{fill:var(--dm-on)}
.bt-stat .dm .off{fill:var(--dm-off)}
.bt-stat-lbl{font-size:14px;line-height:24px;color:var(--ink-2)}

/* ---------- 降级：不支持 offset-path 时隐藏运行光点 ---------- */
@supports not (offset-path:path("M0 0")){
  .bt-pkt{display:none}
}

/* ---------- 响应式 ---------- */
@media (max-width:1024px){
  .bt-cmp{gap:20px;margin-top:48px}
  .bt-card-hd{padding:20px 20px 0}
  .bt-map-wrap{padding:4px 20px 8px}
  .bt-map{max-width:330px}
  .bt-foot{padding:18px 20px 20px}
  .bt-metric b{font-size:22px;line-height:30px}
  .bt-stats .dm svg{height:48px}
}

@media (max-width:900px){
  .bt-cmp{grid-template-columns:1fr}
  .bt-map{max-width:380px}
  .bt-map-wrap{padding:12px 24px 16px}
}

@media (max-width:760px){
  .bt-cmp{margin-top:40px}
  .bt-stat{padding:24px 16px;gap:8px}
  .bt-stats .dm svg{height:44px}
  .bt-stat-lbl{font-size:13px;line-height:22px}
}

@media (max-width:600px){
  .bt-card-hd{flex-direction:column;align-items:flex-start;gap:8px;padding:20px 20px 0}
  .bt-card-title{font-size:17px;line-height:26px}
  .bt-map{max-width:100%}
  .bt-foot{padding:16px 20px 20px;gap:12px}
  .bt-metric b{font-size:20px;line-height:28px}
  .bt-stats{grid-template-columns:1fr}
  .bt-stat + .bt-stat{border-left:0;border-top:1px solid var(--line)}
}

@media (max-width:420px){
  .bt-card-hd{padding:18px 16px 0}
  .bt-map-wrap{padding:0 14px 4px}
  .bt-foot{padding:14px 16px 18px;gap:8px}
  .bt-metric b{font-size:19px;line-height:26px}
  .bt-metric span{font-size:12px;line-height:18px}
  .bt-stats .dm svg{height:40px}
}

/* ---------- reduced motion：全部静止 ---------- */
@media (prefers-reduced-motion:reduce){
  .bt-pkt{display:none}
  .bt-x-ring{opacity:0;animation:none!important}
  .bt-relay-ring{opacity:.14;animation:none!important}
  .bt-arrive-ring{opacity:0;animation:none!important}
}
