/* ========================================
   ADVANCED ANIMATIONS & EFFECTS
   Premium Mobile Tire Service
   ======================================== */

/* ========================================
   KEYFRAME ANIMATIONS
   ======================================== */

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes wiggle {
    0%, 7% {
        transform: rotateZ(0);
    }
    15% {
        transform: rotateZ(-15deg);
    }
    20% {
        transform: rotateZ(10deg);
    }
    25% {
        transform: rotateZ(-10deg);
    }
    30% {
        transform: rotateZ(6deg);
    }
    35% {
        transform: rotateZ(-4deg);
    }
    40%, 100% {
        transform: rotateZ(0);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 212, 255, 0.8);
    }
    100% {
        box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
    }
}

@keyframes floatUp {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
    100% {
        transform: translateY(0px);
    }
}

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

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

@keyframes blink {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--accent-neon-blue);
    }
}

@keyframes neonGlow {
    0%, 100% {
        text-shadow: 
            0 0 5px currentColor,
            0 0 10px currentColor,
            0 0 15px currentColor,
            0 0 20px var(--accent-neon-blue);
    }
    50% {
        text-shadow: 
            0 0 2px currentColor,
            0 0 5px currentColor,
            0 0 8px currentColor,
            0 0 12px var(--accent-neon-blue);
    }
}

@keyframes electricPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 212, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0);
    }
}

@keyframes slideInFromLeft {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromRight {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes morphing {
    0%, 100% {
        border-radius: 50% 20% 50% 20%;
    }
    25% {
        border-radius: 20% 50% 20% 50%;
    }
    50% {
        border-radius: 50% 40% 30% 60%;
    }
    75% {
        border-radius: 40% 30% 60% 50%;
    }
}

/* ========================================
   SCROLL ANIMATIONS
   ======================================== */

.animate-in {
    animation: slideInUp 0.8s ease-out forwards;
}

.animate-in.delay-1 {
    animation-delay: 0.2s;
}

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

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

/* Service Cards Animation on Scroll */
.service-card {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.service-card.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Stats Animation */
.stat-item {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.6s ease-out;
}

.stat-item.animate-in {
    opacity: 1;
    transform: scale(1);
    animation: bounceIn 0.6s ease-out;
}

/* Blog Cards Stagger */
.blog-card:nth-child(1) {
    animation-delay: 0s;
}

.blog-card:nth-child(2) {
    animation-delay: 0.2s;
}

.blog-card:nth-child(3) {
    animation-delay: 0.4s;
}

/* ========================================
   HOVER EFFECTS
   ======================================== */

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

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

.hover-glow {
    transition: all 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
    transform: scale(1.02);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

.hover-slide {
    position: relative;
    overflow: hidden;
}

.hover-slide::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.hover-slide:hover::before {
    left: 100%;
}

/* ========================================
   LOADING ANIMATIONS
   ======================================== */

.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.4s infinite both;
}

@keyframes loadingDots {
    0%, 80%, 100% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80% {
        content: '...';
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 212, 255, 0.3);
    border-top: 4px solid var(--accent-neon-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pulse-loader {
    width: 60px;
    height: 60px;
    background: var(--accent-neon-blue);
    border-radius: 50%;
    animation: pulseLoader 1.5s ease-in-out infinite;
}

@keyframes pulseLoader {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ========================================
   PARTICLE EFFECTS
   ======================================== */

.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-neon-blue);
    border-radius: 50%;
    animation: particleFloat 6s linear infinite;
    opacity: 0.7;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) translateX(0px);
        opacity: 0;
    }
    10% {
        opacity: 0.7;
    }
    90% {
        opacity: 0.7;
    }
    100% {
        transform: translateY(-100px) translateX(100px);
        opacity: 0;
    }
}

.particle:nth-child(2) { animation-delay: 1s; }
.particle:nth-child(3) { animation-delay: 2s; }
.particle:nth-child(4) { animation-delay: 3s; }
.particle:nth-child(5) { animation-delay: 4s; }

/* ========================================
   TEXT EFFECTS
   ======================================== */

.glitch-text {
    position: relative;
    color: var(--white);
    font-weight: bold;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-dark);
}

.glitch-text::before {
    animation: glitchTop 1s linear infinite;
    clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
    color: var(--accent-neon-blue);
}

.glitch-text::after {
    animation: glitchBottom 1.5s linear infinite;
    clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
    color: var(--error);
}

@keyframes glitchTop {
    2%, 64% {
        transform: translate(2px, -2px);
    }
    4%, 60% {
        transform: translate(-2px, 2px);
    }
    62% {
        transform: translate(13px, -1px) skew(-13deg);
    }
}

@keyframes glitchBottom {
    2%, 64% {
        transform: translate(-2px, 0);
    }
    4%, 60% {
        transform: translate(-2px, 0);
    }
    62% {
        transform: translate(-22px, 5px) skew(21deg);
    }
}

.typing-text {
    overflow: hidden;
    border-right: 3px solid var(--accent-neon-blue);
    white-space: nowrap;
    margin: 0 auto;
    letter-spacing: 0.15em;
    animation: 
        typewriter 3.5s steps(40, end),
        blink 0.75s step-end infinite;
}

.neon-text {
    color: var(--accent-neon-blue);
    animation: neonGlow 2s ease-in-out infinite alternate;
}

/* ========================================
   BUTTON EFFECTS
   ======================================== */

.btn-electric {
    position: relative;
    background: var(--gradient-neon);
    border: none;
    padding: 15px 30px;
    border-radius: var(--border-radius);
    color: var(--primary-dark);
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-electric::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg, 
        transparent, 
        rgba(255,255,255,0.4), 
        transparent
    );
    transition: left 0.6s ease;
}

.btn-electric:hover::before {
    left: 100%;
}

.btn-electric:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.4);
}

.btn-electric:active {
    transform: translateY(0);
    animation: electricPulse 0.6s ease;
}

.btn-morphing {
    background: var(--gradient-neon);
    border: none;
    padding: 15px 30px;
    color: var(--primary-dark);
    font-weight: 600;
    cursor: pointer;
    animation: morphing 4s ease-in-out infinite;
    transition: all 0.3s ease;
}

.btn-morphing:hover {
    animation-play-state: paused;
    transform: scale(1.05);
}

/* ========================================
   CARD EFFECTS
   ======================================== */

.card-flip {
    perspective: 1000px;
    width: 100%;
    height: 300px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius-large);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.card-flip-front {
    background: var(--gradient-glass);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.card-flip-back {
    background: var(--gradient-neon);
    color: var(--primary-dark);
    transform: rotateY(180deg);
}

/* ========================================
   PARALLAX EFFECTS
   ======================================== */

.parallax-container {
    position: relative;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.parallax-back {
    transform: translateZ(-1px) scale(2);
}

.parallax-mid {
    transform: translateZ(-0.5px) scale(1.5);
}

.parallax-front {
    transform: translateZ(0);
}

/* ========================================
   INTERACTION FEEDBACK
   ======================================== */

.ripple {
    position: relative;
    overflow: hidden;
}

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

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

.shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
    10%, 90% {
        transform: translate3d(-1px, 0, 0);
    }
    20%, 80% {
        transform: translate3d(2px, 0, 0);
    }
    30%, 50%, 70% {
        transform: translate3d(-4px, 0, 0);
    }
    40%, 60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* ========================================
   LOADING STATES
   ======================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
}

@keyframes skeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.loading-content {
    text-align: center;
    color: var(--white);
}

.loading-content .spinner {
    margin-bottom: 20px;
}

/* ========================================
   SUCCESS STATES
   ======================================== */

.success-checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 3;
    stroke: var(--success);
    stroke-miterlimit: 10;
    margin: 20px auto;
    box-shadow: inset 0px 0px 0px var(--success);
    animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
}

.success-checkmark__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: var(--success);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-checkmark__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scale {
    0%, 100% {
        transform: none;
    }
    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0px 0px 0px 30px var(--success);
    }
}

/* ========================================
   RESPONSIVE ANIMATIONS
   ======================================== */

@media (max-width: 768px) {
    /* Reduce motion for mobile */
    .service-card,
    .stat-item,
    .blog-card {
        animation-duration: 0.4s;
    }
    
    .hero-visual .tire {
        animation-duration: 4s;
    }
    
    /* Disable complex animations on mobile */
    .parallax-layer {
        transform: none !important;
    }
    
    .particle {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Respect user's motion preferences */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tire {
        animation: none;
    }
    
    .animated-grid {
        animation: none;
    }
}

/* ========================================
   UTILITY ANIMATION CLASSES
   ======================================== */

.animate-bounce {
    animation: bounce 1s infinite;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

.animate-wiggle {
    animation: wiggle 1s ease-in-out;
}

.animate-float {
    animation: floatUp 3s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

/* Hover triggers */
.hover-animate:hover .animate-on-hover {
    animation-play-state: running;
}

.animate-on-hover {
    animation-play-state: paused;
}

/* Click triggers */
.click-animate:active {
    animation: bounce 0.3s ease;
}

/* Focus triggers */
.focus-animate:focus {
    animation: glow 0.5s ease;
}

/* ========================================
   TIRE BRANDS ANIMATIONS
   ======================================== */

.tire-brands {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.tire-brands.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.brand {
    opacity: 0;
    transform: scale(0.8);
    animation: brandFadeIn 0.6s ease-out forwards;
}

.brand:nth-child(1) { animation-delay: 0.1s; }
.brand:nth-child(2) { animation-delay: 0.2s; }
.brand:nth-child(3) { animation-delay: 0.3s; }
.brand:nth-child(4) { animation-delay: 0.4s; }
.brand:nth-child(5) { animation-delay: 0.5s; }
.brand:nth-child(6) { animation-delay: 0.6s; }
.brand:nth-child(7) { animation-delay: 0.7s; }
.brand:nth-child(8) { animation-delay: 0.8s; }

@keyframes brandFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    50% {
        transform: scale(1.1) translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ========================================
   EMERGENCY CALLOUT ANIMATIONS
   ======================================== */

.emergency-callout {
    opacity: 0;
    transform: translateX(-50px);
    animation: emergencySlideIn 1s ease-out 0.5s forwards;
}

@keyframes emergencySlideIn {
    0% {
        opacity: 0;
        transform: translateX(-50px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.callout-signature {
    animation: signatureTypewriter 2s ease-out 1.5s forwards;
    opacity: 0;
}

@keyframes signatureTypewriter {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   MAIN TIRES IMAGE ANIMATIONS
   ======================================== */

.main-tires-image {
    opacity: 0;
    transform: scale(0.8);
    animation: imageReveal 1.2s ease-out 0.8s forwards;
}

@keyframes imageReveal {
    0% {
        opacity: 0;
        transform: scale(0.8) rotateY(15deg);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1) rotateY(-5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

.hero-image {
    position: relative;
}

.hero-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 30%, rgba(0, 212, 255, 0.1) 100%);
    border-radius: var(--border-radius-large);
    animation: imageGlow 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes imageGlow {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
} 