/**
 * 相关文章自定义样式
 * 支持Post和Blog文章的独立样式控制
 */

/* 基础容器样式 */
.mer-related-posts {
    margin: 10px 0;
    padding: 0 0 10px 0; /* 底部留白与左右一致 */
    font-family: inherit;
}

.mer-related-posts.mer-post-related {
    /* Post文章特定样式 */
}

.mer-related-posts.mer-blog-related {
    /* Blog文章特定样式 */
}

/* 网格布局 */
.mer-grid-layout {
    display: grid;
    gap: 20px;
    margin: 0;
    padding: 0;
}

.mer-post-related .mer-grid-layout {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.mer-blog-related .mer-grid-layout {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* 列表布局 */
.mer-list-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0;
    padding: 0;
}

/* 卡片布局 */
.mer-card-layout {
    display: grid;
    gap: 20px;
    margin: 0;
    padding: 0;
}

.mer-post-related .mer-card-layout {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.mer-blog-related .mer-card-layout {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

/* 文章项目样式 */
.mer-related-article {
    background: inherit;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 0px 1px rgba(0, 0, 0, 0.15);
    margin: 0;
    padding: 0;
}

.mer-related-article:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* 网格项目 */
.mer-grid-item {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mer-grid-item .mer-thumbnail {
    flex-shrink: 0;
}

.mer-grid-item .mer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

/* 列表项目 */
.mer-list-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
}

.mer-list-item .mer-thumbnail {
    flex-shrink: 0;
    width: 120px;
    height: 80px;
}

.mer-list-item .mer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 卡片项目 */
.mer-card-item {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mer-card-item .mer-thumbnail {
    flex-shrink: 0;
}

.mer-card-item .mer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 12px;
}

/* 缩略图样式 */
.mer-thumbnail {
    position: relative;
    overflow: hidden;
}

.mer-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.mer-related-article:hover .mer-thumbnail img {
    transform: scale(1.05);
}

/* 内容区域样式 */
.mer-content {
    color: inherit;
}

/* 标题样式 */
.mer-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    word-wrap: break-word;
    word-break: break-word;
}

.mer-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.mer-title a:hover {
    color: var(--theme-color, #0073aa);
}

/* 分类样式：复用 Modown 主题卡片的分类视觉 */
.mer-categories {
    position: relative;
    display: -webkit-box;
    height: 19px;
    margin-bottom: 7px;
    padding-left: 14px;
    overflow: hidden;
    color: #777;
    font-size: 12px;
    word-break: break-all;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

.mer-category {
    background: transparent;
    color: inherit;
    padding: 0;
    border: 0;
    border-radius: 0;
    font: inherit;
}

.mer-categories::after {
    content: " ";
    position: absolute;
    top: 7px;
    left: 0;
    width: 4px;
    height: 4px;
    border: 2px solid var(--theme-color, #ff5e3a);
    border-radius: 50%;
}

/* 摘要样式 */
.mer-excerpt {
    margin: 8px 0;
    line-height: 1.6;
}

.mer-excerpt p {
    margin: 0;
    color: inherit;
    font-size: 13px;
    word-wrap: break-word;
    word-break: break-word;
}

/* 元信息样式 */
.mer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.mer-meta span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.mer-meta i {
    font-size: 11px;
}

/* 日期样式 */
.mer-date {
    color: #999;
}

.mer-date time {
    font-style: italic;
}

/* 文章标签：与主题卡片的 .tag 标签保持一致 */
.mer-tags {
    display: block;
    height: 19px;
    margin-bottom: 7px;
    overflow: hidden;
    color: #777;
    font-size: 12px;
    line-height: 19px;
    word-break: break-all;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mer-tags a {
    position: relative;
    display: inline-block;
    margin-right: 10px;
    padding-left: 10px;
    color: inherit;
}

.mer-tags a::before {
    content: "";
    position: absolute;
    top: 7px;
    left: 0;
    width: 4px;
    height: 4px;
    border-radius: 50%;
}

.mer-tags a:nth-child(1)::before { background-color: #ff5e5c; }
.mer-tags a:nth-child(2)::before { background-color: #ffbb50; }
.mer-tags a:nth-child(3)::before { background-color: #1ac756; }

/* 主题标题小标记 */
.mer-related-posts .mer-title .post-sign {
    position: relative;
    top: -1px;
    display: inline-block;
    margin-right: 5px;
    padding: 0 4px;
    border-radius: 5px 0 5px 0;
    background: #ff9600;
    color: #fff;
    font-size: 12px;
    font-weight: normal;
    line-height: 18px;
}



/* 响应式设计 */
@media (max-width: 768px) {
    /* 所有推荐样式在手机端首屏最多显示 4 篇；AJAX 同步按 4 篇分页。 */
    .single-related .mer-mobile-overflow,
    .single-related > .grids.relateds > .grid:nth-of-type(n+5),
    .single-related > .lists.relateds > .post:nth-of-type(n+5),
    .single-related > .lists.relateds > .list:nth-of-type(n+5),
    .single-related .mer-grid-layout > .mer-related-article:nth-child(n+5),
    .single-related .mer-card-layout > .mer-related-article:nth-child(n+5),
    .single-related .mer-list-layout > .mer-related-article:nth-child(n+5) {
        display: none !important;
    }

    .mer-grid-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 15px;
    }
    
    .mer-card-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 15px;
    }
    
    .mer-list-item {
        flex-direction: column;
        gap: 10px;
    }
    
    .mer-list-item .mer-thumbnail {
        width: 100%;
        height: auto;
    }
    
    .mer-title {
        font-size: 15px;
    }
    
    .mer-excerpt p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .mer-related-posts {
        margin: 10px 0;
    }
    
    .mer-content {
        padding: 12px;
    }
    
    .mer-title {
        font-size: 14px;
    }
    
    .mer-excerpt p {
        font-size: 12px;
    }

    /* 保持 2 列布局在小屏手机上 */
    .mer-grid-layout, .mer-card-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 360px) {
    /* 极小屏幕下使用单列布局，保证可读性 */
    .mer-grid-layout,
    .mer-card-layout {
        grid-template-columns: 1fr;
    }
}

/* 主题夜间模式适配 */
body.night .mer-title a:hover { 
    color: var(--theme-color, #4a90e2); 
}

body.night .mer-related-article { 
    box-shadow: 0 0px 1px rgba(255, 255, 255, 0.15), 0 1px 2px rgba(255, 255, 255, 0.1); 
}

body.night .mer-related-article:hover { 
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.2), 0 2px 8px rgba(255, 255, 255, 0.15); 
}

/* 主题集成样式 */
.mer-related-posts.theme-integration {
    /* 与主题样式集成的特殊样式 */
    border: 1px solid currentColor;
    padding: 20px;
    background: inherit;
}

/* 自定义CSS类支持 */
.mer-related-posts.custom-style {
    /* 用户自定义样式可以在这里添加 */
}

/* 动画效果 */
.mer-related-article {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 加载状态 */
.mer-related-posts.loading {
    opacity: 0.6;
    pointer-events: none;
}

.mer-related-posts.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--theme-color, #0073aa);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Modown 原生推荐角标；结构不同，但视觉参数与主题完全一致。 */
.mer-related-posts .recommend-tag {
    position: absolute;
    top: 0;
    right: 10px;
    left: auto;
    z-index: 2;
    height: 20px;
    padding: 0 4px;
    border: 0;
    border-radius: 2px;
    border-top-left-radius: 0;
    background: var(--theme-color, #ff5e3a);
    color: #fff;
    line-height: 20px;
    font-size: 12px;
    font-weight: 400;
    text-align: center;
}

.mer-related-posts .recommend-tag::before {
    content: "";
    position: absolute;
    left: -4px;
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 5px 5px;
    border-color: transparent transparent var(--theme-color, #ff5e3a) transparent;
}

/* 价格、VIP 与免费标签复用主题的标签配色。 */
.mer-related-posts .mer-meta .price .fee {
    position: relative;
    padding: 1px 4px;
    border-radius: 2px;
    background: #ababab;
    color: #fff;
}

.mer-related-posts .mer-meta .price .vip-tag {
    background: linear-gradient(90deg, rgba(240, 214, 141, 1) 0%, rgba(224, 191, 115, 1) 100%);
    color: #4e342e;
}

.mer-related-posts .mer-meta .price .free-tag {
    background: #5cb85c;
    color: #fff;
}

/* 强制移动端两列（提高选择器优先级） */
@media (max-width: 768px) {
    .mer-related-posts .mer-grid-layout,
    .mer-post-related .mer-grid-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .mer-related-posts .mer-card-layout,
    .mer-post-related .mer-card-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* 极小屏手机单列（提高选择器优先级） */
@media (max-width: 360px) {
    .mer-related-posts .mer-grid-layout,
    .mer-post-related .mer-grid-layout,
    .mer-related-posts .mer-card-layout,
    .mer-post-related .mer-card-layout {
        grid-template-columns: 1fr !important;
    }
} 

/* 以后台设置为基准（--mer-thumb-h），在移动端按比例缩放 */
.mer-related-posts .mer-thumbnail img,
.mer-post-related .mer-thumbnail img {
    height: var(--mer-thumb-h, 200px);
    object-fit: cover;
    width: 100%;
}

@media (max-width: 768px) {
    .mer-related-posts .mer-thumbnail img,
    .mer-post-related .mer-thumbnail img {
        height: calc(var(--mer-thumb-h, 200px) * 0.75) !important;
    }
}

@media (max-width: 480px) {
    .mer-related-posts .mer-thumbnail img,
    .mer-post-related .mer-thumbnail img {
        height: calc(var(--mer-thumb-h, 200px) * 0.65) !important;
    }
}

@media (max-width: 360px) {
    .mer-related-posts .mer-thumbnail img,
    .mer-post-related .mer-thumbnail img {
        height: calc(var(--mer-thumb-h, 200px) * 0.58) !important;
    }
} 

@media (max-width: 768px) {
    /* 网格间距缩小 */
    .mer-related-posts .mer-grid-layout,
    .mer-post-related .mer-grid-layout,
    .mer-related-posts .mer-card-layout,
    .mer-post-related .mer-card-layout {
        gap: 12px !important;
    }
    /* 卡片内边距缩小 */
    .mer-related-posts .mer-content,
    .mer-post-related .mer-content {
        padding: 10px !important;
    }
    /* 标题与摘要间距缩小 */
    .mer-related-posts .mer-title,
    .mer-post-related .mer-title { margin-bottom: 6px !important; }
}

@media (max-width: 480px) {
    .mer-related-posts .mer-grid-layout,
    .mer-post-related .mer-grid-layout,
    .mer-related-posts .mer-card-layout,
    .mer-post-related .mer-card-layout {
        gap: 8px !important;
    }
    .mer-related-posts .mer-content,
    .mer-post-related .mer-content { padding: 8px !important; }
    .mer-related-posts .mer-title,
    .mer-post-related .mer-title { margin-bottom: 4px !important; }
} 
