/* Performance & Responsive Optimizations */

/* Image Optimization */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy Loading Images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Contain Layout for Better Performance */
.arvan-card,
.arvan-section {
    contain: layout style paint;
}

/* Will-change for Animations */
.arvan-card:hover,
.arvan-btn-primary:hover,
.arvan-btn-secondary:hover {
    will-change: transform;
}

/* GPU Acceleration */
.arvan-card,
.arvan-btn-primary,
.arvan-btn-secondary {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Font Loading Optimization */
@font-face {
    font-family: 'Vazirmatn';
    font-display: swap;
}

/* Critical CSS - Above the fold content */
.arvan-header {
    will-change: transform;
}

/* Reduce Layout Shifts */
.arvan-logo img {
    width: auto;
    height: 40px;
    aspect-ratio: auto;
}

/* Container Queries (if supported) */
@supports (container-type: inline-size) {
    .arvan-card {
        container-type: inline-size;
    }
}

/* Grid Auto-fit Optimization */
.arvan-grid {
    grid-auto-rows: minmax(min-content, max-content);
}

/* Smooth Scrolling */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Focus Visible for Accessibility */
.arvan-btn-primary:focus-visible,
.arvan-btn-secondary:focus-visible,
.arvan-nav-menu a:focus-visible {
    outline: 2px solid var(--arvan-primary);
    outline-offset: 2px;
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .arvan-card:hover {
        transform: none;
    }
    
    .arvan-btn-primary:active,
    .arvan-btn-secondary:active {
        transform: scale(0.98);
    }
    
    /* Larger touch targets on mobile */
    .arvan-nav-menu a,
    .arvan-btn-primary,
    .arvan-btn-secondary {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .arvan-card {
        border: 2px solid var(--arvan-text);
    }
    
    .arvan-btn-primary,
    .arvan-btn-secondary {
        border: 2px solid currentColor;
    }
}

/* Viewport Height Units for Mobile */
@media (max-width: 768px) {
    .arvan-hero {
        min-height: 60vh;
        display: flex;
        align-items: center;
    }
}

/* Optimize Repaints */
.arvan-header nav,
.arvan-footer-content {
    contain: layout;
}

/* Intersection Observer for Lazy Loading */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Prevent Flash of Unstyled Content */
.arvan-header {
    visibility: visible;
    opacity: 1;
}

/* Optimize Animations */
@media (prefers-reduced-motion: no-preference) {
    .arvan-card {
        transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    }
}

/* Text Rendering Optimization */
body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Content Visibility for Performance */
@media (max-width: 768px) {
    .arvan-section:not(:first-of-type) {
        content-visibility: auto;
        contain-intrinsic-size: 400px;
    }
}

