/**
 * Additional Animations
 * Дополнительные анимации
 */

/* ============================================
   LOADING STATES
   ============================================ */

.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   HOVER EFFECTS
   ============================================ */

/* Эффект поднятия для карточек */
.lift-on-hover {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    will-change: transform, box-shadow;
    contain: layout style paint;
}

.lift-on-hover:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Эффект масштабирования */
.scale-on-hover {
    transition: transform var(--transition-normal);
    will-change: transform;
    contain: layout style paint;
}

.scale-on-hover:hover {
    transform: scale(1.05);
}

/* Эффект свечения */
.glow-on-hover {
    transition: box-shadow var(--transition-normal);
}

.glow-on-hover:hover {
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
}

/* ============================================
   ENTRANCE ANIMATIONS
   ============================================ */

/* Оптимизированные анимации с использованием transform3d для GPU ускорения */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translate3d(-50px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translate3d(50px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 50px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -50px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale3d(0.8, 0.8, 1);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

@keyframes zoomOut {
    from {
        opacity: 0;
        transform: scale3d(1.2, 1.2, 1);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate3d(0, 0, 1, -180deg) scale3d(0.8, 0.8, 1);
    }
    to {
        opacity: 1;
        transform: rotate3d(0, 0, 1, 0deg) scale3d(1, 1, 1);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.animate-on-scroll {
    opacity: 0;
}

/* Оптимизированные классы анимаций с will-change и contain */
.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
    will-change: opacity;
    contain: layout style paint;
}

.animate-slide-left {
    animation: slideInLeft 0.6s ease-out forwards;
    will-change: transform, opacity;
    contain: layout style paint;
}

.animate-slide-right {
    animation: slideInRight 0.6s ease-out forwards;
    will-change: transform, opacity;
    contain: layout style paint;
}

.animate-slide-up {
    animation: slideInUp 0.6s ease-out forwards;
    will-change: transform, opacity;
    contain: layout style paint;
}

.animate-slide-down {
    animation: slideInDown 0.6s ease-out forwards;
    will-change: transform, opacity;
    contain: layout style paint;
}

.animate-zoom-in {
    animation: zoomIn 0.6s ease-out forwards;
    will-change: transform, opacity;
    contain: layout style paint;
}

.animate-zoom-out {
    animation: zoomOut 0.6s ease-out forwards;
    will-change: transform, opacity;
    contain: layout style paint;
}

.animate-rotate-in {
    animation: rotateIn 0.6s ease-out forwards;
    will-change: transform, opacity;
    contain: layout style paint;
}

/* Убираем will-change после завершения анимации */
.animate-fade-in,
.animate-slide-left,
.animate-slide-right,
.animate-slide-up,
.animate-slide-down,
.animate-zoom-in,
.animate-zoom-out,
.animate-rotate-in {
    animation-fill-mode: forwards;
}

/* Убираем will-change после завершения анимации (оптимизация производительности) */
.animate-fade-in.animation-complete,
.animate-slide-left.animation-complete,
.animate-slide-right.animation-complete,
.animate-slide-up.animation-complete,
.animate-slide-down.animation-complete,
.animate-zoom-in.animation-complete,
.animate-zoom-out.animation-complete,
.animate-rotate-in.animation-complete {
    will-change: auto !important;
}

/* Оптимизация для hover эффектов - will-change только при hover */
.lift-on-hover:not(:hover),
.scale-on-hover:not(:hover) {
    will-change: auto;
}

.lift-on-hover:hover,
.scale-on-hover:hover {
    will-change: transform;
}

/* ============================================
   STAGGER ANIMATIONS
   ============================================ */

.stagger-children > * {
    animation: fadeInUp 0.6s ease-out forwards;
    opacity: 0;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.8s; }

/* ============================================
   SUCCESS/ERROR ANIMATIONS
   ============================================ */

@keyframes successCheckmark {
    0% {
        transform: scale3d(0, 0, 1);
    }
    50% {
        transform: scale3d(1.2, 1.2, 1);
    }
    100% {
        transform: scale3d(1, 1, 1);
    }
}

.success-icon {
    animation: successCheckmark 0.5s ease-out;
    will-change: transform;
    contain: layout style paint;
}

@keyframes errorShake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate3d(-5px, 0, 0); }
    20%, 40%, 60%, 80% { transform: translate3d(5px, 0, 0); }
}

.error-shake {
    animation: errorShake 0.5s ease-out;
    will-change: transform;
    contain: layout style paint;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 107, 53, 0.2);
    border-top-color: var(--primary-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    will-change: transform;
    contain: layout style paint;
    transform: translateZ(0); /* GPU ускорение */
}

.spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* ============================================
   PROGRESS BAR ANIMATION
   ============================================ */

@keyframes progressBar {
    from {
        width: 0%;
    }
}

.progress-bar {
    animation: progressBar 1s ease-out forwards;
}

/* ============================================
   TOOLTIP ANIMATIONS
   ============================================ */

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translate3d(0, -10px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.tooltip {
    animation: tooltipFadeIn 0.3s ease-out;
    will-change: transform, opacity;
    contain: layout style paint;
}

/* ============================================
   MODAL ANIMATIONS
   ============================================ */

.modal-overlay {
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale3d(0.9, 0.9, 1) translate3d(0, -20px, 0);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
    }
}

/* ============================================
   CARD FLIP EFFECT
   ============================================ */

.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
    will-change: transform;
    contain: layout style paint;
    backface-visibility: hidden;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    backface-visibility: hidden;
}

.card-flip-back {
    transform: rotateY(180deg);
}

/* ============================================
   RIPPLE EFFECT
   ============================================ */

.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate3d(-50%, -50%, 0);
    transition: width 0.6s, height 0.6s;
    will-change: width, height;
    contain: layout style paint;
}

.ripple-effect:active::after {
    width: 300px;
    height: 300px;
}

/* ============================================
   GRADIENT ANIMATION
   ============================================ */

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animated {
    background: linear-gradient(-45deg, var(--primary-orange), var(--accent-yellow), var(--primary-orange));
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
    will-change: background-position;
    contain: layout style paint;
    /* Отключаем на слабых устройствах */
}

@media (prefers-reduced-motion: reduce) {
    .gradient-animated {
        animation: none;
    }
}

/* ============================================
   FLOATING ANIMATION
   ============================================ */

@keyframes float {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(0, -20px, 0);
    }
}

.float-animation {
    animation: float 3s ease-in-out infinite;
    will-change: transform;
    contain: layout style paint;
}

/* Отключаем анимации для пользователей с prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

