/* WOA Instagram Feed — Frontend */

/* ------------------------------------------------------------------ */
/*  Alignment — self-constraining so Wide/Full/None work even inside   */
/*  unconstrained (default-layout) containers like full-width homepage */
/*  sections. Uses the theme's global width tokens.                    */
/* ------------------------------------------------------------------ */

.woa-ig {
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* None (default): content width, but never wider than the viewport
   minus the theme's root gutter — so it never touches the edges. */
.woa-ig:not(.alignwide):not(.alignfull) {
    max-width: min(
        var(--wp--style--global--content-size, 645px),
        calc(100vw - var(--wp--style--root--padding-left, 1rem) - var(--wp--style--root--padding-right, 1rem))
    );
}

/* Wide: full wide-size on desktop, gutter-aware on narrow screens. */
.woa-ig.alignwide {
    max-width: min(
        var(--wp--style--global--wide-size, 1340px),
        calc(100vw - var(--wp--style--root--padding-left, 1rem) - var(--wp--style--root--padding-right, 1rem))
    );
}

/* Full: edge to edge */
.woa-ig.alignfull {
    max-width: none;
}

.woa-ig-feed {
    display: grid;
    grid-template-columns: repeat(var(--woa-ig-cols, 3), 1fr);
    gap: var(--woa-ig-gap, 4px);
}

.woa-ig-item {
    position: relative;
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.04);
    cursor: pointer;
}

.woa-ig-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.woa-ig-item:hover .woa-ig-media,
.woa-ig-item:focus .woa-ig-media {
    transform: scale(1.05);
}

/* Video / carousel badges */
.woa-ig-video-badge,
.woa-ig-carousel-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

/* Caption overlay on hover */
.woa-ig-caption {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, transparent 60%);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.woa-ig-item:hover .woa-ig-caption,
.woa-ig-item:focus .woa-ig-caption {
    opacity: 1;
}

/* Error (admin only) */
.woa-ig-error {
    color: #d63638;
    font-style: italic;
}

/* Carousel mode — tiles fill the slide */
.woa-ig-carousel .woa-carousel__slide .woa-ig-item {
    height: 100%;
    aspect-ratio: 1;
}

/* Responsive grid */
@media (max-width: 640px) {
    .woa-ig-feed--grid {
        grid-template-columns: repeat(
            min(var(--woa-ig-cols, 3), 2),
            1fr
        );
    }
}

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

.woa-ig-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}

.woa-ig-lightbox.is-open {
    display: flex;
}

body.woa-ig-lightbox-open {
    overflow: hidden;
}

.woa-ig-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

.woa-ig-lightbox__dialog {
    position: relative;
    z-index: 1;
    max-width: min(90vw, 560px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.woa-ig-lightbox__stage {
    max-height: 80vh;
    overflow-y: auto;
    background: #000;
    border-radius: 6px;
}

.woa-ig-lightbox__stage img,
.woa-ig-lightbox__stage video {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    margin: 0 auto;
}

.woa-ig-lightbox__caption {
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 16px;
    margin: 0;
    max-width: 560px;
}

.woa-ig-lightbox__close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.woa-ig-lightbox__link {
    margin-top: 14px;
    color: #fff;
    font-size: 14px;
    text-decoration: underline;
}
