/* ============================================================
 * 相关文章 / 热门榜单 插件 —— 前台样式
 * 由 plugins/related-hot 经 front_head 钩子自动引入，模板无需改动。
 * 自带 --rh-* 变量，4 套模板通用；支持系统深色模式。
 * ============================================================ */

.rh-wrap {
    --rh-border: #ececf0;
    --rh-text: #2c3138;
    --rh-muted: #8b939f;
    --rh-bg: #fff;
    --rh-bg-soft: #fafbfc;
    --rh-accent: #ff6b35;
    --rh-radius: 12px;

    margin: 36px 0 8px;
    padding: 0;
    color: var(--rh-text);
    font-size: 15px;
    line-height: 1.6;
}

/* 版式：宽屏左右两栏 */
.rh-wrap[data-rh-layout="side"] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

/* 版式：上下堆叠 */
.rh-wrap[data-rh-layout="stack"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
}

.rh-block {
    min-width: 0;
    padding: 18px 20px 14px;
    border: 1px solid var(--rh-border);
    border-radius: var(--rh-radius);
    background: var(--rh-bg);
}

.rh-title {
    margin: 0 0 12px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--rh-border);
    font-size: 15px;
    font-weight: 600;
    color: var(--rh-text);
    letter-spacing: .5px;
}

.rh-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: rh-rank;
}

.rh-item {
    border-bottom: 1px dashed var(--rh-border);
}

.rh-item:last-child {
    border-bottom: none;
}

.rh-link {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    color: inherit;
    text-decoration: none;
    transition: opacity .25s;
}

.rh-link:hover {
    opacity: .75;
}

/* 无封面时少一列（class 由 PHP 输出，不依赖 :has()） */
.rh-link.rh-link-nocover {
    grid-template-columns: minmax(0, 1fr);
}

/* 带序号的行多一列 */
.rh-item-ranked .rh-link {
    grid-template-columns: 22px auto minmax(0, 1fr);
}

.rh-item-ranked .rh-link.rh-link-nocover {
    grid-template-columns: 22px minmax(0, 1fr);
}

/* 名次 */
.rh-rank {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--rh-bg-soft);
    color: var(--rh-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

.rh-item-top .rh-rank {
    background: var(--rh-accent);
    color: #fff;
}

/* 封面 */
.rh-cover {
    display: block;
    width: 72px;
    height: 52px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--rh-bg-soft);
}

.rh-cover-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 文字区 */
.rh-main {
    min-width: 0;
    display: block;
}

/* 标题 + 阅读数同一行，阅读数靠右 */
.rh-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.rh-item-title {
    flex: 1 1 auto;
    min-width: 0;
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--rh-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .25s;
}

.rh-link:hover .rh-item-title {
    color: var(--rh-accent);
}

.rh-meta {
    flex: 0 0 auto;
    margin: 0;
    font-size: 12px;
    color: var(--rh-muted);
    white-space: nowrap;
}

.rh-sep {
    margin: 0 6px;
}

/* ---------- 窄屏：两栏自动降为一栏 ---------- */
@media (max-width: 720px) {
    .rh-wrap { margin: 28px 0 6px; }
    .rh-wrap[data-rh-layout="side"] { grid-template-columns: minmax(0, 1fr); }
    .rh-block { padding: 16px 16px 12px; }
    .rh-cover { width: 62px; height: 46px; }
    /* 标题允许换到两行；阅读数仍靠右、与标题首行基线对齐 */
    .rh-head { align-items: flex-start; gap: 8px; }
    .rh-item-title { font-size: 13.5px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .rh-meta { padding-top: 1px; }
}

/* ---------- 深色模式 ---------- */
@media (prefers-color-scheme: dark) {
    .rh-wrap {
        --rh-border: #333a45;
        --rh-text: #e3e7ee;
        --rh-muted: #9aa3b2;
        --rh-bg: #1e232b;
        --rh-bg-soft: #242a33;
    }
}
