@keyframes eigFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* ==================== BASE RESETS ==================== */
[id^="eig-gallery-"],
[id^="eig-gb-gallery-"] {
    box-sizing: border-box;
}

[id^="eig-gallery-"] *,
[id^="eig-gb-gallery-"] * {
    box-sizing: border-box;
}

/* Grid structure */
[id^="eig-gallery-"] .eig-gallery-grid,
[id^="eig-gb-gallery-"] .eig-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
}

/* Item structure */
[id^="eig-gallery-"] .eig-gallery-item,
[id^="eig-gb-gallery-"] .eig-gallery-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* Image structure */
[id^="eig-gallery-"] .eig-gallery-item img,
[id^="eig-gb-gallery-"] .eig-gallery-item img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Link structure */
[id^="eig-gallery-"] .eig-gallery-item a,
[id^="eig-gb-gallery-"] .eig-gallery-item a {
    display: block;
    text-decoration: none;
    line-height: 0;
    font-size: 0;
}

/* Filter bar structure — flex layout, no cosmetic properties */
.eig-filter-bar {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

/* Filter button structure */
[id^="eig-gallery-"] .eig-filter-btn,
[id^="eig-gb-gallery-"] .eig-filter-btn {
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
}

[id^="eig-gallery-"] .eig-filter-btn:focus-visible,
[id^="eig-gb-gallery-"] .eig-filter-btn:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

[id^="eig-gallery-"] .eig-filter-btn .eig-filter-count,
[id^="eig-gb-gallery-"] .eig-filter-btn .eig-filter-count {
    margin-left: 4px;
}

/* Overlay text */
.eig-overlay-title,
.eig-overlay-desc {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* No images */
.eig-no-images {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* Filter states */
[id^="eig-gallery-"] .eig-gallery-item.eig-hidden,
[id^="eig-gb-gallery-"] .eig-gallery-item.eig-hidden {
    display: none !important;
}
[id^="eig-gallery-"] .eig-gallery-item.eig-show,
[id^="eig-gb-gallery-"] .eig-gallery-item.eig-show {
    animation: eigFadeIn 0.4s ease forwards;
}

/* No info items — no hover effect, default cursor */
.eig-gallery-item.eig-no-info {
    cursor: default;
}
.eig-gallery-item.eig-no-info:hover img {
    transform: none;
    filter: none;
}

/* ==================== FILTER HIERARCHY ==================== */
[id^="eig-gallery-"] .eig-filter-child-btn,
[id^="eig-gb-gallery-"] .eig-filter-child-btn {
    margin-left: -2px;
    border-left: 2px solid rgba(0, 0, 0, 0.15);
    border-radius: 0 4px 4px 0;
}
[id^="eig-gallery-"] .eig-filter-child-btn.active,
[id^="eig-gb-gallery-"] .eig-filter-child-btn.active {
    border-left-color: currentColor;
}

/* ==================== OVERLAY LAYOUT ==================== */
.eig-layout-overlay .eig-gallery-item {
    position: relative;
    overflow: hidden;
}
.eig-layout-overlay .eig-gallery-item img {
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 4/3;
    transition: transform 0.3s ease, filter 0.3s ease;
}
.eig-layout-overlay .eig-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1;
}
.eig-layout-overlay .eig-gallery-item:hover .eig-gallery-overlay {
    transform: translateY(0);
}

/* ==================== SIDE-BY-SIDE LAYOUT ==================== */
.eig-layout-side .eig-gallery-grid {
    display: flex;
    flex-direction: column;
}
.eig-layout-side .eig-gallery-item {
    display: flex;
    overflow: hidden;
    flex-direction: row;
}
.eig-layout-side .eig-gallery-item-image {
    flex: 0 0 50%;
    overflow: hidden;
    min-width: 0;
}
.eig-layout-side .eig-gallery-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: unset;
}
.eig-layout-side .eig-gallery-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.eig-info-right .eig-gallery-item {
    flex-direction: row-reverse;
}
.eig-layout-side .eig-gallery-item-image a {
    height: 100%;
    display: block;
}
.eig-layout-side .eig-gallery-item-image a img {
    height: 100%;
    aspect-ratio: unset;
}

/* ==================== BELOW LAYOUT ==================== */
.eig-layout-below .eig-gallery-item {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.eig-layout-below .eig-gallery-item-image {
    overflow: hidden;
}
.eig-layout-below .eig-gallery-item-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 4/3;
    transition: transform 0.3s ease, filter 0.3s ease;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 767px) {
    .eig-layout-side .eig-gallery-item {
        flex-direction: column;
    }
    .eig-layout-side .eig-gallery-item-image {
        flex: 0 0 auto;
    }
    .eig-layout-side .eig-gallery-item-image img {
        height: auto;
        aspect-ratio: 4/3;
    }
}

/* ==================== CUSTOM LIGHTBOX ==================== */
.eig-lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 999999;
    justify-content: center;
    align-items: center;
    -webkit-user-select: none;
    user-select: none;
}
.eig-lightbox-overlay.eig-lb-active {
    display: flex;
}
.eig-lb-content {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    background: #1a1a1a;
    border-radius: 6px;
    overflow: hidden;
}
.eig-lb-img-wrap {
    flex: 1 1 60%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    background: #000;
    overflow: hidden;
}
.eig-lb-img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}
.eig-lb-info {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    padding: 28px 24px;
    overflow-y: auto;
    background: #1a1a1a;
    color: #fff;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}
.eig-lb-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 12px 0;
    line-height: 1.4;
    color: #fff;
}
.eig-lb-desc {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.7;
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    white-space: pre-line;
}
.eig-lb-counter {
    position: absolute;
    bottom: 12px;
    left: 28px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}
.eig-lb-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    border-radius: 50%;
    transition: background 0.2s;
}
.eig-lb-close:hover { background: rgba(0, 0, 0, 0.8); }
.eig-lb-prev,
.eig-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    padding: 0;
    line-height: 1;
    z-index: 10;
}
.eig-lb-prev { left: -60px; }
.eig-lb-next { right: -60px; }
.eig-lb-prev:hover,
.eig-lb-next:hover { background: rgba(255, 255, 255, 0.25); }

/* No description: just image centered */
.eig-lb-content.eig-lb-no-info .eig-lb-img-wrap {
    flex: 1 1 100%;
}
.eig-lb-content.eig-lb-no-info .eig-lb-info {
    display: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .eig-lb-content {
        flex-direction: column;
        max-width: 96vw;
        max-height: 94vh;
    }
    .eig-lb-img-wrap {
        flex: 1 1 auto;
        max-height: 65vh;
    }
    .eig-lb-img {
        max-height: 65vh;
    }
    .eig-lb-info {
        flex: 0 0 auto;
        max-height: 30vh;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding: 16px 20px;
    }
    .eig-lb-title { font-size: 17px; margin-bottom: 8px; }
    .eig-lb-desc { font-size: 13px; }
    .eig-lb-prev,
    .eig-lb-next {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
    .eig-lb-prev { left: 8px; }
    .eig-lb-next { right: 8px; }
    .eig-lb-close { top: 8px; right: 10px; font-size: 26px; width: 36px; height: 36px; }
    .eig-lb-counter { left: 16px; bottom: 8px; }
}
