/* ==================== 图书列表页 ==================== */
@keyframes books-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: books-fade-in 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.is-results-transitioning {
    opacity: 0.3;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
@media (prefers-reduced-motion: reduce) {
    .animate-fade-in { animation: none; }
    .is-results-transitioning { opacity: 0.6; transform: none; filter: none; }
}

/* 图书卡片 */
.book-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid rgba(var(--color-brand-primary-rgb), 0.08);
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.35s ease,
                border-color 0.35s ease;
}
.book-card:hover {
    transform: translateY(-4px);
    border-color: rgba(var(--color-brand-primary-rgb), 0.25);
    box-shadow: 0 18px 40px -20px rgba(var(--color-brand-primary-rgb), 0.35),
                0 8px 16px -8px rgba(139, 92, 246, 0.2);
}
.book-card-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: linear-gradient(135deg, #fdf2f8, #f3e8ff);
}
.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}
.book-card:hover .book-card-cover img { transform: scale(1.06); }
.book-card-cover img.lazy-img { opacity: 0; }
.book-card-cover img.lazy-img.is-loaded { opacity: 1; }
.book-card-status {
    position: absolute;
    z-index: 2;
    top: 0.5rem;
    left: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
}
.book-card-status.is-available {
    background: #dcfce7;
    color: #166534;
}
.book-card-status.is-unavailable {
    background: #fee2e2;
    color: #991b1b;
}
.book-card-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* 标题固定预留两行高度(配合 line-clamp-2),保证不同标题长度下卡片高度一致 */
.book-card h3 {
    min-height: 2.5rem; /* 移动端:2 × 1.25rem(text-sm 行高) */
}
@media (min-width: 640px) {
    .book-card h3 {
        min-height: 3rem; /* sm+:2 × 1.5rem(text-base 行高) */
    }
}

/* 骨架屏 */
.book-skeleton {
    border-radius: 1rem;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(var(--color-brand-primary-rgb), 0.08);
}
.book-skeleton-cover { aspect-ratio: 3 / 4; }
.skeleton-shimmer {
    background: linear-gradient(
        90deg,
        rgba(253, 242, 248, 0.5) 0%,
        rgba(243, 232, 255, 0.9) 50%,
        rgba(253, 242, 248, 0.5) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton-shimmer { animation: none; }
}

/* 工具条芯片 */
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    gap: 6px;
    padding: 0.625rem 0.875rem;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(131, 24, 67, 0.7);
    background: #fff;
    border: 1px solid rgba(var(--color-brand-primary-rgb), 0.12);
    cursor: pointer;
    transition: all 0.25s ease;
}
.chip:hover {
    color: var(--color-brand-primary);
    border-color: rgba(var(--color-brand-primary-rgb), 0.4);
    background: rgba(253, 242, 248, 0.6);
}
.chip.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--color-brand-accent), var(--color-brand-primary));
    border-color: transparent;
    box-shadow: 0 6px 14px -4px rgba(168, 85, 247, 0.5);
}

/* 图书结果区数量徽章过渡 */
[data-category] { transition: transform 0.25s ease; }
[data-category].scale-110 { transform: scale(1.15); }

@media (min-width: 1024px) {
    /* 两列等高：高度由馆藏资源内容决定，图书分类底部与其齐平 */
    .books-page-layout {
        align-items: stretch;
    }

    /* 馆藏资源完整展示，不使用内部滚动条，其内容高度决定整行高度 */
    .books-main-panel {
        display: flex;
        flex-direction: column;
    }

    .books-results-scroll {
        overflow: visible;
    }

    /* 侧栏高度跟随馆藏资源：height:0 使其不反向撑高整行，
       min-height:100% 再把它拉伸到与馆藏资源等高 */
    .books-category-sidebar {
        height: 0;
        min-height: 100%;
        display: flex;
        flex-direction: column;
    }

    .books-sidebar-shell {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .books-category-card {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* 图书分类超出等高区域的部分使用内部滚动条显示 */
    #books-desktop-categories {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    /* 空状态(无搜索结果)也不收缩,保持与正常单行结果页等高,文案垂直居中 */
    #books-results-content > .text-center {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 618px; /* ≈ 封面行(521)+分页占位(97),使内容区与正常页等高 */
    }
}
