/**
 * BookShelf —— 首页「博客模板」图文墙（gallery.ejs）
 *
 * 几何照 mirage-gallery：外层 20px 内边距，左 25% / 右 73% 两栏，
 * 左栏 368px 高，右栏 3 列 × 2 行、每格 175px，格间距 2%，标题压图、元信息悬停升起。
 * 颜色一律走主题变量，深色模式自动跟随。
 */

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

.bookshelf-gallery {
    overflow: hidden;
    margin: 15px 0 0;
    padding: 20px;
    box-sizing: border-box;
    background-color: var(--vt-bg-color-card);
    border: 1px solid var(--vt-border-color);
    border-radius: 8px;
    box-shadow: 0 0 3px 0 var(--vt-shadow-color);
}

/* 手机端专用标题行：桌面端由左侧门面卡承担标题，这里不显示 */
.bookshelf-gallery-mhead {
    display: none;
}

/* ===== 左：25% 竖版门面卡 ===== */
.bookshelf-gallery-hero {
    float: left;
    width: 25%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.bookshelf-gallery-hero > a {
    display: block;
    position: relative;
    width: 100%;
    height: 368px;
    z-index: 2;
    background-color: var(--vt-bg-color-grey);
    background-size: cover;
    background-position: center center;
}

/* 压暗整张图，白字才站得住 */
.bookshelf-gallery-hero > a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    transition: all 1s ease 0s;
}

/* 左上角胶囊：栏目名 */
.bookshelf-gallery-hero h3 {
    position: absolute;
    left: 20px;
    top: 20px;
    z-index: 4;
    margin: 0;
    height: 30px;
    line-height: 30px;
    max-width: 160px;
    padding: 0 10px;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 18px;
    font-weight: normal;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 栏目名下方的文字块：水平居中，压在垂直中线偏上 */
.bookshelf-gallery-hero-name {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 5;
    transform: translate(-50%, -155%);
    width: 85%;
    margin: 0;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 1px;
    text-align: center;
    text-shadow: 1px 2px 5px rgba(0, 0, 0, 0.6);
}

.bookshelf-gallery-hero p {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 5;
    transform: translate(-50%, -20%);
    width: 85%;
    margin: 0;
    color: #fff;
    font-size: 14px;
    line-height: 25px;
    text-align: center;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

/* ===== 右：3 列 × 2 行封面卡 ===== */
.bookshelf-gallery-list {
    float: right;
    width: 73%;
}

.bookshelf-gallery-list ul {
    margin: 0 -2% -2% 0;
    padding: 0;
    overflow: hidden;
    list-style: none;
}

.bookshelf-gallery-list li {
    float: left;
    width: 31.333%;
    margin: 0 2% 2% 0;
    overflow: hidden;
    list-style: none;
}

.bookshelf-gallery-item {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 175px;
    overflow: hidden;
}

.bookshelf-gallery-thumb {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    display: block;
    background-color: var(--vt-bg-color-grey);
    background-size: cover;
    background-position: 50% 50%;
    background-repeat: no-repeat;
}

/* 图片上的暗层，默认 0.28，悬停加深到 0.68 */
.bookshelf-gallery-thumb::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.28);
    transition: all 1s ease 0s;
}

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

.bookshelf-gallery-item-title {
    position: absolute;
    left: 20px;
    top: 115px;
    z-index: 3;
    width: calc(100% - 40px);
    height: 50px;
    margin: 0;
    color: #fff;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    transition: all 0.3s ease-out 0s;
}

.bookshelf-gallery-item-title a {
    color: #fff;
    font-size: 15px;
    letter-spacing: normal;
    text-decoration: none;
}

/* 分类 · 日期：默认藏在卡片下沿外，悬停升起 */
.bookshelf-gallery-meta {
    position: absolute;
    left: 20px;
    bottom: -20px;
    z-index: 3;
    width: calc(100% - 40px);
    overflow: hidden;
    color: #fff;
    font-size: 12px;
    line-height: 22px;
    transition: all 0.3s ease-out 0s;
}

.bookshelf-gallery-meta h4 {
    float: left;
    margin: 0;
    font-size: 1em;
    font-weight: normal;
}

.bookshelf-gallery-dot {
    position: relative;
    display: inline-block;
    padding: 0 10px 0 5px;
}

.bookshelf-gallery-dot::after {
    content: "";
    position: absolute;
    top: 10px;
    width: 3px;
    height: 3px;
    border-radius: 10px;
    background-color: #fff;
}

.bookshelf-gallery-item:hover .bookshelf-gallery-item-title {
    top: 90px;
}

.bookshelf-gallery-item:hover .bookshelf-gallery-meta {
    bottom: 10px;
}

.bookshelf-gallery-item:hover .bookshelf-gallery-thumb::before {
    background: rgba(0, 0, 0, 0.68);
}

.bookshelf-gallery-item:hover .bookshelf-gallery-thumb img {
    transform: scale(1.1);
    transition: all 0.7s ease;
}

/* ===== 响应式：≤767 藏门面卡、整行网格；≤580 两列 ===== */
@media only screen and (max-width: 767px) {
    .bookshelf-gallery-hero {
        display: none;
    }

    /* 门面卡被藏掉后，这里顶上板块标题（桌面端不显示） */
    .bookshelf-gallery-mhead {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 0 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--vt-border-color);
    }

    .bookshelf-gallery-mhead .title {
        display: flex;
        align-items: center;
        font-size: var(--vt-font-size-base);
        font-weight: bold;
        color: var(--vt-text-color);
        letter-spacing: 0;
    }

    .bookshelf-gallery-mhead .title .vt-section-icon {
        margin-right: 7px;
        font-size: 90%;
        color: var(--vt-color-primary);
    }

    .bookshelf-gallery-mhead-more {
        flex: none;
        font-size: 12px;
        color: var(--vt-text-color-grey);
        text-decoration: none;
    }

    .bookshelf-gallery-mhead-more i {
        margin-left: 3px;
        font-size: 11px;
    }

    .bookshelf-gallery-list {
        float: none;
        width: 100%;
    }
    .bookshelf-gallery-item {
        height: 20.83333vw;
    }
    .bookshelf-gallery-item-title {
        top: auto;
        bottom: 5px;
        left: 0;
        width: 100%;
        padding: 0 10px;
        /* 主题没有全局 border-box，不加这句 100% + 20px 内边距会撑出卡片，
           文字被 overflow 硬切、省略号也不出现 */
        box-sizing: border-box;
        font-weight: 500;
        /* 桌面端是固定 50px 高、文字顶对齐；手机上卡片矮，改成随内容贴底 */
        height: auto;
    }
    .bookshelf-gallery-meta {
        left: 0;
        width: 100%;
        padding: 0 10px;
        box-sizing: border-box;
    }
    .bookshelf-gallery-item:hover .bookshelf-gallery-item-title {
        top: auto;
        bottom: 20px;
    }
}

@media only screen and (max-width: 580px) {
    .bookshelf-gallery {
        padding: 13px;
    }
    .bookshelf-gallery-list li {
        width: 48%;
    }
    /* 卡片抬高一点（28.4vw → 30vw），否则两行标题压掉大半张图 */
    .bookshelf-gallery-item {
        height: 30vw;
    }
    /* 标题降一号，两行只占 1/3 卡高，图片还能看出内容 */
    .bookshelf-gallery-item-title,
    .bookshelf-gallery-item-title a {
        font-size: 12.5px;
        line-height: 1.45;
    }
}
