/* ================================== */
/* BOEK SPECIFIEKE OPMAAK            */
/* ================================== */

/* De boek-container die de pagina's en zwevende knoppen vasthoudt */
.book-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0;
    width: 100%;
    perspective: 2200px;
    -webkit-perspective: 2200px;
}

.book {
    display: flex;
    position: relative;
    width: 100%;
    min-height: 520px;
    background-color: #faf6f0; /* Zacht crème papierkleur */
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15), 
                0 5px 15px rgba(0, 0, 0, 0.08);
    border: 10px solid #5c4033; /* Houten/lederen boekrand effect */
    overflow: hidden;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: background-color 0.3s ease;
}

body.dark-mode .book {
    background-color: #1e293b; /* Donkerder blauw/grijs papier in dark mode */
    border-color: #0f172a; /* Donkere leren rand */
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

/* De individuele pagina's */
.book-page {
    flex: 1;
    width: 50%;
    padding: 24px 28px 30px 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background-color: #faf6f0;
    transition: background-color 0.3s ease;
    box-sizing: border-box;
}

body.dark-mode .book-page {
    background-color: #1e293b;
}

/* De vouw in het midden (boekrug effect) */
.book-spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 16px;
    transform: translateX(-50%);
    background: linear-gradient(to right, 
        rgba(0,0,0,0.1) 0%, 
        rgba(0,0,0,0.25) 30%, 
        rgba(0,0,0,0.3) 50%, 
        rgba(0,0,0,0.25) 70%, 
        rgba(0,0,0,0.1) 100%);
    z-index: 10;
    border-top: none;
    border-bottom: none;
    pointer-events: none;
}

body.dark-mode .book-spine {
    background: linear-gradient(to right, 
        rgba(0,0,0,0.2) 0%, 
        rgba(0,0,0,0.5) 30%, 
        rgba(0,0,0,0.6) 50%, 
        rgba(0,0,0,0.5) 70%, 
        rgba(0,0,0,0.2) 100%);
}

/* Pagina-inhoud elementen */
.page-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* 2x2 Raster voor 4 afbeeldingen per pagina */
.book-items-layout {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 16px 20px;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-items: center;
}

.book-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.book-image-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 8px;
    padding: 8px;
    background-color: #ffffff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.dark-mode .book-image-container {
    background-color: #0f172a;
    border-color: #334155;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.book-image-container:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
}

body.dark-mode .book-image-container:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
}

.book-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.book-word {
    font-size: 1.15rem;
    font-weight: 700;
    color: #5c4033; /* Warm bruin voor prentenboek sfeer */
    margin: 6px 0 0 0;
    text-transform: lowercase;
    text-align: center;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

body.dark-mode .book-word {
    color: #bfdbfe; /* Zacht blauw accent */
}

/* Subtiel paginanummer rechtsonder */
.page-number {
    position: absolute;
    bottom: 8px;
    right: 16px;
    font-size: 0.85rem;
    color: #a89f91;
    font-weight: 600;
    user-select: none;
    line-height: 1;
}

body.dark-mode .page-number {
    color: #64748b;
}

/* Lege/Einde pagina */
.empty-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #8c7e6c;
}

body.dark-mode .empty-page {
    color: #64748b;
}

.empty-page svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Zwevende Bladerknoppen (Midden-links en Midden-rechts) */
.book-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.75);
    color: #334155;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0.65;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode .book-nav-btn {
    background-color: rgba(30, 41, 59, 0.75);
    color: #f1f5f9;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.book-nav-btn.prev-btn {
    left: 12px;
}

.book-nav-btn.next-btn {
    right: 12px;
}

.book-nav-btn:hover:not(:disabled) {
    opacity: 1;
    transform: translateY(-50%) scale(1.12);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    background-color: #ffffff;
    color: #2563eb;
}

body.dark-mode .book-nav-btn:hover:not(:disabled) {
    background-color: #334155;
    color: #38bdf8;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
}

.book-nav-btn:active:not(:disabled) {
    transform: translateY(-50%) scale(0.95);
}

.book-nav-btn:disabled {
    opacity: 0.15;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
}

/* ================================== */
/* 3D BLADZIJDE OMSLAAN ANIMATIE      */
/* ================================== */

.flipping-sheet {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    z-index: 20;
    pointer-events: none;
}

.flipping-sheet.flip-next {
    left: 50%;
    transform-origin: left center;
    animation: flipNextSheet 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.flipping-sheet.flip-prev {
    left: 0;
    transform-origin: right center;
    animation: flipPrevSheet 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.sheet-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    padding: 24px 28px 30px 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #faf6f0;
    box-sizing: border-box;
    overflow: hidden;
}

body.dark-mode .sheet-face {
    background-color: #1e293b;
}

.sheet-face.sheet-back {
    transform: rotateY(180deg);
}

/* Schaduweffect over de omslaande pagina */
.sheet-face::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.flipping-sheet.flip-next .sheet-front::after {
    animation: shadowNextFront 0.65s ease-in-out forwards;
}

.flipping-sheet.flip-next .sheet-back::after {
    animation: shadowNextBack 0.65s ease-in-out forwards;
}

.flipping-sheet.flip-prev .sheet-front::after {
    animation: shadowPrevFront 0.65s ease-in-out forwards;
}

.flipping-sheet.flip-prev .sheet-back::after {
    animation: shadowPrevBack 0.65s ease-in-out forwards;
}

@keyframes flipNextSheet {
    0% {
        transform: rotateY(0deg);
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: -15px 0 35px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: rotateY(-180deg);
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.1);
    }
}

@keyframes flipPrevSheet {
    0% {
        transform: rotateY(0deg);
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 15px 0 35px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: rotateY(180deg);
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
    }
}

@keyframes shadowNextFront {
    0% { background: linear-gradient(to left, rgba(0,0,0,0) 70%, rgba(0,0,0,0.1) 100%); }
    50% { background: linear-gradient(to left, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.25) 100%); }
    100% { background: linear-gradient(to left, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 100%); }
}

@keyframes shadowNextBack {
    0% { background: linear-gradient(to right, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.1) 100%); }
    50% { background: linear-gradient(to right, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.05) 100%); }
    100% { background: linear-gradient(to right, rgba(0,0,0,0) 70%, rgba(0,0,0,0) 100%); }
}

@keyframes shadowPrevFront {
    0% { background: linear-gradient(to right, rgba(0,0,0,0) 70%, rgba(0,0,0,0.1) 100%); }
    50% { background: linear-gradient(to right, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.25) 100%); }
    100% { background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 100%); }
}

@keyframes shadowPrevBack {
    0% { background: linear-gradient(to left, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.1) 100%); }
    50% { background: linear-gradient(to left, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.05) 100%); }
    100% { background: linear-gradient(to left, rgba(0,0,0,0) 70%, rgba(0,0,0,0) 100%); }
}

/* Responsieve weergave (Mobiel: 1 pagina tegelijk) */
@media (max-width: 767px) {
    .book {
        min-height: 440px;
        border-width: 6px;
    }
    
    .book-spine {
        display: none;
    }
    
    .book-page {
        width: 100%;
        padding: 16px 16px 28px 16px;
    }
    
    .book-page.right-page {
        display: none;
    }

    .book-nav-btn {
        width: 42px;
        height: 42px;
    }

    .book-nav-btn.prev-btn {
        left: 6px;
    }

    .book-nav-btn.next-btn {
        right: 6px;
    }

    .book-items-layout {
        gap: 12px 14px;
    }

    .book-word {
        font-size: 1rem;
    }

    .flipping-sheet {
        display: none; /* Op mobiel directe overgang */
    }
}
