/**
 * Critical CSS for SEO Performance (Core Web Vitals)
 *
 * This CSS contains critical above-the-fold styles to improve:
 * - First Contentful Paint (FCP)
 * - Largest Contentful Paint (LCP)
 * - Cumulative Layout Shift (CLS)
 *
 * @package Enfold
 * @since 1.0.0
 */

/* Prevent layout shift */
html {
    scroll-behavior: smooth;
}

/* Reserve space for images to prevent CLS */
img {
    max-width: 100%;
    height: auto;
    aspect-ratio: attr(width) / attr(height);
}

/* Font loading optimization */
body {
    font-display: swap;
}

/* Critical header styles */
#header {
    position: relative;
    z-index: 100;
}

#header_main {
    min-height: 70px;
}

/* Logo placeholder to prevent CLS */
.logo img {
    width: auto;
    max-height: 60px;
}

/* Navigation stability */
.main_menu {
    min-height: 70px;
}

/* Hero section placeholder */
.av-slideshow-full,
.avia-slideshow {
    min-height: 400px;
    background: #f5f5f5;
}

/* Content area minimum height */
#main {
    min-height: 100vh;
}

/* Footer stability */
#footer {
    min-height: 200px;
}

/* Lazy loaded images placeholder */
img[loading="lazy"] {
    background-color: #f0f0f0;
}

/* Skeleton loading effect for dynamic content */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* Optimize font rendering */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Reduce repaints */
.av-content-full,
.av-content-small {
    contain: layout style;
}

/* Button and link touch targets (mobile SEO) */
a, button {
    min-height: 44px;
    min-width: 44px;
}

/* Accessibility improvements (SEO factor) */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Skip to content link for accessibility */
.skip-to-content {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 15px;
    background: #000;
    color: #fff;
    text-decoration: none;
}

.skip-to-content:focus {
    left: 10px;
    top: 10px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: #fff;
        color: #000;
    }

    a {
        color: #0000EE;
        text-decoration: underline;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Print styles for SEO */
@media print {
    .noprint,
    #header,
    #footer,
    .av-burger-menu-main,
    .cookie-notice {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }

    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }
}

/* Schema.org microdata visual indicators (development) */
[itemscope] {
    /* Visual debugging aid - remove in production */
}

/* Structured data container */
.schema-data {
    display: none;
}

/* SEO-friendly heading hierarchy */
h1 {
    font-size: 2.5em;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

h2 {
    font-size: 2em;
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

h3 {
    font-size: 1.5em;
    line-height: 1.4;
    margin-top: 1em;
    margin-bottom: 0.5em;
}

/* Ensure heading order visibility */
article h1:first-of-type {
    font-weight: bold;
}

/* Breadcrumb styles for SEO */
.breadcrumb {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 1em;
}

.breadcrumb a {
    color: #0066cc;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 0.5em;
    color: #999;
}

/* Rich snippet friendly styles */
.rating {
    color: #f5a623;
}

.price {
    font-weight: bold;
    color: #333;
}

.availability {
    color: #27ae60;
}

/* Mobile-first responsive (Google's mobile-first indexing) */
@media screen and (max-width: 767px) {
    h1 {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.5em;
    }

    h3 {
        font-size: 1.2em;
    }

    /* Ensure tap targets are accessible */
    .menu-item a,
    .button,
    .btn {
        padding: 12px 16px;
        min-height: 48px;
    }

    /* Improve readability on mobile */
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    p {
        margin-bottom: 1em;
    }
}

/* Tablet optimizations */
@media screen and (min-width: 768px) and (max-width: 989px) {
    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.7em;
    }
}

/* Core Web Vitals optimization helpers */
.lcp-image {
    /* Mark this class for LCP images */
    will-change: transform;
    contain: paint;
}

.prevent-cls {
    /* Use this class to prevent layout shifts */
    min-height: var(--placeholder-height, 200px);
}

/* Cookie consent styling (GDPR compliance) */
.cookie-notice {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #333;
    color: #fff;
    padding: 15px;
    text-align: center;
}

.cookie-notice a {
    color: #4da3ff;
}

.cookie-notice button {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 8px 20px;
    margin-left: 10px;
    cursor: pointer;
    border-radius: 3px;
}

/* Improve INP (Interaction to Next Paint) */
button,
a,
input,
select,
textarea {
    touch-action: manipulation;
}

/* Content visibility for offscreen content */
.offscreen-content {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
}
