/* 瀑布流布局样式 */
.masonry-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}

/* 确保容器在所有屏幕尺寸下都能正确显示列 */
.masonry-container {
    max-width: 100%;
    box-sizing: border-box;
}

/* 确保列不会被压缩 */
.masonry-column {
    flex-shrink: 0 !important;
}

/* 瀑布流列 */
.masonry-column {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

/* 响应式列数控制 - 手机端只显示2列 */
@media (max-width: 639px) {
    .masonry-column:nth-child(n+3) {
        display: none !important;
    }
    .masonry-column {
        flex-basis: 48% !important;
        width: 48% !important;
        flex: 0 0 48% !important;
        box-sizing: border-box !important;
    }
    
    /* 确保手机端显示2列 */
    .masonry-container {
        flex-direction: row;
        justify-content: space-between;
        flex-wrap: wrap;
        box-sizing: border-box !important;
        gap: 0.5rem;
    }
    
    /* 确保卡片内容不超出列宽 */
    .masonry-column > * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* 平板设备 - 显示3列 */
@media (min-width: 640px) and (max-width: 767px) {
    .masonry-column:nth-child(n+4) {
        display: none;
    }
    .masonry-column {
        flex-basis: calc(33.333% - 0.666rem) !important;
    }
}

/* 中等屏幕 - 显示4列 */
@media (min-width: 768px) and (max-width: 1023px) {
    .masonry-column:nth-child(n+5) {
        display: none;
    }
    .masonry-column {
        flex-basis: calc(25% - 0.75rem) !important;
    }
}

/* 大屏幕 - 默认显示5列 */
@media (min-width: 1024px) {
    .masonry-column {
        flex-basis: calc(20% - 0.8rem) !important;
    }
    
    /* 头像分类大屏幕显示10列 */
    [data-category-type="avatar"] .masonry-column {
        flex-basis: calc(10% - 0.9rem) !important;
        display: flex !important;
    }
    
    /* 确保头像分类在大屏幕下显示所有10列 */
    [data-category-type="avatar"] .masonry-column:nth-child(n) {
        display: flex !important;
    }
}

/* 手机端首页瀑布流全屏显示 */
@media (max-width: 639px) {
    .mobile-full-width {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    .mobile-full-width .masonry-container {
        gap: 0.5rem;
    }
    .mobile-full-width .masonry-column {
        gap: 0.5rem;
    }
    .mobile-full-width .masonry-column {
        flex-basis: 48% !important;
        width: 48% !important;
        flex: 0 0 48% !important;
        box-sizing: border-box !important;
    }
}

/* 防止内容跨列断裂 */
.break-inside-avoid {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* 隐藏滚动条但保留功能 */
.scrollbar-hide {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
}

/* 分类卡片悬停效果增强 */
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* 深色模式下的分类卡片悬停效果 */
@media (prefers-color-scheme: dark) {
    .category-card:hover {
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
    }
}

/* 分类卡片基础样式 */
.category-card {
    scroll-snap-align: start;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

/* 滑动容器样式 - 增强平滑效果 */
#categories-scroll {
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
    overscroll-behavior-x: contain; /* 防止滚动链 */
    padding-bottom: 8px;
}

/* 平滑滚动动画 */
#categories-scroll {
    transition: scroll-left 0.3s ease-out;
}

/* 分类卡片图标容器 */
.category-card .fa {
    transition: all 0.3s ease;
}

.category-card:hover .fa {
    transform: scale(1.1);
}

/* 预览模态框样式优化 */
#preview-modal {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.95);
}

#preview-modal .relative {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: 100vh;
}

#preview-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 1rem;
}

#preview-content img,
#preview-content video {
    max-width: 100% !important;
    max-height: 90vh !important;
    object-contain !important;
    margin: 0 auto !important;
    display: block !important;
}

#close-preview {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    z-index: 10;
}

#close-preview:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

/* 确保预览内容在移动设备上也能完整显示 */
@media (max-width: 768px) {
    #preview-modal {
        padding: 0.5rem;
    }
    
    #preview-content {
        padding: 0.5rem;
    }
    
    #preview-content img,
    #preview-content video {
        max-height: 85vh !important;
    }
    
    #close-preview {
        width: 2.5rem;
        height: 2.5rem;
        top: 0.5rem;
        right: 0.5rem;
    }
}



/* 精选壁纸横向滚动样式 - 与分类板块保持一致 */
.featured-wallpapers-container {
    position: relative;
    margin: 2rem 0;
}

.featured-wallpapers-scroll {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding: 0.5rem 0 1.5rem;
    scroll-behavior: smooth;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
}

.featured-wallpapers-scroll::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
}

.featured-wallpaper-card {
    flex: 0 0 auto;
    width: 280px;
    border-radius: 0.5rem;
    overflow: hidden;
    aspect-ratio: 16/9;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    scroll-snap-align: start;
    position: relative;
}

.featured-wallpaper-card.vertical {
    aspect-ratio: 9/18;
}

.featured-wallpaper-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.featured-wallpaper-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.featured-wallpaper-card:hover img {
    transform: scale(1.05);
}

/* 渐变遮罩，增强视觉效果 */
.featured-wallpaper-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.2), transparent 50%);
    pointer-events: none;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .featured-wallpaper-card {
        width: 200px;
    }
    
    .featured-wallpapers-scroll {
        gap: 0.75rem;
        padding: 0.25rem 0 1rem;
    }
}

/* 轮播图样式 */
.carousel-container {
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

.carousel-wrapper {
    position: relative;
    width: 100%;
    height: 80vh;
    overflow: hidden;
    
    display: flex; /* 核心：开启弹性盒 */    /* 确保轮播图垂直居中 */
    align-items: center;     /* 确保轮播图垂直居中 */    
}

.carousel-images {
    display: flex;
    transition: transform 0.5s ease-in-out;
    will-change: transform;
    
    align-items: center;    /* 确保轮播图垂直居中 */    
}

.carousel-item {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
}

.carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 左右渐变遮罩 */
.carousel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.carousel-overlay-left {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 15%;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
}

.carousel-overlay-right {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 15%;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
}

/* 导航按钮 */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.carousel-btn-left {
    left: 20px;
}

.carousel-btn-right {
    right: 20px;
}

/* 指示器 */
.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 20;
}

.carousel-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-indicator:hover {
    background: rgba(255, 255, 255, 0.8);
}

.carousel-indicator.active {
    background: white;
    transform: scale(1.25);
}

/* 轮播图响应式设计 */
@media (max-width: 1024px) {
    .carousel-overlay-left,
    .carousel-overlay-right {
        width: 20%;
    }
}

@media (max-width: 768px) {
    .carousel-overlay-left,
    .carousel-overlay-right {
        width: 25%;
    }
    
    .carousel-btn {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .carousel-btn-left {
        left: 10px;
    }
    
    .carousel-btn-right {
        right: 10px;
    }
}

@media (max-width: 768px) {
    /* 平板端调整轮播图高度 */
    .carousel-wrapper {
        height: 50vh !important;
    }
}

@media (max-width: 480px) {
    .carousel-overlay-left,
    .carousel-overlay-right {
        width: 30%;
    }
    
    /* 手机端调整轮播图高度，确保不超过屏幕高度的50% */
    .carousel-wrapper {
        height: 28vh !important;
        max-height: 28vh !important;
        position: relative;
    }
    
    /* 确保图片在手机端完全覆盖轮播区域，避免留白 */
    .carousel-item img {
        object-fit: cover !important;
    }
    
    /* 手机端调整分类卡片容器 */
    #categories-section {
        position: relative;
        height: auto;
    }
    
    /* 手机端调整分类卡片大小 */
    .category-card {
        width: 80px !important;
        height: 39px !important;
        margin-bottom: 0 !important;
    }
    
    /* 手机端调整分类卡片文字大小 */
    .category-card h3 {
        font-size: 0.875rem !important;
    }
    
    /* 调整轮播图和分类卡片区域的间距 */
    .carousel-container {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* 加载更多平滑淡入动画 */
.animate-fade-in {
    animation: fadeInFromTop 0.6s ease-out forwards;
    opacity: 0;
    transform: translateY(-40px);
    /* 确保元素初始位置在可视区域上方 */
    position: relative;
}

@keyframes fadeInFromTop {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}