/* =========================================================
   ZH2O Gallery — Frontend Styles v1.0.1
   ========================================================= */

/* ── Masonry grid ──────────────────────────────────────── */
.zh2o-gal-masonry {
    columns: 3;
    column-gap: 16px;
    width: 100%;
}
.zh2o-gal-masonry.zh2o-gal-cols-1 { columns: 1; }
.zh2o-gal-masonry.zh2o-gal-cols-2 { columns: 2; }
.zh2o-gal-masonry.zh2o-gal-cols-3 { columns: 3; }
.zh2o-gal-masonry.zh2o-gal-cols-4 { columns: 4; }

@media (max-width: 900px) {
    .zh2o-gal-masonry.zh2o-gal-cols-3,
    .zh2o-gal-masonry.zh2o-gal-cols-4 { columns: 2; }
}
@media (max-width: 540px) {
    .zh2o-gal-masonry { columns: 1 !important; }
}

/* ── Item ──────────────────────────────────────────────── */
.zh2o-gal-item {
    break-inside: avoid;
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
}

.zh2o-gal-link {
    display: block;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none !important;
    cursor: zoom-in;
    background: rgba(13, 42, 74, 0.4);
}

/* ── Image ─────────────────────────────────────────────── */
.zh2o-gal-img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    transition: transform 0.3s ease, filter 0.3s ease, opacity 0.4s ease;
    opacity: 0;
}
.zh2o-gal-img.zh2o-gal-loaded {
    opacity: 1;
}
.zh2o-gal-link:hover .zh2o-gal-img {
    transform: scale(1.04);
    filter: brightness(1.08);
}

/* ── Caption overlay ───────────────────────────────────── */
.zh2o-gal-caption {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 28px 14px 14px;
    background: linear-gradient(to top, rgba(2,14,24,0.85) 0%, transparent 100%);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    border-radius: 0 0 12px 12px;
}
.zh2o-gal-link:hover .zh2o-gal-caption {
    opacity: 1;
    transform: translateY(0);
}

/* ── Empty state ───────────────────────────────────────── */
.zh2o-gal-empty {
    color: rgba(255,255,255,0.5);
    font-style: italic;
    text-align: center;
    padding: 40px 0;
}

/* =========================================================
   LIGHTBOX
   ========================================================= */
.zh2o-gal-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    isolation: isolate;
    background: rgba(2, 14, 24, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    height: 100vh;
    height: 100dvh;
}
.zh2o-gal-lightbox:not([hidden]) { opacity: 1; }
.zh2o-gal-lightbox[hidden]       { display: none; }

/* ── Layout: close top, image+arrows middle, caption bottom ── */
.zh2o-gal-lb-top {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 16px;
    z-index: 1000000;
}

/* Centre zone: arrows flank the image on desktop,
   sit below on mobile */
.zh2o-gal-lb-centre {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    padding: 60px 0 0; /* clear the top bar */
    flex: 1;
    min-height: 0;
}

.zh2o-gal-lb-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    flex: 1;
    max-width: calc(100vw - 160px); /* leave room for arrows on desktop */
}

.zh2o-gal-lb-img {
    max-width: 100%;
    max-height: calc(100dvh - 140px); /* top bar + caption area */
    border-radius: 10px;
    object-fit: contain;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
    transition: opacity 0.2s ease;
    display: block;
}
.zh2o-gal-lb-img.zh2o-lb-loading { opacity: 0.3; }

.zh2o-gal-lb-caption {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 14px 20px 18px;
    text-align: center;
    color: rgba(255,255,255,0.75);
    font-size: 0.88rem;
    background: linear-gradient(to top, rgba(2,14,24,0.7) 0%, transparent 100%);
    pointer-events: none;
    min-height: 50px;
    /* ensure it sits above the lightbox z-index */
    z-index: 1000001;
}

/* ── Buttons shared ── */
.zh2o-gal-lb-close,
.zh2o-gal-lb-prev,
.zh2o-gal-lb-next {
    flex-shrink: 0;
    background: rgba(255,255,255,0.18);
    border: 1.5px solid rgba(255,255,255,0.5);
    color: #ffffff;
    cursor: pointer;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    z-index: 1000001;
    opacity: 0;  /* hidden by default on desktop — shown on lb hover */
}
.zh2o-gal-lightbox:hover .zh2o-gal-lb-close,
.zh2o-gal-lightbox:hover .zh2o-gal-lb-prev,
.zh2o-gal-lightbox:hover .zh2o-gal-lb-next { opacity: 1; }

.zh2o-gal-lb-close:hover,
.zh2o-gal-lb-prev:hover,
.zh2o-gal-lb-next:hover {
    background: rgba(126, 200, 227, 0.35);
    border-color: rgba(126, 200, 227, 0.8);
}

/* Close sits in the top bar */
.zh2o-gal-lb-close {
    font-size: 30px;
    width: 44px;
    height: 44px;
}

/* Prev/next sit flanking the image inside .zh2o-gal-lb-centre */
.zh2o-gal-lb-prev,
.zh2o-gal-lb-next {
    /* nothing extra needed — flexbox handles position */
}

/* ── Mobile ── */
@media (max-width: 640px) {
    /* Always show buttons on mobile — no hover */
    .zh2o-gal-lb-close,
    .zh2o-gal-lb-prev,
    .zh2o-gal-lb-next { opacity: 1; }

    /* Image takes full width */
    .zh2o-gal-lb-img-wrap {
        max-width: 100vw;
    }

    /* Stack: image on top, arrows below */
    .zh2o-gal-lb-centre {
        flex-direction: column;
        gap: 0;
        padding-top: 52px;
    }

    .zh2o-gal-lb-img {
        max-height: calc(100dvh - 200px);
        width: 100vw;
        border-radius: 0;
    }

    /* Lift caption above mobile arrow row */
    .zh2o-gal-lb-caption {
        padding-bottom: 100px;
    }

    /* Arrows row below image */
    .zh2o-gal-lb-arrows-mobile {
        display: flex;
        gap: 24px;
        justify-content: center;
        padding: 14px 0 8px;
    }

    /* Hide desktop-flanking arrows */
    .zh2o-gal-lb-prev,
    .zh2o-gal-lb-next {
        display: none;
    }
}

/* Mobile-only arrow row — hidden on desktop */
.zh2o-gal-lb-arrows-mobile {
    display: none;
}
@media (max-width: 640px) {
    .zh2o-gal-lb-arrows-mobile {
        display: flex;
        gap: 24px;
        justify-content: center;
        padding: 12px 0 6px;
    }
    .zh2o-gal-lb-prev-m,
    .zh2o-gal-lb-next-m {
        background: rgba(255,255,255,0.18);
        border: 1.5px solid rgba(255,255,255,0.5);
        color: #ffffff;
        cursor: pointer;
        border-radius: 50%;
        width: 52px;
        height: 52px;
        font-size: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s ease;
        position: relative;
        z-index: 1000002;
    }
    .zh2o-gal-lb-prev-m:hover,
    .zh2o-gal-lb-next-m:hover {
        background: rgba(126, 200, 227, 0.35);
        border-color: rgba(126, 200, 227, 0.8);
    }
}
