/**
 * SEO & Core Web Vitals Optimization CSS
 * Improves LCP, CLS, and overall page performance
 * 
 * @package TREXONN Website SEO
 * @version 2.0
 */

/* ==========================================================================
   Critical CSS - Above the Fold Optimization
   ========================================================================== */

/* Prevent Layout Shift (CLS) */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
    aspect-ratio: attr(width) / attr(height);
}

/* Reserve space for images to prevent CLS */
img[width][height] {
    aspect-ratio: attr(width) / attr(height);
}

/* Lazy loading placeholder styles */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img.lazy.loaded {
    opacity: 1;
}

/* Image loading skeleton */
.img-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;
    }
}

/* ==========================================================================
   Typography Optimization
   ========================================================================== */

/* 
 * Font Display Optimization
 * Ensure all custom fonts use font-display: swap in their @font-face declarations
 * This is typically done in the main stylesheet or font loading service
 */

/* Optimize text rendering */
body {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Preload critical fonts hint */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-display: swap;
}

/* ==========================================================================
   SEO-Friendly Heading Styles
   ========================================================================== */

/* Proper heading hierarchy for SEO */
h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    line-height: 1.2;
    margin-bottom: 1rem;
    font-weight: 700;
}

h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    line-height: 1.3;
    margin-bottom: 0.875rem;
    font-weight: 600;
}

h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    line-height: 1.4;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* ==========================================================================
   Accessibility Improvements (also benefits SEO)
   ========================================================================== */

/* Focus states for better accessibility */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #075B46;
    outline-offset: 2px;
}

/* Skip to content link for accessibility and SEO */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #075B46;
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s;
    text-decoration: none;
    font-weight: 600;
}

.skip-to-content:focus {
    top: 0;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Link Optimization for SEO
   ========================================================================== */

/* Make links more visible for crawlers and users */
a {
    text-decoration-skip-ink: auto;
    color: inherit;
}

/* External link indicator - DISABLED to prevent layout issues in tables */
/* Uncomment if you want external link arrows on text links only */
/*
a[target="_blank"]:not(.btn):not([class*="btn-"])::after {
    content: " ↗";
    font-size: 0.75em;
    vertical-align: super;
}
*/

/* Ensure arrows never appear on global navigation or action buttons */
.header-menu-list a::after,
.btn::after,
[class*="btn-"]::after,
#iso-logo::after {
    display: none !important;
    content: none !important;
}

/* ==========================================================================
   Breadcrumb Styles for SEO
   ========================================================================== */

.breadcrumb-nav {
    padding: 12px 0;
    font-size: 0.875rem;
}

.breadcrumb-nav ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 8px;
}

.breadcrumb-nav li {
    display: flex;
    align-items: center;
}

.breadcrumb-nav li:not(:last-child)::after {
    content: "›";
    margin-left: 8px;
    color: #666;
}

.breadcrumb-nav a {
    color: #075B46;
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    text-decoration: underline;
}

.breadcrumb-nav [aria-current="page"] {
    color: #333;
    font-weight: 500;
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* Reduce paint complexity */
* {
    will-change: auto;
}

/* Hardware acceleration for animations */
.animated,
.owl-carousel,
.slider-activation {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* 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;
    }
}

/* ==========================================================================
   Print Styles for SEO (PDF generation)
   ========================================================================== */

@media print {

    /* Show URLs for links in print */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Hide navigation and non-essential elements */
    header nav,
    footer,
    .popup_wrapper,
    .slogan-area-start,
    .skip-to-content {
        display: none !important;
    }

    /* Ensure text is readable */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }

    /* Break pages appropriately */
    h1,
    h2,
    h3 {
        page-break-after: avoid;
    }

    img {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   Schema Markup Visual Helpers (hidden from users, visible to crawlers)
   ========================================================================== */

/* Hidden structured data containers */
[itemscope]:not([itemtype*="schema.org"]) {
    display: contents;
}

/* ==========================================================================
   Mobile SEO Optimization
   ========================================================================== */

@media (max-width: 768px) {

    /* Ensure tap targets are at least 44px - only for navigation links, not table buttons */
    nav a,
    .footer-list a,
    .header-menu-list a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Improve mobile readability */
    body {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Ensure text doesn't overflow */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* ==========================================================================
   FAQ Accordion SEO Styles (for FAQ schema)
   ========================================================================== */

.faq-item {
    border-bottom: 1px solid #e0e0e0;
    padding: 16px 0;
}

.faq-question {
    font-weight: 600;
    color: #075B46;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.faq-question::after {
    content: "+";
    font-size: 1.5rem;
    font-weight: 300;
    transition: transform 0.3s ease;
}

.faq-item.active .faq-question::after {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 0 12px 0;
    line-height: 1.7;
    color: #444;
}

/* ==========================================================================
   Product Card SEO Enhancement
   ========================================================================== */

.product-card {
    position: relative;
}

.product-card .product-name {
    font-weight: 600;
}

.product-card .product-price {
    font-size: 1.125rem;
    color: #075B46;
    font-weight: 700;
}

.product-card .product-availability {
    color: #28a745;
    font-size: 0.875rem;
}

/* ==========================================================================
   Rich Snippet Enhancement
   ========================================================================== */

/* Star rating display */
.star-rating {
    color: #FCC417;
    font-size: 1rem;
}

.star-rating .empty {
    color: #ddd;
}

/* Price display */
.price-display {
    font-size: 1.25rem;
    font-weight: 700;
    color: #075B46;
}

.price-display .currency {
    font-size: 0.875rem;
    font-weight: normal;
}

/* ==========================================================================
   Content Optimization
   ========================================================================== */

/* Improve readability scores - only for article content, not containers */
article>p,
.content-area>p {
    max-width: 100%;
    line-height: 1.8;
}

/* Paragraph spacing */
article p,
.blog-details p {
    margin-bottom: 1.25em;
}

/* List styling for SEO */
article ul,
article ol {
    padding-left: 1.5rem;
    margin-bottom: 1.25em;
}

article li {
    margin-bottom: 0.5em;
    line-height: 1.6;
}