/* SuleCMS - Photo Gallery CSS */

/* Grid della Galleria */
.sulecms-gallery {
    margin: 30px 0;
}

.sulecms-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

/* Elemento Immagine (Thumbnail) */
.sulecms-gallery-item {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    background-color: #f1f5f9;
    border: 1px solid rgba(0, 0, 0, 0.03);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.sulecms-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Hover Effects */
.sulecms-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.12);
}

.sulecms-gallery-item:hover img {
    transform: scale(1.08);
}

/* Overlay su Hover */
.sulecms-gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.2) 100%);
    opacity: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    transition: opacity 0.4s ease;
    color: #ffffff;
    text-align: center;
    z-index: 2;
}

.sulecms-gallery-item:hover .sulecms-gallery-overlay {
    opacity: 1;
}

.sulecms-gallery-overlay .zoom-icon {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: auto; /* Spinge verso l'alto */
    margin-top: 10px;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-10px);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.sulecms-gallery-item:hover .zoom-icon {
    transform: translateY(0);
}

.sulecms-gallery-overlay .img-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    letter-spacing: -0.3px;
}

/* Lightbox Modal (Glassmorphism) */
.sulecms-gallery-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.sulecms-gallery-modal.show {
    display: flex;
    opacity: 1;
}

.sulecms-gallery-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 85%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.92);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100000;
}

.sulecms-gallery-modal.show .sulecms-gallery-modal-content {
    transform: scale(1);
}

.sulecms-gallery-image-container {
    max-height: 70vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #000;
}

.sulecms-gallery-modal-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    user-select: none;
}

/* Didascalia del Lightbox */
.sulecms-gallery-caption {
    width: 100%;
    max-width: 700px;
    margin-top: 15px;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    color: #f8fafc;
    text-align: center;
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.sulecms-gallery-caption h4 {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--primary, #f59e0b);
    letter-spacing: -0.3px;
}

.sulecms-gallery-caption p {
    margin: 0;
    font-size: 14px;
    color: #cbd5e1;
    line-height: 1.5;
}

/* Bottone Chiudi */
.sulecms-gallery-close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: #f8fafc;
    font-size: 44px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    z-index: 100002;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.25s, transform 0.25s, color 0.25s;
}

.sulecms-gallery-close:hover {
    color: #ffffff;
    background: rgba(239, 68, 68, 0.8);
    border-color: rgba(239, 68, 68, 0.9);
    transform: rotate(90deg);
}

/* Frecce di Navigazione */
.sulecms-gallery-prev,
.sulecms-gallery-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #f8fafc;
    cursor: pointer;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 24px;
    user-select: none;
    transition: background 0.25s, transform 0.25s, border-color 0.25s;
    z-index: 100001;
}

.sulecms-gallery-prev {
    left: 40px;
}

.sulecms-gallery-next {
    right: 40px;
}

.sulecms-gallery-prev:hover,
.sulecms-gallery-next:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.sulecms-gallery-prev:active {
    transform: translateY(-50%) scale(0.92) translateX(-3px);
}

.sulecms-gallery-next:active {
    transform: translateY(-50%) scale(0.92) translateX(3px);
}

/* Adattabilità Mobile (Responsive) */
@media (max-width: 900px) {
    .sulecms-gallery-prev {
        left: 20px;
    }
    .sulecms-gallery-next {
        right: 20px;
    }
    .sulecms-gallery-prev,
    .sulecms-gallery-next {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    .sulecms-gallery-close {
        top: 15px;
        right: 15px;
        width: 44px;
        height: 44px;
        font-size: 36px;
    }
}

@media (max-width: 768px) {
    .sulecms-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 12px;
    }
    .sulecms-gallery-item {
        border-radius: 12px;
    }
    .sulecms-gallery-modal-content {
        max-width: 95%;
        max-height: 80%;
    }
    .sulecms-gallery-image-container {
        max-height: 55vh;
    }
    .sulecms-gallery-modal-img {
        max-height: 55vh;
    }
    .sulecms-gallery-caption {
        padding: 12px 18px;
        margin-top: 10px;
        border-radius: 10px;
    }
    .sulecms-gallery-caption h4 {
        font-size: 15px;
    }
    .sulecms-gallery-caption p {
        font-size: 12px;
    }
    /* Posiziona le frecce in basso per non coprire l'immagine su telefoni stretti */
    .sulecms-gallery-prev,
    .sulecms-gallery-next {
        top: auto;
        bottom: 20px;
        transform: none;
    }
    .sulecms-gallery-prev {
        left: 30%;
        margin-left: -25px;
    }
    .sulecms-gallery-next {
        right: 30%;
        margin-right: -25px;
    }
    .sulecms-gallery-prev:active {
        transform: scale(0.92) translateX(-3px);
    }
    .sulecms-gallery-next:active {
        transform: scale(0.92) translateX(3px);
    }
}
