/**
 * Анимации для игры
 * Плавные переходы и эффекты для улучшения пользовательского опыта
 */

/* Анимация появления экрана */
.screen.active {
    animation: screenFadeIn 0.3s ease;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Анимация выстрела */
.shot-animation {
    animation: shotEffect 0.3s ease;
}

@keyframes shotEffect {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(244, 67, 54, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0);
    }
}

/* Анимация попадания */
.hit-animation {
    animation: hitEffect 0.4s ease;
}

@keyframes hitEffect {
    0% {
        transform: scale(1);
        background-color: #E3F2FD;
    }
    25% {
        transform: scale(1.2);
        background-color: #FF5722;
    }
    50% {
        transform: scale(1.1);
        background-color: #F44336;
    }
    100% {
        transform: scale(1);
        background-color: #F44336;
    }
}

/* Анимация промаха */
.miss-animation {
    animation: missEffect 0.3s ease;
}

@keyframes missEffect {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Анимация уничтожения корабля - эффект взрыва */
.sink-animation {
    animation: sinkEffect 0.6s ease-out;
    z-index: 10;
    /* Используем transform-origin для предотвращения деформации сетки */
    transform-origin: center center;
}

@keyframes sinkEffect {
    0% {
        background-color: #F44336;
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.7);
        opacity: 1;
    }
    20% {
        background-color: #FF5722;
        box-shadow: 0 0 15px 8px rgba(255, 87, 34, 0.8);
        opacity: 1;
    }
    40% {
        background-color: #E53935;
        box-shadow: 0 0 20px 10px rgba(229, 57, 53, 0.9);
        opacity: 0.95;
    }
    60% {
        background-color: #D32F2F;
        box-shadow: 0 0 18px 9px rgba(211, 47, 47, 0.8);
        opacity: 0.9;
    }
    80% {
        background-color: #C62828;
        box-shadow: 0 0 12px 6px rgba(198, 40, 40, 0.7);
        opacity: 0.95;
    }
    100% {
        background-color: #D32F2F;
        box-shadow: 0 0 10px rgba(211, 47, 47, 0.6),
                    inset 0 0 10px rgba(183, 28, 28, 0.4);
        opacity: 1;
    }
}

/* Анимация волны взрыва для всех клеток корабля одновременно */
.sink-animation-wave {
    animation: sinkWaveEffect 0.6s ease-out;
    /* Предотвращаем деформацию */
    transform-origin: center center;
}

@keyframes sinkWaveEffect {
    0% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.8);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(211, 47, 47, 0.4),
                    0 0 0 20px rgba(211, 47, 47, 0.2);
    }
    100% {
        box-shadow: 0 0 10px rgba(211, 47, 47, 0.6),
                    inset 0 0 10px rgba(183, 28, 28, 0.4);
    }
}

/* Пульсация для активной клетки */
.cell.pulse {
    animation: pulseEffect 1s ease infinite;
}

@keyframes pulseEffect {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(25, 118, 210, 0);
    }
}

/* Анимация появления кнопки */
.btn {
    animation: buttonAppear 0.4s ease;
}

@keyframes buttonAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Анимация вибрации (для ошибок) */
.shake {
    animation: shakeEffect 0.5s ease;
}

@keyframes shakeEffect {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Плавное появление элементов */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Плавное исчезновение элементов */
.fade-out {
    animation: fadeOut 0.3s ease;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Анимация победы */
.victory-animation {
    animation: victoryEffect 0.8s ease;
}

@keyframes victoryEffect {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Оптимизация производительности анимаций */
.cell,
.btn,
.screen {
    will-change: transform;
}

/* Отключение анимаций для пользователей, предпочитающих уменьшенное движение */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}








