/* ============================================================
 * PLEAT · THE ORGANIC LINE / 形状语言 + 语义动画
 * 视觉：Lygia Clark 折叠平面 · 有机线细缝 · Hilma af Klint 圆弧螺旋
 * 动画：每个 keyframe 对应一个「解构 / 重构」动作，见 motion.js 映射表
 * 精度：统一 spring、transform/opacity 优先、reduced-motion 全量降级
 * ============================================================ */

/* ---------- 排印与语言开关（保留双语层的约束） ---------- */
.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(--glass-strong);
  border: 1px solid var(--stroke); border-radius: 999px;
  box-shadow: var(--hi), 0 2px 8px rgba(22,24,31,.04);
  transition: transform var(--dur-1) var(--spring), box-shadow var(--dur-1) var(--spring), background var(--dur-1) ease;
}
.lang-btn:hover { transform: translateY(-2px); background: var(--glass-strong); border-color: rgba(27,79,216,.30); box-shadow: var(--hi), 0 8px 22px rgba(22,24,31,.08); }
.lang-btn:active { transform: scale(.96); box-shadow: var(--hi); }
.lang-btn[data-current="en"] { background: var(--blue-grad); color: #fff; border-color: rgba(12,40,150,.42); box-shadow: var(--blue-shadow), var(--hi); }
@media (max-width: 640px) {
  .lang-btn { height: 30px; min-width: 40px; padding: 0 9px; font-size: 11px; }
}
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; }

/* ============================================================
 * 一、形状语言：折叠投影 / 有机线 / 圆弧
 * ============================================================ */
/* Hero 构成图带 1° 旋转，包围盒会多出几像素；clip 不创建滚动容器，
   既消除横向溢出又不破坏 land.js 的 3D 跟手 */
html, body { overflow-x: clip; }
.hero { position: relative; }
.hero-grid { position: relative; z-index: 1; }
.hero-organic {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; opacity: .62;
}
.ho-line { vector-effect: non-scaling-stroke; }
.ho-main { opacity: .9; }
.ho-sub { opacity: .55; }
.panel, .flow-rail, .method-card, .feature, .tier, .sub-card,
.fission-card, .bridge, .lex-card, .sub-card {
  box-shadow: var(--hi), var(--shadow);
}
/* 折叠脊：裂变卡左侧不再是一根纯色条，而是一道折痕 + 颜料 */
.fold-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px; z-index: 2;
  background: linear-gradient(180deg, var(--c, var(--accent)), color-mix(in srgb, var(--c, var(--accent)) 45%, var(--paper)));
}
.fold-spine::after {
  content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 1.5px;
  background: var(--line); opacity: .55;
}
.fission-grid { position: relative; }
.fission-head, .fission-sub, .branch, .ai-status { position: relative; z-index: 1; }

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

/* ============================================================
 * 二、融合进程轨道：阶段色随语义变化
 * ============================================================ */
.flow-rail {
  position: relative; margin: 0 auto 26px; padding: 20px 26px 18px;
  border: 1px solid var(--stroke); border-radius: 20px;
  background: var(--glass-strong); overflow: hidden;
  --sem-c: var(--accent);
}
.flow-rail::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--blue-grad);
}
.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, #3D6BFF, #1B4FD8);
  transition: width .9s var(--spring);
}
.flow-progress::after {
  content: ''; position: absolute; right: -5px; top: -4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--sem-c); border: 2px solid rgba(255,255,255,.9); box-shadow: 0 2px 10px rgba(27,79,216,.35);
  transition: background .5s var(--spring);
}
.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-3); color: #fff; border-color: var(--ink); }
.flow-node.active { color: var(--text); }
.flow-node.active b { font-weight: 700; }
/* 当前节点是一段「缺口圆弧」（af Klint 的圆），颜色 = 当前阶段语义色 */
.flow-node.active i {
  background: var(--sem-c); color: #fff; border-color: var(--ink);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--sem-c) 22%, transparent);
  animation: nodePulse 1.8s ease-in-out infinite;
}
@keyframes nodePulse { 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--sem-c) 9%, transparent); } }

/* ---------- 语义解读行：动效在解释什么 ---------- */
.flow-semantic {
  display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 11px 14px;
  border-top: 1px dashed var(--stroke); border-radius: 0 0 10px 10px;
  background: color-mix(in srgb, var(--sem-c, var(--accent)) 5%, transparent);
  color: var(--text-2); font-size: 12px; line-height: 1.65;
  transition: background .5s var(--spring);
}
.sem-glyph {
  flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center;
  color: var(--sem-c, var(--accent));
  border: 1.5px solid color-mix(in srgb, var(--sem-c, var(--accent)) 48%, transparent);
  border-radius: 50%; background: var(--bg);
  animation: glyphIn .5s var(--spring) both;
}
.sem-glyph svg { width: 20px; height: 20px; display: block; }
@keyframes glyphIn { from { opacity: 0; transform: rotate(-45deg) scale(.7); } to { opacity: 1; transform: none; } }
.sem-text { flex: 1; }
.sem-key { flex: 0 0 auto; font: 700 9.5px/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; color: var(--sem-c, var(--accent)); white-space: nowrap; }

/* ---------- AI：颜料从边缘渗透 + 螺旋 orb ---------- */
.flow-ai { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--mauve); }
.flow-ai-orb {
  width: 12px; height: 12px; border-radius: 50%; background: transparent;
  border: 2px solid var(--mauve); border-right-color: transparent;
  animation: orbSpin 1.35s linear infinite;
}
@keyframes orbSpin { to { transform: rotate(360deg); } }
.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), transparent); animation: aiShimmer 1.8s linear infinite; }
@keyframes aiShimmer { from { transform: translateX(-110%); } to { transform: translateX(240%); } }

#fissionGrid.ai-pending .fission-card::after,
#bridgeList.ai-pending .bridge::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; z-index: 3;
  background:
    radial-gradient(95% 125% at -12% 50%, color-mix(in srgb, var(--mauve) 26%, transparent), transparent 68%),
    radial-gradient(95% 125% at 112% 50%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 68%);
  animation: pigment 2.4s ease-in-out infinite alternate;
}
#fissionGrid .fission-card, #bridgeList .bridge { position: relative; }
@keyframes pigment { from { opacity: .22; transform: scale(.95); } to { opacity: .92; transform: scale(1.06); } }
.ai-settle > * { animation: settleIn .7s var(--spring) both; }
@keyframes settleIn { from { filter: saturate(1.45); transform: translateY(-3px); } to { filter: none; transform: none; } }

/* ============================================================
 * 三、语义动画：每个 keyframe 对应一个元素含义
 * ============================================================ */

/* ① 抽卡 —— 从叠合纸堆沿折线抽出、摊成独立平面 */
.cards-row .card-slot { animation: none; position: relative; }
.cards-row .card-slot.unfold {
  animation: unfold var(--dur-4) var(--spring) both;
  animation-delay: var(--d, 0ms); will-change: transform, opacity;
}
@keyframes unfold {
  from { opacity: 0; transform: perspective(1100px) rotateY(-64deg) translateY(22px) scale(.9); transform-origin: 0% 50%; }
  55% { opacity: 1; }
  to { opacity: 1; transform: perspective(1100px) rotateY(0deg) translateY(0) scale(1); transform-origin: 0% 50%; }
}
.cards-row .card-slot.unfold::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: 20px; z-index: 5;
  background: linear-gradient(105deg, transparent 40%, color-mix(in srgb, var(--c, var(--accent)) 42%, transparent) 50%, transparent 60%);
  background-size: 240% 100%; animation: foldGlint 1s var(--spring) both; animation-delay: var(--d, 0ms);
}
@keyframes foldGlint { from { background-position: 130% 0; opacity: 1; } to { background-position: -130% 0; opacity: 0; } }

/* ② 裂变 —— 平面展开、分支从母词中心放射、细线连回母词 */
.fission-card.fission-in {
  animation: planeUnfold .72s var(--spring) both;
  animation-delay: var(--d, 0ms); will-change: transform, opacity;
}
@keyframes planeUnfold {
  from { opacity: 0; transform: perspective(900px) rotateX(-26deg) scaleY(.88); transform-origin: 50% 0; }
  to { opacity: 1; transform: none; }
}
.branch.radiate { animation: radiate .62s var(--spring) both; animation-delay: var(--d, 0ms); transform-origin: 0% 0%; }
@keyframes radiate { from { opacity: 0; transform: scale(.42) translate(-12px, -8px) rotate(-5deg); } to { opacity: 1; transform: none; } }
.inspo.node-in { animation: sporeIn .52s var(--spring) both; animation-delay: var(--d, 0ms); }
@keyframes sporeIn { from { opacity: 0; transform: translate(-9px, -7px) scale(.72); } to { opacity: 1; transform: none; } }
.fission-threads { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.fission-threads .thread {
  fill: none; stroke-width: 1.1; opacity: .5; stroke-dasharray: 800; stroke-dashoffset: 800;
  animation: threadDraw .95s var(--spring) both; animation-delay: var(--d, 0ms);
}
@keyframes threadDraw { to { stroke-dashoffset: 0; } }

/* ③ 三方向 —— 同一个词的三种「看」，三种不同几何变换 */
.mini[data-dir="form"] { animation: dirForm .58s var(--spring) both; }
@keyframes dirForm {
  from { opacity: .2; clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); transform: rotate(-4deg); }
  to { opacity: 1; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); transform: none; }
}
.mini[data-dir="chroma"] { animation: dirChroma .7s var(--spring) both; }
@keyframes dirChroma { from { opacity: .2; filter: saturate(.08) blur(4px); transform: scale(1.06); } to { opacity: 1; filter: none; transform: none; } }
.mini[data-dir="motif"] { animation: dirMotif .56s var(--spring) both; }
@keyframes dirMotif { from { opacity: .2; transform: rotate(-14deg) scale(.7); } to { opacity: 1; transform: none; } }
/* 被选中的方向：强调方式也与方向含义一致 */
.mini.on { border-color: var(--c, var(--accent)) !important; }
.mini.on[data-dir="form"] { box-shadow: 0 0 0 2px var(--c, var(--accent)), 3px 3px 0 var(--fold), var(--hi); }
.mini.on[data-dir="chroma"] { box-shadow: 0 0 0 2px var(--c, var(--accent)), 0 8px 22px color-mix(in srgb, var(--c, var(--accent)) 45%, transparent); }
.mini.on[data-dir="motif"] { box-shadow: 0 0 0 2px var(--c, var(--accent)), 0 0 0 5px color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); }

/* ④ 关联 —— 跨卡有机线，颜色是两张卡维度色的混合 */
.organic-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; overflow: visible; mix-blend-mode: multiply; }
.organic-line {
  fill: none; stroke-width: 2; stroke-linecap: round; opacity: .6;
  stroke-dasharray: 1600; stroke-dashoffset: 1600;
  animation: lineDraw 1.15s var(--spring) both; animation-delay: var(--d, 0ms);
}
@keyframes lineDraw { to { stroke-dashoffset: 0; } }
.organic-node { opacity: 0; animation: nodeFade .55s var(--spring) both; animation-delay: var(--d, 0ms); }
@keyframes nodeFade { from { opacity: 0; transform: scale(.2); } 60% { opacity: 1; transform: scale(1.5); } to { opacity: .85; transform: scale(1); } }
.bridge-thread {
  position: absolute; left: 20px; bottom: 7px; width: calc(100% - 40px); height: 12px;
  opacity: .8; pointer-events: none;
}
.bridge-in { animation: bridgeIn .5s var(--spring) both; animation-delay: var(--d, 0ms); }
@keyframes bridgeIn { from { opacity: 0; transform: translateX(-12px) rotate(-1deg); } to { opacity: 1; transform: none; } }
.bridge:hover { border-color: var(--c, var(--accent)) !important; }
.bridge.on { border-color: var(--c, var(--accent)) !important; background: color-mix(in srgb, var(--c, var(--accent)) 9%, transparent); }

/* ⑤ 融合池 —— 线索带来源色折入，落地折平 */
.pool-chip {
  --c: var(--accent);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  border-color: color-mix(in srgb, var(--c) 38%, transparent);
}
.pool-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.chip-origin { opacity: .55; font-size: 10.5px; }
.pool-chip.new { animation: chipFold .5s var(--spring) both; }
@keyframes chipFold {
  0% { opacity: 0; transform: perspective(500px) rotateX(-78deg) scale(.7); transform-origin: 50% 0; }
  100% { opacity: 1; transform: none; }
}
.soft-swap { animation: softSwap .3s var(--spring) both; }
@keyframes softSwap { from { opacity: .52; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.node-in.quick, .bridge-in.quick, .fission-in.quick, .inspo.quick { animation-duration: .24s; }
.fly-clue {
  position: fixed; z-index: 200; pointer-events: none; white-space: nowrap;
  padding: 7px 12px; border: 1px solid var(--stroke); border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--accent)) 84%, var(--paper)); color: var(--ink);
  font: 700 11.5px/1.2 var(--font);
  box-shadow: var(--hi), var(--shadow-lg);
  display: inline-flex; align-items: center; gap: 7px;
}
.fly-clue::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--accent)); }
/* 三种方向的线索形状也不同：形=斜切四边形 / 色=圆角渐层 / 物=叶形旋转 */
.fly-form { clip-path: polygon(0 0, 100% 0, 96% 100%, 4% 100%); border-radius: 2px; }
.fly-chroma { border-radius: 3px; }
.fly-motif { border-radius: 50% 9px 50% 9px; }
.fly-dot { position: fixed; z-index: 200; width: 9px; height: 9px; border-radius: 50%; pointer-events: none; }

/* ⑥ 重构 —— 铰接平面（Bichos）折叠展开，七项拆解逐片翻开 */
.result-box { position: relative; }
.result-box.reveal { animation: bichoUnfold 1s var(--spring) both; transform-origin: 50% 0; }
@keyframes bichoUnfold {
  0% { opacity: .16; transform: perspective(1400px) rotateX(-42deg) scaleY(.78); clip-path: inset(0 0 64% 0); }
  45% { opacity: .82; clip-path: inset(0 0 22% 0); }
  100% { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}
.result-box.reveal::before {
  content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 4px; z-index: 2;
  background: linear-gradient(90deg, var(--result-c, var(--accent)), var(--accent) 52%, #3D6BFF);
  opacity: 0; animation: barIn .8s var(--spring) .35s both;
}
@keyframes barIn { from { opacity: 0; transform: scaleX(0); transform-origin: 0 50%; } to { opacity: .95; transform: scaleX(1); } }
.result-box.reveal .result-name { animation: nameIn .72s var(--spring) .16s both; }
@keyframes nameIn { from { opacity: 0; transform: translateY(14px) rotate(-1.4deg); letter-spacing: .09em; } to { opacity: 1; transform: none; } }
.bd-in { animation: plateUnfold .6s var(--spring) both; animation-delay: var(--d, 0ms); transform-origin: 50% 0; will-change: transform, opacity; }
@keyframes plateUnfold { from { opacity: 0; transform: perspective(700px) rotateX(-62deg) translateY(-8px); } 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; } }

/* ============================================================
 * 四、移动端 / 降低动态效果
 * ============================================================ */
@media (max-width: 640px) {
  .flow-rail { padding: 16px 14px 14px; }
  .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; }
  .flow-semantic { flex-wrap: wrap; gap: 8px; font-size: 11px; }
  .sem-key { width: 100%; text-align: right; }
  .mobile-bar button { font-size: 11px; }
  .hero-organic { opacity: .38; }
}
@media (prefers-reduced-motion: reduce) {
  .flow-rail *, .flow-rail *::before, .flow-rail *::after,
  .cards-row .card-slot.unfold, .cards-row .card-slot.unfold::after,
  .fission-card.fission-in, .branch.radiate, .inspo.node-in,
  .fission-threads .thread, .mini[data-dir], .organic-line, .organic-node,
  .bridge-in, .pool-chip.new, .result-box.reveal, .result-box.reveal .result-name,
  .bd-in, .art-in, .soft-swap, .flow-state.swap, .sem-glyph,
  .ai-settle > *, .fly-clue, .flow-ai-orb, .flow-ai-bar i,
  #fissionGrid.ai-pending .fission-card::after, #bridgeList.ai-pending .bridge::after {
    animation: none !important; transition: none !important;
    opacity: 1 !important; transform: none !important; filter: none !important;
    clip-path: none !important; stroke-dashoffset: 0 !important;
  }
  .flow-progress { transition: none !important; }
  .hero-organic { display: none; }
}
