/* ============================================================
 * PLEAT · 双语开关 / 融合进程 / 过渡动画
 * 与 styles.css 共用变量，深浅主题与构成主义视觉同源
 * ============================================================ */

/* 英文文案更长，导航统计与通道胶囊不折行 */
.nav-stat, #aiPill { white-space: nowrap; }
@media (max-width: 640px) { #aiPill { display: none; } }

/* ---------- 语言切换按钮 ---------- */
.lang-btn {
  flex: 0 0 auto; height: 34px; min-width: 46px; padding: 0 12px;
  font: 700 12px/1 var(--font-display); letter-spacing: .08em;
  color: var(--text); background: var(--bg);
  border: 1.5px solid var(--text); border-radius: 8px;
  box-shadow: 3px 3px 0 var(--text);
  transition: transform .18s var(--spring), box-shadow .18s var(--spring), background .18s ease;
}
.lang-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--text); background: var(--gold); }
.lang-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--text); }
.lang-btn[data-current="en"] { background: var(--accent); color: #fff; }
.lang-btn[data-current="en"]:hover { background: var(--accent); }
@media (max-width: 640px) {
  .lang-btn { height: 30px; min-width: 40px; padding: 0 9px; font-size: 11px; box-shadow: 2px 2px 0 var(--text); }
}

/* 英文模式下收紧标题字距，更贴近 Space Grotesk 的构成主义气质 */
html[data-lang="en"] h1, html[data-lang="en"] h2, html[data-lang="en"] .result-name { letter-spacing: -.042em; }
html[data-lang="en"] .hero-lede, html[data-lang="en"] .sec-head p { max-width: 62ch; }

/* ---------- 融合进程轨道 ---------- */
.flow-rail {
  position: relative; margin: 0 auto 26px; padding: 20px 26px 22px;
  border: 1.5px solid var(--text); border-radius: var(--radius-sm);
  background: var(--glass-strong); box-shadow: 5px 5px 0 var(--text);
  overflow: hidden;
}
.flow-rail::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--accent);
}
.flow-head { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; margin-bottom: 20px; }
.flow-kicker { font: 700 11px/1 var(--font-display); letter-spacing: .2em; text-transform: uppercase; color: var(--text-3); }
.flow-state { font-size: 12.5px; font-weight: 550; color: var(--text-2); text-align: right; }
.flow-state.swap { animation: flowText .44s var(--spring) both; }
@keyframes flowText {
  from { opacity: 0; transform: translateY(6px); filter: blur(3px); }
  to   { opacity: 1; transform: none; filter: none; }
}
.flow-track { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.flow-line { position: absolute; left: 8%; right: 8%; top: 15px; height: 2px; background: var(--stroke); overflow: hidden; }
.flow-progress {
  position: absolute; left: 0; top: 0; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--gold));
  transition: width .9s var(--spring);
}
.flow-progress::after {
  content: ''; position: absolute; right: -5px; top: -4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent-2); border: 1.5px solid var(--text);
}
.flow-rail.running .flow-line::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 32%; left: -32%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.9), transparent);
  animation: flowSweep 2.6s linear infinite;
}
@keyframes flowSweep { to { left: 105%; } }
.flow-node {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-3); transition: color .4s ease;
}
.flow-node i {
  width: 30px; height: 30px; display: grid; place-items: center; font-style: normal;
  font: 700 10px/1 var(--font-display); letter-spacing: .02em;
  border: 1.5px solid var(--stroke); border-radius: 50%; background: var(--bg); color: var(--text-3);
  transition: background .45s var(--spring), color .45s ease, border-color .45s ease, box-shadow .45s ease;
}
.flow-node b { font-weight: 600; }
.flow-node.done { color: var(--text-2); }
.flow-node.done i { background: var(--accent); color: #fff; border-color: var(--text); }
.flow-node.active { color: var(--text); }
.flow-node.active b { font-weight: 700; }
.flow-node.active i {
  background: var(--gold); color: var(--text); border-color: var(--text);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--gold) 34%, transparent);
  animation: nodePulse 1.7s ease-in-out infinite;
}
@keyframes nodePulse { 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--gold) 12%, transparent); } }

.flow-ai {
  display: flex; align-items: center; gap: 10px; margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed var(--stroke); font-size: 12px; font-weight: 600; color: var(--accent);
}
.flow-ai-orb { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: orbPulse 1.25s ease-in-out infinite; }
@keyframes orbPulse { 50% { transform: scale(1.55); opacity: .55; } }
.flow-ai-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--stroke-soft); overflow: hidden; }
.flow-ai-bar i {
  display: block; height: 100%; width: 46%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-3), transparent);
  animation: aiShimmer 1.6s linear infinite;
}
@keyframes aiShimmer { from { transform: translateX(-110%); } to { transform: translateX(240%); } }

/* ---------- AI 剖析期间的流光骨架 ---------- */
#fissionGrid.ai-pending .fission-card::after,
#bridgeList.ai-pending .bridge::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(105deg, transparent 32%, color-mix(in srgb, var(--accent) 13%, transparent) 48%, transparent 64%);
  background-size: 230% 100%; animation: aiSweep 2s linear infinite;
}
#fissionGrid .fission-card, #bridgeList .bridge { position: relative; }
@keyframes aiSweep { from { background-position: 130% 0; } to { background-position: -130% 0; } }

/* ---------- DOM 重绘的软过渡 ---------- */
.soft-swap { animation: softSwap .3s var(--spring) both; }
@keyframes softSwap { from { opacity: .52; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.node-in { animation: nodeIn .52s var(--spring) both; animation-delay: var(--d, 0ms); }
.node-in.quick, .bridge-in.quick { animation-duration: .24s; }
@keyframes nodeIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.bridge-in { animation: bridgeIn .5s var(--spring) both; animation-delay: var(--d, 0ms); }
@keyframes bridgeIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
.pool-chip.new { animation: chipPop .48s var(--spring) both; }
@keyframes chipPop {
  0%   { opacity: 0; transform: translateY(-12px) scale(.62); }
  62%  { opacity: 1; transform: translateY(0) scale(1.06); }
  100% { transform: none; }
}

/* ---------- 结果揭幕 ---------- */
.result-box.reveal { animation: resultUnfold .9s var(--spring) both; }
@keyframes resultUnfold { from { clip-path: inset(0 100% 0 0); opacity: .35; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
.result-box.reveal .result-name { animation: nameIn .72s var(--spring) .16s both; }
@keyframes nameIn { from { opacity: 0; transform: translateY(14px); letter-spacing: .09em; } to { opacity: 1; transform: none; } }
.bd-in { animation: bdIn .5s var(--spring) both; animation-delay: var(--d, 0ms); }
@keyframes bdIn { from { opacity: 0; transform: translateY(11px); } to { opacity: 1; transform: none; } }
.art-in { animation: artIn .72s var(--spring) both; }
@keyframes artIn { from { opacity: 0; filter: blur(9px); transform: scale(1.025); } to { opacity: 1; filter: none; transform: none; } }

/* ---------- 飞入的线索与融合色点 ---------- */
.fly-clue {
  position: fixed; z-index: 200; pointer-events: none; white-space: nowrap;
  padding: 6px 12px; border: 1.5px solid var(--text); border-radius: 8px;
  background: var(--gold); color: var(--text); font: 700 11.5px/1.2 var(--font);
  box-shadow: 3px 3px 0 var(--text);
}
.fly-dot { position: fixed; z-index: 200; width: 9px; height: 9px; border-radius: 50%; pointer-events: none; }

/* ---------- 词库双语说明 ---------- */
.lex-source-note {
  margin-top: 16px; padding: 10px 14px; border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-size: 12px; line-height: 1.6; color: var(--text-2);
}

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .flow-rail { padding: 16px 14px 18px; box-shadow: 3px 3px 0 var(--text); }
  .flow-head { flex-direction: column; align-items: flex-start; gap: 7px; margin-bottom: 16px; }
  .flow-state { text-align: left; font-size: 11.5px; }
  .flow-node b { font-size: 10.5px; }
  .flow-node i { width: 26px; height: 26px; }
  .flow-line { top: 13px; }
  .mobile-bar button { font-size: 11px; }
}

/* ---------- 降低动态效果偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .flow-rail *, .flow-rail *::before, .flow-rail *::after,
  .node-in, .bridge-in, .pool-chip.new, .result-box.reveal, .bd-in, .art-in,
  .soft-swap, .flow-state.swap, .result-box.reveal .result-name,
  #fissionGrid.ai-pending .fission-card::after, #bridgeList.ai-pending .bridge::after {
    animation: none !important; transition: none !important;
  }
  .flow-progress { transition: none !important; }
}
