body,
html {
    margin: 0;
    padding: 0;
    height: 100vh;
    font-family: 'Arial', sans-serif;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../img/sfondo.jpeg') no-repeat center center fixed;
    background-size: cover;
    z-index: -1;
    /* Mette lo sfondo dietro tutto il contenuto */
}

.background::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.5) 1px, transparent 1px);
    background-size: 1px 1px;
    /* Reticolo fitto */
    pointer-events: none;
}

.content {
    position: relative;
    /* Assicura che il contenuto sia sopra lo sfondo */
    z-index: 1;
    padding: 20px;
    color: white;
}



div.gallery {
    margin: 8px;
    border: 1px solid #ddd;
    float: left;
    width: 280px;
    height: 300px;
    cursor: pointer;
    /* Indica che l'elemento è cliccabile */
    border-radius: 12px;
    /* Angoli smussati */
    background-color: rgb(255, 255, 255);
    /* Blu */
    font-family: 'Arial', sans-serif;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    overflow: hidden;
}

#gallery2 {

    border: 2px solid red;

}

#gallery2:hover {
    border: 2px solid green;
}


div.gallery:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border-color: #0d6efd;
}


div.gallery1 {
    width: 100%;
    height: 220px;
    overflow: hidden;
}

div.gallery1 img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Mantiene proporzioni coprendo l'area */
    border-radius: 12px 12px 0 0;
    transition: transform 0.5s ease;
    aspect-ratio: auto; /* Rispetta il rapporto originale dell'immagine */
}

div.gallery:hover img {
    transform: scale(1.05);
}

div.desc {
    padding: 12px;
    text-align: center;
    font-weight: 500;
    color: #333;
}

/* Overlay completamente rivisto */
#overlay {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: auto;
}

.overlay-content {
    max-width: 1200px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.overlay-image-container {
    width: 100%;
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

#overlayImg {
    max-width: 90%;
    max-height: 70vh;
    object-fit: contain; /* Mantiene le proporzioni corrette dell'immagine */
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    width: auto; /* Importante per evitare distorsioni */
    height: auto; /* Importante per evitare distorsioni */
}

.overlay-title {
    font-size: 2em;
    font-weight: bold;
    margin: 10px 0;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.overlay-description h4 {
    font-weight: normal;
    line-height: 1.6;
    font-size: 1.2em;
    max-width: 800px;
    margin: 20px auto;
    text-align: justify;
}

.overlay-author h4 {
    font-style: italic;
    margin-top: 20px;
    color: #ccc;
}

/* Pulsante di chiusura migliorato */
#closeOverlay {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(200, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 1;
}

#closeOverlay:hover {
    background: rgba(255, 0, 0, 1);
    transform: scale(1.1);
}

#centrato {
    position: relative;
    top: 70px; /* Aumentato spazio dal pulsante superiore */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 15px;
}

/* Pulsante Home migliorato */
#home-button {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 15px;
    height: 55px;
    background: linear-gradient(to right, #343a40, #495057);
    border: none;
    color: white;
    font-family: 'Arial', sans-serif;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

#home-button:hover {
    background: linear-gradient(to right, #0d6efd, #0b5ed7);
    color: white;
}

/* Stile per le frecce di navigazione */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.nav-arrow:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

.nav-arrow-left {
    left: 20px;
}

.nav-arrow-right {
    right: 20px;
}

@media (max-width: 768px) {
    .nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .nav-arrow-left {
        left: 10px;
    }
    
    .nav-arrow-right {
        right: 10px;
    }
}

@media (max-width: 480px) {
    .nav-arrow {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .nav-arrow-left {
        left: 5px;
    }
    
    .nav-arrow-right {
        right: 5px;
    }
}

/* Responsive gallery: smartphone e tablet */
@media (max-width: 900px) {
    #centrato {
        gap: 10px;
        padding: 10px;
        top: 60px; /* Ridotto lo spazio dal pulsante superiore */
    }
    div.gallery {
        width: 45%;
        min-width: 140px;
        max-width: 220px;
        height: 220px; /* Aumentato per mantenere proporzioni */
        margin: 5px;
    }
    div.gallery1 {
        height: 160px; /* Aumentato per mantenere proporzioni */
    }
    div.gallery1 img {
        border-radius: 12px 12px 0 0;
        object-fit: cover; /* Assicura che l'immagine copra l'area in modo appropriato */
    }
    div.desc {
        font-size: 0.95em;
        padding: 8px;
    }
}

/* Media query per l'overlay su tablet */
@media (max-width: 900px) {
    .overlay-title {
        font-size: 1.6em;
    }
    
    .overlay-description h4 {
        font-size: 1.1em;
        padding: 0 15px;
    }
    
    #overlayImg {
        max-width: 95%;
        max-height: 60vh;
    }
    
    #closeOverlay {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
    }
}

/* Media query per l'overlay su smartphone */
@media (max-width: 600px) {
    .overlay-content {
        width: 98%;
        padding: 10px 5px;
    }
    
    .overlay-title {
        font-size: 1.3em;
        margin: 5px 0;
    }
    
    .overlay-description h4 {
        font-size: 0.95em;
        line-height: 1.5;
        padding: 0 10px;
        margin: 10px auto;
    }
    
    .overlay-author h4 {
        font-size: 0.9em;
        margin-top: 10px;
    }
    
    #overlayImg {
        max-width: 95%;
        max-height: 60vh;
        object-fit: contain; /* Mantiene le proporzioni dell'immagine senza schiacciarla */
    }
    
    .overlay-image-container {
        display: flex;
        align-items: center;
        justify-content: center;
        height: auto;
        margin: 15px 0;
    }
    
    #closeOverlay {
        width: 32px;
        height: 32px;
        font-size: 20px;
        top: 8px;
        right: 8px;
    }
}

@media (max-width: 480px) {
    #centrato {
        gap: 8px;
        padding: 8px;
    }
    div.gallery {
        width: 45%;
        height: 200px;
        min-width: 130px;
        max-width: none;
        margin: 4px;
    }
    div.gallery1 {
        height: 130px;
    }
    div.desc {
        font-size: 0.85em;
        padding: 6px;
        line-height: 1.3;
    }
}

@media (max-width: 360px) {
    div.gallery {
        width: 95%;
        height: 250px;
        margin: 5px auto;
    }
    div.gallery1 {
        height: 200px;
    }
    div.desc {
        font-size: 0.9em;
        padding: 8px;
    }
}


