/* Work Gallery component styles (scoped) */
.cainco-work-gallery {
    --fade-ms: 450ms; /* fades */
    --slide-ms: 3000ms; /* slide-to-grid (EXACTLY 3s) */
    --slide-ease: cubic-bezier(.16, .84, .44, 1);
    --accent: #00a3e0;
}

.cainco-work-gallery .filter-nav {
    justify-content: center;
    gap: .75rem;
}

.cainco-work-gallery .filter-nav .nav-link {
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 600;
    font-size: .85rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.cainco-work-gallery .filter-nav .nav-link.active {
    color: var(--accent);
    background: #f6f8fb;
    border-color: #e5e7eb;
}

.cainco-work-gallery .filter-nav .nav-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Gallery as CSS GRID (no gaps) */
.cainco-work-gallery [data-gallery] {
    position: relative; /* anchor for proxies */
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0;
}

@media (min-width: 768px) {
    .cainco-work-gallery [data-gallery] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .cainco-work-gallery [data-gallery] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Neutralize Bootstrap flex so grid fully controls layout */
.cainco-work-gallery .gallery-col {
    padding: 0 !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
    width: auto !important;
    position: relative;
}

/* Real tiles (in the grid) */
.cainco-work-gallery .tile {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 4; /* 1 : 1.25 */
    background: #eef1f6;
    overflow: hidden;
    display: block;
    will-change: transform, opacity;
    transition: opacity var(--fade-ms) ease;
}

/* Colored top border strip */
.cainco-work-gallery .tile::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    height: 15px;
    z-index: 2;
    background: #2DACE3; /* default, will be cycled per tile */
}

/* Cycle colors across tiles using nth-child pattern */
.cainco-work-gallery .gallery-col:nth-child(4n+1) .tile::before {
    background: #2DACE3;
}

.cainco-work-gallery .gallery-col:nth-child(4n+2) .tile::before {
    background: #EC3273;
}

.cainco-work-gallery .gallery-col:nth-child(4n+3) .tile::before {
    background: #FBE919;
}
.cainco-work-gallery .gallery-col:nth-child(4n+4) .tile::before {
    background: #000000;
}

/* Hide real tiles during the proxy slide (layout still preserved) */
.cainco-work-gallery .tile.is-hidden {
    visibility: hidden;
}

/* Anti-seam bleed for real tiles */
.cainco-work-gallery .tile img {
    position: relative;
    width: calc(100% + 1px);
    height: calc(100% + 1px);
    transform: translate(-0.5px, -0.5px);
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
}

/* Hover overlay */
.cainco-work-gallery .tile-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    opacity: 0;
    transition: opacity var(--fade-ms) ease;
    pointer-events: none;
}

.cainco-work-gallery .tile:hover.is-active .tile-overlay, .cainco-work-gallery .tile.is-active {
    opacity: 1;
}
.cainco-work-gallery .tile.is-active .tile-caption{
    opacity: 1;
}

/* Caption */
.cainco-work-gallery .tile-caption {
    position: absolute;
    left: 1.75rem;
    bottom: 4.25rem;
    transform: translate(0, 10px);
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.25;
    text-align: left;
    padding: 0 0 .5rem;
    width: 70%;
    max-width: 85%;
    border-bottom: 3px solid #fff;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity var(--fade-ms) ease, transform var(--fade-ms) ease;
    pointer-events: none;
    z-index: 1;
}

.cainco-work-gallery .tile:hover .tile-caption.is-active {
    opacity: 1;
    transform: translate(0, 0);
}

/* View link under caption */
.cainco-work-gallery .tile-view {
    position: absolute;
    left: 1.75rem;
    bottom: 2.3rem;
    transform: none;
    color: #fff;
    text-decoration: none;
    text-transform: uppercase;
    font-weight: 100;
    font-size: 1rem;
    opacity: 0;
    transition: opacity var(--fade-ms) ease;
    z-index: 1;
}

.cainco-work-gallery .tile:hover .tile-view {
    opacity: 1;
}

.cainco-work-gallery .tile-view:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.wg-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--fade-ms) ease;
    z-index: 9999;
}

.wg-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.wg-lightbox__inner {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
}

.wg-lightbox__inner img {
    max-width: 95vw;
    max-height: 95vh;
    display: block;
}

.wg-lightbox__close {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #fff;
    color: #000;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 32px;
}

/* Animation layer (absolute proxies) */
.cainco-work-gallery .anim-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.cainco-work-gallery .proxy {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform, opacity;
    transition: transform var(--slide-ms) var(--slide-ease);
    overflow: visible;
    background: #eef1f6;
}

.cainco-work-gallery .proxy img {
    position: relative;
    width: calc(100% + 1px);
    height: calc(100% + 1px);
    transform: translate(-0.5px, -0.5px);
    object-fit: cover;
    display: block;
}
/* Hide filtered-out items */
.cainco-work-gallery .gallery-col.is-hidden {
    display: none !important;
}

/* Treat .is-active like :hover on small/touch screens */
@media (hover: none), (max-width: 767.98px) {
    .cainco-work-gallery .tile.is-active .tile-overlay,
    .cainco-work-gallery .tile.is-active .tile-caption {
        /* Mirror your existing :hover state. If your file already
           sets these on `.tile:hover`, alias them here too. */
        opacity: 1;
        visibility: visible;
        transform: none;
    }
}
