/* Loading Screen Styles */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--loading-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease, background 0.3s ease;
    animation: fadeIn 0.3s ease-out;
}

.loading-content {
    text-align: center;
    color: var(--loading-text);
    max-width: 400px;
    padding: 2rem;
    animation: slideInUp 0.6s ease-out 0.2s both;
    transition: color 0.3s ease;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--loading-text);
    border-radius: 50%;
    animation: spin 1s linear infinite, pulse 2s ease-in-out infinite;
    margin: 0 auto 20px;
    position: relative;
}

.loading-spinner::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid transparent;
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1.5s linear infinite reverse;
}

.loading-text {
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0 0 20px 0;
    animation: fadeInUp 0.8s ease-out 0.4s both;
    transition: color 0.3s ease;
}

/* Progress Bar */
.loading-progress {
    width: 100%;
    height: 6px;
    background: var(--progress-bg, rgba(255, 255, 255, 0.1));
    border-radius: 3px;
    overflow: hidden;
    margin: 20px 0;
    position: relative;
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--text-primary));
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s ease;
    position: relative;
}

.loading-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

/* Loading Steps */
.loading-steps {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    animation: fadeInUp 0.8s ease-out 0.8s both;
    transition: color 0.3s ease;
}

.loading-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out both;
}

.loading-step:nth-child(1) { animation-delay: 1.0s; }
.loading-step:nth-child(2) { animation-delay: 1.1s; }
.loading-step:nth-child(3) { animation-delay: 1.2s; }
.loading-step:nth-child(4) { animation-delay: 1.3s; }
.loading-step:nth-child(5) { animation-delay: 1.4s; }

.loading-step-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--step-icon-bg, rgba(255, 255, 255, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
}

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

.loading-step.active .loading-step-icon {
    background: var(--accent-color);
    color: var(--text-on-accent);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(var(--accent-color-rgb), 0.3);
}

.loading-step.active .loading-step-icon::before {
    left: 100%;
}

.loading-step.completed .loading-step-icon {
    background: var(--success-color);
    color: var(--text-on-accent);
    transform: scale(1.05);
    animation: completedPulse 0.6s ease-out;
}

/* Resource Counter */
.loading-resources {
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-top: 10px;
    animation: fadeInUp 0.8s ease-out 1.4s both;
    transition: color 0.3s ease;
}

/* All animations now centralized in animations.css */
/* Note: shimmer and completedPulse are loader-specific and kept in animations.css */

/* Loading Screen Exit Animation */
.loading-screen.fade-out {
    animation: fadeOut 0.5s ease-in forwards;
}

.loading-screen.fade-out .loading-content {
    animation: slideOutUp 0.5s ease-in forwards;
}

/* fadeOut and slideOutUp animations moved to animations.css */

/* Hide loading screen when content is ready */
.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .loading-content {
        max-width: 300px;
        padding: 1.5rem;
    }
    
    .loading-text {
        font-size: 1rem;
    }
    
    .loading-steps {
        font-size: 0.7rem;
    }
    
    .loading-step-icon {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }
}

/* Slow connection optimizations */
.slow-connection {
    /* Disable non-critical animations */
    --animation-duration: 0.1s;
    --transition-duration: 0.1s;
}

.slow-connection * {
    animation-duration: var(--animation-duration) !important;
    transition-duration: var(--transition-duration) !important;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--accent-color);
    color: var(--text-on-accent);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.offline-indicator svg {
    flex-shrink: 0;
}

/* slideInRight animation moved to animations.css */

/* Slow connection loading screen adjustments */
.loading-screen.slow-connection .loading-spinner {
    animation-duration: 1s;
}

.loading-screen.slow-connection .loading-progress-bar {
    transition-duration: 0.2s;
}

/* Screen reader only content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Reduced motion support */
.reduced-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

.reduced-motion .loading-spinner {
    animation: none !important;
}

.reduced-motion .loading-progress-bar {
    transition: none !important;
}

.reduced-motion .loading-step-icon {
    animation: none !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .loading-screen {
        border: 2px solid var(--text-color);
    }
    
    .loading-progress-bar {
        border: 1px solid var(--text-color);
    }
    
    .loading-step-icon {
        border: 1px solid var(--text-color);
    }
}

/* Focus indicators for keyboard navigation */
.loading-screen:focus-within {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.loading-step:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Smooth content entrance animations */
.main-content {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.main-content.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Section entrance animations */
.hero, .about-section, .services-overview, .contact, .cta, .footer {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Ensure header is never affected by animations */
.header,
.header *,
.nav,
.nav *,
.nav-container,
.nav-menu,
.nav-link {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    transition: none !important;
}

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

.about-section.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.services-overview.animate-in {
    opacity: 1;
    transform: translateY(0);
}

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

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

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

/* Enhanced loading screen exit animation */
.loading-screen.fade-out {
    animation: enhancedFadeOut 0.8s ease-in-out forwards;
}

.loading-screen.fade-out .loading-content {
    animation: enhancedSlideOutUp 0.8s ease-in-out forwards;
}

/* Enhanced animations moved to animations.css */

/* Device-specific optimizations */
@media (max-width: 768px) {
    .main-content {
        transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    }
    
    .hero, .about-section, .services-overview, .contact, .cta, .footer {
        transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    }
    
    .loading-screen.fade-out {
        animation-duration: 0.6s;
    }
}

/* High-performance devices */
@media (min-width: 1200px) {
    .main-content {
        transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    }
    
    .hero, .about-section, .services-overview, .contact, .cta, .footer {
        transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    }
} /* Image Optimization and Loading States */

/* Background image loading states */
.bg-loaded {
    background-attachment: scroll; /* Default, can be overridden */
}

/* Parallax effect for hero section */
.hero.bg-loaded {
    background-attachment: fixed;
}

/* Smooth background transitions */
section {
    transition: background-image 0.3s ease-in-out;
}

/* Responsive image loading */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img.loaded {
    opacity: 1;
}

/* Image loading placeholder */
img.lazy::before {
    content: '';
    display: block;
    width: 100%;
    height: 200px;
    background: linear-gradient(90deg, var(--surface-color) 0%, var(--border-color) 50%, var(--surface-color) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* Section background overlay for better text readability */
.hero,
.about-section,
.services-overview,
.contact,
.cta {
    position: relative;
}

.hero::before,
.about-section::before,
.services-overview::before,
.contact::before,
.cta::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 1;
    transition: background-color 0.3s ease;
}

[data-theme="dark"] .hero::before,
[data-theme="dark"] .about-section::before,
[data-theme="dark"] .services-overview::before,
[data-theme="dark"] .contact::before,
[data-theme="dark"] .cta::before {
    background: rgba(0, 0, 0, 0.3);
}

/* Content should be above overlay */
.hero > *,
.about-section > *,
.services-overview > *,
.contact > *,
.cta > * {
    position: relative;
    z-index: 2;
}

/* Responsive image optimization */
@media (max-width: 768px) {
    /* Disable parallax on mobile for performance */
    .hero.bg-loaded {
        background-attachment: scroll;
    }
    
    /* Reduce background image complexity on small screens */
    .about-section,
    .services-overview,
    .contact,
    .cta {
        background-size: cover;
        background-position: center;
    }
}

/* High-resolution display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* High-res specific styles could go here */
}

/* Prefers-reduced-motion support */
@media (prefers-reduced-motion: reduce) {
    section,
    img.lazy,
    .hero::before,
    .about-section::before,
    .services-overview::before,
    .contact::before,
    .cta::before {
        transition: none;
    }
    
    .hero.bg-loaded {
        background-attachment: scroll;
    }
    
    @keyframes shimmer {
        0%, 100% { background-position: 0% 0; }
    }
}

/* Loading states for background images */
.hero,
.about-section,
.services-overview,
.contact,
.cta {
    /* Default gradient background while images load */
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--background-color) 100%);
}

/* Image format support classes for progressive enhancement */
.webp .hero,
.webp .about-section,
.webp .services-overview,
.webp .contact,
.webp .cta {
    /* WebP-specific optimizations could go here */
}

.avif .hero,
.avif .about-section,
.avif .services-overview,
.avif .contact,
.avif .cta {
    /* AVIF-specific optimizations could go here */
}

/* Error state for failed image loads */
.bg-error {
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--border-color) 100%);
}

.bg-error::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: var(--text-muted);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.3;
    z-index: 1;
}/* Mobile Enhancements CSS - Task 5 Implementation */
/* Enhanced mobile experience with improved touch interactions and animations */

/* Touch feedback styles */
.touch-active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Touch ripple effect */
.touch-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: touch-ripple 0.6s ease-out;
    pointer-events: none;
    z-index: 1;
}

@keyframes touch-ripple {
    0% {
        transform: scale(0);
        opacity: 0.8;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Enhanced mobile menu animations - don't override existing transitions */
.nav-menu {
    /* Don't override existing critical CSS transitions */
}

.nav-menu.active {
    /* Don't override existing animations that conflict with critical CSS */
}

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

/* Mobile menu item stagger animations */
.nav-menu .nav-link {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-menu.active .nav-link {
    animation: slide-in-up 0.4s ease-out both;
}

.nav-menu.active .nav-link:nth-child(1) { animation-delay: 0.1s; }
.nav-menu.active .nav-link:nth-child(2) { animation-delay: 0.15s; }
.nav-menu.active .nav-link:nth-child(3) { animation-delay: 0.2s; }
.nav-menu.active .nav-link:nth-child(4) { animation-delay: 0.25s; }
.nav-menu.active .nav-link:nth-child(5) { animation-delay: 0.3s; }

@keyframes slide-in-up {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced touch targets for mobile */
@media (max-width: 768px) {
    /* Ensure minimum touch target size for interactive elements (excluding nav elements) */
    button:not(.mobile-menu-toggle),
    a:not(.nav-link),
    input,
    [role="button"] {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: relative;
        overflow: hidden;
    }
    
    /* Enhanced mobile menu toggle styles (don't override layout properties) */
    .mobile-menu-toggle {
        /* Only add visual enhancements, let responsive.css handle layout */
        border-radius: 8px;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:active {
        transform: scale(0.9);
        background: rgba(0, 0, 0, 0.1);
    }
    
    /* Enhanced hamburger animation */
    .mobile-menu-toggle span {
        transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        transform-origin: center;
    }
    
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
        transform: scale(0);
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    /* Touch-friendly form inputs */
    input,
    textarea,
    select {
        min-height: 48px;
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: 8px;
        transition: all 0.2s ease;
    }
    
    input:focus,
    textarea:focus,
    select:focus {
        transform: scale(1.02);
        box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    }
    
    /* Enhanced button interactions */
    .btn,
    button {
        position: relative;
        overflow: hidden;
        transition: all 0.2s ease;
        border-radius: 8px;
        min-height: 48px;
        padding: 12px 24px;
    }
    
    .btn:active,
    button:active {
        transform: scale(0.95);
    }
    
    /* Card touch interactions */
    .card,
    .service-item {
        transition: all 0.2s ease;
        position: relative;
        overflow: hidden;
    }
    
    .card:active,
    .service-item:active {
        transform: scale(0.98);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    }
    
    /* Theme toggle enhanced for mobile */
    .theme-toggle {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .theme-toggle:active {
        transform: scale(0.9) rotate(180deg);
    }
    
    /* Section scroll indicators for swipe gestures */
    .section-scroll-indicator {
        position: fixed;
        top: 50%;
        right: 16px;
        transform: translateY(-50%);
        display: flex;
        flex-direction: column;
        gap: 8px;
        z-index: 100;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .section-scroll-indicator.visible {
        opacity: 1;
    }
    
    .section-scroll-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(52, 152, 219, 0.5);
        transition: all 0.3s ease;
    }
    
    .section-scroll-dot.active {
        background: #3498db;
        transform: scale(1.5);
    }
    
    /* Swipe gesture hints */
    .swipe-hint {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 12px;
        opacity: 0;
        transition: all 0.3s ease;
        z-index: 1000;
        pointer-events: none;
    }
    
    .swipe-hint.show {
        opacity: 1;
        animation: swipe-hint-bounce 2s ease-in-out infinite;
    }
    
    @keyframes swipe-hint-bounce {
        0%, 100% {
            transform: translateX(-50%) translateY(0);
        }
        50% {
            transform: translateX(-50%) translateY(-5px);
        }
    }
}

/* Dark theme support for mobile enhancements */
[data-theme="dark"] .touch-ripple {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .mobile-menu-toggle:active {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .swipe-hint {
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .touch-active,
    .nav-menu,
    .nav-menu .nav-link,
    .mobile-menu-toggle span,
    input,
    textarea,
    select,
    .btn,
    button,
    .card,
    .service-item,
    .theme-toggle,
    .section-scroll-indicator,
    .section-scroll-dot,
    .swipe-hint {
        animation: none !important;
        transition: none !important;
    }
    
    .touch-ripple {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .touch-ripple {
        background: rgba(0, 0, 0, 0.5);
        border: 2px solid currentColor;
    }
    
    .section-scroll-dot {
        border: 2px solid currentColor;
        background: transparent;
    }
    
    .section-scroll-dot.active {
        background: currentColor;
    }
}

/* Orientation change handling */
@media (orientation: landscape) and (max-height: 500px) {
    .nav-menu.active {
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .swipe-hint {
        bottom: 10px;
        font-size: 11px;
        padding: 6px 12px;
    }
}