@charset "utf-8";


/* ========================================
   IMPOSTAZIONI GENERALI
======================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 30px;

    background-color: #f5f5f5;

    font-family: Arial, Helvetica, sans-serif;
}


/* ========================================
   GALLERY
======================================== */

.gallery {
    width: 100%;
    max-width: 1400px;

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(250px, 1fr));

    gap: 15px;
}


/* ========================================
   MINIATURE
======================================== */

.gallery-image {
    width: 100%;
    height: 250px;

    display: block;

    object-fit: cover;

    cursor: pointer;

    border-radius: 8px;

    transition:
        transform 0.3s ease,
        opacity 0.3s ease;
}


.gallery-image:hover {
    transform: scale(1.03);
    opacity: 0.88;
}


/* ========================================
   LIGHTBOX
======================================== */

.lightbox {
    display: none;

    position: fixed;

    z-index: 9999;

    top: 0;
    left: 0;

    width: 100%;
    height: 100%;

    background-color: rgba(0, 0, 0, 0.94);

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

    padding: 60px 80px 40px;
}


/* Lightbox aperta */

.lightbox.active {
    display: flex;
}


/* ========================================
   CONTENUTO CENTRALE
======================================== */

.lightbox-content {
    display: flex;

    flex-direction: column;

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

    max-width: 100%;
    max-height: 100%;
}


/* ========================================
   IMMAGINE GRANDE
======================================== */

.lightbox-image {
    display: block;

    max-width: 90vw;
    max-height: calc(100vh - 160px);

    width: auto;
    height: auto;

    object-fit: contain;

    border-radius: 5px;

    user-select: none;

    -webkit-user-drag: none;
}


/* Animazione */

.lightbox-image.animate {
    animation: zoom 0.25s ease;
}


@keyframes zoom {

    from {
        opacity: 0;
        transform: scale(0.94);
    }

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

}


/* ========================================
   DIDASCALIA
======================================== */

.caption {
    width: 100%;

    max-width: 900px;

    margin-top: 15px;

    padding: 0 10px;

    color: #ffffff;

    font-size: 17px;

    line-height: 1.4;

    text-align: center;
}


/* ========================================
   CONTATORE FOTO
======================================== */

.counter {
    position: absolute;

    top: 22px;
    left: 30px;

    color: #ffffff;

    font-size: 16px;

    font-weight: 500;

    letter-spacing: 1px;

    z-index: 10002;
}


/* ========================================
   PULSANTE CHIUDI
======================================== */

.close {
    position: absolute;

    top: 10px;
    right: 25px;

    z-index: 10002;

    padding: 5px 10px;

    border: none;

    background: transparent;

    color: white;

    font-size: 50px;

    font-weight: 300;

    line-height: 1;

    cursor: pointer;
}


.close:hover {
    opacity: 0.7;
}


/* ========================================
   FRECCE
======================================== */

.prev,
.next {
    position: absolute;

    top: 50%;

    transform: translateY(-50%);

    z-index: 10001;

    border: none;

    border-radius: 6px;

    background-color: rgba(0, 0, 0, 0.35);

    color: white;

    font-size: 50px;

    padding: 15px 20px;

    cursor: pointer;

    transition:
        background-color 0.25s ease,
        opacity 0.25s ease;
}


.prev {
    left: 20px;
}


.next {
    right: 20px;
}



.prev:hover,
.next:hover {
    background-color: rgba(255, 255, 255, 0.18);
}


/* ========================================
   TABLET
======================================== */

@media screen and (max-width: 900px) {

    body {
        padding: 20px;
    }


    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }


    .gallery-image {
        height: 220px;
    }


    .lightbox {
        padding: 55px 50px 35px;
    }


    .lightbox-image {
        max-width: 90vw;

        max-height:
            calc(100vh - 150px);
    }


    .prev,
    .next {
        font-size: 40px;

        padding: 12px 15px;
    }

}


/* ========================================
   SMARTPHONE
======================================== */

@media screen and (max-width: 600px) {

    body {
        padding: 10px;
    }


    .gallery {
        grid-template-columns:
            repeat(2, 1fr);

        gap: 8px;
    }


    .gallery-image {
        height: 160px;

        border-radius: 5px;
    }


    .lightbox {
        padding: 60px 10px 25px;
    }


    .lightbox-content {
        width: 100%;
    }


    .lightbox-image {
        max-width: 96vw;

        max-height:
            calc(100vh - 170px);
    }


    .caption {
        margin-top: 12px;

        font-size: 15px;

        padding: 0 15px;
    }


    .counter {
        top: 20px;
        left: 15px;

        font-size: 14px;
    }


    .close {
        top: 7px;
        right: 10px;

        font-size: 42px;
    }


    /*
       Su smartphone le frecce
       rimangono visibili, ma più discrete.
    */

    .prev,
    .next {
        font-size: 30px;

        padding: 12px;

        background-color:
            rgba(0, 0, 0, 0.35);
    }


    .prev {
        left: 3px;
    }


    .next {
        right: 3px;
    }

}


/* ========================================
   SMARTPHONE PICCOLO
======================================== */

@media screen and (max-width: 400px) {

    .gallery {
        grid-template-columns: 1fr;
    }


    .gallery-image {
        height: 220px;
    }

}