/**
 * BookShelf —— 首页「分类调用」三列分类卡（guide_cards.ejs）
 *
 * 1:1 照 mirage-cat（目标站 .line-big / .line-box）：
 *   外层负边距 1.5% 拉出栅格，卡片 31.833% + 1.5% 间距，一排三张；
 *   卡内标题栏左侧 4px 主色竖条 + 16px 分类名 + 右侧「更多」；
 *   下面 6 行文章，日期右浮、标题单行。
 * 颜色一律走主题变量，深色模式自动跟随。
 */

/* 主题在 ≥768px 把 .main-container 改成 flex（主栏 + 侧栏并排），
   这块是整页通栏，必须退回块级，否则会被压成内容宽度。 */
.main-container.main-container--full {
    display: block;
}

/* ===== 栅格 ===== */
.bookshelf-cat-row {
    overflow: hidden;
    margin: 15px 0 0 -1.5%;
}

/* ===== 每张分类卡 ===== */
.bookshelf-cat-box {
    position: relative;
    float: left;
    width: 31.833%;
    margin: 0 0 15px 1.5%;
    padding: 0 20px;
    box-sizing: border-box;
    overflow: hidden;
    background-color: var(--vt-bg-color-card);
    border-radius: 8px;
    box-shadow: 0 0 10px -2px rgba(158, 158, 158, 0.2);
    transition: box-shadow 0.3s ease-in-out;
}

body.dark-mode .bookshelf-cat-box {
    box-shadow: 0 0 10px -2px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
    body.dark-mode-auto .bookshelf-cat-box {
        box-shadow: 0 0 10px -2px rgba(0, 0, 0, 0.6);
    }
}

/* ===== 右上角装饰图（照目标站 .line-box:nth-child(1~3) 的三张图，六张卡循环用） =====
   图片是 441×120 的透明贴纸，尺寸 / 位置全部沿用目标站的计算值。 */
.bookshelf-cat-box {
    background-repeat: no-repeat;
}

.bookshelf-cat-box:nth-child(3n + 1) {
    background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
                      url("/images/lhlwdg.webp");
    background-size: 215px;
    background-position: 58% 11px;
}

.bookshelf-cat-box:nth-child(3n + 2) {
    background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
                      url("/images/cgqz.webp");
    background-size: 200px;
    background-position: 66% 2px;
}

.bookshelf-cat-box:nth-child(3n + 3) {
    background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
                      url("/images/rjdj.webp");
    background-size: 168px;
    background-position: 68% 6px;
}

/* 配置里单独给了 deco 时，以配置的图为准（写在后面覆盖上面三条） */
.bookshelf-cat-box[style*="--box-deco"] {
    background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
                      var(--box-deco);
    background-repeat: no-repeat;
    background-position: 68% 6px;
    background-size: 168px;
}

/* 暗色模式：贴纸自带浅色底/白色描边，压在深色卡上会糊出一块浅斑，直接关掉 */
body.dark-mode .bookshelf-cat-box {
    background-image: none;
}

@media (prefers-color-scheme: dark) {
    body.dark-mode-auto .bookshelf-cat-box {
        background-image: none;
    }
}

/* 手机端卡片只有 336px 宽，按桌面尺寸（168–215px）摆贴纸会顶到右侧「更多」，
   统一缩到 120–150px，右边缘与「更多」留出空隙。 */
@media only screen and (max-width: 767px) {
    .bookshelf-cat-box:nth-child(3n + 1) {
        background-size: 150px;
    }

    .bookshelf-cat-box:nth-child(3n + 2) {
        background-size: 140px;
    }

    .bookshelf-cat-box:nth-child(3n + 3) {
        background-size: 120px;
    }

    .bookshelf-cat-box[style*="--box-deco"] {
        background-size: 120px;
    }
}

/* ===== 标题栏 ===== */
.bookshelf-cat-head {
    display: block;
    position: relative;
    margin-top: 15px;
    padding-bottom: 15px;
    overflow: hidden;
    border-bottom: 1px solid var(--vt-border-color);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bookshelf-cat-name {
    float: left;
    margin: 0;
    padding-left: 15px;
    border-left: 4px solid var(--vt-color-primary);
    color: var(--vt-text-color);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
}

.bookshelf-cat-more {
    float: right;
    position: relative;
    top: 4px;
    margin-left: 10px;
}

.bookshelf-cat-more a {
    color: var(--vt-text-color-grey);
    font-size: 12px;
    letter-spacing: normal;
    text-decoration: none;
    transition: color 0.3s ease-in-out;
}

.bookshelf-cat-more a:hover {
    color: var(--vt-color-primary);
}

.bookshelf-cat-more i {
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-left: 4px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 8px;
    line-height: 11px;
    text-align: center;
    vertical-align: -1px;
}

/* ===== 文章列表 ===== */
.bookshelf-cat-body {
    padding-top: 10px;
    padding-bottom: 10px;
}

.bookshelf-cat-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.bookshelf-cat-list li {
    display: flex;
    align-items: center;
    height: 35px;
    line-height: 35px;
    overflow: hidden;
    list-style: none;
}

.bookshelf-cat-list li a {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--vt-text-color);
    font-size: 14px;
    letter-spacing: normal;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.bookshelf-cat-list li a:hover {
    color: var(--vt-color-primary);
    transform: translateX(6px);
}

/* 行首标签图标（目标站每条前面都挂一个小图标） */
.bookshelf-cat-ico {
    margin-right: 6px;
    color: var(--vt-text-color-grey);
    font-size: 11px;
    transition: color 0.3s ease-in-out;
}

.bookshelf-cat-list li a:hover .bookshelf-cat-ico {
    color: var(--vt-color-primary);
}

.bookshelf-cat-date {
    flex: 0 0 auto;
    margin-left: 8px;
    color: var(--vt-text-color-grey);
    font-size: 12px;
}

/* ===== 响应式：≤960 两列，≤680 单列 ===== */
@media only screen and (max-width: 960px) {
    .bookshelf-cat-box {
        width: 48%;
    }
}

@media only screen and (max-width: 680px) {
    .bookshelf-cat-row {
        margin-left: 0;
    }
    .bookshelf-cat-box {
        width: 100%;
        margin-left: 0;
    }
}
