/* ===== Bookshelf Layout ===== */

.bookshelf-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem 2rem;
}

.bookshelf-header {
    text-align: center;
    margin-bottom: 2rem;
}

.bookshelf-header h2 {
    margin-bottom: 0.25rem;
}

/* ===== Individual Shelf (one per year) ===== */

.shelf {
    position: relative;
    margin-bottom: 0.5rem;
}

.shelf-year-label {
    position: absolute;
    right: 8px;
    top: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #5a3a1a;
    background: rgba(210, 170, 120, 0.7);
    padding: 2px 10px;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
}

.shelf-back {
    background: linear-gradient(180deg, #6b3a1f 0%, #8b5e3c 40%, #a0714a 100%);
    border-radius: 6px;
    padding: 10px 16px 0 16px;
    min-height: 130px;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.35);
}

.shelf-books {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0;
    min-height: 110px;
    scrollbar-width: thin;
    scrollbar-color: #a0714a #6b3a1f;
}

.shelf-books::-webkit-scrollbar {
    height: 6px;
}
.shelf-books::-webkit-scrollbar-track {
    background: #6b3a1f;
    border-radius: 3px;
}
.shelf-books::-webkit-scrollbar-thumb {
    background: #a0714a;
    border-radius: 3px;
}

/* The wooden plank at the bottom */
.shelf-plank {
    height: 18px;
    background: linear-gradient(180deg, #c49a6c 0%, #a07040 50%, #8b5e3c 100%);
    border-radius: 0 0 6px 6px;
    box-shadow:
        0 4px 8px rgba(0,0,0,0.3),
        inset 0 2px 2px rgba(255,255,255,0.15);
    position: relative;
}

/* Side brackets */
.shelf-side-left,
.shelf-side-right {
    position: absolute;
    top: -4px;
    width: 14px;
    height: calc(100% + 4px);
    z-index: 3;
}

.shelf-side-left {
    left: -2px;
    background: linear-gradient(90deg, #5a3a1a, #7a5030);
    border-radius: 4px 0 0 4px;
    box-shadow: -2px 0 4px rgba(0,0,0,0.2);
}

.shelf-side-right {
    right: -2px;
    background: linear-gradient(90deg, #7a5030, #5a3a1a);
    border-radius: 0 4px 4px 0;
    box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}


/* ===== Book Items ===== */

.book-item {
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.25s ease, z-index 0s;
    position: relative;
    z-index: 1;
}

.book-item:hover {
    z-index: 10;
}

/* --- Cover view (front-facing book) --- */
.book-cover-view {
    width: 70px;
    height: 105px;
    border-radius: 2px;
    overflow: hidden;
    box-shadow:
        2px 2px 6px rgba(0,0,0,0.4),
        -1px 0 3px rgba(0,0,0,0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.book-cover-view:hover {
    transform: translateY(-12px) scale(1.08);
    box-shadow:
        4px 4px 16px rgba(0,0,0,0.5),
        -2px 0 6px rgba(0,0,0,0.2);
}

.book-cover-view img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    background: linear-gradient(135deg, #4a6741, #2d4a2d);
}


/* --- Spine view (for overflow books) --- */
.book-spine-view {
    width: 28px;
    height: 105px;
    border-radius: 2px;
    position: relative;
    overflow: visible;
    box-shadow:
        1px 1px 4px rgba(0,0,0,0.3);
    transition: width 0.35s ease, box-shadow 0.3s ease;
}

.book-spine-view .spine-face {
    width: 28px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.55rem;
    font-weight: 600;
    color: #fff;
    padding: 4px 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-radius: 2px;
    transition: opacity 0.3s ease;
}

.book-spine-view .spine-cover-reveal {
    position: absolute;
    top: 0;
    left: 0;
    width: 70px;
    height: 105px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 4px 4px 16px rgba(0,0,0,0.5);
    z-index: 20;
}

.book-spine-view .spine-cover-reveal img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-spine-view:hover {
    width: 70px;
    box-shadow: 4px 4px 16px rgba(0,0,0,0.5);
    z-index: 20;
}

.book-spine-view:hover .spine-face {
    opacity: 0;
}

.book-spine-view:hover .spine-cover-reveal {
    opacity: 1;
    pointer-events: auto;
}


/* ===== Spine color palette ===== */
.spine-color-0 { background: linear-gradient(180deg, #8b4513, #6b3410); }
.spine-color-1 { background: linear-gradient(180deg, #2c3e50, #1a252f); }
.spine-color-2 { background: linear-gradient(180deg, #7b3f61, #5a2d47); }
.spine-color-3 { background: linear-gradient(180deg, #1b5e20, #0d3311); }
.spine-color-4 { background: linear-gradient(180deg, #4a148c, #2a0a52); }
.spine-color-5 { background: linear-gradient(180deg, #b71c1c, #7f1313); }
.spine-color-6 { background: linear-gradient(180deg, #004d40, #00332a); }
.spine-color-7 { background: linear-gradient(180deg, #e65100, #b33f00); }
.spine-color-8 { background: linear-gradient(180deg, #1a237e, #0d1240); }
.spine-color-9 { background: linear-gradient(180deg, #3e2723, #261a17); }


/* ===== Book Detail Modal ===== */

.book-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.book-modal-overlay.active {
    display: flex;
}

.book-modal {
    background: #faf6f0;
    color: #333;
    border-radius: 12px;
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    position: relative;
}

.book-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    z-index: 5;
    line-height: 1;
    padding: 4px 8px;
}

.book-modal-close:hover {
    color: #333;
}

.book-modal-type-icon {
    position: absolute;
    top: 14px;
    right: 52px;
    font-size: 1.2rem;
    color: #8b5e3c;
    z-index: 5;
}

.book-modal-type-icon .type-label {
    font-size: 0.7rem;
    display: block;
    text-align: center;
    color: #999;
    margin-top: 2px;
}

.book-modal-body {
    display: flex;
    gap: 1.25rem;
    padding: 1.5rem;
}

.book-modal-cover {
    flex-shrink: 0;
    width: 140px;
    height: 210px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 3px 3px 12px rgba(0,0,0,0.25);
}

.book-modal-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-modal-info {
    flex: 1;
    min-width: 0;
}

.book-modal-info h3 {
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
    color: #2c1810;
}

.book-modal-info .modal-author {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.book-modal-info .modal-meta {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.book-modal-info .modal-meta span {
    background: #ede7df;
    padding: 2px 8px;
    border-radius: 4px;
}

.book-modal-info .modal-rating {
    color: #f8ce0b;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.book-modal-info .modal-comments {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.5;
}


/* ===== Responsive ===== */

@media (max-width: 768px) {
    .bookshelf-container {
        padding: 1rem;
    }

    .shelf-back {
        padding: 8px 10px 0 10px;
    }

    .book-cover-view {
        width: 55px;
        height: 82px;
    }

    .book-spine-view {
        width: 22px;
        height: 82px;
    }

    .book-spine-view:hover {
        width: 55px;
    }

    .book-spine-view .spine-cover-reveal {
        width: 55px;
        height: 82px;
    }

    .book-modal-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .book-modal-info .modal-meta {
        justify-content: center;
    }
}
