// Instagram Feed — frontend (Template-style header + grid / carousel / masonry)

.wp-block-ask-instagram-feed {
    box-sizing: border-box;

    .ask-instagram-feed {
        width: 100%;
        max-width: 100%;
    }
}

.ask-instagram-feed {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;

    .ask-ig-header {
        margin-bottom: 24px;
        padding-bottom: 20px;
        border-bottom: 1px solid #efefef;
    }

    .ask-ig-header-main {
        display: flex;
        align-items: flex-start;
        gap: 20px;
        flex-wrap: wrap;
    }

    .ask-ig-header-avatar {
        width: 88px;
        height: 88px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
        border: 2px solid #f0f0f0;
    }

    .ask-ig-header-avatar--placeholder {
        background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af);
        opacity: 0.35;
    }

    .ask-ig-header-text {
        flex: 1;
        min-width: 200px;
    }

    .ask-ig-header-username {
        font-size: 20px;
        font-weight: 600;
        margin-bottom: 4px;
    }

    .ask-ig-header-name {
        font-size: 15px;
        font-weight: 500;
        margin-bottom: 10px;
        opacity: 0.9;
    }

    .ask-ig-header-stats {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        font-size: 14px;
        margin-bottom: 12px;

        strong {
            font-weight: 600;
        }
    }

    .ask-ig-header-bio {
        font-size: 14px;
        line-height: 1.5;
        margin: 0 0 14px;
        max-width: 520px;
    }

    .ask-ig-follow-btn {
        display: inline-block;
        padding: 8px 22px;
        border-radius: 8px;
        background: linear-gradient(90deg, #f58529, #dd2a7b 55%, #8134af);
        color: #fff !important;
        text-decoration: none !important;
        font-size: 14px;
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(221, 42, 123, 0.25);
        transition: transform 0.2s ease, box-shadow 0.2s ease;

        &:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 14px rgba(221, 42, 123, 0.35);
        }
    }

    .ask-ig-grid {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .ask-ig-masonry {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;

        .ask-ig-card {
            break-inside: avoid;
            margin-bottom: var(--ask-ig-masonry-gap, 16px);
        }
    }

    .ask-ig-card {
        overflow: hidden;
        border: 1px solid #ececec;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
        transition: transform 0.25s ease, box-shadow 0.25s ease;

        &:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
        }
    }

    .ask-ig-media-link {
        display: block;
        text-decoration: none;
        color: inherit;
    }

    .ask-ig-image-wrap {
        position: relative;
        width: 100%;
        aspect-ratio: 1 / 1;
        background: #f4f4f4;
        overflow: hidden;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            transition: transform 0.35s ease;
        }

        &:hover img {
            transform: scale(1.04);
        }
    }

    .ask-ig-image-placeholder {
        aspect-ratio: 1 / 1;
        background: #eee;
    }

    .ask-ig-badge {
        position: absolute;
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.55);
        color: #fff;
        font-size: 12px;
        padding: 4px 8px;
        border-radius: 6px;
        line-height: 1;
    }

    .ask-ig-card-body {
        box-sizing: border-box;
    }

    .ask-ig-caption {
        margin: 0 0 8px;
        line-height: 1.45;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .ask-ig-stats {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        align-items: center;
    }

    .ask-ig-stat {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .ask-ig-loadmore-wrap {
        text-align: center;
        margin-top: 24px;
    }

    .ask-ig-load-more {
        display: inline-block;
        padding: 10px 28px;
        border-radius: 8px;
        border: 1px solid #dbdbdb;
        background: #fafafa;
        color: #262626;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.2s ease, border-color 0.2s ease;

        &:hover {
            background: #fff;
            border-color: #c7c7c7;
        }
    }

    &.ask-layout-carousel {
        /* Exact column widths (matches editor); avoids Swiper fractional slides showing a “peek” of the next column */
        .ask-ig-swiper {
            box-sizing: border-box;
            width: 100%;
            max-width: 100%;
            margin-left: auto;
            margin-right: auto;
            overflow: hidden;
        }

        .swiper-wrapper {
            align-items: stretch;
        }

        .swiper-slide {
            height: auto;
            display: flex;
            box-sizing: border-box;
            width: 100% !important;
            flex-shrink: 0;
        }

        /* Gaps between slides (spaceBetween: 0 in JS so widths match this math exactly) */
        .swiper-slide:not(:last-child) {
            margin-right: var(--ask-ig-gap, 16px) !important;
        }

        @media (min-width: 768px) and (max-width: 1023px) {
            .swiper-slide {
                width: calc((100% - var(--ask-ig-gap, 16px)) / 2) !important;
            }
        }

        @media (min-width: 1024px) {
            .swiper-slide {
                width: calc(
                    (100% - (var(--ask-ig-gap, 16px) * (var(--ask-ig-cols, 3) - 1))) / var(--ask-ig-cols, 3)
                ) !important;
            }
        }

        .ask-ig-slide-inner {
            display: flex;
            flex-direction: column;
            min-height: 0;
            min-width: 0;
            box-sizing: border-box;
        }

        .ask-ig-card {
            width: 100%;
            height: 100%;
            min-width: 0;
            display: flex;
            flex-direction: column;
            flex: 1;

            .ask-ig-media-link {
                flex-shrink: 0;
            }

            .ask-ig-image-wrap {
                flex: 0 0 auto;
            }

            .ask-ig-card-body {
                flex: 1;
                display: flex;
                flex-direction: column;
                min-height: 0;
            }

            .ask-ig-caption {
                flex: 1;
            }
        }

        .swiper-pagination {
            bottom: 10px !important;
            left: 0;
            width: 100%;
        }

        .swiper-pagination-bullet {
            width: 8px;
            height: 8px;
            background: #c7c7c7;
            opacity: 1;
        }

        .swiper-pagination-bullet-active {
            background: #e1306c;
        }
    }
}

.ask-instagram-feed .ask-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;

    .spinner {
        display: inline-block;
        width: 20px;
        height: 20px;
        margin-right: 10px;
        vertical-align: middle;
    }
}

.ask-instagram-feed .ask-no-posts,
.ask-instagram-feed .ask-error {
    text-align: center;
    padding: 28px 16px;
    border-radius: 8px;
    background: #f9f9f9;
    color: #555;
    border: 1px dashed #ddd;
}

.ask-instagram-feed .ask-error {
    background: #fff5f5;
    border-color: #fcc;
    color: #c33;
}

@media (max-width: 600px) {
    .ask-instagram-feed {
        .ask-ig-header-stats {
            flex-direction: column;
            gap: 8px;
        }

        .ask-ig-grid {
            grid-template-columns: repeat(2, 1fr) !important;
        }

        .ask-ig-masonry {
            column-count: 2 !important;
        }
    }
}
