/* ── MLD Gallery – Frontend ───────────────────────────────────────────── */

.cts-gallery-wrap {
    width: 100%;
}

/* ── Filter buttons ───────────────────────────────────────────────────── */
.cts-gallery-filters {
    margin-bottom: 24px;
    text-align: center;
}

.cts-gallery-filters-cats {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.cts-filter-btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mld-btn-color, #145694);
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 7px 14px;
    margin: 5px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1.4;
    display: inline-block;
    vertical-align: middle;
}

.cts-filter-btn:focus,
.cts-filter-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.cts-filter-btn:hover {
    color: var(--mld-btn-hover-color, #0b4b91);
    background: transparent;
    outline: none;
    box-shadow: none;
}

.cts-filter-btn.active {
    color: var(--mld-btn-active-color, #5192d4);
    background: transparent;
    text-decoration: none;
}

/* View All — bordered box at end of row */
.cts-filter-view-all {
    border: 1.5px solid var(--mld-btn-border-color, #0b4b91) !important;
    color: var(--mld-btn-color, #0b4b91) !important;
    padding: 7px 20px !important;
    background: transparent !important;
    margin-left: 10px;
    text-decoration: none !important;
}

.cts-filter-view-all:focus,
.cts-filter-view-all:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.cts-filter-view-all:hover {
    color: var(--mld-btn-hover-color, #0b4b91) !important;
    background: transparent !important;
    box-shadow: none !important;
    border-color: var(--mld-btn-border-color, #0b4b91) !important;
}

.cts-filter-view-all.active {
    color: var(--mld-btn-active-color, #0b4b91) !important;
    background: transparent !important;
    border-color: var(--mld-btn-border-color, #0b4b91) !important;
    text-decoration: none !important;
}

/* ── Grid ─────────────────────────────────────────────────────────────── */
.cts-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

@media (max-width: 900px) {
    .cts-gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .cts-gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
}

/* ── Gallery items ────────────────────────────────────────────────────── */
.cts-gallery-item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: #ebebeb;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.cts-gallery-item.cts-visible {
    opacity: 1;
    transform: translateY(0);
}

.cts-gallery-item.cts-hidden {
    display: none;
}

.cts-gallery-item:nth-child(2) { transition-delay: 0.04s; }
.cts-gallery-item:nth-child(3) { transition-delay: 0.08s; }
.cts-gallery-item:nth-child(4) { transition-delay: 0.12s; }
.cts-gallery-item:nth-child(5) { transition-delay: 0.16s; }
.cts-gallery-item:nth-child(6) { transition-delay: 0.20s; }
.cts-gallery-item:nth-child(7) { transition-delay: 0.24s; }
.cts-gallery-item:nth-child(8) { transition-delay: 0.28s; }

.cts-gallery-item a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

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

.cts-gallery-item:hover img {
    transform: scale(1.04);
}

.cts-gallery-overlay {
    position: absolute;
    inset: 0;
    background: var(--mld-hover-color, rgba(20, 86, 148, 0.45));
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}

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

.cts-gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #888;
    padding: 40px 0;
}

/* ── Load More ────────────────────────────────────────────────────────── */
.cts-load-more-wrap {
    text-align: center;
    margin-top: 28px;
}

.cts-load-more-btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: #0b4b91;
    border: 1.5px solid #0b4b91;
    border-radius: 0;
    padding: 10px 32px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    line-height: 1.4;
}

.cts-load-more-btn:hover {
    background: #145694;
    border-color: #145694;
}

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

.cts-lightbox.cts-lb-open {
    display: flex;
}

.cts-lb-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    text-align: center;
    /* keep image centred, not pushed by arrow buttons */
    padding: 0 60px;
    box-sizing: border-box;
}

.cts-lb-inner img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.cts-lb-title {
    color: #fff;
    margin: 12px 0 0;
    font-size: 14px;
    font-family: inherit;
}

/* ── Lightbox controls — fixed to viewport edges, never over image ───── */
.cts-lb-close,
.cts-lb-prev,
.cts-lb-next {
    position: fixed;
    background: var(--mld-lb-btn-bg, rgba(11, 75, 145, 0.8));
    color: var(--mld-lb-btn-color, #fff);
    border: none;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s;
    padding: 0;
    border-radius: var(--mld-lb-btn-radius, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* Prevent any layout/position jump on hover */
    will-change: transform;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.cts-lb-close:hover,
.cts-lb-prev:hover,
.cts-lb-next:hover {
    background: var(--mld-lb-btn-bg-hover, #0b4b91);
    /* Re-state transform so hover doesn't reset it */
    transform: translateY(-50%);
}

.cts-lb-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 22px;
    z-index: 100001;
    /* Close button doesn't translate, override the hover rule */
    transform: none !important;
}

.cts-lb-prev,
.cts-lb-next {
    top: 50%;
    transform: translateY(-50%);
    /* Square so border-radius: 50% actually makes a circle */
    width: 44px;
    height: 44px;
    font-size: 22px;
    z-index: 100001;
}

/* Fixed to screen edges — never overlap image */
.cts-lb-prev { left: 10px; }
.cts-lb-next { right: 10px; }

/* Mobile — smaller controls, ensure they stay on screen */
@media (max-width: 600px) {
    .cts-lb-inner {
        padding: 0 50px;
        max-width: 100vw;
    }

    .cts-lb-prev,
    .cts-lb-next {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .cts-lb-prev { left: 4px; }
    .cts-lb-next { right: 4px; }

    .cts-lb-close {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}
