.library {
    padding: var(--spacing-unit);
    background-color: var(--white);
    max-width: none;
    width: 100%;
}

.library-intro {
    max-width: 650px;
    margin: 0 auto 3rem;
    text-align: center;
}

.library h1 {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--primary-color);
    font-weight: 500;
}

.library-subtitle {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-color);
    opacity: 0.8;
    margin: 0 auto;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(3, 60px);
    gap: 0.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-unit);
    justify-content: center;
    position: relative;
}

/* Define different positions for each card */
.books-grid .book-item:nth-child(1) { --offset-x: 120px; --offset-y: -200px; }
.books-grid .book-item:nth-child(2) { --offset-x: -250px; --offset-y: -80px; }
.books-grid .book-item:nth-child(3) { --offset-x: -250px; --offset-y: -180px; }
.books-grid .book-item:nth-child(4) { --offset-x: -150px; --offset-y: 50px; }
.books-grid .book-item:nth-child(5) { --offset-x: -250px; --offset-y: -120px; }
.books-grid .book-item:nth-child(6) { --offset-x: 200px; --offset-y: -150px; }
.books-grid .book-item:nth-child(7) { --offset-x: 150px; --offset-y: -80px; }
.books-grid .book-item:nth-child(8) { --offset-x: -180px; --offset-y: -50px; }
.books-grid .book-item:nth-child(9) { --offset-x: -220px; --offset-y: 30px; }

.book-item {
    width: 60px;
    height: 60px;
    position: relative;
    cursor: pointer;
}

.avatar-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-item:hover:not(.active) .avatar-wrapper {
    transform: translateY(-5px);
}

.author-image {
    width: 120%;
    height: 120%;
    object-fit: cover;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.more-details-text {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 101;
    background-color: white;
    padding: 4px 12px;
    border-radius: 100px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.book-item:hover:not(.active) .more-details-text {
    opacity: 1;
}

.book-item.active {
    width: 200px;
    height: auto;
    min-height: 300px;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding-bottom: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(var(--offset-x), var(--offset-y)) !important;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 24px;
}

.book-item.active .avatar-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 25px auto 0;
    transform: none;
}

.book-item.active .author-image {
    width: 100%;
    height: 100%;
    position: relative;
    top: 0;
    left: 0;
    transform: none;
}

.author-info {
    position: relative;
    margin-top: 35px;
    padding: 0 15px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.book-item.active .author-info {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.15s ease;
    pointer-events: auto;
}

.author-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.author-bio {
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 20px;
}

.author-books {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.book-link {
    font-size: 13px;
    color: var(--primary-color);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    transition: background 0.2s ease;
}

.book-link:hover {
    background: rgba(0, 0, 0, 0.1);
}

.book-content {
    text-align: center;
    color: white;
}

.book-content h3 {
    font-size: 20px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.book-content p {
    font-size: 16px;
    opacity: 0.9;
}

.close-button {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.15s ease;
    transform: scale(1);
}

.book-item.active .close-button {
    opacity: 1;
}

.close-button:hover {
    background: rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .library-intro {
        margin-bottom: 2rem;
    }

    .library-subtitle {
        font-size: 16px;
        line-height: 1.5;
    }

    .books-grid {
        gap: 0.75rem;
        padding: 0;
        margin-bottom: 20px;
    }

    .more-details-text {
        display: none;
    }

    .book-item {
        position: relative;
    }

    .avatar-wrapper {
        transition: transform 0.1s ease;
    }

    .book-item:active .avatar-wrapper {
        transform: scale(0.95);
    }

    .book-item:hover:not(.active) .avatar-wrapper {
        transform: none;
    }

    .book-item.active {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) !important;
        z-index: 1000;
        width: 90%;
        max-width: 400px;
        height: auto;
        margin: 0;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        transition: all 0.1s cubic-bezier(0.2, 0, 0.1, 1);
    }

    .book-item.active .author-image {
        transform: none;
        transition: none;
    }

    .book-item.active .author-info {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.1s ease;
        padding: 0 20px;
    }

    .author-books {
        gap: 12px;
        margin: 20px 0;
    }

    .book-link {
        padding: 11px;
        font-size: 14px;
        display: block;
        text-align: center;
        background: rgba(0, 0, 0, 0.08);
    }

    .book-link:active {
        background: rgba(0, 0, 0, 0.15);
    }
} 