/* ---- Wrapper ---- */
.sc-photo-gallery {
    margin: 28px 0;
}

/* Lazy load fade-in */
.sc-gallery-item img.sc-lazy {
    opacity: 0;
}
.sc-gallery-item img:not(.sc-lazy) {
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* ============================================================
   GRID LAYOUT — square thumbnails, fixed columns
   ============================================================ */
.sc-layout-grid .sc-gallery-grid {
    display: grid;
    gap: 6px;
    /* grid-template-columns set via inline style from PHP */
}

.sc-layout-grid .sc-gallery-item {
    margin: 0;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    background: #e8e8e8;
    display: block;
    width: 100%;
}

.sc-layout-grid .sc-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.22s ease;
}

.sc-layout-grid .sc-gallery-item:hover img {
    transform: scale(1.05);
}

.sc-layout-grid .sc-gallery-item figcaption {
    display: none; /* captions visible in lightbox only for grid */
}

/* ============================================================
   MASONRY LAYOUT — natural proportions, CSS columns
   ============================================================ */
.sc-layout-masonry .sc-gallery-grid {
    /* column-count or column-width set via inline style from PHP */
    column-gap: 6px;
}

.sc-layout-masonry .sc-gallery-item {
    break-inside: avoid;
    margin: 0 0 6px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    display: block;
    background: #e8e8e8;
}

.sc-layout-masonry .sc-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.18s ease;
}

.sc-layout-masonry .sc-gallery-item:hover img {
    opacity: 0.88;
}

.sc-layout-masonry .sc-gallery-item figcaption {
    font-size: 12px;
    color: #555;
    padding: 4px 8px 6px;
    line-height: 1.4;
}

/* ============================================================
   FOOTER — count + load more
   ============================================================ */
.sc-gallery-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e0e0e0;
}

.sc-gallery-footer[hidden] {
    display: none;
}

.sc-gallery-count {
    color: #666;
    font-size: 14px;
}

.sc-load-more {
    background: #1a6fb5;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 9px 22px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1;
}

.sc-load-more:hover:not(:disabled) {
    background: #0f5290;
}

.sc-load-more:disabled {
    opacity: 0.55;
    cursor: default;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.sc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sc-lightbox[hidden] {
    display: none;
}

.sc-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.93);
    cursor: pointer;
}

.sc-lightbox-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 92vw;
    max-height: 96vh;
}

.sc-lightbox-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 82vh;
}

.sc-lightbox-img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    display: block;
    border-radius: 2px;
}

.sc-lightbox-close {
    position: fixed;
    top: 12px;
    right: 18px;
    background: none;
    border: none;
    color: #fff;
    font-size: 40px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.75;
    transition: opacity 0.15s;
    z-index: 2;
}

.sc-lightbox-close:hover {
    opacity: 1;
}

.sc-lightbox-prev,
.sc-lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.35);
    border: none;
    color: #fff;
    font-size: 52px;
    line-height: 1;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 4px;
    opacity: 0.75;
    transition: opacity 0.15s, background 0.15s;
    z-index: 2;
}

.sc-lightbox-prev { left: 8px; }
.sc-lightbox-next { right: 8px; }

.sc-lightbox-prev:hover,
.sc-lightbox-next:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.65);
}

.sc-lightbox-caption {
    color: #ddd;
    font-size: 14px;
    margin: 10px 0 0;
    text-align: center;
    max-width: 640px;
    min-height: 1.4em;
    line-height: 1.4;
}

.sc-lightbox-counter {
    color: #888;
    font-size: 13px;
    margin: 4px 0 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    /* auto-fill already handles narrow screens — just ensure min 2 columns */
    .sc-layout-grid .sc-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    }

    .sc-gallery-footer {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .sc-load-more {
        width: 100%;
    }

    .sc-lightbox-prev { left: 2px; }
    .sc-lightbox-next { right: 2px; }
}
