/* contenitore risultati */
#results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 20px;
    align-items: start;
}


/* singolo libro */
.book {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 410px;
}

.book:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.15);
}

/* immagine */
.book img {
    width: 150px;
    height: auto;
    border-radius: 8px;
}

h1,
p,
.search-box {
    text-align: center;
}

/* titolo */
.book h3 {
    font-size: 1.1rem;
    margin: 0;
}

/* autori */
.book p:last-of-type {
    margin-top: 10px;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* bottone */
.book button {
    margin-top: 8px;
    padding: 8px 14px;
    border: none;
    border-radius: 20px;
    background-color: #4f46e5;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
}

.book button:hover {
    background-color: #4338ca;
}

#loader {
    display: block;
    /* Importante! */
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.no-results {
    text-align: center;
    font-size: 1.2rem;
    margin-top: 30px;
    color: #555;
}

.hidden {
    display: none;
}

/* Overlay grigio scuro semi-trasparente */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    /* nascosto inizialmente */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Finestra centrale del modal */
.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 70%;
    overflow-y: auto;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    position: relative;

    /* magia */
    animation: modalFadeIn 0.3s ease-out;
}

/* Animazione apertura */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Scrollbar elegante (Chrome, Edge, Safari) */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

/* Bottone di chiusura */
.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-content {
    padding: 24px;
    line-height: 1.6;
}

.modal-content h2 {
    margin-bottom: 8px;
}

.modal-content p {
    text-align: justify;
    margin-top: 12px;
}

button {
    background-color: #4f46e5;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition:
        background-color 0.25s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

button:hover {
    background-color: #4338ca;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}