/* =============================================================================
   Animations and Interactive Effects CSS for £100 Website Business
   Hover states, transitions, loading effects, and animations
   ============================================================================= */

/* =============================================================================
   GLOBAL ANIMATIONS
   ============================================================================= */

/* Smooth scrolling for all anchors */
html {
    scroll-behavior: smooth;
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide in from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale in animation */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Bounce animation for CTAs */
@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(-5px);
    }
}

/* Pulse animation for buttons */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0);
    }
}

/* Typing animation for text */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* Loading spinner */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Shake animation for errors */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

/* =============================================================================
   LOADING STATES
   ============================================================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-300);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: var(--spacing-md);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    color: var(--white);
}

/* =============================================================================
   BUTTON ANIMATIONS
   ============================================================================= */

.btn {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.btn::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 var(--transition-slow);
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
    transition: transform var(--transition-fast);
}

/* CTA button special animation */
.btn-cta {
    animation: pulse 2s infinite;
}

.btn-cta:hover {
    animation: none;
}

/* =============================================================================
   FORM ANIMATIONS
   ============================================================================= */

.form-group {
    position: relative;
}

.form-control {
    transition: all var(--transition-normal);
    border: 2px solid var(--gray-300);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    transform: scale(1.02);
}

.form-control.error {
    border-color: var(--error-color);
    animation: shake 0.5s ease-in-out;
}

.form-control.success {
    border-color: var(--success-color);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2328a745" stroke-width="2"><polyline points="9,11 12,14 22,4"></polyline><path d="m21,21h-18c-1.105,0 -2,-0.895 -2,-2v-14c0,-1.105 0.895,-2 2,-2h18c1.105,0 2,0.895 2,2v14c0,1.105 -0.895,2 -2,2z"></path></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

/* Floating labels animation */
.floating-label {
    position: relative;
}

.floating-label input,
.floating-label textarea {
    padding-top: var(--spacing-xl);
}

.floating-label label {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    color: var(--text-secondary);
    transition: all var(--transition-normal);
    pointer-events: none;
}

.floating-label input:focus + label,
.floating-label input:not(:placeholder-shown) + label,
.floating-label textarea:focus + label,
.floating-label textarea:not(:placeholder-shown) + label {
    top: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--primary-color);
}

/* =============================================================================
   CARD ANIMATIONS
   ============================================================================= */

.card {
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

.card:hover::before {
    transform: scaleX(1);
}

/* Portfolio card specific animations */
.portfolio-item {
    position: relative;
    overflow: hidden;
}

.portfolio-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(var(--primary-rgb), 0.9);
    opacity: 0;
    transition: opacity var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.portfolio-item:hover::after {
    opacity: 1;
}

.portfolio-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--white);
    opacity: 0;
    transition: all var(--transition-normal);
}

.portfolio-item:hover .portfolio-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* =============================================================================
   TESTIMONIAL ANIMATIONS
   ============================================================================= */

.testimonial-card {
    transition: all var(--transition-normal);
    position: relative;
}

.testimonial-card::before {
    content: '"';
    position: absolute;
    top: -20px;
    left: var(--spacing-lg);
    font-size: 60px;
    color: var(--primary-color);
    opacity: 0.3;
    font-family: serif;
    transition: all var(--transition-normal);
}

.testimonial-card:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl);
}

.testimonial-card:hover::before {
    opacity: 0.6;
    top: -25px;
}

/* =============================================================================
   PRICING ANIMATIONS
   ============================================================================= */

.pricing-card {
    transition: all var(--transition-normal);
    position: relative;
}

.pricing-card:hover {
    transform: translateY(-10px) scale(1.03);
    box-shadow: var(--shadow-xl);
}

.pricing-card.featured {
    animation: pulse 3s infinite;
}

.pricing-card.featured:hover {
    animation: none;
}

/* Price flip animation */
.price-amount {
    position: relative;
    overflow: hidden;
}

.price-amount.updating {
    animation: slideInRight 0.5s ease-out;
}

/* =============================================================================
   HERO SECTION ANIMATIONS
   ============================================================================= */

.hero-title {
    animation: fadeIn 1s ease-out;
}

.hero-subtitle {
    animation: fadeIn 1s ease-out 0.3s both;
}

.hero-cta {
    animation: fadeIn 1s ease-out 0.6s both;
}

.hero-image {
    animation: slideInRight 1s ease-out 0.9s both;
}

/* Typing effect for hero text */
.typing-text {
    border-right: 3px solid var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--primary-color);
    }
}

/* =============================================================================
   SCROLL ANIMATIONS
   ============================================================================= */

.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s ease-out;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s ease-out;
}

.scroll-reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s ease-out;
}

.scroll-reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s ease-out;
}

.scroll-reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* =============================================================================
   MODAL ANIMATIONS
   ============================================================================= */

.modal {
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    transform: scale(0.8);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.modal-content {
    transform: translateY(-50px);
    transition: transform var(--transition-normal);
}

.modal.active .modal-content {
    transform: translateY(0);
}

/* =============================================================================
   TOOLTIP ANIMATIONS
   ============================================================================= */

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip-text {
    visibility: hidden;
    opacity: 0;
    background: var(--text-primary);
    color: var(--white);
    text-align: center;
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    font-size: var(--font-size-sm);
    transition: all var(--transition-normal);
    transform: translateY(10px);
}

.tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--text-primary) transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* =============================================================================
   NOTIFICATION ANIMATIONS
   ============================================================================= */

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--transition-normal);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    border-color: var(--success-color);
    background: var(--success-bg);
}

.notification.error {
    border-color: var(--error-color);
    background: var(--error-bg);
}

.notification.warning {
    border-color: var(--warning-color);
    background: var(--warning-bg);
}

/* =============================================================================
   ACCESSIBILITY ANIMATIONS
   ============================================================================= */

/* Reduce motion for users who prefer it */
@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;
    }
    
    .scroll-reveal,
    .scroll-reveal-left,
    .scroll-reveal-right,
    .scroll-reveal-scale {
        opacity: 1;
        transform: none;
    }
}

/* Focus animations for keyboard navigation */
.focus-visible:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    animation: pulse 1s ease-in-out;
}

/* =============================================================================
   RESPONSIVE ANIMATIONS
   ============================================================================= */

@media (max-width: 768px) {
    /* Simplify animations on mobile */
    .card:hover {
        transform: translateY(-4px);
    }
    
    .pricing-card:hover {
        transform: translateY(-5px) scale(1.02);
    }
    
    .testimonial-card:hover {
        transform: scale(1.02);
    }
    
    /* Disable hover effects on touch devices */
    @media (hover: none) {
        .card:hover,
        .pricing-card:hover,
        .testimonial-card:hover,
        .btn:hover {
            transform: none;
            box-shadow: var(--shadow-sm);
        }
        
        .portfolio-item:hover::after {
            opacity: 0;
        }
        
        .portfolio-item:hover .portfolio-overlay {
            opacity: 0;
            transform: translate(-50%, -50%);
        }
    }
}
