/* Book container */
.book {
    position: relative;
    width: 200px;
    height: 150px;
    perspective: 1000px; /* Adds 3D perspective */
    margin: 50px auto;
}

/* Front cover */
.cover {
    position: absolute;
    width: 200px;
    height: 150px;
    background: #00662a;
    border-radius: 5px;
    transform-origin: left; /* Rotate from the left edge */
    transform: rotateY(0deg);
    z-index: 3;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: openCover 2s ease-in-out forwards;
}

/* Pages */
.pages {
    position: absolute;
    width: 200px;
    height: 150px;
    background: #fff;
    border-radius: 5px;
    transform-origin: left;
    z-index: 2;
    overflow: hidden;
}

.pages .page {
    position: absolute;
    width: 200px;
    height: 150px;
    background: #f9f9f9;
    border-radius: 5px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
    transform-origin: left;
    animation: flipPage 1.5s ease-in-out infinite;
}

/* Back cover */
.back-cover {
    position: absolute;
    width: 200px;
    height: 150px;
    background: #004d1a;
    border-radius: 5px;
    transform-origin: left;
    transform: rotateY(-180deg);
    z-index: 1;
}

/* Animations */
@keyframes openCover {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(-120deg); /* Opens the cover outward */
    }
}

@keyframes flipPage {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(-90deg); /* Midway flip */
    }
    100% {
        transform: rotateY(-180deg); /* Fully flipped */
    }
}

/* Styling for individual pages */
.pages .page:nth-child(1) {
    animation-delay: 0.5s;
}
.pages .page:nth-child(2) {
    animation-delay: 1s;
}
.pages .page:nth-child(3) {
    animation-delay: 1.5s;
}