/**
 * 相关文章瀑布流样式
 * 简化版本，使用BEM命名规范
 */

/* 相关文章区域 */
.related-section {
    margin-top: 30px;
    margin-bottom: 30px;
}

/* 相关文章标题 - 绿色加粗样式 */
.related-title {
    font-size: var(--font-size-xxl);
    color: var(--color-primary);
    font-weight: 700;
    margin-bottom: var(--space-lg);
    display: block;
    width: 100%;
}

/* 相关文章网格 - 使用related-posts-waterfall容器 */
.related-posts-waterfall {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

/* 相关文章卡片 */
.related-card {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none !important;
    color: inherit !important;
}

.related-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* 卡片缩略图 */
.related-card__thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: cover;
    box-shadow: none !important;
}

.related-card__thumb--loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.related-card__thumb--loaded {
    opacity: 1;
}

/* 图片加载失败时的兜底样式 */
.related-card__thumb--error {
    background: #f0f0f0 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23ccc"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>') center/50% no-repeat !important;
}

/* 深色模式下加载失败样式 */
html.dark-mode .related-card__thumb--error {
    background: #3a3a3a url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23666"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>') center/50% no-repeat !important;
}

/* 卡片内容 */
.related-card__content {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
}

/* 卡片标题 */
.related-card__title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-card:hover .related-card__title {
    color: var(--color-primary);
}

/* 卡片元信息 */
.related-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #999;
}

/* 分类标签 */
.related-card__category {
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 13px;
}

/* 加载状态 */
.loading-indicator {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}

.loading-indicator__spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 结束提示 */
.end-message {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

/* 错误提示 */
.error-message {
    text-align: center;
    padding: 20px;
    color: #ff6b6b;
    font-size: 14px;
}

/* 骨架屏状态 */
.related-card--skeleton {
    pointer-events: none;
}

.related-card--skeleton .related-card__thumb {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.related-card--skeleton .related-card__title {
    height: 18px;
    background: #f0f0f0;
    border-radius: 4px;
}

.related-card--skeleton .related-card__meta span {
    display: inline-block;
    height: 14px;
    background: #f0f0f0;
    border-radius: 4px;
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .related-posts-waterfall {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .related-posts-waterfall {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .related-card {
        padding: 12px;
    }
    
    .related-card__thumb {
        width: 55px;
        height: 55px;
    }
    
    .related-card__title {
        font-size: 13px;
    }
    
    .related-card__meta {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .related-posts-waterfall {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .related-card {
        padding: 12px;
    }
    
    .related-card__thumb {
        width: 60px;
        height: 60px;
    }
    
    .related-card__title {
        font-size: 14px;
    }
}

/* 深色模式适配 */
html.dark-mode .related-card {
    background: #2F2F2F;
}

/* 深色模式下保持标题绿色 */
html.dark-mode .related-title {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

html.dark-mode .related-card__title {
    color: #B0B0B0;
}

html.dark-mode .related-card:hover .related-card__title {
    color: #48AF51;
}

html.dark-mode .related-card__category {
    background: #3a3a3a;
    color: #999;
}

html.dark-mode .related-card__meta {
    color: #999;
}

html.dark-mode .related-card--skeleton .related-card__title,
html.dark-mode .related-card--skeleton .related-card__meta span {
    background: #3a3a3a;
}

html.dark-mode .loading-indicator {
    color: #999;
}

html.dark-mode .loading-indicator__spinner {
    border-color: #4a4a4a;
    border-top-color: #48AF51;
}
