/**
 * 首页网格布局样式
 * 优化版本 - 最佳性能状态
 */

/* 基础网格容器 */
.home-grid-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 15px;
    margin: 20px auto; /* 修改为auto以居中 */
    width: 98%; /* 修改宽度为98%，左右各空出1% */
    max-width: 98%; /* 确保最大宽度也是98% */
}

/* 网格区域基础样式 */
.grid-area {
    /*background-color: #fff;*/
    border-radius: 5px;
    overflow: hidden;
    /*box-shadow: 0 1px 3px rgba(0,0,0,0.1);*/
    /*transition: transform 0.3s ease, box-shadow 0.3s ease;*/
    will-change: transform, box-shadow;
    position: relative;
}


/* 空区域样式 */
.empty-area {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.empty-area h4 {
    margin-top: 0;
    font-size: 18px;
}

/* 加载状态 */
.grid-area.loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    z-index: 10;
}

.grid-area.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    z-index: 11;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 图片懒加载样式 */
.media-img.lazy {
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.3s ease;
}

.media-img.lazy.loaded {
    opacity: 1;
    filter: contrast(1.1) saturate(1.1);
}

/* 响应式调整 */
@media (max-width: 992px) {
    .home-grid-container {
        grid-template-columns: repeat(6, 1fr);
        width: 97%; /* 中等屏幕稍微减少边距 */
    }
    
    .grid-area-featured,
    .grid-area-latest,
    .grid-area-popular,
    .grid-area-sidebar,
    .grid-area-category1,
    .grid-area-category2,
    .grid-area-category3,
    .grid-area-category4 {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }
}

@media (max-width: 576px) {
    .home-grid-container {
        display: flex;
        flex-direction: column;
        gap: 15px;
        width: 96%; /* 小屏幕进一步减少边距 */
    }
    
    .grid-area {
        margin-bottom: 15px;
    }
}

/* 移动端隐藏辅助类（对应 page-home-grid.php 中 hide_on_mobile 配置项）*/
.mobile-hidden {
    display: none !important;
}

@media (min-width: 769px) {
    .mobile-hidden {
        display: block !important;
    }
}

/* 打印媒体查询 - 优化打印样式 */
@media print {
    .home-grid-container {
        display: block;
        width: 100%; /* 打印时使用全宽 */
    }
    
    .grid-area {
        margin-bottom: 20px;
        page-break-inside: avoid;
    }
}
