/* Hiệu ứng cuộn giấy Thư Pháp */
.parchment-card {
    background-color: #faf5ea;
    background-image: radial-gradient(rgba(255, 255, 255, 0.4) 0%, rgba(240, 225, 195, 0.2) 100%);
    border: 3px double #b45309;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), inset 0 0 40px rgba(139, 92, 26, 0.15);
    color: #2c1a0c;
}

.parchment-card-dark {
    background-color: rgba(26, 12, 5, 0.9);
    border: 2px solid #d97706;
    box-shadow: 0 0 25px rgba(217, 119, 6, 0.15), inset 0 0 30px rgba(0,0,0,0.8);
}

/* Nền ảo diệu mờ ảo sử dụng hình ảnh thư phòng cổ trang */
.ancient-bg {
    background: linear-gradient(to bottom, rgba(13, 5, 2, 0.85), rgba(21, 9, 4, 0.96)), 
                url('avatar.png'); /* Chuyển về sử dụng ảnh nền phù hợp */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

/* Khung bát quái phát hào quang cho Avatar */
.celestial-frame {
    position: relative;
    border-radius: 50%;
    padding: 12px;
    background: radial-gradient(circle, rgba(217,119,6,0.3) 0%, transparent 70%);
    border: 2px dashed rgba(217, 119, 6, 0.6);
    animation: rotate-dashed 40s linear infinite;
}

@keyframes rotate-dashed {
    100% { transform: rotate(360deg); }
}

/* Hạt đom đóm bay chậm lãng mạn */
.firefly {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fbbf24;
    border-radius: 50%;
    filter: drop-shadow(0 0 6px #fbbf24);
    pointer-events: none;
    opacity: 0;
    animation: drift 12s infinite ease-in-out;
}

@keyframes drift {
    0% { transform: translateY(0) translateX(0) scale(0.5); opacity: 0; }
    30% { opacity: 0.8; }
    70% { opacity: 0.8; }
    100% { transform: translateY(-150px) translateX(80px) scale(1.2); opacity: 0; }
}

/* Hiệu ứng chuyển động mây trôi hoặc sương mờ */
.mist-overlay {
    background: linear-gradient(180deg, transparent 0%, rgba(21, 9, 4, 0.4) 100%);
    pointer-events: none;
}

/* Thanh cuộn thư pháp cổ trang */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: #1a0c05;
}
::-webkit-scrollbar-thumb {
    background: #b45309;
    border-radius: 5px;
    border: 2px solid #1a0c05;
}
::-webkit-scrollbar-thumb:hover {
    background: #d97706;
}

/* =========================================================
   NEW 3D FLIPPING BOOK SCROLL CSS (EXPANDING VERSION)
   ========================================================= */
:root {
    --book-width: 170px;
    --book-height: calc(var(--book-width) * 1.618); 
}

/* Toàn bộ vùng chứa danh mục sách */
.book-catalog-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    perspective: 1500px;
}

/* Khung bọc ngoài, sẽ dãn rộng gấp đôi khi mở */
.book-wrapper {
    width: var(--book-width);
    height: var(--book-height);
    position: relative;
    cursor: pointer;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s ease;
    flex-shrink: 0;
}

/* Hover nhẹ khi chưa mở */
.book-wrapper:not(.is-open):hover {
    transform: translateY(-8px) scale(1.03);
}

/* Khi sách mở, chiều rộng tăng gấp đôi, đẩy các sách bên cạnh */
.book-wrapper.is-open {
    width: calc(var(--book-width) * 2);
    cursor: default;
    z-index: 10;
}

/* Trang sách nằm bên phải (ban đầu bị bìa che khuất ở vị trí left:0) */
.book-right-page {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--book-width);
    height: var(--book-height);
    background: #f4ebd0;
    color: #2b1f1d;
    border: 1px solid #c3b091;
    box-shadow: inset 15px 0 20px rgba(0, 0, 0, 0.15), 0 10px 25px rgba(0, 0, 0, 0.3);
    border-radius: 4px 8px 8px 4px;
    padding: 20px 15px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* Khi mở, trang phải trượt sang lấp đầy nửa bên phải của khung đã dãn */
.book-wrapper.is-open .book-right-page {
    transform: translateX(var(--book-width));
}

/* Phần bìa sách (chứa mặt trước và mặt sau) */
.book-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--book-width);
    height: var(--book-height);
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

/* Khi mở, bìa sách trượt sang phải rồi lật ngược 180 độ về bên trái */
.book-wrapper.is-open .book-cover {
    transform: translateX(var(--book-width)) rotateY(-180deg);
}

/* Định dạng chung cho 2 mặt của cuốn sách */
.book-side {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 4px 8px 8px 4px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* MẶT TRƯỚC: BÌA SÁCH */
.book-front {
    background: linear-gradient(135deg, #2b1f1d 0%, #1a1211 100%);
    border: 1px solid #4a3429;
    color: #e6c687;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    overflow: hidden;
    z-index: 2;
}

/* Đường chỉ gáy sách */
.book-front .book-spine-line {
    position: absolute;
    top: 0;
    left: 12px;
    width: 2px;
    height: 100%;
    background: rgba(230, 198, 135, 0.2);
    border-right: 1px dashed rgba(230, 198, 135, 0.4);
}

.book-cover-border {
    border: 1px solid #5a4538;
    outline: 3px double #e6c687;
    outline-offset: -6px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Đưa text ra giữa bìa sách */
    padding: 15px;
    text-align: center;
}

.book-title-vertical {
    font-family: 'Playfair Display', 'Times New Roman', serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fce7b2;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    text-transform: uppercase;
    line-height: 1.35;
    margin-bottom: 12px;
}

.book-sub-vertical {
    font-family: 'Times New Roman', serif;
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: #bfa36f;
    text-transform: uppercase;
    border-top: 1px solid rgba(191, 163, 111, 0.4);
    border-bottom: 1px solid rgba(191, 163, 111, 0.4);
    padding: 5px 10px;
}

.book-seal-stamp {
    position: absolute;
    bottom: 25px;
    font-family: 'Playfair Display', serif;
    font-size: 0.6rem;
    color: #c93b3b;
    border: 2px solid #c93b3b;
    padding: 3px;
    font-weight: bold;
    line-height: 1;
    transform: rotate(-5deg);
    background: rgba(26, 18, 17, 0.6);
    text-transform: uppercase;
}

/* MẶT TRONG: TRANG TRÁI (MẶT SAU CỦA BÌA) */
.book-back {
    background: #f4ebd0;
    color: #2b1f1d;
    transform: rotateY(180deg);
    padding: 20px 15px;
    border: 1px solid #c3b091;
    box-shadow: inset -15px 0 20px rgba(0, 0, 0, 0.15); /* Bóng gáy sách nằm bên phải */
    border-radius: 8px 4px 4px 8px; /* Lật lại nên góc bo đổi chiều */
}

/* NỘI DUNG BÊN TRONG CÁC TRANG */
.book-inner-page {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.inner-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    text-align: center;
    border-bottom: 1px solid #d0bc9c;
    padding-bottom: 4px;
    margin-bottom: 10px;
    color: #614022;
    font-weight: bold;
}

.inner-content {
    font-family: 'Times New Roman', serif;
    font-size: 0.75rem;
    line-height: 1.5;
    text-align: justify;
    font-style: italic;
    overflow-y: hidden;
}

.book-page-number {
    font-size: 0.6rem;
    text-align: center;
    color: #9c8468;
}
