/**
 * 前端样式 - 文库列表页 A4 缩略图 + 紧凑标题
 * 参考即刻文库样式，与其视觉效果一致
 * 文件类型类名（.doc .pdf 等）通过 PHP 自动添加到 <article> 元素
 */

/* ==================== 缩略图区 ==================== */

.posts-item .fit-cover {
    object-fit: contain !important;
}

.posts-item.card {
    padding: 0 !important;
}

/* A4 比例（1:1.38，接近 A4 纸 1:1.414） */
.posts-item .item-thumbnail {
    width: 100%;
    padding-bottom: 138% !important;
    position: relative;
    overflow: visible;
}

/* 文档类型缩略图特殊处理 - 顶部对齐并放大 */
.posts-item.doc .item-thumbnail img,
.posts-item.docx .item-thumbnail img,
.posts-item.txt .item-thumbnail img,
.posts-item.pdf .item-thumbnail img,
.posts-item.xls .item-thumbnail img,
.posts-item.xlsx .item-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: top;
    transform-box: fill-box;
    transform-style: flat;
    transform: scale(1.3);
    height: 79%;
}

.posts-item.doc .item-thumbnail img:hover,
.posts-item.docx .item-thumbnail img:hover,
.posts-item.txt .item-thumbnail img:hover,
.posts-item.pdf .item-thumbnail img:hover,
.posts-item.xls .item-thumbnail img:hover,
.posts-item.xlsx .item-thumbnail img:hover {
    transform: scale(1.4);
}

/* 卡片内边距紧凑化 */
.posts-item.card .item-body {
    padding: 10px !important;
}

/* 列表模式缩略图 */
.posts-item.list .item-thumbnail {
    width: 100px;
    padding-bottom: 138% !important;
}

/* PPT 类型垂直居中 */
.posts-item.ppt .item-thumbnail img,
.posts-item.pptx .item-thumbnail img {
    border-radius: 8px;
    top: 50%;
    transform: translateY(-50%);
    height: auto;
}

.posts-item {
    position: relative;
    padding: 10px;
}

/* ==================== 文件类型角标图标（暂时下线，v4.3 版本再启用） ==================== */
/*
.posts-item.rar .item-thumbnail::after,
.posts-item.zip .item-thumbnail::after,
.posts-item.tar .item-thumbnail::after,
.posts-item.gz .item-thumbnail::after,
.posts-item.ppt .item-thumbnail::after,
.posts-item.pptx .item-thumbnail::after,
.posts-item.doc .item-thumbnail::after,
.posts-item.docx .item-thumbnail::after,
.posts-item.xls .item-thumbnail::after,
.posts-item.xlsx .item-thumbnail::after,
.posts-item.pdf .item-thumbnail::after,
.posts-item.txt .item-thumbnail::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    height: 20px;
    width: 50px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 2;
}

.posts-item.rar .item-thumbnail::after,
.posts-item.zip .item-thumbnail::after,
.posts-item.tar .item-thumbnail::after,
.posts-item.gz .item-thumbnail::after {
    background-image: url('../img/zip.png');
}
.posts-item.ppt .item-thumbnail::after,
.posts-item.pptx .item-thumbnail::after {
    background-image: url('../img/ppt.png');
}
.posts-item.doc .item-thumbnail::after,
.posts-item.docx .item-thumbnail::after {
    background-image: url('../img/doc.png');
}
.posts-item.xls .item-thumbnail::after,
.posts-item.xlsx .item-thumbnail::after {
    background-image: url('../img/xls.png');
}
.posts-item.pdf .item-thumbnail::after {
    background-image: url('../img/pdf.png');
}
.posts-item.txt .item-thumbnail::after {
    background-image: url('../img/txt.png');
}
*/

/* ==================== 标题与文字紧凑化 ==================== */

.posts-item .text-ellipsis {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    white-space: normal;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@media (max-width: 767px) {
    .posts-item:not(.no-thumb) .item-excerpt {
        display: -webkit-box;
    }
}

/* 标题字号紧凑化 - 提高选择器权重 + !important 双保险 */
.posts-item .item-heading,
.posts-item .item-heading a,
.posts-item.card .item-heading,
.posts-item.card .item-body .item-heading,
.posts-item.card .item-body .item-heading a {
    font-size: 15px !important;
    line-height: 1.4 !important;
}

/* 摘要字号紧凑化 */
.posts-item .item-excerpt,
.posts-item .text-ellipsis {
    font-size: 13px !important;
}

/* ==================== 卡片浅灰背景 ==================== */
.posts-item.card {
    background: #F5F6F7 !important;
    border-radius: 8px !important;
    overflow: hidden;
}

/* 缩略图浅灰边框 */
.posts-item .item-thumbnail {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
}

/* ==================== 暗色主题适配 ==================== */
.dark-theme .posts-item.card {
    background: #292A2D !important;
}
.dark-theme .posts-item .item-thumbnail {
    border-color: #3A3B3E;
}

/* ==================== 响应式布局 ==================== */
@media (max-width: 767px) {
    .posts-item .item-thumbnail {
        padding-bottom: 138% !important;
    }
}