/* ============================================================
   InstaFeed WP - Frontend Styles
   ============================================================ */

.instafeed-wp-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.instafeed-wp-notice {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* --- Grid --- */
.instafeed-wp-grid {
    display: grid;
    grid-template-columns: repeat(var(--instafeed-columns, 3), 1fr);
    gap: 8px;
}

/* --- Masonry --- */
.instafeed-wp-masonry {
    column-count: var(--instafeed-columns, 3);
    column-gap: 8px;
}
.instafeed-wp-masonry .instafeed-wp-item {
    break-inside: avoid;
    margin-bottom: 8px;
}

/* --- Highlight --- */
.instafeed-wp-layout-highlight .instafeed-wp-grid {
    grid-template-columns: repeat(var(--instafeed-columns, 3), 1fr);
}
.instafeed-wp-layout-highlight .instafeed-wp-highlight-main {
    grid-column: span 2;
    grid-row: span 2;
}

/* --- Carousel Layout --- */
.instafeed-wp-carousel-wrapper {
    position: relative;
    overflow: hidden;
}
.instafeed-wp-carousel-track {
    overflow: hidden;
}
.instafeed-wp-carousel-items {
    display: flex;
    transition: transform 0.4s ease;
    gap: 8px;
}
.instafeed-wp-carousel-items .instafeed-wp-item {
    flex: 0 0 calc(33.333% - 6px);
    min-width: 0;
}
.instafeed-wp-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.instafeed-wp-carousel-btn:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.instafeed-wp-carousel-prev { left: 10px; }
.instafeed-wp-carousel-next { right: 10px; }

/* ============================================================
   Feed Item — the image card
   ============================================================ */
.instafeed-wp-item {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

/* The <a> wrapping everything — acts as positioning context */
.instafeed-wp-link {
    display: block;
    position: relative;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
}

.instafeed-wp-item img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.4s ease;
}

/* Grid: square images */
.instafeed-wp-grid .instafeed-wp-item:not(.instafeed-wp-highlight-main) img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.instafeed-wp-highlight-main img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    height: 100%;
}

/* --- IG Logo — absolutely positioned TOP-RIGHT over image --- */
.instafeed-wp-ig-logo {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    pointer-events: none;
    opacity: 0.3;
    color: #fff;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.instafeed-wp-item:hover .instafeed-wp-ig-logo {
    opacity: 0.7;
}

/* --- Carousel Badge — TOP-LEFT multi-image indicator --- */
.instafeed-wp-carousel-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    pointer-events: none;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* --- Dark overlay on hover --- */
.instafeed-wp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 2;
    pointer-events: none;
    transition: background 0.35s ease;
}
.instafeed-wp-item:hover .instafeed-wp-overlay {
    background: rgba(0, 0, 0, 0.25);
}
.instafeed-wp-item:hover img {
    transform: scale(1.04);
}

/* --- Load More --- */
.instafeed-wp-load-more-wrap {
    text-align: center;
    margin-top: 24px;
}
.instafeed-wp-load-more {
    display: inline-block;
    padding: 12px 32px;
    background: #262626;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.instafeed-wp-load-more:hover { background: #444; }
.instafeed-wp-load-more:disabled { opacity: 0.5; cursor: not-allowed; }

.instafeed-wp-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #ddd;
    border-top-color: #262626;
    border-radius: 50%;
    animation: instafeed-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}
@keyframes instafeed-spin { to { transform: rotate(360deg); } }

/* ============================================================
   LIGHTBOX
   ============================================================ */
.instafeed-wp-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
}
.instafeed-wp-lightbox.active {
    display: flex;
}

/* Dark background */
.instafeed-wp-lightbox-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.92);
}

/* Content wrapper */
.instafeed-wp-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Image wrapper — this is the positioning parent for arrows */
.instafeed-wp-lightbox-img-wrap {
    position: relative;
    max-width: 90vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.instafeed-wp-lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* Animations */
.instafeed-wp-lightbox[data-animation="fade"] .instafeed-wp-lightbox-content {
    animation: instafeed-lb-fade 0.3s ease;
}
.instafeed-wp-lightbox[data-animation="slide"] .instafeed-wp-lightbox-content {
    animation: instafeed-lb-slide 0.3s ease;
}
.instafeed-wp-lightbox[data-animation="zoom"] .instafeed-wp-lightbox-content {
    animation: instafeed-lb-zoom 0.3s ease;
}
@keyframes instafeed-lb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes instafeed-lb-slide { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes instafeed-lb-zoom { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* --- Close button (top-right of content) --- */
.instafeed-wp-lightbox-close {
    position: absolute;
    top: -48px;
    right: -8px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    line-height: 1;
    padding: 4px;
    z-index: 20;
}
.instafeed-wp-lightbox-close:hover { opacity: 1; }

/* --- Prev / Next arrows — INSIDE the image wrapper --- */
.instafeed-wp-lightbox-prev,
.instafeed-wp-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0.85;
}
.instafeed-wp-lightbox-prev:hover,
.instafeed-wp-lightbox-next:hover {
    background: rgba(0, 0, 0, 0.8);
    opacity: 1;
}
.instafeed-wp-lightbox-prev { left: 12px; }
.instafeed-wp-lightbox-next { right: 12px; }

/* --- Carousel dots --- */
.instafeed-wp-lightbox-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
    min-height: 10px;
}
.instafeed-wp-lightbox-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}
.instafeed-wp-lightbox-dot.active {
    background: #fff;
    transform: scale(1.25);
}
.instafeed-wp-lightbox-dot:hover {
    background: rgba(255, 255, 255, 0.7);
}

/* --- Caption — WHITE box, BLACK text --- */
.instafeed-wp-lightbox-caption {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 12px;
    max-width: 700px;
    text-align: center;
    padding: 10px 20px;
    border-radius: 6px;
    max-height: 80px;
    overflow: hidden;
}
.instafeed-wp-lightbox-caption:empty {
    display: none;
}

/* --- View on Instagram icon --- */
.instafeed-wp-lightbox-link {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    opacity: 0.75;
    transition: opacity 0.2s, transform 0.2s;
}
.instafeed-wp-lightbox-link:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .instafeed-wp-grid {
        grid-template-columns: repeat(min(var(--instafeed-columns, 3), 3), 1fr) !important;
    }
    .instafeed-wp-masonry {
        column-count: min(var(--instafeed-columns, 3), 3) !important;
    }
    .instafeed-wp-carousel-items .instafeed-wp-item {
        flex: 0 0 calc(50% - 4px);
    }
}

@media (max-width: 768px) {
    .instafeed-wp-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .instafeed-wp-masonry {
        column-count: 2 !important;
    }
    .instafeed-wp-layout-highlight .instafeed-wp-highlight-main {
        grid-column: span 2;
        grid-row: span 1;
    }
    .instafeed-wp-lightbox-prev,
    .instafeed-wp-lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
    .instafeed-wp-lightbox-prev { left: 6px; }
    .instafeed-wp-lightbox-next { right: 6px; }
}

@media (max-width: 480px) {
    .instafeed-wp-grid {
        grid-template-columns: 1fr !important;
    }
    .instafeed-wp-masonry {
        column-count: 1 !important;
    }
    .instafeed-wp-carousel-items .instafeed-wp-item {
        flex: 0 0 100%;
    }
    .instafeed-wp-layout-highlight .instafeed-wp-highlight-main {
        grid-column: span 1;
    }
}
