/* BattleLoot.css - Стили для системы ништяков */
/* Версия 2.0 — круглая рамка, пульсация, покачивание, эффекты подбора/потери */

/* ═══════════════════════════════════════════════════════════════
   БАЗОВЫЕ АНИМАЦИИ
   ═══════════════════════════════════════════════════════════════ */

/* Покачивание ништяка внутри рамки */
@keyframes loot-wobble {
    0%, 100% {
        transform: rotate(-5deg) translateY(0);
    }
    25% {
        transform: rotate(3deg) translateY(-1px);
    }
    50% {
        transform: rotate(5deg) translateY(0);
    }
    75% {
        transform: rotate(-3deg) translateY(1px);
    }
}

/* Пульсация круглой рамки — ОПТИМИЗИРОВАНО v15 */
/* box-shadow с 3+ слоями убран — вызывает repaint каждый кадр */
@keyframes border-pulse {
    0%, 100% {
        border-color: rgba(255, 255, 255, 0.5);
        transform: scale(1);
    }
    50% {
        border-color: rgba(255, 255, 255, 0.9);
        transform: scale(1.06);
    }
}

/* Пульсация рамки для каждого типа — ОПТИМИЗИРОВАНО v15 */
@keyframes border-pulse-red {
    0%, 100% {
        border-color: rgba(255, 51, 102, 0.6);
        transform: scale(1);
    }
    50% {
        border-color: rgba(255, 51, 102, 1);
        transform: scale(1.06);
    }
}

@keyframes border-pulse-blue {
    0%, 100% {
        border-color: rgba(0, 204, 255, 0.6);
        transform: scale(1);
    }
    50% {
        border-color: rgba(0, 204, 255, 1);
        transform: scale(1.06);
    }
}

@keyframes border-pulse-green {
    0%, 100% {
        border-color: rgba(0, 255, 136, 0.6);
        transform: scale(1);
    }
    50% {
        border-color: rgba(0, 255, 136, 1);
        transform: scale(1.06);
    }
}

@keyframes border-pulse-purple {
    0%, 100% {
        border-color: rgba(255, 102, 255, 0.6);
        transform: scale(1);
    }
    50% {
        border-color: rgba(255, 102, 255, 1);
        transform: scale(1.06);
    }
}

@keyframes border-pulse-gold {
    0%, 100% {
        border-color: rgba(255, 215, 0, 0.6);
        transform: scale(1);
    }
    50% {
        border-color: rgba(255, 215, 0, 1);
        transform: scale(1.06);
    }
}

/* Свечение типов (для спрайта внутри) — ОПТИМИЗИРОВАНО v15 */
/* filter: drop-shadow() УБРАН — это самая дорогая CSS-операция, */
/* вызывает перерисовку каждого кадра для КАЖДОГО ништяка. */
/* На уровнях с 50+ ништяками = 50+ drop-shadow пересчётов каждый кадр = лаги. */
/* Заменено на простое изменение opacity, которое GPU-ускорено. */
@keyframes glow-pulse-gold {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}
@keyframes glow-pulse-red {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}
@keyframes glow-pulse-blue {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}
@keyframes glow-pulse-green {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}
@keyframes glow-pulse-purple {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   НИШТЯК НА ПОЛЕ — круглая рамка-контейнер
   ═══════════════════════════════════════════════════════════════ */

/* Анимация появления ништяка (спавн) — ОПТИМИЗИРОВАНО v15 */
@keyframes loot-spawn-in {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
        opacity: 1;
    }
    75% {
        transform: scale(0.9) rotate(-5deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.battle-loot.spawning {
    animation: loot-spawn-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

/* Внешний контейнер — круглая пульсирующая рамка */
.battle-loot {
    position: absolute;
    width: 42px;
    height: 42px;
    pointer-events: none;
    z-index: 8;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: radial-gradient(circle, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.1) 70%, transparent 100%);
    box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.25);
    animation: border-pulse 2s ease-in-out infinite;
    /* GPU-ускорение: только transform и border-color анимируются */
    will-change: transform, border-color;
    /* Центрируем спрайт внутри */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Спрайт ништяка внутри рамки — покачивается */
.battle-loot::before {
    content: '';
    position: absolute;
    width: 33px;
    height: 33px;
    background-image: var(--loot-bg-image);
    background-size: var(--loot-bg-size);
    background-position: var(--loot-bg-pos);
    background-repeat: no-repeat;
    image-rendering: pixelated;
    animation: loot-wobble 2.5s ease-in-out infinite;
    will-change: transform;
}

/* ═══════════════════════════════════════════════════════════════
   ТИПЫ НИШТЯКОВ — цветные рамки
   ═══════════════════════════════════════════════════════════════ */

.battle-loot.attack {
    animation: border-pulse-red 2s ease-in-out infinite;
    box-shadow: 0 0 6px 2px rgba(255, 51, 102, 0.35);
}
.battle-loot.attack::before {
    animation: loot-wobble 2.5s ease-in-out infinite;
}

.battle-loot.defense {
    animation: border-pulse-blue 2s ease-in-out infinite;
    box-shadow: 0 0 6px 2px rgba(0, 204, 255, 0.35);
}
.battle-loot.defense::before {
    animation: loot-wobble 2.5s ease-in-out infinite;
}

.battle-loot.speed {
    animation: border-pulse-green 2s ease-in-out infinite;
    box-shadow: 0 0 6px 2px rgba(0, 255, 136, 0.35);
}
.battle-loot.speed::before {
    animation: loot-wobble 2.5s ease-in-out infinite;
}

.battle-loot.health {
    animation: border-pulse-purple 2s ease-in-out infinite;
    box-shadow: 0 0 6px 2px rgba(255, 102, 255, 0.35);
}
.battle-loot.health::before {
    animation: loot-wobble 2.5s ease-in-out infinite;
}

.battle-loot.bobla {
    animation: border-pulse-gold 2s ease-in-out infinite;
    box-shadow: 0 0 8px 3px rgba(255, 215, 0, 0.4);
}
.battle-loot.bobla::before {
    animation: loot-wobble 2.5s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   ЭФФЕКТ ПОДБОРА — взрыв света + частицы + кольцо
   ═══════════════════════════════════════════════════════════════ */

@keyframes loot-pickup-burst {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    20% {
        transform: scale(1.5) rotate(90deg);
        opacity: 1;
        border-color: rgba(255, 215, 0, 1);
        box-shadow: 
            0 0 0 3px rgba(255, 215, 0, 1),
            0 0 20px 8px rgba(255, 215, 0, 0.8),
            0 0 40px 16px rgba(255, 215, 0, 0.5);
        filter: brightness(2);
    }
    50% {
        transform: scale(2.5) rotate(270deg);
        opacity: 0.6;
        box-shadow: 
            0 0 0 4px rgba(255, 215, 0, 0.6),
            0 0 40px 20px rgba(255, 215, 0, 0.4),
            0 0 80px 30px rgba(255, 215, 0, 0.2);
        filter: brightness(3);
    }
    100% {
        transform: scale(0) rotate(540deg);
        opacity: 0;
        box-shadow: none;
        filter: brightness(1);
    }
}

/* Расширяющееся кольцо при подборе */
@keyframes pickup-ring-expand {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
        border-width: 3px;
    }
    100% {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
        border-width: 1px;
    }
}

/* Частицы-искры при подборе */
@keyframes pickup-sparkle-1 {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(calc(-50% + 25px), calc(-50% - 20px)) scale(1); opacity: 0; }
}
@keyframes pickup-sparkle-2 {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(calc(-50% - 20px), calc(-50% - 25px)) scale(1); opacity: 0; }
}
@keyframes pickup-sparkle-3 {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(calc(-50% + 15px), calc(-50% + 22px)) scale(1); opacity: 0; }
}
@keyframes pickup-sparkle-4 {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(calc(-50% - 22px), calc(-50% + 18px)) scale(1); opacity: 0; }
}

.battle-loot.picked-up {
    animation: loot-pickup-burst 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
    pointer-events: none;
}

/* Кольцо при подборе */
.battle-loot.picked-up::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255, 215, 0, 0.9);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pickup-ring-expand 0.6s ease-out forwards;
}

/* ═══════════════════════════════════════════════════════════════
   ЭФФЕКТ ПОТЕРИ НИШТЯКА (смерть солдата) — красная вспышка + разлёт
   ═══════════════════════════════════════════════════════════════ */

@keyframes loot-drop-scatter {
    0% {
        transform: translate(0, 0) scale(0.2) rotate(0deg);
        opacity: 0;
        filter: brightness(3) saturate(0);
    }
    30% {
        transform: translate(calc(var(--offset-x) * 0.4), calc(var(--offset-y) * 0.4 - 15px)) scale(1.3) rotate(180deg);
        opacity: 1;
        filter: brightness(1.5) saturate(1);
    }
    60% {
        transform: translate(calc(var(--offset-x) * 0.8), calc(var(--offset-y) * 0.8 + 5px)) scale(0.9) rotate(300deg);
        opacity: 1;
        filter: brightness(1) saturate(1);
    }
    100% {
        transform: translate(var(--offset-x), var(--offset-y)) scale(1) rotate(360deg);
        opacity: 1;
        filter: brightness(1) saturate(1);
    }
}

/* Красная вспышка на месте смерти */
@keyframes death-loot-flash {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
        background: radial-gradient(circle, rgba(255, 50, 50, 0.8), transparent);
    }
    50% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

.battle-loot.loot-drop-scatter {
    animation: loot-drop-scatter 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Вспышка при потере */
.loot-death-flash {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9;
    animation: death-loot-flash 0.5s ease-out forwards;
}

/* ═══════════════════════════════════════════════════════════════
   ЭФФЕКТ ТЕКСТА ПОДБОРА (+1 с иконкой)
   ═══════════════════════════════════════════════════════════════ */

@keyframes loot-pickup-text {
    0% {
        transform: translateY(0) scale(0.3);
        opacity: 0;
    }
    15% {
        transform: translateY(-15px) scale(1.4);
        opacity: 1;
        text-shadow: 
            0 0 12px rgba(0, 0, 0, 1),
            0 0 24px rgba(255, 215, 0, 1),
            0 0 36px rgba(255, 215, 0, 0.6),
            2px 2px 6px rgba(0, 0, 0, 0.9);
    }
    30% {
        transform: translateY(-25px) scale(1.2);
        opacity: 1;
    }
    80% {
        transform: translateY(-50px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-70px) scale(0.7);
        opacity: 0;
    }
}

.loot-pickup-effect {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 22px;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(0, 0, 0, 1),
                 0 0 16px rgba(255, 215, 0, 0.8),
                 2px 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 100;
    animation: loot-pickup-text 1.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.loot-pickup-effect .icon {
    font-size: 28px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 1))
            drop-shadow(0 0 20px rgba(255, 215, 0, 0.6));
    animation: icon-spin 0.6s ease-out;
}

@keyframes icon-spin {
    0% { transform: rotate(0deg) scale(0.5); }
    50% { transform: rotate(180deg) scale(1.3); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ═══════════════════════════════════════════════════════════════
   ЗОЛОТОЕ СВЕЧЕНИЕ СОЛДАТА ПРИ ПОДБОРЕ
   ═══════════════════════════════════════════════════════════════ */

@keyframes soldier-golden-glow {
    0% {
        filter: drop-shadow(0 0 0px rgba(255, 204, 0, 0));
    }
    20% {
        filter: drop-shadow(0 0 20px rgba(255, 204, 0, 1))
                drop-shadow(0 0 40px rgba(255, 204, 0, 0.8))
                drop-shadow(0 0 60px rgba(255, 204, 0, 0.6));
    }
    80% {
        filter: drop-shadow(0 0 20px rgba(255, 204, 0, 1))
                drop-shadow(0 0 40px rgba(255, 204, 0, 0.8))
                drop-shadow(0 0 60px rgba(255, 204, 0, 0.6));
    }
    100% {
        filter: drop-shadow(0 0 0px rgba(255, 204, 0, 0));
    }
}

.soldier-picked-loot {
    animation: soldier-golden-glow 1s ease-in-out forwards;
}

/* Красное свечение солдата при потере ништяков */
@keyframes soldier-death-red-flash {
    0% {
        filter: drop-shadow(0 0 0px rgba(255, 50, 50, 0));
    }
    30% {
        filter: drop-shadow(0 0 15px rgba(255, 50, 50, 1))
                drop-shadow(0 0 30px rgba(255, 50, 50, 0.7));
    }
    100% {
        filter: drop-shadow(0 0 0px rgba(255, 50, 50, 0));
    }
}

.soldier-dropping-loot {
    animation: soldier-death-red-flash 0.6s ease-out forwards;
}

/* ═══════════════════════════════════════════════════════════════
   ЧАСТИЦЫ ПРИ ПОДБОРЕ (DOM-элементы)
   ═══════════════════════════════════════════════════════════════ */

.pickup-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #ffd700;
    pointer-events: none;
    z-index: 101;
    box-shadow: 0 0 6px 2px rgba(255, 215, 0, 0.8);
}

@keyframes particle-fly-0 {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(30px, -25px) scale(0); opacity: 0; }
}
@keyframes particle-fly-1 {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(-25px, -30px) scale(0); opacity: 0; }
}
@keyframes particle-fly-2 {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(20px, 28px) scale(0); opacity: 0; }
}
@keyframes particle-fly-3 {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(-28px, 22px) scale(0); opacity: 0; }
}
@keyframes particle-fly-4 {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(35px, 5px) scale(0); opacity: 0; }
}
@keyframes particle-fly-5 {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(-32px, -8px) scale(0); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   ИНДИКАТОР НИШТЯКА НАД ГОЛОВОЙ
   ═══════════════════════════════════════════════════════════════ */

.unit-loot-indicator {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8),
                 0 0 8px rgba(255, 204, 0, 0.6);
    pointer-events: none;
    z-index: 10;
    animation: loot-indicator-float 2s ease-in-out infinite;
}

@keyframes loot-indicator-float {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

/* ═══════════════════════════════════════════════════════════════
   UI ЭЛЕМЕНТЫ (счётчики, конец боя)
   ═══════════════════════════════════════════════════════════════ */

.loot-counter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    font-size: 12px;
    color: #ffcc00;
    text-shadow: 0 0 4px rgba(255, 204, 0, 0.8);
}

.loot-counter .icon {
    font-size: 14px;
    filter: drop-shadow(0 0 4px rgba(255, 204, 0, 0.8));
}

.battle-end-loots {
    margin-top: 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 204, 0, 0.3);
}

.battle-end-loots .title {
    font-size: 14px;
    color: #ffcc00;
    margin-bottom: 8px;
    text-align: center;
    text-shadow: 0 0 8px rgba(255, 204, 0, 0.8);
}

.battle-end-loots .loot-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.battle-end-loots .loot-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    font-size: 12px;
    color: #fff;
}

.battle-end-loots .loot-item .icon { font-size: 16px; }
.battle-end-loots .loot-item.attack { border: 1px solid #ff3366; }
.battle-end-loots .loot-item.defense { border: 1px solid #00ccff; }
.battle-end-loots .loot-item.speed { border: 1px solid #00ff88; }
.battle-end-loots .loot-item.health { border: 1px solid #ff66ff; }
.battle-end-loots .loot-item.bobla { 
    border: 1px solid #ffcc00;
    animation: border-pulse-gold 2s ease-in-out infinite;
}
