/* ==========================================================================
   Expandable Gallery - Frontend Styles
   ========================================================================== */

/* Grid Layout
   ========================================================================== */

.eg-gallery {
    margin: 1.5em 0;
}

.eg-grid {
    display: grid;
    grid-template-columns: repeat(var(--eg-columns, 3), 1fr);
    gap: 8px;
}

.eg-item {
    position: relative;
    overflow: hidden;
}

.eg-image-link {
    display: block;
    line-height: 0;
    cursor: pointer;
    text-decoration: none;
}

.eg-image-link img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.eg-image-link:hover img {
    transform: scale(1.05);
}


/* Part 2 - Hidden by default (SEO-friendly: stays in DOM)
   ========================================================================== */

.eg-part-2 {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s ease, opacity 0.4s ease, margin 0.4s ease;
    margin-top: 0;
}

.eg-part-2.eg-visible {
    max-height: none;
    overflow: visible;
    opacity: 1;
    margin-top: 8px;
}

/* Toggle Button
   ========================================================================== */

.eg-toggle-wrapper {
    text-align: center;
    margin: 16px 0;
}

.eg-toggle-btn {
    display: inline-block;
    padding: 10px 28px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    color: #333;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.eg-toggle-btn:hover {
    background: #e8e8e8;
    color: #111;
}

.eg-toggle-btn:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Lightbox Overlay
   ========================================================================== */

.eg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.eg-lightbox.eg-lightbox-open {
    opacity: 1;
    visibility: visible;
}

.eg-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

/* Lightbox Image
   ========================================================================== */

.eg-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.eg-lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* Lightbox Close Button
   ========================================================================== */

.eg-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

.eg-lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Lightbox Navigation Buttons
   ========================================================================== */

.eg-lightbox-prev,
.eg-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 50px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
}

.eg-lightbox-prev {
    left: 16px;
    border-radius: 4px;
}

.eg-lightbox-next {
    right: 16px;
    border-radius: 4px;
}

.eg-lightbox-prev:hover,
.eg-lightbox-next:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Lightbox Footer (Counter + Caption)
   ========================================================================== */

.eg-lightbox-footer {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    text-align: center;
    color: #fff;
    max-width: 80vw;
}

.eg-lightbox-counter {
    display: block;
    font-size: 13px;
    opacity: 0.6;
    margin-bottom: 6px;
}

.eg-lightbox-title {
    display: block;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.eg-lightbox-title:empty {
    display: none;
}

.eg-lightbox-description {
    display: block;
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.85;
    margin-top: 4px;
}

.eg-lightbox-description:empty {
    display: none;
}

/* Responsive Breakpoints
   ========================================================================== */

@media (max-width: 768px) {
    .eg-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .eg-lightbox-prev,
    .eg-lightbox-next {
        width: 40px;
        height: 60px;
        font-size: 1.5rem;
    }

    .eg-lightbox-prev {
        left: 8px;
    }

    .eg-lightbox-next {
        right: 8px;
    }

    .eg-lightbox-close {
        top: 8px;
        right: 8px;
    }
}

@media (max-width: 480px) {
    .eg-grid {
        grid-template-columns: 1fr;
    }

    .eg-image-link img {
        aspect-ratio: auto;
    }
}
