/* ================== Book Section Styles ================== */
.book-container {
    background: #111;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0px 0px 20px rgba(139, 0, 0, 0.7);
    max-width: 90%;
    margin: 40px auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;  /* Prevents overflow from the container */
}

/* Ensure the book wrapper allows smooth sliding */
.book-wrapper {
    display: flex;
    transition: transform 0.5s ease-in-out;
    width: 200%; /* Enough space for both books */
    overflow: hidden;
}

/* Make each book take full width */
.book-item {
    flex: 0 0 100%;
    text-align: center;
    display: block;
}


.book-cover:hover {
    transform: scale(1.05);
    box-shadow: 0px 0px 15px rgba(139, 0, 0, 0.7);
}

/* Ensure the carousel has smooth transitions */
#book-carousel {
    position: relative;
    text-align: center;
}

/* Fade animation for the book cover */
.book-cover {
    width: 300px;
    height: 450px;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover; /* Crop and fill the container */
    display: block;
    margin: 0 auto;
}

/* Fade animation for the book title */
.book-title {
    opacity: 1;
    transition: opacity 1s ease-in-out;
}

/* Book Title */
.book-title {
    font-weight: bold;
    color: #ffffff;
    text-shadow: 5px 2px 6px rgb(173, 17, 17);
    letter-spacing: 1px;
    text-align: center;
    white-space: normal; /* Allows multi-line text */
    line-height: 1.4; /* Improves readability */
    margin-left: auto;
    margin-right: auto;
    max-width: 90%; /* Reduce width to fit inside container */
    white-space: normal; /* Allow wrapping */
    word-wrap: break-word; /* Ensure long words break */
    overflow-wrap: break-word;
    text-align: center; /* Keep it centered */
    font-size: clamp(1.2em, 5vw, 1.8em); /* Responsive font size */
}

/* Book Subtitle */
.book-subtitle {
    font-weight: bold;
    color: #ffffff;
    text-shadow: 2px 2px 6px rgb(204, 5, 5);
    word-wrap: break-word;
    text-align: center;
    white-space: normal; /* Allows multi-line text */
    margin-left: auto;
    margin-right: auto;
    max-width: 90%; /* Reduce width to fit inside container */
    white-space: normal; /* Allow wrapping */
    word-wrap: break-word; /* Ensure long words break */
    overflow-wrap: break-word;
    text-align: center; /* Keep it centered */
    font-size: clamp(1.2em, 5vw, 1.8em); /* Responsive font size */
    padding:0;
}

/* Book Description */
.book-description {
    font-size: 1.1em;
    line-height: 1.8;
    color: #c5c5c5;
    margin-bottom: 15px;
    text-align: center;
}

/* Buy Button */
.buy-button {
    display: inline-block;
    padding: 12px 20px;
    font-size: 1.2em;
    font-weight: bold;
    background: #7b0202;
    color: white;
    border-radius: 5px;
    text-decoration: none;
    border: 2px solid #a30000;
    transition: background 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.buy-button:hover {
    background: #a30000;
    box-shadow: 0px 0px 15px rgba(139, 0, 0, 0.9);
}

/* Book Carousel */
#book-carousel {
    text-align: center;
    padding: 20px;
    background: #1a1a1a;
    border-radius: 10px;
    box-shadow: 0px 0px 20px rgba(139, 0, 0, 0.7);
    max-width: 95%;
    margin: 20px auto;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Swipe Indicator (Hidden on Desktop) */
.swipe-indicator {
    display: none; /* Default: Hidden */
    color: #fff;
    font-size: 1em;
    text-align: center;
    margin-bottom: 10px;
    opacity: 0.7;
    padding:10px;
}

/* ========================= Mobile-Specific Styling ========================= */
@media (max-width: 768px) {
    /* Show Swipe Indicator on Mobile */
    .swipe-indicator {
        display: block; /* Show swipe hint */
        animation: fadeOut 3s ease-in-out forwards;
    }


    /* Ensure swipe functionality only applies on mobile */
    .book-wrapper {
        display: flex;
        overflow: hidden;
        touch-action: pan-y; /* Prevent scrolling conflicts */
    }

    /* Adjust book size for smooth swipe */
    .book-item {
        display: block;
        width: 100%;
    }

    /* Adjust container for better spacing */
    .book-container {
        padding: 15px;
    }

    /* Responsive Fixes for Mobile - Resize Book Title */
    .book-title {
        font-size: 1.2em; /* Reduce size for mobile */
        max-width: 90%; /* Ensures it remains contained */
        padding: 0 10px; /* Adds spacing on sides */
    }


    /* Ensure the subtitle is always within bounds */
    .book-subtitle {
        font-size: 1.2em;  /* Adjust subtitle font size on mobile */
        max-width: 90%;  /* Subtitle will fit within the container */
        text-align: center;  /* Ensure subtitle is centered */
    }

    /* Fix between 420px to 408px range for smaller screens */
    @media (max-width: 420px) and (min-width: 408px) {

        .book-title {
            font-size: 1.1em; /* Adjust title font size for small screens */
        }

        .book-subtitle {
            font-size: 1em;  /* Adjust subtitle font size for small screens */
        }
    }

    /* Ensure that between 408px and 263px, the image and title fit within the container */
    @media (max-width: 408px) and (min-width: 263px) {

        .book-title {
            font-size: 1em; /* Further adjust title size for this range */
        }

        .book-subtitle {
            font-size: 0.9em;  /* Adjust subtitle font size for very small screens */
        }
    }
}

/* Mobile-Specific Styling */
@media (max-width: 768px) {
    .book-cover {
        width: 90%; /* Scale down on smaller screens */
        height: auto; /* Maintain aspect ratio */
        max-width: 250px; /* Set a reasonable max-width */
        max-height: 375px; /* Keep proportional */
    }
}

@media (max-width: 480px) {
    .book-cover {
        width: 80%; /* Reduce size further on very small screens */
        max-width: 200px;
        max-height: 300px;
    }
}
