/* ============================================================
   Coderix Widgets — Gallery  (cxgl-)
   ============================================================ */

.cxgl-wrapper { width: 100%; box-sizing: border-box; position: relative; }
.cxgl-wrapper *, .cxgl-wrapper *::before, .cxgl-wrapper *::after { box-sizing: border-box; }

/* ══════════════════════════════════════════════════════════════
   SHARED ITEM BASE
   Every item (.cxgl-item, .cxgl-tile-item, .cxgl-mosaic-item,
   .cxgl-masonry-item) shares these basics:
   - overflow:hidden so zoom/animations don't bleed
   - position:relative so the overlay can be positioned
   - cursor:pointer for UX feedback
   ══════════════════════════════════════════════════════════════ */
.cxgl-item,
.cxgl-mosaic-item,
.cxgl-tile-item,
.cxgl-masonry-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: 6px;
    display: block;
}

/* The image inside every item */
.cxgl-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease, filter 0.4s ease, opacity 0.3s ease;
    will-change: transform;
}

/* Tile images: natural height (no height:100% override) */
.cxgl-tile-item .cxgl-img {
    height: auto;
}

/* Masonry images: natural height */
.cxgl-masonry-item .cxgl-img {
    height: auto;
}

/* ══════════════════════════════════════════════════════════════
   HOVER ANIMATIONS  — applied via .cxgl-anim-* on the item
   ══════════════════════════════════════════════════════════════ */

/* zoom-in */
.cxgl-anim-zoom-in:hover .cxgl-img {
    transform: scale(1.1);
}

/* zoom-out — image starts bigger, zooms to normal */
.cxgl-anim-zoom-out .cxgl-img {
    transform: scale(1.1);
}
.cxgl-anim-zoom-out:hover .cxgl-img {
    transform: scale(1);
}

/* slide-up — image slides up on hover */
.cxgl-anim-slide-up:hover .cxgl-img {
    transform: translateY(-6%);
}

/* slide-down */
.cxgl-anim-slide-down:hover .cxgl-img {
    transform: translateY(6%);
}

/* rotate — subtle rotation */
.cxgl-anim-rotate:hover .cxgl-img {
    transform: scale(1.08) rotate(2deg);
}

/* blur — image blurs on hover, sharpens on hover (reverse = blur to clear) */
.cxgl-anim-blur .cxgl-img {
    filter: blur(4px);
    transform: scale(1.04);
}
.cxgl-anim-blur:hover .cxgl-img {
    filter: blur(0);
    transform: scale(1);
}

/* flash — brief flash of brightness on hover */
@keyframes cxglFlash {
    0%   { opacity: 1; }
    25%  { opacity: 0.5; }
    50%  { opacity: 1; }
    75%  { opacity: 0.75; }
    100% { opacity: 1; }
}
.cxgl-anim-flash:hover .cxgl-img {
    animation: cxglFlash 0.5s ease;
}

/* grayscale → color */
.cxgl-anim-grayscale .cxgl-img {
    filter: grayscale(100%);
}
.cxgl-anim-grayscale:hover .cxgl-img {
    filter: grayscale(0%);
}

/* ══════════════════════════════════════════════════════════════
   OVERLAY
   ══════════════════════════════════════════════════════════════ */
.cxgl-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.28s ease;
    pointer-events: none;
    z-index: 2;
}
.cxgl-item:hover .cxgl-overlay,
.cxgl-mosaic-item:hover .cxgl-overlay,
.cxgl-tile-item:hover .cxgl-overlay,
.cxgl-masonry-item:hover .cxgl-overlay {
    opacity: 1;
}

.cxgl-overlay-icon {
    font-size: 20px;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}
.cxgl-item:hover .cxgl-overlay-icon,
.cxgl-mosaic-item:hover .cxgl-overlay-icon,
.cxgl-tile-item:hover .cxgl-overlay-icon,
.cxgl-masonry-item:hover .cxgl-overlay-icon {
    transform: scale(1.1);
}

.cxgl-overlay-title {
    color: #fff;
    font-size: 13px;
    text-align: center;
    padding: 0 12px;
    max-width: 90%;
    line-height: 1.3;
}

/* Lightbox trigger — fills entire item */
.cxgl-lb-trigger {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 3;
    cursor: pointer;
}

/* ══════════════════════════════════════════════════════════════
   1. THUMBNAILS & THUMBNAIL GRID
   ══════════════════════════════════════════════════════════════ */
.cxgl-grid {
    display: grid;
    grid-template-columns: repeat(var(--cxgl-cols, 3), 1fr);
    gap: var(--cxgl-gap, 8px);
}
@media (max-width: 1024px) {
    .cxgl-grid { grid-template-columns: repeat(var(--cxgl-cols-tab, 2), 1fr); }
}
@media (max-width: 768px) {
    .cxgl-grid { grid-template-columns: repeat(var(--cxgl-cols-mob, 1), 1fr); }
}

/* .cxgl-item (thumbnails) — fixed height set by Elementor slider via --cxgl-thumb-h */
.cxgl-item {
    height: 220px;   /* default; overridden by Elementor selectors control */
}

/* thumbnail-grid: force equal aspect-ratio */
.cxgl-grid-thumbnail-grid .cxgl-item {
    aspect-ratio: 4/3;
    height: auto;
}

/* ══════════════════════════════════════════════════════════════
   2. MOSAIC
   ══════════════════════════════════════════════════════════════ */
.cxgl-mosaic {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 220px;   /* default; overridden by Elementor thumb_height */
    gap: var(--cxgl-gap, 8px);
}
.cxgl-mosaic-item {
    height: 100%; /* fills the grid cell defined by grid-auto-rows + span */
}
@media (max-width: 768px) {
    .cxgl-mosaic {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 160px;
    }
}
@media (max-width: 480px) {
    .cxgl-mosaic {
        grid-template-columns: 1fr;
        grid-auto-rows: 180px;
    }
}

/* ══════════════════════════════════════════════════════════════
   3. TILE  (CSS column-count — Pinterest waterfall)
   ══════════════════════════════════════════════════════════════ */
.cxgl-tile {
    column-count: var(--cxgl-cols, 3);
    column-gap: var(--cxgl-gap, 8px);
}
@media (max-width: 1024px) { .cxgl-tile { column-count: var(--cxgl-cols-tab, 2); } }
@media (max-width: 768px)  { .cxgl-tile { column-count: var(--cxgl-cols-mob, 1); } }

.cxgl-tile-item {
    break-inside: avoid;
    margin-bottom: var(--cxgl-gap, 8px);
    display: block;
}
/* img is full natural height — no fixed height override */
.cxgl-tile-item .cxgl-img {
    height: auto;
}

/* ══════════════════════════════════════════════════════════════
   4. MASONRY  (JS absolute positioning)
   ══════════════════════════════════════════════════════════════ */
.cxgl-masonry {
    position: relative;
    width: 100%;
    /* height set by JS */
}
.cxgl-masonry-item {
    position: absolute;
    /* top / left / width set by JS */
}
.cxgl-masonry-item .cxgl-img {
    height: auto;
    width: 100%;
}

/* ══════════════════════════════════════════════════════════════
   5. SLIDESHOW
   ══════════════════════════════════════════════════════════════ */
.cxgl-slideshow { position: relative; user-select: none; }

.cxgl-slide-main {
    position: relative;
    overflow: hidden;
    height: 480px;
    border-radius: 6px;
    background: #111;
}
.cxgl-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.55s ease;
    pointer-events: none;
}
.cxgl-slide.cxgl-active {
    opacity: 1;
    pointer-events: auto;
}
.cxgl-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cxgl-slide-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.65));
    padding: 32px 20px 16px;
}
.cxgl-slide-title { color: #fff; font-size: 18px; font-weight: 700; display: block; }
.cxgl-slide-text  { color: rgba(255,255,255,0.82); font-size: 14px; display: block; margin-top: 4px; }

.cxgl-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.cxgl-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: rgba(0,0,0,0.25);
    border: none; cursor: pointer; padding: 0;
    transition: background 0.2s, transform 0.2s;
}
.cxgl-dot.cxgl-active { background: #333; transform: scale(1.3); }

/* ══════════════════════════════════════════════════════════════
   6. FILM STRIP
   ══════════════════════════════════════════════════════════════ */
.cxgl-film { display: flex; flex-direction: column; gap: 8px; }

.cxgl-filmstrip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: thin;
}
.cxgl-filmstrip::-webkit-scrollbar { height: 4px; }
.cxgl-filmstrip::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }

.cxgl-film-thumb {
    flex-shrink: 0;
    width: 100px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.55;
    scroll-snap-align: start;
    transition: opacity 0.2s, outline 0.15s;
    outline: 2px solid transparent;
}
.cxgl-film-thumb:hover { opacity: 0.8; }
.cxgl-film-thumb.cxgl-active { opacity: 1; outline: 2px solid #4a90d9; }
.cxgl-film-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════
   SHARED — Arrows
   ══════════════════════════════════════════════════════════════ */
.cxgl-arrow {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    z-index: 10;
    background: rgba(0,0,0,0.4);
    color: #fff;
    border: none; border-radius: 50%;
    width: 40px; height: 40px;
    font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0.8;
}
.cxgl-arrow:hover { opacity: 1; background: rgba(0,0,0,0.65); }
.cxgl-arrow-prev { left: 10px; }
.cxgl-arrow-next { right: 10px; }

/* ══════════════════════════════════════════════════════════════
   LIGHTBOX
   ══════════════════════════════════════════════════════════════ */
.cxgl-lightbox {
    position: fixed; inset: 0; z-index: 999999;
    background: rgba(0,0,0,0.92);
    display: flex !important;
    align-items: center; justify-content: center;
    animation: cxglFadeIn 0.22s ease;
}
.cxgl-lightbox[style*="display:none"],
.cxgl-lightbox[style*="display: none"] { display: none !important; }

@keyframes cxglFadeIn {
    from { opacity: 0; } to { opacity: 1; }
}
.cxgl-lb-inner {
    position: relative;
    max-width: 90vw; max-height: 90vh;
    display: flex; flex-direction: column;
    align-items: center; gap: 12px;
}
.cxgl-lb-img {
    max-width: 90vw; max-height: 80vh;
    width: auto; height: auto;
    object-fit: contain; border-radius: 4px; display: block;
    animation: cxglImgIn 0.25s ease;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    transition: opacity 0.2s ease;
}
@keyframes cxglImgIn {
    from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); }
}
.cxgl-lb-caption {
    color: #ddd; font-size: 14px; text-align: center;
    max-width: 700px; line-height: 1.5; padding: 0 20px;
}
.cxgl-lb-counter {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,0.6); font-size: 13px;
    letter-spacing: 0.04em; white-space: nowrap;
}
.cxgl-lb-close {
    position: fixed; top: 16px; right: 20px;
    background: none; border: none; color: #fff;
    font-size: 26px; cursor: pointer; z-index: 10;
    opacity: 0.7; transition: opacity 0.2s, transform 0.2s; padding: 4px 8px;
}
.cxgl-lb-close:hover { opacity: 1; transform: rotate(90deg); }
.cxgl-lb-nav {
    position: fixed; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff; font-size: 20px; cursor: pointer;
    border-radius: 50%; width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s; z-index: 10;
}
.cxgl-lb-nav:hover { background: rgba(255,255,255,0.25); }
.cxgl-lb-prev { left: 16px; }
.cxgl-lb-next { right: 16px; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .cxgl-slide-main { height: 280px !important; }
    .cxgl-arrow { width: 32px; height: 32px; font-size: 13px; }
    .cxgl-lb-nav { width: 36px; height: 36px; font-size: 15px; }
    .cxgl-lb-prev { left: 6px; } .cxgl-lb-next { right: 6px; }
    .cxgl-lb-img { max-width: 96vw; max-height: 75vh; }
}
@media (max-width: 480px) {
    .cxgl-film-thumb { width: 70px; }
    .cxgl-slide-main { height: 220px !important; }
}

/* ══════════════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════════════ */
.cxgl-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
    width: 100%;
}

.cxgl-filter-btn {
    display: inline-block;
    padding: 8px 22px;
    background: #f0f0f0;
    color: #444;
    border: none;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.22s ease, color 0.22s ease, transform 0.15s ease, box-shadow 0.22s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.cxgl-filter-btn:hover {
    background: #555;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.cxgl-filter-btn.cxgl-active {
    background: #333;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

/* ── Filtered items ─────────────────────────────────────────── */
/* Items that don't match the active filter */
.cxgl-item.cxgl-filtered-out,
.cxgl-mosaic-item.cxgl-filtered-out,
.cxgl-tile-item.cxgl-filtered-out,
.cxgl-masonry-item.cxgl-filtered-out {
    display: none;
}

/* Animate items back in */
.cxgl-item.cxgl-filter-in,
.cxgl-mosaic-item.cxgl-filter-in,
.cxgl-tile-item.cxgl-filter-in,
.cxgl-masonry-item.cxgl-filter-in {
    animation: cxglFilterIn 0.3s ease forwards;
}

@keyframes cxglFilterIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ══════════════════════════════════════════════════════════════
   IMAGE LOAD SKELETON
   Shows shimmer while image is loading — prevents layout jump
   ══════════════════════════════════════════════════════════════ */
.cxgl-item,
.cxgl-mosaic-item,
.cxgl-tile-item,
.cxgl-masonry-item {
    background: #e8e8e8; /* skeleton base colour */
}

/* Shimmer sweep across the placeholder */
.cxgl-item::before,
.cxgl-mosaic-item::before,
.cxgl-tile-item::before,
.cxgl-masonry-item::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.5) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: cxglShimmer 1.4s infinite;
    pointer-events: none;
    border-radius: inherit;
}

@keyframes cxglShimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

/* Once loaded — hide skeleton */
.cxgl-item.cxgl-img-loaded::before,
.cxgl-mosaic-item.cxgl-img-loaded::before,
.cxgl-tile-item.cxgl-img-loaded::before,
.cxgl-masonry-item.cxgl-img-loaded::before {
    display: none;
}

/* Image fades in after load */
.cxgl-img {
    opacity: 0;
    transition: opacity 0.35s ease, transform 0.4s ease, filter 0.4s ease;
}
.cxgl-img.cxgl-img-visible {
    opacity: 1;
}

@media (max-width: 480px) {
    .cxgl-filter-btn { padding: 6px 14px; font-size: 12px; }
}
