/* 战争卡牌对战 · 动效样式表（fx- 前缀）
   移动类动画用独立变换属性 translate/scale/rotate，避免覆盖元素原有 transform（如 .selected 缩放） */

/* 1. 出牌：卡片飞入战场 */
@keyframes fxPlay {
  0%   { translate: 0 -46px; scale: 1.28; opacity: .35; filter: brightness(1.9); }
  45%  { translate: 0 0;     scale: 1.10; opacity: 1;   filter: brightness(1.4); }
  65%  { translate: 0 0;     scale: .96;                 filter: brightness(1.1); }
  100% { translate: 0 0;     scale: 1;    opacity: 1;   filter: brightness(1); }
}
.fx-play {
  animation: fxPlay .5s cubic-bezier(.22, 1, .36, 1);
  box-shadow: 0 0 24px rgba(230,180,80,.85), 0 0 60px rgba(230,180,80,.4);
  will-change: translate, scale, filter;
}
@keyframes fxRing {
  0%   { transform: translate(-50%, -50%) scale(.2); opacity: .9; }
  100% { transform: translate(-50%, -50%) scale(2.3); opacity: 0; }
}
.fx-ring {
  position: absolute; left: 50%; top: 62%;
  width: 70px; height: 70px; border-radius: 50%;
  border: 3px solid var(--gold);
  box-shadow: 0 0 18px var(--gold), inset 0 0 12px rgba(230,180,80,.6);
  pointer-events: none; z-index: 10;
  animation: fxRing .55s ease-out forwards;
}

/* 2. 攻击：冲撞 + 回弹 */
@keyframes fxAttack {
  0%   { translate: 0 0;                        scale: 1; }
  30%  { translate: var(--fx-lunge, 54px) 0;    scale: 1.12; }
  55%  { translate: calc(var(--fx-lunge, 54px) * .35) 0; scale: 1; }
  100% { translate: 0 0;                        scale: 1; }
}
.fx-attack { animation: fxAttack .5s cubic-bezier(.3, 1.4, .5, 1); will-change: translate, scale; z-index: 20; }
@keyframes fxImpact {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0); filter: brightness(1); }
  30%  { box-shadow: 0 0 24px 8px rgba(255,255,255,.95); filter: brightness(2.1); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); filter: brightness(1); }
}
.fx-impact { animation: fxImpact .4s ease-out; }

/* 3. 受击：抖动 + 红闪 + 飘字 */
@keyframes fxShake {
  0%, 100% { translate: 0 0; }
  20% { translate: -6px 0; }
  40% { translate: 6px 0; }
  60% { translate: -4px 0; }
  80% { translate: 4px 0; }
}
.fx-shake { animation: fxShake .35s ease; }
@keyframes fxHitFlash {
  0%   { filter: brightness(1); }
  25%  { filter: brightness(2.4) saturate(3);
         box-shadow: 0 0 0 3px rgba(224,82,82,.95), 0 0 26px 8px rgba(224,82,82,.85); }
  100% { filter: brightness(1); box-shadow: 0 0 0 0 rgba(224,82,82,0); }
}
.fx-hit { animation: fxHitFlash .5s ease-out; }
@keyframes fxFloatUp {
  0%   { transform: translate(-50%, 0) scale(.6); opacity: 0; }
  15%  { transform: translate(-50%, -12px) scale(1.35); opacity: 1; }
  30%  { transform: translate(-50%, -20px) scale(1); }
  100% { transform: translate(-50%, -64px) scale(1); opacity: 0; }
}
.fx-dmg {
  position: absolute; left: 50%; top: 18%;
  pointer-events: none; z-index: 20;   /* 在随从内部（.minion 自带层叠上下文），不参与全局层级 */
  font: 900 22px/1 system-ui, sans-serif;
  color: var(--red);
  text-shadow: 0 0 6px rgba(0,0,0,.65), 0 0 14px var(--red);
  animation: fxFloatUp .9s ease-out forwards;
  white-space: nowrap;
}

/* 4. 死亡：破碎消散 + 淡出 */
@keyframes fxDie {
  0%   { scale: 1; opacity: 1; filter: none; }
  30%  { scale: 1.15; opacity: 1; filter: brightness(1.7); }
  100% { scale: .15; opacity: 0; rotate: 14deg; filter: blur(10px) brightness(2); }
}
.fx-die { animation: fxDie .6s ease-in forwards; will-change: scale, rotate, filter, opacity; }
@keyframes fxShard {
  0%   { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx, 60px), var(--dy, -30px)) rotate(var(--rot, 180deg)) scale(.15); opacity: 0; }
}
.fx-shard {
  position: fixed;
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--fx-shard-color, #e6b450);
  box-shadow: 0 0 6px var(--fx-shard-color, #e6b450);
  pointer-events: none; z-index: var(--z-fx, 250);   /* 碎片：随从/英雄之上、手牌之下 */
  animation: fxShard .6s ease-out forwards;
}

/* 5. 回合切换：轮到谁谁发光 */
@keyframes fxTurnGlow {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 2px transparent); }
  50%      { filter: brightness(1.18) drop-shadow(0 0 10px var(--gold)); }
}
body.fx-my-turn #myHp,
body.fx-my-turn .hero.mine,
body.fx-my-turn .minion.mine { animation: fxTurnGlow 1.6s ease-in-out infinite; }
body.fx-foe-turn #oppHp,
body.fx-foe-turn .hero.foe,
body.fx-foe-turn .minion.foe { animation: fxTurnGlow 1.6s ease-in-out infinite; }
body.fx-my-turn .minion.foe,
body.fx-my-turn #oppHp { filter: brightness(.82); transition: filter .4s; }
body.fx-foe-turn .minion.mine,
body.fx-foe-turn #myHp  { filter: brightness(.82); transition: filter .4s; }

/* 6. 法力水晶：点亮脉冲 */
@keyframes fxManaPulse {
  0%, 100% { scale: 1;    filter: brightness(1) drop-shadow(0 0 0 transparent); }
  40%      { scale: 1.28; filter: brightness(1.7) drop-shadow(0 0 10px var(--blue)); }
}
.fx-mana { animation: fxManaPulse .6s ease-out; will-change: scale, filter; }

/* 7. 胜负 */
body.fx-win { animation: fxWinGlow 2s ease-in-out 3; }  /* 只闪 3 次，不要一直亮 */
@keyframes fxWinGlow {
  0%, 100% { filter: none; }
  50%      { filter: saturate(1.35) brightness(1.15); }
}
.fx-win-sweep {
  position: fixed; inset: 0; pointer-events: none; z-index: 750;   /* 胜利扫光：盖住结算卡，仍在阻断式浮层之下 */
  background: linear-gradient(115deg, transparent 30%, rgba(230,180,80,.38) 50%, transparent 70%);
  background-size: 300% 100%;
  animation: fxSweep 2.2s ease-in-out both;
}
@keyframes fxSweep {
  0%   { background-position: 130% 0; opacity: 0; }
  25%  { opacity: 1; }
  100% { background-position: -70% 0; opacity: 0; }
}
#win.fx-overlay-in { animation: fxOverlayIn .5s ease-out both; }
@keyframes fxOverlayIn { from { opacity: 0; } to { opacity: 1; } }
.fx-win-text { animation: fxWinText .9s cubic-bezier(.2, 1.4, .4, 1) both; will-change: transform, opacity; }
@keyframes fxWinText {
  0%   { transform: scale(.2) rotate(-8deg); opacity: 0; }
  55%  { transform: scale(1.22) rotate(2deg); opacity: 1; }
  75%  { transform: scale(.95); }
  100% { transform: scale(1); opacity: 1; }
}
body.fx-lose { filter: grayscale(1) brightness(.55) saturate(.7); transition: filter 1.2s ease; }
.fx-lose-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 650;   /* 失败暗角：在结算卡（700）之下，不再把「战败」压黑 */
  background: radial-gradient(ellipse at center, rgba(0,0,0,.12) 0%, rgba(0,0,0,.68) 100%);
  animation: fxVignette 1.2s ease both;
}
@keyframes fxVignette { from { opacity: 0; } to { opacity: 1; } }

/* 8. 卡牌飞行层：抽牌 / 洗入 / 发现（幽灵卡，结束自清理） */
.fx-fly {
  position: fixed;
  top: 0; left: 0;
  margin: 0;
  pointer-events: none;
  z-index: var(--z-fly, 450);   /* 飞牌：压住手牌，仍在浮层之下 */
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}
.fx-fly-card {
  border-radius: 8px;
  background: linear-gradient(160deg, #2b3a4a, #141b24 60%);
  border: 1.5px solid #e6b450;
  box-shadow: 0 0 16px rgba(230,180,80,.4), 0 10px 24px -10px #000;
}
.fx-fly-card::after {
  content: '';
  position: absolute; inset: 4px;
  border-radius: 5px;
  border: 1px solid rgba(230,180,80,.3);
}

/* ===== 手牌已满：抽到的牌被弃置 → 燃烧消散 ===== */
.fx-burn{ border-radius: 10px; }
/* 火焰层：从下往上吞。顶边压一条白热"火线"（跟着高度一起上移），底部是余焰 */
.fx-burn-fire{
  position:absolute; left:-10%; right:-10%; bottom:-6%; height:0;
  background:
    radial-gradient(90% 62% at 50% 106%, rgba(255,176,56,.88), rgba(255,104,24,.45) 55%, rgba(255,40,0,0) 82%);
  filter: blur(2px) saturate(1.4);
  mix-blend-mode: screen;
  border-radius: 18px 18px 55% 55%;
  box-shadow: 0 -4px 18px rgba(255,214,130,.95), 0 -14px 40px rgba(255,140,40,.75), 0 -34px 70px rgba(255,100,20,.4);
  pointer-events: none;
}
/* 焦黑底版：上层卡面被裁掉后露出来的部分 */
.fx-burn-char{ filter: brightness(.12) sepia(1) saturate(.55) contrast(1.25); opacity: .96; }
/* 火线：固定厚度，贴在火焰顶部，跟着一起上移（不随火焰高度变细） */
.fx-burn-edge{
  position:absolute; left:-8%; right:-8%; top:-9px; height:18px;
  background: radial-gradient(55% 120% at 50% 100%, #ffffff 0%, #fff6d8 26%, rgba(255,206,120,.9) 52%, rgba(255,150,50,.45) 74%, rgba(255,110,30,0) 100%);
  filter: blur(2.5px) saturate(1.3);
  mix-blend-mode: screen;
  pointer-events: none;
}
.fx-burn-label{
  position:absolute; left:-20px; right:-20px; bottom:-30px; text-align:center;
  font:700 12px/1.4 "Microsoft YaHei",sans-serif;
  color:#ffb457; letter-spacing:.08em; opacity:0;
  text-shadow:0 2px 8px rgba(0,0,0,.85), 0 0 14px rgba(255,120,40,.6);
}

/* 9. 战吼 / 亡语 粒子特效 */
.fx-particle {
  position: fixed;
  margin: 0;
  pointer-events: none;
  z-index: var(--z-fx, 250);   /* 粒子：随从/英雄之上、手牌之下 */
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}
@keyframes fxParticle {
  0%   { transform: translate(0, 0) rotate(0deg) scale(.3); opacity: 0; }
  18%  { opacity: 1; }
  100% { transform: translate(var(--dx, 0px), var(--dy, -60px)) rotate(var(--rot, 180deg)) scale(var(--scale, .1)); opacity: 0; }
}
.fx-particle.fx-spark {
  border-radius: 50%;
  background: var(--color, #ffd97a);
  box-shadow: 0 0 8px var(--color, #ffd97a), 0 0 16px rgba(255, 215, 122, .45);
  animation: fxParticle var(--dur, .6s) cubic-bezier(.2, .7, .3, 1) forwards;
}
.fx-particle.fx-smoke {
  border-radius: 50%;
  background: radial-gradient(circle, var(--color, #7a5aa0) 0%, rgba(122, 90, 160, 0) 72%);
  filter: blur(3px);
  animation: fxParticle var(--dur, .9s) ease-out forwards;
}
.fx-particle.fx-ash {
  border-radius: 50%;
  background: var(--color, #d8d2c2);
  box-shadow: 0 0 5px var(--color, #d8d2c2);
  animation: fxParticle var(--dur, .85s) ease-in-out forwards;
}
@keyframes fxRingExpand {
  0%   { transform: scale(.18); opacity: .85; }
  100% { transform: scale(1.5); opacity: 0; }
}
.fx-particle.fx-ring {
  border-radius: 50%;
  border: 2px solid var(--ring-color, #e6b450);
  box-shadow: 0 0 26px var(--ring-color, #e6b450), inset 0 0 14px rgba(230, 180, 80, .35);
  animation: fxRingExpand var(--dur, .6s) cubic-bezier(.2, .7, .3, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
  .fx-play, .fx-ring, .fx-attack, .fx-impact, .fx-shake, .fx-hit,
  .fx-dmg, .fx-die, .fx-shard, .fx-mana, .fx-win-sweep, .fx-win-text,
  .fx-lose-vignette, body.fx-win {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  .fx-fly { transition-duration: .01ms !important; }
  .fx-particle { animation-duration: .01ms !important; }
}

/* ===== 召唤落场 ===== */
@keyframes summonIn {
  0%   { transform: translateY(-8px) scale(.30); filter: brightness(2.1) }
  45%  { transform: translateY(0) scale(1.12);   filter: brightness(1.25) }
  70%  { transform: translateY(0) scale(.95);    filter: brightness(1.05) }
  100% { transform: translateY(0) scale(1);      filter: brightness(1) }
}
.minion.summon-in { animation: summonIn .52s cubic-bezier(.18,.9,.3,1.25) both !important; opacity: 1 !important; }

/* ===== V0.2.0 英雄换头像 ===== */
.hero-portrait{ position:relative; overflow:hidden; }
.hero-portrait img{ width:100%; height:100%; object-fit:cover; display:block; }
.hero-portrait.hero-reveal{ animation: heroReveal .78s cubic-bezier(.22,.8,.26,1) both; }
@keyframes heroReveal{
  0%{ clip-path: inset(100% 0 0 0); transform: scale(1.08); filter: brightness(1.7) saturate(1.2); }
  45%{ clip-path: inset(0 0 0 0); transform: scale(1.045); filter: brightness(1.22); }
  70%{ transform: scale(.995); filter: brightness(1.04); }
  100%{ clip-path: inset(0 0 0 0); transform: scale(1); filter: brightness(1); }
}
.hero-shard{ will-change: transform, opacity; }
.hero-swap-layer{ pointer-events:none; }
.war-card-fx{ pointer-events:none; filter: drop-shadow(0 18px 30px rgba(0,0,0,.6)); }

.hero-fly{ will-change: transform, opacity; border-radius: 50%; }
.hero-old{ will-change: opacity, filter; }
