/* =============================================
   Ellis Trading — SEO & Core Web Vitals Enhancements
   ============================================= */

/* --- Core Web Vitals: avoid layout shift --- */
/* Reserve aspect-ratio boxes for images to prevent CLS */
.product-card__image {
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: var(--color-bg-alt);
}

.product-detail__image {
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: var(--color-bg-alt);
}

.hero__slide {
    /* Ensure hero slides don't cause CLS */
    contain: layout style paint;
}

/* --- Performance: contain paints where possible --- */
.product-card {
    contain: layout style paint;
}

.cart-sidebar {
    contain: layout style paint;
}

/* --- Accessibility: focus styles for keyboard nav --- */
.nav__link:focus-visible,
.btn:focus-visible,
.filter-btn:focus-visible,
.social-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* --- Skip to content link (a11y) --- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--color-primary);
    color: var(--color-bg);
    padding: 8px 16px;
    z-index: 999;
    font-weight: 600;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

/* --- Breadcrumb styles --- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--color-text-muted);
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--color-primary);
}

.breadcrumb__separator {
    color: var(--color-text-dark);
    user-select: none;
}

/* --- FAQ Section styles --- */
.faq-section {
    padding: 60px 0;
}

.faq-section__title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 32px;
    text-align: center;
}

.faq-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
}

.faq-item__question {
    width: 100%;
    background: var(--color-bg-card);
    border: none;
    color: var(--color-text);
    padding: 16px 24px;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-body);
    transition: background 0.2s;
}

.faq-item__question:hover {
    background: rgba(201, 168, 76, 0.05);
}

.faq-item__answer {
    padding: 8px 24px 20px;
    margin-top: 4px;
    color: var(--color-text-muted);
    line-height: 1.7;
    font-size: 0.95rem;
    display: none;
}

.faq-item.open .faq-item__answer {
    display: block;
}

.faq-item__question::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--color-primary);
    transition: transform 0.3s;
}

.faq-item.open .faq-item__question::after {
    content: '−';
}

/* --- SEO: visually hidden but accessible --- */
.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;
}

/* --- Lazy loading fade-in animation --- */
img[loading="lazy"] {
    transition: opacity 0.3s ease;
}

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

img[loading="lazy"] {
    opacity: 0;
}

/* --- Print styles --- */
@media print {
    .header, .cart-sidebar, .overlay, .search-overlay, .hero__prev, .hero__next {
        display: none !important;
    }
    body {
        background: white;
        color: black;
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* --- Cart item styles --- */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border, #2a2440);
    gap: 12px;
}
.cart-item__info { flex: 1; min-width: 0; }
.cart-item__name {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.3;
}
.cart-item__price {
    font-size: 0.85rem;
    color: var(--color-primary, #c9a84c);
    font-weight: 600;
}
.cart-item__qty {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.cart-item__qty button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border, #2a2440);
    background: var(--color-bg-card, #1e1830);
    color: var(--color-text, #e8e4ef);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cart-item__qty button:hover {
    background: var(--color-primary, #c9a84c);
    color: #000;
}
.cart-item__qty span {
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* --- Mobile nav overlay --- */
@media (max-width: 768px) {
    .nav {
        display: none !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 11, 20, 0.98);
        z-index: 9999;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
    }
    .nav.open {
        display: flex !important;
    }
    .nav__list {
        flex-direction: column;
        align-items: center;
        gap: 0;
    }
    .nav__item {
        margin: 0;
    }
    .nav__link {
        font-size: 1.4rem;
        padding: 16px 24px;
        display: block;
    }
    .dropdown {
        position: static;
        background: transparent;
        box-shadow: none;
        padding: 0;
        margin-top: 0;
    }
    .dropdown__link {
        font-size: 1rem;
        padding: 10px 40px;
        color: var(--color-text-muted, #9a93b0);
    }
}

/* --- Search results dropdown --- */
.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-card, #1e1830);
    border: 1px solid var(--color-border, #2a2440);
    border-top: none;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    border-radius: 0 0 8px 8px;
}
.search-overlay.active .search-results {
    display: block;
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--color-text, #e8e4ef);
    border-bottom: 1px solid var(--color-border, #2a2440);
    transition: background 0.2s;
}
.search-result-item:hover {
    background: rgba(201, 168, 76, 0.08);
}
.search-result-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.search-result-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.search-result-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-price {
    font-size: 0.8rem;
    color: var(--color-primary, #c9a84c);
    font-weight: 600;
}
.search-no-results {
    padding: 20px 16px;
    text-align: center;
    color: var(--color-text-muted, #9a93b0);
    font-size: 0.9rem;
}

/* --- Mobile menu button visible on small screens --- */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 10000;
}
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    .mobile-menu-btn span {
        display: block;
        width: 24px;
        height: 2px;
        background: var(--color-text, #e8e4ef);
        border-radius: 2px;
        transition: transform 0.3s;
    }
}
