/* =============================================
   Page-specific styles
   ============================================= */

/* Catalog pages */
.page-content {
    padding: 24px 0;
}

/* Deity catalog cards grid */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .catalog-grid {
        grid-template-columns: 1fr;
    }
}

/* Article list cards */
.article-list-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 640px) {
    .article-list-grid {
        grid-template-columns: 1fr;
    }
}

/* About page */
.about-content {
    padding: 20px;
    line-height: 1.8;
}

.about-content h2 {
    color: var(--primary-darker);
    margin: 24px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.about-content p {
    margin-bottom: 16px;
}

.about-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.about-feature {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.about-feature .feature-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.about-feature h3 {
    font-size: 1rem;
    color: var(--primary-darker);
    margin-bottom: 6px;
}

.about-feature p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* =============================================
   Book Library (Thư viện Kinh sách)
   ============================================= */

/* --- Book Grid --- */
.book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Homepage variant: 4 columns */
.book-grid-home {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 960px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .book-grid {
        grid-template-columns: 1fr;
    }
}

/* Homepage book grid (4 cols) — responsive */
@media (max-width: 960px) {
    .book-grid-home {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .book-grid-home {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .book-grid-home {
        grid-template-columns: 1fr;
    }
}

/* --- Book Card --- */
.book-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s var(--ease);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
    color: inherit;
}

/* Book Cover */
.book-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: linear-gradient(145deg, #1a1a2e 0%, #2d1117 40%, #3d1a1a 100%);
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s var(--ease);
}

.book-card:hover .book-cover img {
    transform: scale(1.05);
}

/* Cover Placeholder */
.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1a1a2e 0%, #2d1117 40%, #3d1a1a 100%);
    position: relative;
    overflow: hidden;
}

.book-cover-placeholder::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(212, 160, 23, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(139, 26, 26, 0.1) 0%, transparent 40%);
    animation: shimmer 8s ease-in-out infinite;
}

@keyframes shimmer {

    0%,
    100% {
        transform: translate(-10%, -10%);
    }

    50% {
        transform: translate(10%, 10%);
    }
}

.book-cover-placeholder .placeholder-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    opacity: 0.4;
    filter: grayscale(0.5);
}

.book-cover-placeholder .placeholder-char {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 4rem;
    color: rgba(212, 160, 23, 0.15);
    line-height: 1;
}

.book-cover-placeholder-lg .placeholder-icon {
    font-size: 3rem;
}

.book-cover-placeholder-lg .placeholder-char {
    font-size: 5rem;
}

/* File Badge */
.file-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.file-badge-pdf {
    background: rgba(229, 57, 53, 0.9);
    color: #fff;
}

.file-badge-docx,
.file-badge-doc {
    background: rgba(21, 101, 192, 0.9);
    color: #fff;
}

/* Book Info */
.book-info {
    padding: 14px 16px 8px;
    flex: 1;
}

.book-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 4px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.8rem;
    color: var(--accent-warm);
    margin-bottom: 6px;
    font-weight: 600;
}

.book-author i {
    margin-right: 3px;
    font-size: 0.7rem;
}

.book-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.book-meta i {
    margin-right: 2px;
}

.book-cat-tag {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 1px 8px;
    font-size: 0.68rem;
    font-weight: 600;
}

/* Book Action */
.book-action {
    padding: 10px 16px 14px;
}

.btn-read {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    transition: all 0.2s var(--ease);
}

.book-card:hover .btn-read {
    color: var(--primary-dark);
}

.btn-read i {
    transition: transform 0.2s var(--ease);
    font-size: 0.7rem;
}

.book-card:hover .btn-read i {
    transform: translateX(4px);
}

/* =============================================
   Book Detail Page
   ============================================= */

.book-detail-header {
    display: flex;
    gap: 28px;
    padding: 24px;
}

.book-detail-cover {
    flex-shrink: 0;
    width: 220px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.book-detail-cover img {
    width: 100%;
    display: block;
}

.book-detail-cover .book-cover-placeholder {
    aspect-ratio: 3 / 4;
}

.book-detail-info {
    flex: 1;
    min-width: 0;
}

.book-detail-info h1 {
    font-size: 1.5rem;
    margin-bottom: 6px;
    line-height: 1.35;
}

.book-detail-author {
    font-size: 0.95rem;
    color: var(--accent-warm);
    font-weight: 600;
    margin-bottom: 14px;
}

.book-detail-author i {
    margin-right: 4px;
}

.book-detail-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 18px;
}

/* Stats */
.book-detail-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.82rem;
}

.stat-icon {
    color: var(--primary);
    font-size: 0.85rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-weight: 700;
    color: var(--ink);
}

/* Actions */
.book-detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* PDF Viewer */
.pdf-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.pdf-viewer-container {
    width: 100%;
    background: #525659;
}

.pdf-viewer-iframe {
    display: block;
    width: 100%;
    height: 85vh;
    min-height: 500px;
    border: none;
}

/* Responsive Detail */
@media (max-width: 768px) {
    .book-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .book-detail-cover {
        width: 180px;
    }

    .book-detail-stats {
        justify-content: center;
    }

    .book-detail-actions {
        justify-content: center;
    }

    .pdf-viewer-iframe {
        height: 60vh;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* DOCX Viewer (mammoth.js) */
.docx-viewer {
    background: #fff;
    min-height: 500px;
    max-height: 85vh;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.docx-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.docx-content {
    padding: 40px 48px;
    font-size: 0.95rem;
    line-height: 1.85;
    color: var(--ink);
    max-width: 800px;
    margin: 0 auto;
}

.docx-content h1 {
    font-size: 1.6rem;
    margin: 24px 0 12px;
    font-weight: 800;
}

.docx-content h2 {
    font-size: 1.3rem;
    margin: 20px 0 10px;
    font-weight: 700;
}

.docx-content h3 {
    font-size: 1.1rem;
    margin: 16px 0 8px;
    font-weight: 700;
}

.docx-content p {
    margin-bottom: 12px;
}

.docx-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 12px 0;
}

.docx-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.88rem;
}

.docx-content th,
.docx-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.docx-content th {
    background: var(--bg-light);
    font-weight: 700;
}

.docx-content ul,
.docx-content ol {
    padding-left: 24px;
    margin-bottom: 12px;
}

.docx-content li {
    margin-bottom: 4px;
}

@media (max-width: 768px) {
    .docx-content {
        padding: 20px 16px;
    }
}

/* =============================================
   Cover Image for Articles
   ============================================= */

figure.cover-image {
    margin: 0 0 24px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #f5f5f5;
}

figure.cover-image img.cover-image-img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 500px;
    object-fit: cover;
}

figure.cover-image figcaption {
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 500;
}