/**
 * Performance Optimized CSS
 * 
 * Critical CSS for above-the-fold content
 * 
 * @package Triply_Child
 * @since 1.0.0
 */

/* Critical CSS - Above the fold */
.site-header {
    position: relative;
    z-index: 1000;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    max-width: 1200px;
    margin: 0 auto;
}

.site-branding {
    flex: 0 0 auto;
}

.site-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    text-decoration: none;
}

.primary-nav {
    flex: 1;
    text-align: center;
}

.primary-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    justify-content: center;
    gap: 30px;
}

.primary-menu li a {
    /* color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease; */
}

.primary-menu li a:hover {
    /* color: #aa8453; */
}

/* Hero Section - Critical */
.hero-section {
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

/* Performance optimizations */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

/* Lazy loading - Improved implementation */
img {
    transition: opacity 0.3s ease-in-out;
}

/* Only apply lazy loading styles to images with data-src */
img[data-src] {
    opacity: 0;
    background: #f0f0f0;
    background-image: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

img[data-src].loaded {
    opacity: 1;
    background: none;
    animation: none;
}

/* Loading shimmer animation */
@keyframes loading-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Native lazy loading fallback */
img[loading="lazy"] {
    opacity: 1;
}

/* Error state for failed images */
img.error {
    opacity: 0.5;
    background: #f8f8f8;
    border: 1px dashed #ccc;
}

/* Aspect ratio containers for better layout */
.image-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 default */
    overflow: hidden;
}

.image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Different aspect ratios */
.image-container--square {
    padding-bottom: 100%;
}

.image-container--portrait {
    padding-bottom: 133.33%; /* 3:4 */
}

.image-container--landscape {
    padding-bottom: 75%; /* 4:3 */
}

/* Lazy loading placeholder */
.lazy-placeholder {
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    min-height: 200px;
    border-radius: 4px;
}

.placeholder-content {
    text-align: center;
}

.placeholder-content svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

/* Reduce layout shifts */
.aspect-ratio {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.aspect-ratio img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Optimize animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Critical responsive styles */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .primary-menu {
        /* flex-direction: column;
        gap: 15px; */
    }
    
    .header-inner {
        flex-direction: column;
        gap: 15px;
    }
}

/* Preload critical resources */
/* Google Fonts are enqueued via WordPress; avoid declaring @font-face with a CSS URL */

/* Optimize for Core Web Vitals */
.hero-section {
    contain: layout style paint;
}

.site-header {
    /* contain: layout style; */
}

/* Reduce paint complexity */
.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    will-change: transform;
    transform: translateZ(0);
}

/* Optimize scrolling */
html {
    scroll-behavior: smooth;
}

/* Critical loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
