/**
 * CLS (Cumulative Layout Shift) Fixes
 * Prevents layout shifts by reserving space for elements
 */

/* Reserve space for header to prevent shift */
.site-header {
    min-height: 80px;
    position: relative;
    contain: layout style;
}

.header-inner {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Fix navigation layout shift */
.main-navigation {
    min-height: 50px;
    display: flex;
    align-items: center;
    contain: layout;
}

.main-navigation ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    min-height: 50px;
    align-items: center;
}

.main-navigation li {
    position: relative;
    margin: 0;
    padding: 0;
}

.main-navigation a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    white-space: nowrap;
    min-height: 50px;
    display: flex;
    align-items: center;
}

/* Reserve space for main content */
#primary.site-main {
    min-height: 100vh;
    contain: layout style;
}

/* Magazine layout container - starts immediately after header */
.magazine-layout {
    min-height: 800px;
    contain: layout style;
    padding-top: 40px;
}

@media (max-width: 768px) {
    .magazine-layout {
        padding-top: 20px;
    }
}

/* Fix image containers to prevent shift */
.post-thumbnail {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
    aspect-ratio: 4/3;
}

.magazine-item.featured-large .post-thumbnail {
    aspect-ratio: 16/9;
}

.magazine-item .post-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Typography - prevent font loading shifts */
body {
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Preload font display */
@font-face {
    font-family: 'System';
    font-display: swap;
    src: local(-apple-system), local(BlinkMacSystemFont), local("Segoe UI"), local(Roboto);
}

/* Removed feature grid - no longer used */

/* Prevent button shifts */
.button,
.read-more {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
}

/* Post meta fixed height */
.post-meta {
    min-height: 24px;
    display: flex;
    align-items: center;
}

/* Skeleton loading for images */
.post-thumbnail:not(.loaded) {
    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;
    }
}

/* Container widths to prevent shifts */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

/* Section padding consistency */
.content-section {
    padding: 60px 0;
}

/* Pagination fixed height */
.magazine-pagination {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer reservation */
.site-footer {
    min-height: 200px;
    contain: layout style;
}

/* Critical CSS for above-the-fold rendering */
.site {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Prevent FOUC (Flash of Unstyled Content) */
.no-js .site {
    visibility: hidden;
}

/* Logo dimensions */
.site-logo,
.custom-logo-link {
    display: block;
    max-height: 60px;
    width: auto;
}

.custom-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

/* Mobile menu button fixed size */
.menu-toggle {
    width: 44px;
    height: 44px;
    padding: 10px;
    display: none;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .main-navigation ul {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        min-height: auto;
        display: none;
    }
    
    .main-navigation.toggled ul {
        display: flex;
    }
}