/* Book Shelf Layout */
.bookshelf {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 60px;
    padding: 50px 0 80px;
    perspective: 1200px;
    flex-wrap: wrap;
}

.course-book-container {
    position: relative;
    width: 200px;
    height: 300px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

/* Catalog Mode overrides */
.course-book-container.catalog-mode {
    width: 260px;
    height: 380px;
}

.course-book-container:hover {
    transform: translateY(-20px) rotateY(-10deg);
}

.book-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    border-radius: 5px 10px 10px 5px;
    box-shadow: inset 4px 0 10px rgba(0, 0, 0, 0.1), 5px 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 2;
    transform-origin: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    background-color: #0b1c3c;
    overflow: hidden;
    color: #ffd700;
}

.book-spine {
    position: absolute;
    top: 0;
    left: -40px;
    width: 40px;
    height: 100%;
    background: #061025;
    transform: rotateY(-90deg);
    transform-origin: right;
    border-radius: 5px 0 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-spine span {
    transform: rotate(-90deg);
    color: rgba(255, 255, 255, 0.7);
    font-weight: bold;
    letter-spacing: 2px;
    white-space: nowrap;
}

/* Book Modal */
.book-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    perspective: 2000px;
}

.open-book {
    width: 900px;
    height: 600px;
    position: relative;
    transform-style: preserve-3d;
}

.open-book .page {
    position: absolute;
    top: 0;
    left: 50%;
    /* Start on right side */
    width: 50%;
    height: 100%;
    background: #fff;
    transform-origin: left;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: pointer;
}

/* Page Faces */
.page-front,
.page-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    backface-visibility: hidden;
    padding: 0;
    /* Changed to 0 for catalog layout flexibility */
    display: flex;
    flex-direction: column;
}

.page-front {
    z-index: 2;
}

.page-back {
    transform: rotateY(180deg);
    z-index: 1;
    background: #fff;
    border-right: 1px solid #ddd;
}

/* Book Logos */
.book-cover-logo {
    max-height: 60px;
    width: auto;
    margin-bottom: 20px;
    /* Increased margin for balance */
    object-fit: contain;
}

.book-back-logo {
    max-height: 60px;
    width: auto;
    margin-bottom: 15px;
    object-fit: contain;
}

/* Catalog Page Content Styling */
.catalog-page-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #fcfcfc;
    /* Subtle paper texture */
    background-image: radial-gradient(#e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
}

.catalog-img-wrapper {
    padding: 30px 30px 10px 30px;
    height: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.catalog-img {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    /* Slight round logic */
    box-shadow:
        0 10px 20px rgba(0, 0, 0, 0.2),
        /* Drop shadow */
        0 0 0 8px #fff,
        /* Mount */
        0 0 0 9px #ddd,
        /* Inner Border */
        0 0 0 10px #fff;
    /* Outer Edge */
    position: relative;
    transition: transform 0.3s ease;
}

.catalog-img:hover {
    transform: scale(1.02);
}

.catalog-body {
    padding: 20px 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.catalog-body h4 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    color: #0b1c3c;
    margin-bottom: 5px;
    border-bottom: 3px solid #ffd700;
    display: inline-block;
    padding-bottom: 5px;
    width: fit-content;
}

.catalog-body .text-warning {
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.catalog-body p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
    flex-grow: 1;
    /* Push buttons down */
}

.catalog-btns {
    margin-top: 20px;
    display: flex;
    gap: 15px;
}

.catalog-btns .btn {
    border-radius: 0;
    /* Sharp buttons */
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 10px 0;
}

/* Flipped State */
.page.flipped {
    transform: rotateY(-180deg);
}

.close-book-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    color: #fff;
    cursor: pointer;
    z-index: 10000;
}