/**
 * VereniConsult Animations
 * Smooth, modern animations for a professional feel
 * Author: Angel Petrov
 */

/* ==========================================================================
   Animation Keyframes
   ========================================================================== */

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide In Up */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Slide In Down */
@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Rotate In */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: rotate(0);
    }
}

/* Blur In */
@keyframes blurIn {
    from {
        opacity: 0;
        filter: blur(10px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* Float Animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* Pulse */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

/* Bounce */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

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

/* Spin */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Gradient Flow */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Shimmer */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ==========================================================================
   Animation Classes - Initial States
   ========================================================================== */

/* Hero Animations - Play Immediately */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

.animate-fade-in-up {
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
}

.animate-fade-in-left {
    opacity: 0;
    animation: fadeInLeft 0.8s ease forwards;
}

/* Animation Delays */
.delay-1 {
    animation-delay: 0.2s;
}

.delay-2 {
    animation-delay: 0.4s;
}

.delay-3 {
    animation-delay: 0.6s;
}

.delay-4 {
    animation-delay: 0.8s;
}

.delay-5 {
    animation-delay: 1s;
}

/* ==========================================================================
   Scroll Triggered Animations
   ========================================================================== */

/* Elements that animate on scroll */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered animations for grid items */
.animate-on-scroll:nth-child(1) { transition-delay: 0s; }
.animate-on-scroll:nth-child(2) { transition-delay: 0.1s; }
.animate-on-scroll:nth-child(3) { transition-delay: 0.2s; }
.animate-on-scroll:nth-child(4) { transition-delay: 0.3s; }
.animate-on-scroll:nth-child(5) { transition-delay: 0.4s; }
.animate-on-scroll:nth-child(6) { transition-delay: 0.5s; }
.animate-on-scroll:nth-child(7) { transition-delay: 0.6s; }
.animate-on-scroll:nth-child(8) { transition-delay: 0.7s; }

/* Different animation types on scroll */
.animate-on-scroll.fade-up {
    transform: translateY(40px);
}

.animate-on-scroll.fade-down {
    transform: translateY(-40px);
}

.animate-on-scroll.fade-left {
    transform: translateX(40px);
}

.animate-on-scroll.fade-right {
    transform: translateX(-40px);
}

.animate-on-scroll.scale {
    transform: scale(0.9);
}

.animate-on-scroll.fade-up.animated,
.animate-on-scroll.fade-down.animated,
.animate-on-scroll.fade-left.animated,
.animate-on-scroll.fade-right.animated,
.animate-on-scroll.scale.animated {
    transform: none;
}

/* ==========================================================================
   Interactive Hover Animations
   ========================================================================== */

/* Lift Effect */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Scale Effect */
.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Glow Effect */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
}

/* Shine Effect */
.hover-shine {
    position: relative;
    overflow: hidden;
}

.hover-shine::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(30deg);
    transition: transform 0.6s ease;
    pointer-events: none;
    opacity: 0;
}

.hover-shine:hover::after {
    opacity: 1;
    transform: rotate(30deg) translate(100%, 100%);
}

/* Underline Grow Effect */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 0.3s ease, left 0.3s ease;
}

.hover-underline:hover::after {
    width: 100%;
    left: 0;
}

/* ==========================================================================
   Loading Animations
   ========================================================================== */

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Dots Loading */
.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200) 25%,
        var(--color-gray-100) 50%,
        var(--color-gray-200) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ==========================================================================
   Text Animations
   ========================================================================== */

/* Typing Effect */
.typing-text {
    overflow: hidden;
    border-right: 2px solid var(--color-primary);
    white-space: nowrap;
    animation:
        typing 3s steps(30) forwards,
        blink 0.7s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    50% { border-color: transparent; }
}

/* Gradient Text Animation */
.gradient-text-animated {
    background: linear-gradient(
        90deg,
        var(--color-primary),
        var(--color-secondary),
        var(--color-accent),
        var(--color-secondary),
        var(--color-primary)
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientFlow 6s ease infinite;
}

/* ==========================================================================
   Number Counter Animation
   ========================================================================== */

.counter {
    transition: all 0.5s ease-out;
}

/* ==========================================================================
   Parallax Effects
   ========================================================================== */

.parallax-slow {
    will-change: transform;
}

.parallax-medium {
    will-change: transform;
}

.parallax-fast {
    will-change: transform;
}

/* ==========================================================================
   Button Animations
   ========================================================================== */

/* Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-ripple:active::before {
    width: 300px;
    height: 300px;
}

/* Arrow Bounce on Hover */
.btn svg {
    transition: transform 0.3s ease;
}

.btn:hover svg {
    animation: arrowBounce 0.6s ease;
}

@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

/* ==========================================================================
   Card Animations
   ========================================================================== */

/* Card Tilt Effect - 3D */
.card-3d {
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.3s ease;
}

.card-3d:hover {
    transform: rotateY(-5deg) rotateX(5deg);
}

/* Card Border Animation */
.card-border-animate {
    position: relative;
}

.card-border-animate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
}

.card-border-animate:hover::before {
    transform: scaleX(1);
}

/* ==========================================================================
   Icon Animations
   ========================================================================== */

/* Icon Bounce */
.icon-bounce:hover {
    animation: bounce 0.6s ease;
}

/* Icon Spin */
.icon-spin:hover {
    animation: spin 0.6s ease;
}

/* Icon Pulse */
.icon-pulse {
    animation: pulse 2s ease infinite;
}

/* ==========================================================================
   Form Animations
   ========================================================================== */

/* Input Focus Animation */
.input-animated {
    position: relative;
}

.input-animated::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--color-secondary);
    transition: width 0.3s ease, left 0.3s ease;
}

.input-animated:focus-within::after {
    width: 100%;
    left: 0;
}

/* Label Float Animation */
.label-float {
    position: relative;
}

.label-float label {
    position: absolute;
    top: 50%;
    left: var(--space-4);
    transform: translateY(-50%);
    transition: all 0.3s ease;
    pointer-events: none;
    color: var(--color-gray-400);
}

.label-float input:focus + label,
.label-float input:not(:placeholder-shown) + label {
    top: 0;
    font-size: var(--text-xs);
    background: var(--color-white);
    padding: 0 var(--space-1);
    color: var(--color-secondary);
}

/* ==========================================================================
   Page Transition Animations
   ========================================================================== */

/* Fade Transition */
.page-transition {
    animation: fadeIn 0.5s ease;
}

/* Slide Transition */
.page-slide-in {
    animation: slideInUp 0.5s ease;
}

/* ==========================================================================
   Reveal Animations
   ========================================================================== */

/* Reveal from bottom */
.reveal-bottom {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 0.6s ease;
}

.reveal-bottom.revealed {
    clip-path: inset(0 0 0 0);
}

/* Reveal from left */
.reveal-left {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.6s ease;
}

.reveal-left.revealed {
    clip-path: inset(0 0 0 0);
}

/* ==========================================================================
   Special Effects
   ========================================================================== */

/* Morphing Background */
.morph-bg {
    background: linear-gradient(-45deg, var(--color-primary), var(--color-secondary), var(--color-accent), var(--color-primary-light));
    background-size: 400% 400%;
    animation: gradientFlow 15s ease infinite;
}

/* Floating Elements */
.float {
    animation: float 6s ease-in-out infinite;
}

.float-delayed {
    animation: float 6s ease-in-out infinite;
    animation-delay: -3s;
}

/* Blur In on Load */
.blur-in {
    animation: blurIn 0.8s ease forwards;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }

    .hero-card {
        opacity: 1;
        transform: none;
    }

    .animate-fade-in,
    .animate-fade-in-up,
    .animate-fade-in-left {
        opacity: 1;
        animation: none;
    }
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* Use GPU acceleration for animated elements */
.animate-on-scroll,
.hover-lift,
.hover-scale,
.service-card,
.hero-card,
.back-to-top,
.mobile-menu {
    will-change: transform, opacity;
}

/* Clean up will-change after animation */
.animated {
    will-change: auto;
}
