/* Library-only layout: cover (or placeholder) on the left, title on the right */

#library-view .books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 18px;
    padding: 8px 0;
}

/* Fixed-height cards so covers can feel "larger" and consistent */
#library-view .book-card {
    display: flex;
    align-items: center;
    gap: 16px;

    height: 200px;         /* requested fixed cell height */
    padding: 0 14px;       /* no vertical padding so the 200px cover fits cleanly */
    text-decoration: none;

    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 8px 24px var(--shadow-color);

    transition: transform 120ms ease, box-shadow 120ms ease;
}

#library-view .book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px var(--shadow-color);
}

/* Cover area (max 200px wide). If the image becomes wider when scaled to 200px tall,
   we allow horizontal clipping via overflow hidden (no cropping vertically, no distortion). */
#library-view .book-cover-box {
    height: 200px;
    width: 200px;
    max-width: 200px;
    flex: 0 0 200px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 12px;
    overflow: hidden;
    background: var(--code-bg);
    border: 1px solid var(--border-color);
}

/* Cover image: fill the cover-box height, keep aspect ratio (no distortion).
   Any excess width is clipped by the cover-box. */
#library-view .book-cover {
    height: 200px;
    width: auto;
    display: block;
}

/* No cover? show emoji placeholder sized to the cover box */
#library-view .book-cover-placeholder {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    line-height: 1;
    opacity: 0.85;
}

#library-view .book-meta {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;

    height: 200px;                 /* match card height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;              /* prevent layout break on very long titles */
}

#library-view .book-name {
    font-size: 1.10rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.25;
    word-break: break-word;

    /* Clamp to keep within fixed-height cards */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#library-view .book-author {
    margin-top: 6px;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
    line-height: 1.2;
    word-break: break-word;

    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile: slightly smaller fixed card + cover */
@media (max-width: 520px) {
    #library-view .book-card {
        height: 180px;
        padding: 0 12px;
        gap: 12px;
    }

    #library-view .book-cover-box {
        height: 180px;
        width: 160px;
        max-width: 160px;
        flex-basis: 160px;
    }

    #library-view .book-cover {
        height: 180px;
    }

    #library-view .book-cover-placeholder {
        width: 160px;
        height: 180px;
        font-size: 50px;
    }

    #library-view .book-meta {
        height: 180px;
    }
}
