/* ==========================================================================
   Book Display Styles
   ========================================================================== */
   .books-container {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    padding: 0.5em;
    width: 100%;
    box-sizing: border-box;
    max-width: 1200px;
    margin: 0 auto;
}

.books-container:last-of-type {
    margin-bottom: 50px !important;
}


.book {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: box-shadow 0.3s ease;
    box-sizing: border-box;
}

.book-link {
    display: flex;
    flex-direction: row;
    gap: 1em;
    padding: 0.75em;
    box-sizing: border-box;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    min-height: 0; /* Enable proper flexbox overflow behavior */
}

.book img {
    width: 70px;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.book-content {
    flex-grow: 1;
    min-height: 0; /* Allow flex item to shrink below content size */
}

.book-title {
    margin: 0;
    font-size: var(--base-font-size);
    font-weight: bold;
}

.book-link:focus-visible {
    outline: 2px solid var(--accent-color, #1a4fa3);
    outline-offset: 2px;
}

.book-date {
    font-size: calc(var(--base-font-size) * 0.8);
    color: var(--text-color-secondary, #666);
    font-weight: normal;
    font-family: inherit;
    margin-left: 0.5em;
}

.full-description {
    display: block;
    margin: 0.5em 0 0 0;
    line-height: 1.4;
    font-size: calc(var(--base-font-size) * 0.95);
    color: var(--text-color-secondary, #666);
}

/* Hover effects */
.book:hover {
    box-shadow: 0 4px 8px var(--shadow-color);
}

.book:hover .book-link,
.book-link:focus-visible {
    text-decoration: none;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .book-link {
        flex-direction: column;
        align-items: center;
    }

    .book-link img {
        width: 120px;
        margin-bottom: 0.5em;
    }
}

/* 2-column layout for wider screens */
@media (min-width: 900px) {
    .books-container {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1em;
    }

    .books-container .book {
        width: calc(50% - 0.5em); /* Half width minus half the gap */
        height: 300px; /* Fixed height for uniform grid appearance */
        display: flex; /* Enable flex container for height control */
        flex-direction: column;
    }

    .books-container .book:only-child {
        width: 100%;
    }

    .book-link {
        flex: 1; /* Take available height */
        display: flex;
        flex-direction: row;
        min-height: 0;
        align-items: stretch; /* Allow content to fill height */
    }

    .book img {
        align-self: flex-start; /* Prevent image from stretching */
    }

    .book-content {
        flex: 1; /* Take available width */
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    .book-title {
        flex-shrink: 0; /* Don't shrink title */
    }
    
    .full-description {
        flex: 1; /* Take remaining space */
        overflow-y: auto;
        min-height: 0;
        /* Firefox scrollbar styling */
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
    }

    /* Webkit scrollbar styling (Chrome, Edge, Safari) */
    .full-description::-webkit-scrollbar {
        width: 8px;
    }

    .full-description::-webkit-scrollbar-track {
        background: transparent;
    }

    .full-description::-webkit-scrollbar-thumb {
        background: transparent;
        border-radius: 4px;
    }

    /* Show scrollbar on card hover */
    .book:hover .full-description {
        scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
    }

    .book:hover .full-description::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.15);
    }

    .book:hover .full-description::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.3);
    }
}
