/* =========================================================
   THE MELODY HIDEAWAY - GALLERY
   ========================================================= */

.melody-gallery {
    padding: 100px 0;
    background: #fff;
}

.melody-gallery .section-title {
    max-width: 850px;
    margin: 0 auto 45px;
}

/* 3-column gallery */
.melody-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.melody-gallery-item {
    position: relative;
    display: block;
    overflow: hidden;
    height: 360px;
    border-radius: 8px;
    background: #eee;
    text-decoration: none;
    isolation: isolate;
}

.melody-gallery-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.melody-gallery-item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.68) 0%,
        rgba(0, 0, 0, 0.18) 45%,
        rgba(0, 0, 0, 0) 75%
    );
    opacity: 0.85;
    transition: opacity 0.35s ease;
    z-index: 1;
}

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

.melody-gallery-item:hover::after {
    opacity: 1;
}

.melody-gallery-overlay {
    position: absolute;
    left: 24px;
    right: 20px;
    bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    color: #fff;
    z-index: 2;
}

.melody-gallery-caption {
    font-size: 20px;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.melody-gallery-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 50%;
    font-size: 27px;
    font-weight: 300;
    line-height: 1;
    transition: all 0.3s ease;
}

.melody-gallery-item:hover .melody-gallery-icon {
    background: #fff;
    color: #222;
}

/* Lightbox */
.melody-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: rgba(0, 0, 0, 0.92);
}

.melody-lightbox.is-open {
    display: flex;
}

.melody-lightbox-image-wrap {
    position: relative;
    width: min(1100px, 92vw);
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.melody-lightbox-image {
    max-width: 100%;
    max-height: 82vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 4px;
}

.melody-lightbox-title {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -38px;
    text-align: center;
    color: #fff;
    font-size: 17px;
}

.melody-lightbox-close,
.melody-lightbox-prev,
.melody-lightbox-next {
    position: fixed;
    z-index: 2;
    border: 0;
    color: #fff;
    background: rgba(255,255,255,0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease, transform 0.25s ease;
}

.melody-lightbox-close:hover,
.melody-lightbox-prev:hover,
.melody-lightbox-next:hover {
    background: rgba(255,255,255,0.25);
}

.melody-lightbox-close {
    top: 25px;
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 30px;
}

.melody-lightbox-prev,
.melody-lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 32px;
}

.melody-lightbox-prev {
    left: 25px;
}

.melody-lightbox-next {
    right: 25px;
}

body.melody-lightbox-open {
    overflow: hidden;
}

/* Tablet */
@media (max-width: 991px) {
    .melody-gallery {
        padding: 80px 0;
    }

    .melody-gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }

    .melody-gallery-item {
        height: 320px;
    }
}

/* Mobile */
@media (max-width: 575px) {
    .melody-gallery {
        padding: 65px 0;
    }

    .melody-gallery-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .melody-gallery-item {
        height: 300px;
        border-radius: 6px;
    }

    .melody-gallery-caption {
        font-size: 18px;
    }

    .melody-gallery-overlay {
        left: 18px;
        right: 16px;
        bottom: 17px;
    }

    .melody-gallery-icon {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
        font-size: 24px;
    }

    .melody-lightbox {
        padding: 15px;
    }

    .melody-lightbox-prev,
    .melody-lightbox-next {
        width: 42px;
        height: 42px;
        font-size: 26px;
    }

    .melody-lightbox-prev {
        left: 10px;
    }

    .melody-lightbox-next {
        right: 10px;
    }

    .melody-lightbox-close {
        top: 12px;
        right: 12px;
        width: 42px;
        height: 42px;
        font-size: 26px;
    }

    .melody-lightbox-title {
        bottom: -32px;
        font-size: 15px;
    }
}
