/* ==========================================================================
   ANIMATIONS.CSS — Анимации выпадов, полёта карт/снарядов и раскола при гибели
   ========================================================================== */

/* ==========================================================================
     AUTHENTIC "CHRONICLES OF AETHERIUM" CARD DESIGN & SMOOTH ANIMATIONS
     ========================================================================== */
  .am-card {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease, border-color 0.25s ease;
    border: 2px solid #b5893d;
    box-shadow: 0 4px 10px rgba(0,0,0,0.75), inset 0 0 0 1px rgba(255, 235, 190, 0.18);
    overflow: visible;
  }

  .flying-card-actor {
    position: fixed;
    z-index: 920;
    pointer-events: none;
    perspective: 1000px;
    transition:
      left 0.78s cubic-bezier(0.22, 1, 0.36, 1),
      top 0.78s cubic-bezier(0.22, 1, 0.36, 1),
      width 0.78s cubic-bezier(0.22, 1, 0.36, 1),
      height 0.78s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.78s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.35s ease;
  }

  .flying-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.68s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .flying-card-inner.flipped-back {
    transform: rotateY(180deg);
  }

  .flying-face-front, .flying-face-back {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 8px;
  }

  .flying-face-back {
    transform: rotateY(180deg);
    background: radial-gradient(circle at 50% 50%, #6e4823 0%, #382310 58%, #1c1108 100%);
    border: 2px solid var(--border-gold-bright);
    box-shadow: 0 10px 28px rgba(0,0,0,0.9), inset 0 0 0 3px rgba(242, 202, 116, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .flying-face-back::before {
    content: '';
    position: absolute;
    inset: 7px;
    border: 1.5px dashed rgba(242, 202, 116, 0.55);
    border-radius: 5px;
  }

  .flying-spell-banner {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #2b1d10 0%, #5c3d1e 50%, #2b1d10 100%);
    border: 1.5px solid var(--border-gold-bright);
    color: #fff2c2;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 12px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,0,0,0.9);
    font-family: 'Segoe UI', Tahoma, sans-serif;
  }

  /* Анимация вертикального раскола пополам при гибели существа */
  .split-death-wrapper {
    position: absolute;
    inset: 4px;
    pointer-events: none;
    z-index: 60;
  }

  .split-half {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .split-half.left-half {
    clip-path: polygon(0% 0%, 51% 0%, 46% 25%, 54% 50%, 47% 75%, 52% 100%, 0% 100%);
    animation: splitLeftFall 0.92s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transform-origin: bottom left;
  }

  .split-half.right-half {
    clip-path: polygon(51% 0%, 100% 0%, 100% 100%, 52% 100%, 47% 75%, 54% 50%, 46% 25%);
    animation: splitRightFall 0.92s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transform-origin: bottom right;
  }

  .vertical-crack-line {
    position: absolute;
    top: -4%;
    bottom: -4%;
    left: 50%;
    width: 5px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, transparent 0%, #fffbe0 20%, #ff7b29 50%, #fffbe0 80%, transparent 100%);
    box-shadow: 0 0 18px #ff5126, 0 0 30px #ffd166;
    z-index: 65;
    animation: crackFlashFade 0.55s ease-out forwards;
  }

  @keyframes crackFlashFade {
    0% { opacity: 1; transform: translateX(-50%) scaleY(0.3); }
    30% { opacity: 1; transform: translateX(-50%) scaleY(1.08) scaleX(1.8); }
    100% { opacity: 0; transform: translateX(-50%) scaleY(1) scaleX(0.2); }
  }

  @keyframes splitLeftFall {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; filter: brightness(1.4); }
    25% { transform: translate(-10px, -2px) rotate(-6deg); opacity: 1; filter: brightness(1.1); }
    100% { transform: translate(-34px, 18px) rotate(-20deg); opacity: 0; filter: brightness(0.35) sepia(0.7); }
  }

  @keyframes splitRightFall {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; filter: brightness(1.4); }
    25% { transform: translate(10px, -2px) rotate(6deg); opacity: 1; filter: brightness(1.1); }
    100% { transform: translate(34px, 18px) rotate(20deg); opacity: 0; filter: brightness(0.35) sepia(0.7); }
  }

  /* Боевые анимации */
  .am-card.attack-lunge-up {
    z-index: 45 !important;
    border-color: #ffe89e !important;
    box-shadow: 0 12px 28px rgba(0,0,0,0.9), 0 0 26px rgba(255, 196, 77, 0.9) !important;
    animation: lungeUpSmooth 1.12s cubic-bezier(0.25, 0.8, 0.25, 1) forwards !important;
  }

  @keyframes lungeUpSmooth {
    0% { transform: translateY(0) scale(1); }
    22% { transform: translateY(6px) scale(0.98); }
    48% { transform: translateY(-42px) scale(1.06); }
    62% { transform: translateY(-38px) scale(1.04); }
    100% { transform: translateY(0) scale(1); }
  }

  .am-card.attack-lunge-down {
    z-index: 45 !important;
    border-color: #ff9466 !important;
    box-shadow: 0 12px 28px rgba(0,0,0,0.9), 0 0 26px rgba(255, 110, 64, 0.9) !important;
    animation: lungeDownSmooth 1.12s cubic-bezier(0.25, 0.8, 0.25, 1) forwards !important;
  }

  @keyframes lungeDownSmooth {
    0% { transform: translateY(0) scale(1); }
    22% { transform: translateY(-6px) scale(0.98); }
    48% { transform: translateY(42px) scale(1.06); }
    62% { transform: translateY(38px) scale(1.04); }
    100% { transform: translateY(0) scale(1); }
  }

  .am-card.ability-cast-glow {
    z-index: 46 !important;
    animation: abilityCastSmooth 0.95s ease-in-out forwards !important;
  }

  @keyframes abilityCastSmooth {
    0% { transform: scale(1); filter: brightness(1); }
    35% {
      transform: translateY(-8px) scale(1.07);
      border-color: #fff2b2;
      box-shadow: 0 0 32px rgba(255, 215, 100, 1), inset 0 0 18px rgba(255, 215, 100, 0.65);
      filter: brightness(1.3);
    }
    70% {
      transform: translateY(-5px) scale(1.04);
      box-shadow: 0 0 24px rgba(255, 180, 70, 0.85);
    }
    100% { transform: scale(1); filter: brightness(1); }
  }

  .astral-projectile {
    position: fixed;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff9d6 0%, #ff9d3b 50%, #d92b18 100%);
    box-shadow: 0 0 20px #ff7b29, 0 0 36px #ff331f;
    pointer-events: none;
    z-index: 950;
    transform: translate(-50%, -50%);
    transition: left 0.58s cubic-bezier(0.25, 0.8, 0.25, 1), top 0.58s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.58s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
  }

  .am-card.hit-shake {
    animation: hitShakeSmooth 0.65s ease-in-out !important;
    border-color: #ff4738 !important;
    box-shadow: 0 0 26px rgba(255, 55, 40, 0.9), inset 0 0 18px rgba(255, 55, 40, 0.55) !important;
  }

  @keyframes hitShakeSmooth {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px) rotate(-1.5deg); }
    45% { transform: translateX(6px) rotate(1.5deg); }
    70% { transform: translateX(-4px) rotate(-0.8deg); }
    88% { transform: translateX(3px) rotate(0.5deg); }
  }

  .hp-pulse-change {
    animation: hpPulseSmooth 0.75s ease-out;
  }

  @keyframes hpPulseSmooth {
    0% { transform: scale(1); }
    35% { transform: scale(1.32); background: #c92418; color: #fff; }
    100% { transform: scale(1); }
  }

  .floating-damage {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    font-weight: 900;
    color: #fff8f6;
    background: radial-gradient(circle, rgba(214, 34, 22, 0.96) 0%, rgba(115, 12, 6, 0.94) 100%);
    border: 2px solid #ffc2a8;
    border-radius: 18px;
    padding: 3px 11px;
    text-shadow: 0 2px 4px #000;
    box-shadow: 0 6px 18px rgba(0,0,0,0.9), 0 0 16px rgba(255, 68, 51, 0.8);
    pointer-events: none;
    animation: floatUpDamageSmooth 1.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    z-index: 80;
    white-space: nowrap;
    font-family: Georgia, serif;
  }

  .floating-damage.heal {
    background: radial-gradient(circle, rgba(46, 168, 66, 0.96) 0%, rgba(18, 84, 28, 0.94) 100%);
    border-color: #b5ffbe;
    box-shadow: 0 6px 18px rgba(0,0,0,0.9), 0 0 16px rgba(72, 224, 96, 0.8);
  }

  @keyframes floatUpDamageSmooth {
    0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
    16% { opacity: 1; transform: translate(-50%, -4px) scale(1.1); }
    35% { opacity: 1; transform: translate(-50%, -12px) scale(1.0); }
    78% { opacity: 1; transform: translate(-50%, -28px) scale(1.0); }
    100% { opacity: 0; transform: translate(-50%, -44px) scale(0.92); }
  }
