/* ========================================
   GALLERY - WRAPPER
   ======================================== */

.xio-gallery {
    display: block;
    width: 100%;
    position: relative;
}

/* ========================================
   GALLERY - GRID (4-col mosaic pattern)
   ======================================== */

.xio-gallery__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 220px;
    gap: 6px;
    width: 100%;
}

/* ========================================
   GALLERY - ITEM
   ======================================== */

.xio-gallery__item {
    grid-area: var(--ga);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    margin: 0;
    opacity: 0;
    transform: translateY(30px);
    transition:
        opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--item-index, 0) * 0.06s);
}

.xio-gallery__item--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   GALLERY - LOADER (SHIMMER)
   ======================================== */

.xio-gallery__loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #e0e0e0 0%,
        #f5f5f5 50%,
        #e0e0e0 100%
    );
    background-size: 200% 100%;
    animation: xio-gallery-shimmer 1.5s infinite;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.xio-gallery__item--loading .xio-gallery__loader {
    opacity: 1;
}

.xio-gallery__item--loading .xio-gallery__image {
    opacity: 0;
}

@keyframes xio-gallery-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   GALLERY - IMAGE
   ======================================== */

.xio-gallery__image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
    will-change: transform;
}

.xio-gallery__item:hover .xio-gallery__image {
    transform: scale(1.06);
}

/* ========================================
   GALLERY - OVERLAY
   ======================================== */

.xio-gallery__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.4s ease;
    z-index: 2;
}

.xio-gallery__item:hover .xio-gallery__overlay {
    opacity: 1;
}

/* ----------------------------------------
   OVERLAY ICON
   ---------------------------------------- */

.xio-gallery__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #ffffff;
    transform: scale(0.7) translateY(8px);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.xio-gallery__icon svg {
    width: 22px;
    height: 22px;
}

.xio-gallery__item:hover .xio-gallery__icon {
    transform: scale(1) translateY(0);
}

/* ========================================
   LIGHTBOX
   ======================================== */

.xio-gallery__lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.35s;
}

.xio-gallery__lightbox--active {
    opacity: 1;
    visibility: visible;
}

/* ----------------------------------------
   LIGHTBOX BACKDROP
   ---------------------------------------- */

.xio-gallery__lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ----------------------------------------
   LIGHTBOX CONTENT
   ---------------------------------------- */

.xio-gallery__lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90vw;
    height: 85vh;
    z-index: 2;
}

.xio-gallery__lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transform: scale(0.94);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    user-select: none;
    -webkit-user-drag: none;
}

.xio-gallery__lightbox-image--loaded {
    opacity: 1;
    transform: scale(1);
}

/* ----------------------------------------
   LIGHTBOX SPINNER
   ---------------------------------------- */

.xio-gallery__lightbox-spinner {
    position: absolute;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: xio-gallery-spin 0.7s linear infinite;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.xio-gallery__lightbox-spinner--active {
    opacity: 1;
}

@keyframes xio-gallery-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ----------------------------------------
   LIGHTBOX CLOSE
   ---------------------------------------- */

.xio-gallery__lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    z-index: 3;
    transition: background 0.25s ease, transform 0.25s ease;
    padding: 0;
}

.xio-gallery__lightbox-close svg {
    width: 20px;
    height: 20px;
}

.xio-gallery__lightbox-close:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: rotate(90deg);
}

/* ----------------------------------------
   LIGHTBOX NAVIGATION
   ---------------------------------------- */

.xio-gallery__lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    z-index: 3;
    transition: background 0.25s ease, transform 0.25s ease;
    padding: 0;
}

.xio-gallery__lightbox-nav svg {
    width: 22px;
    height: 22px;
}

.xio-gallery__lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.18);
}

.xio-gallery__lightbox-nav--prev {
    left: 20px;
}

.xio-gallery__lightbox-nav--prev:hover {
    transform: translateY(-50%) translateX(-3px);
}

.xio-gallery__lightbox-nav--next {
    right: 20px;
}

.xio-gallery__lightbox-nav--next:hover {
    transform: translateY(-50%) translateX(3px);
}

/* ----------------------------------------
   LIGHTBOX COUNTER
   ---------------------------------------- */

.xio-gallery__lightbox-counter {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-primary, 'Bebas Neue', sans-serif);
    font-size: 0.95rem;
    letter-spacing: 0.15em;
    z-index: 3;
    user-select: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
    .xio-gallery__grid {
        grid-auto-rows: 180px;
    }
}

@media (max-width: 768px) {
    .xio-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 200px;
        gap: 4px;
    }

    .xio-gallery__item {
        grid-area: auto !important;
        transform: translateY(20px);
    }

    .xio-gallery__icon {
        width: 40px;
        height: 40px;
    }

    .xio-gallery__icon svg {
        width: 18px;
        height: 18px;
    }

    /* ---- Lightbox Mobile ---- */

    .xio-gallery__lightbox-content {
        width: 96vw;
        height: 80vh;
    }

    .xio-gallery__lightbox-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }

    .xio-gallery__lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .xio-gallery__lightbox-nav--prev {
        left: 8px;
    }

    .xio-gallery__lightbox-nav--next {
        right: 8px;
    }

    .xio-gallery__lightbox-counter {
        bottom: 16px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .xio-gallery__grid {
        grid-auto-rows: 160px;
        gap: 3px;
    }

    .xio-gallery__lightbox-nav {
        width: 36px;
        height: 36px;
    }

    .xio-gallery__lightbox-nav svg {
        width: 18px;
        height: 18px;
    }
}
