/* ========================================================
   3D REAL-BOOK FAN & FLIP SHOWCASE (PERFECT DESK HARMONY)
   ======================================================== */

/* ========================================================
   DARK SKELETON SHIMMER PRELOADER (SHOWCASE COVERS)
   ======================================================== */
@keyframes kbfShimmerAnim {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.kbf-stacked-book,
.kbf-cover-front,
#kbf-img-front,
#kbf-img-mid,
#kbf-img-back,
.kbf-stacked-book img,
.kbf-cover-front img {
    background-color: #141e33 !important;
    background-image: linear-gradient(90deg, #141e33 20%, #1e293b 50%, #141e33 80%) !important;
    background-size: 200% 100% !important;
    animation: kbfShimmerAnim 1.6s infinite linear !important;
    color: transparent !important;
}
.kbf-stage {
    perspective: 1800px;
    width: 100%;
    min-height: 395px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    padding: 15px 0;
    overflow: visible;
    transform: scale(0.88);
    transform-origin: center center;
}

/* Background Ambient Lighting Halo */
.kbf-ambient-aura {
    position: absolute;
    width: 550px;
    height: 400px;
    background: radial-gradient(circle, rgba(245, 212, 145, 0.22) 0%, rgba(30, 41, 59, 0) 70%);
    filter: blur(55px);
    pointer-events: none;
    z-index: 1;
}

/* ----------------------------------------------------
   BENDA LATAR BELAKANG MEJA BACA (LEBIH BESAR & PAS DI KANAN)
   ---------------------------------------------------- */
.kbf-desk-props {
    position: absolute;
    right: 25px; /* Geser pas ke sisi kanan */
    top: 50%;
    transform: translateY(-50%) translate3d(0, 0, -30px);
    width: 250px; /* Diperbesar agar jelas terbaca */
    height: 310px;
    pointer-events: none;
    z-index: 1; /* Di belakang tumpukan buku */
    opacity: 0.92;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.8));
    transition: opacity 1.2s ease, transform 1.2s cubic-bezier(0.2, 0.9, 0.25, 1);
}

/* Saat Buku Terbuka: Buku bergeser menutupi benda secara wajar */
.kbf-stage.is-book-open .kbf-desk-props {
    opacity: 0.35;
    transform: translateY(-50%) translate3d(15px, 0, -50px) scale(0.96);
}

.kbf-stage.is-book-closed .kbf-desk-props {
    opacity: 0.92;
    transform: translateY(-50%) translate3d(0, 0, -30px) scale(1);
}

/* ----------------------------------------------------
   TUMPUKAN 3 BUKU DENGAN BUKAAN KIPAS LEBAR
   ---------------------------------------------------- */
.kbf-stack-group {
    position: relative;
    width: 215px;
    height: 305px;
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.2, 0.9, 0.25, 1);
    z-index: 2;
    margin-right: 10px; /* Pas ke kanan */
}

/* Base Style Setiap Buku dalam Tumpukan */
.kbf-stacked-book {
    position: absolute;
    top: 0;
    left: 0;
    width: 215px;
    height: 305px;
    border-radius: 4px 10px 10px 4px;
    border: 1.5px solid rgba(245, 212, 145, 0.35);
    box-shadow: 
        -12px 18px 40px rgba(0, 0, 0, 0.85),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    background-color: #1e120f;
    transition: all 1.2s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.kbf-stacked-book img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ALUR TEKUKAN ENGSEL KIRI OTOMATIS */
.kbf-stacked-book::before,
.kbf-cover-front::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 100%;
    background: linear-gradient(to right, 
        rgba(0, 0, 0, 0.45) 0%, 
        rgba(0, 0, 0, 0.15) 55%, 
        rgba(255, 255, 255, 0.2) 80%, 
        rgba(0, 0, 0, 0.5) 100%);
    pointer-events: none;
    z-index: 5;
}

/* Ketebalan Kertas di Sisi Kanan Buku Tumpukan */
.kbf-stacked-book::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 0;
    width: 6px;
    height: calc(100% - 4px);
    background: repeating-linear-gradient(to right, #f1ece1 0px, #baa892 1px, #f1ece1 2px);
    border-radius: 0 4px 4px 0;
    box-shadow: inset 0 0 2px rgba(0,0,0,0.4);
    z-index: 6;
}

/* ====================================================
   OPSI A: DYNAMIC ADAPTIVE 3D BOOK FAN
   ==================================================== */

/* 1. STATE BUKU TERTUTUP (SIMETRIS SEMPURNA KIRI - TENGAH - KANAN) */

/* Buku Kiri (Sayap Kiri Kipas - Rapat & Seimbang) */
.kbf-book-back,
.kbf-stage.is-book-closed .kbf-book-back {
    transform: translate3d(-75px, 10px, -60px) rotateZ(-15deg) rotateY(10deg);
    opacity: 0.92;
    filter: brightness(0.92);
    border-color: rgba(245, 212, 145, 0.45);
    box-shadow: -15px 20px 45px rgba(0, 0, 0, 0.88), 0 0 15px rgba(245, 212, 145, 0.15);
    z-index: 1;
}

/* Buku Kanan (Sayap Kanan Kipas - Rapat & Seimbang) */
.kbf-book-mid,
.kbf-stage.is-book-closed .kbf-book-mid {
    transform: translate3d(75px, 10px, -45px) rotateZ(15deg) rotateY(-10deg);
    opacity: 0.96;
    filter: brightness(0.95);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 15px 20px 45px rgba(0, 0, 0, 0.88);
    z-index: 2;
}

/* ----------------------------------------------------
   BUKU UTAMA (PALING ATAS) - ADAPTIF DI TENGAH
   ---------------------------------------------------- */
.kbf-book-main {
    position: absolute;
    top: 0;
    left: 0;
    width: 215px;
    height: 305px;
    transform-style: preserve-3d;
    transition: all 1.4s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 10;
    cursor: pointer;
}

/* Posisi Tertutup: Berdiri Megah Tepat di Tengah (Simetris 0°) */
.kbf-book-main.is-closed {
    transform: translate3d(0px, 0px, 10px) rotateZ(0deg) rotateY(0deg);
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.85));
}

/* 2. STATE BUKU TERBUKA: KEDUA BUKU LATAR MEKAR SIMETRIS PROPORSI PAS */

/* Posisi Buku Utama Terbuka: Bergeser Proporsional (+82px) */
.kbf-book-main.is-open {
    transform: translate3d(82px, 4px, 45px) rotateZ(3deg) rotateY(-4deg);
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.22));
}

/* Saat Buku Terbuka: Buku Kanan Meluncur Anggun Pas di Kanan */
.kbf-stage.is-book-open .kbf-book-mid {
    transform: translate3d(115px, 14px, -45px) rotateZ(15deg) rotateY(-10deg);
    box-shadow: 10px 14px 25px rgba(0, 0, 0, 0.18);
}

/* Saat Buku Terbuka: Buku Kiri Meluncur Anggun Pas di Kiri */
.kbf-stage.is-book-open .kbf-book-back {
    transform: translate3d(-120px, 14px, -70px) rotateZ(-18deg) rotateY(12deg);
    box-shadow: -10px 14px 25px rgba(0, 0, 0, 0.18), 0 0 15px rgba(245, 212, 145, 0.15);
}

/* Halaman Dalam Kanan (Sinopsis) */
.kbf-page-right {
    position: absolute;
    top: 0;
    left: 0;
    width: 215px;
    height: 305px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-left: none;
    border-radius: 0 10px 10px 0;
    box-shadow: 
        15px 20px 45px rgba(0, 0, 0, 0.85),
        inset 18px 0 25px -10px rgba(0, 0, 0, 0.85);
    padding: 18px 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.7s ease 0.5s;
}

/* Ketebalan Kertas Halaman Terbuka */
.kbf-page-right::after {
    content: "";
    position: absolute;
    top: 3px;
    right: -4px;
    width: 6px;
    height: calc(100% - 6px);
    background: repeating-linear-gradient(to right, #cbd5e1 0px, #94a3b8 1px, #cbd5e1 2px);
    border-radius: 0 4px 4px 0;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.4);
}

.kbf-book-main.is-open .kbf-page-right {
    opacity: 1;
}

/* Cover Depan yang Membuka ke Kiri (1.8 Detik Halus) */
.kbf-cover-leaf {
    position: absolute;
    top: 0;
    left: 0;
    width: 215px;
    height: 305px;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1.8s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 15;
    border-radius: 4px 10px 10px 4px;
}

.kbf-book-main.is-open .kbf-cover-leaf {
    transform: rotateY(-155deg);
}

/* Sisi Luar Cover Depan */
.kbf-cover-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 4px 10px 10px 4px;
    border: 1.5px solid rgba(245, 212, 145, 0.4);
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.75);
    background-color: #1e120f;
}

.kbf-cover-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.kbf-cover-front::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.05) 30%, transparent 60%);
    pointer-events: none;
    z-index: 6;
}

/* Halaman Balik Kiri saat Buku Terbuka (Bersih, Ramping, & Alami) */
.kbf-cover-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    background: radial-gradient(ellipse at 85% 50%, #1e293b 0%, #0f172a 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    border-radius: 10px 0 0 10px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    /* Bayangan halus tanpa menutupi buku di belakangnya */
    box-shadow:
        -6px 10px 22px rgba(0, 0, 0, 0.45),
        inset -14px 0 18px -8px rgba(0, 0, 0, 0.6);
}

/* Bayangan Lembah Lipatan Punggung Buku Kiri (Halus & Transparan) */
.kbf-cover-back::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 26px;
    height: 100%;
    background: linear-gradient(to left,
        rgba(0, 0, 0, 0.55) 0%,
        rgba(0, 0, 0, 0.18) 45%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 6;
}

/* Engsel Punggung Buku Fisik Ramping & Presisi */
.kbf-book-spine-hinge {
    position: absolute;
    top: 0;
    left: -4px;
    width: 8px;
    height: 100%;
    background: linear-gradient(to right, #0f172a 0%, #334155 40%, #475569 50%, #334155 60%, #0f172a 100%);
    z-index: 25;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.8);
    border-radius: 1px;
}

/* Pita Pembatas Buku Mewah: Rata di Atas (Top: 0) & Menjulur Manis Hanya di Bawah */
.kbf-book-spine-hinge::after {
    content: "";
    position: absolute;
    top: 0px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: calc(100% + 10px);
    background: linear-gradient(to bottom, #d97706 0%, #f59e0b 35%, #d97706 70%, #b45309 100%);
    border-radius: 0 0 2px 2px;
    box-shadow: 1px 3px 6px rgba(0, 0, 0, 0.55);
    clip-path: polygon(0% 0%, 100% 0%, 100% 92%, 50% 100%, 0% 92%);
    pointer-events: none;
    z-index: 30;
    transition: opacity 0.5s ease;
}

/* Pita hanya muncul elegan saat buku terbuka */
.kbf-stage.is-book-closed .kbf-book-spine-hinge::after {
    opacity: 0;
}
.kbf-stage.is-book-open .kbf-book-spine-hinge::after {
    opacity: 1;
}

/* Konten Teks Sinopsis */
.kbf-syn-category {
    font-size: 0.65rem;
    font-weight: 800;
    color: #facc15;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    display: block;
}

.kbf-syn-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #f8fafc;
    line-height: 1.3;
    margin: 0 0 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kbf-syn-author {
    font-size: 0.72rem;
    color: #94a3b8;
    margin: 0 0 8px 0;
}

.kbf-syn-text {
    font-size: 0.72rem;
    color: #cbd5e1;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0 0 10px 0;
    font-style: italic;
    border-left: 2px solid #facc15;
    padding-left: 8px;
}

.kbf-syn-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
}

.kbf-btn-read {
    flex: 1;
    padding: 6px 10px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 9999px;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.kbf-btn-qv {
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.kbf-btn-qv:hover {
    background: rgba(255, 255, 255, 0.2);
}

.kbf-status-pill {
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.kbf-pill-tag {
    font-size: 0.75rem;
    font-weight: 700;
    color: #facc15;
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.25);
    padding: 4px 14px;
    border-radius: 9999px;
}

/* Transisi Halus pada Gambar Cover saat Berganti */
#kbf-img-front,
#kbf-img-mid,
#kbf-img-back {
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* === RESPONSIVE MOBILE SCALING FOR 3D FAN SHOWCASE === */
@media (max-width: 640px) {
    .kbf-stage {
        min-height: 340px;
        padding: 5px 0;
        transform: scale(0.76);
        transform-origin: center center;
    }
    .kbf-stack-group {
        margin-right: 5px;
    }
    .kbf-desk-props {
        right: 0px;
        width: 190px;
        transform: translateY(-50%) translate3d(0, 0, -30px) scale(0.76);
    }
}
@media (max-width: 400px) {
    .kbf-stage {
        transform: scale(0.68);
        margin: -25px 0;
    }
}


/* === SWEET SPOT ALIGNMENT FOR 3D HERO (PAS DI TENGAH-KANAN) === */
@media (min-width: 992px) {
    .hero-art-clean {
        justify-content: center !important;
    }
    .kbf-stage {
        justify-content: center !important;
        padding-right: 0 !important;
        transform: scale(0.88);
        transform-origin: center center;
    }
    .kbf-stack-group {
        margin-right: -10px !important;
    }
    .kbf-desk-props {
        right: 15px !important;
    }
}

/* Wrapper Bawah Lembaran Buku */
.kbf-bottom-wrap {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Label Harga Dinamis di Atas Tombol */
.kbf-price-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 2px;
}

.kbf-price-badge {
    font-size: 0.70rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 4px;
    display: inline-block;
}

.kbf-price-badge.is-free {
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.kbf-price-badge.is-paid {
    color: #facc15;
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.3);
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.76rem;
}

/* Tombol Primary (Baca vs Beli) */
.kbf-btn-primary {
    flex: 1.15;
    height: 30px;
    padding: 0 10px;
    color: #ffffff !important;
    font-size: 0.70rem;
    font-weight: 700;
    border-radius: 9999px;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: transform 0.2s, filter 0.2s;
}

.kbf-btn-primary.is-read {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.kbf-btn-primary.is-buy {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.45);
}

.kbf-btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

/* Tombol Detail Menuju Slug */
.kbf-btn-detail {
    flex: 1;
    height: 30px;
    padding: 0 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc !important;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: transform 0.2s, background 0.2s;
}

.kbf-btn-detail:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff !important;
}

/* ========================================================
   LIGHT MODE: BAYANGAN TIPIS, LEMBUT & TANPA NODA KABUT GELAP
   ======================================================== */
html:not(.dark-mode) .kbf-ambient-aura,
body:not(.dark-mode) .kbf-ambient-aura,
[data-theme="light"] .kbf-ambient-aura {
    display: none !important;
}

html:not(.dark-mode) .kbf-desk-props,
body:not(.dark-mode) .kbf-desk-props,
[data-theme="light"] .kbf-desk-props {
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.08)) !important;
    opacity: 0.65 !important;
}

html:not(.dark-mode) .kbf-book-main.is-closed,
body:not(.dark-mode) .kbf-book-main.is-closed,
[data-theme="light"] .kbf-book-main.is-closed {
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.12)) !important;
}

html:not(.dark-mode) .kbf-book-main.is-open,
body:not(.dark-mode) .kbf-book-main.is-open,
[data-theme="light"] .kbf-book-main.is-open {
    filter: drop-shadow(0 14px 26px rgba(0, 0, 0, 0.14)) !important;
}

html:not(.dark-mode) .kbf-stacked-book,
body:not(.dark-mode) .kbf-stacked-book,
[data-theme="light"] .kbf-stacked-book {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.10) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

html:not(.dark-mode) .kbf-stage.is-book-open .kbf-book-mid,
body:not(.dark-mode) .kbf-stage.is-book-open .kbf-book-mid,
[data-theme="light"] .kbf-stage.is-book-open .kbf-book-mid {
    box-shadow: 6px 10px 20px rgba(0, 0, 0, 0.12) !important;
}

html:not(.dark-mode) .kbf-stage.is-book-open .kbf-book-back,
body:not(.dark-mode) .kbf-stage.is-book-open .kbf-book-back,
[data-theme="light"] .kbf-stage.is-book-open .kbf-book-back {
    box-shadow: -6px 10px 20px rgba(0, 0, 0, 0.12) !important;
}

html:not(.dark-mode) .kbf-page-right,
body:not(.dark-mode) .kbf-page-right,
[data-theme="light"] .kbf-page-right {
    box-shadow: 8px 12px 22px rgba(0, 0, 0, 0.12), 0 3px 0 #cbd5e1, 0 5px 0 #94a3b8, inset 14px 0 18px -8px rgba(0, 0, 0, 0.45) !important;
}

html:not(.dark-mode) .kbf-cover-back,
body:not(.dark-mode) .kbf-cover-back,
[data-theme="light"] .kbf-cover-back {
    box-shadow: -6px 10px 18px rgba(0, 0, 0, 0.10), inset -14px 0 18px -8px rgba(0, 0, 0, 0.40) !important;
}
/* Cosmic & Clean Aura */
.kbf-ambient-aura { display: none !important; opacity: 0 !important; }
.kbf-stage { filter: none !important; }


/* --- MOBILE HERO AURA ANTI-OVERFLOW FIX (<= 640px) --- */
@media (max-width: 640px) {
    .hero-art-clean {
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        overflow: visible !important; /* Jangan potong buku 3D */
    }
    .kbf-stage {
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important; /* Jangan potong buku 3D */
        transform: scale(0.65) !important; /* Skala proporsional pas di layar HP */
        transform-origin: center center !important;
        margin: -25px auto !important;
    }
    .kbf-ambient-aura {
        display: none !important;
    }
}

@media (max-width: 400px) {
    .kbf-stage {
        transform: scale(0.60) !important;
        margin: -35px auto !important;
    }
}
