/**
 * Public Instagram Feed Widget - Frontend Styles
 *
 * @package PublicInstagramFeedWidget
 * @version 1.1.0
 */

/* =========================================================================
   Container
   ========================================================================= */

.pifw-container {
    margin: 1.5em 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* =========================================================================
   Grid Layout
   ========================================================================= */

.pifw-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.pifw-item {
    display: block;
    text-decoration: none;
    overflow: hidden;
    position: relative;
    aspect-ratio: 1 / 1;
    background: #fafafa;
    border-radius: 2px;
}

.pifw-image-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.pifw-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease, opacity 0.35s ease;
}

.pifw-item:hover .pifw-image,
.pifw-carousel-item:hover .pifw-image {
    transform: scale(1.05);
    opacity: 0.85;
}

/* =========================================================================
   Overlay (hover)
   ========================================================================= */

.pifw-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pifw-item:hover .pifw-overlay,
.pifw-carousel-item:hover .pifw-overlay {
    opacity: 1;
}

.pifw-icon {
    width: 28px;
    height: 28px;
    color: #fff;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

/* =========================================================================
   Caption Preview
   ========================================================================= */

.pifw-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 10px 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pifw-item:hover .pifw-caption,
.pifw-carousel-item:hover .pifw-caption {
    opacity: 1;
}

.pifw-caption p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: #fff;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* =========================================================================
   Footer / CTA Button
   ========================================================================= */

.pifw-footer {
    text-align: center;
    margin-top: 16px;
}

.pifw-btn {
    display: inline-block;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #405DE6, #5851DB, #833AB4, #C13584, #E1306C, #FD1D1D, #F56040, #F77737, #FCAF45);
    background-size: 200% 200%;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.25s ease, transform 0.2s ease;
    line-height: 1.4;
}

.pifw-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

.pifw-btn:active {
    transform: translateY(0);
}

/* =========================================================================
   Carousel Layout
   ========================================================================= */

.pifw-carousel-wrapper {
    position: relative;
    overflow: hidden;
}

.pifw-carousel-track {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
}

.pifw-carousel-track::-webkit-scrollbar {
    display: none;
}

.pifw-carousel-item {
    flex: 0 0 calc(33.333% - 3px);
    scroll-snap-align: start;
    display: block;
    text-decoration: none;
    position: relative;
    aspect-ratio: 1 / 1;
    background: #fafafa;
    border-radius: 2px;
    overflow: hidden;
}

.pifw-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: #262626;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.pifw-carousel-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pifw-carousel-prev { left: 8px; }
.pifw-carousel-next { right: 8px; }

/* =========================================================================
   Embed Iframe
   ========================================================================= */

.pifw-embed-wrapper {
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
    border-radius: 8px;
}

.pifw-embed-iframe {
    display: block;
    width: 100%;
    height: 480px; /* initial compact height, JS will auto-resize */
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    background: #fafafa;
    overflow: hidden;
    max-width: 100%;
    transition: height 0.3s ease;
}

/* =========================================================================
   Fallback
   ========================================================================= */

.pifw-fallback {
    text-align: center;
    padding: 40px 20px;
    border: 1px dashed #dbdbdb;
    border-radius: 8px;
    background: #fafafa;
}

.pifw-fallback-inner {
    max-width: 360px;
    margin: 0 auto;
}

.pifw-fallback-icon {
    width: 48px;
    height: 48px;
    color: #8e8e8e;
    margin-bottom: 16px;
}

.pifw-fallback-text {
    font-size: 14px;
    color: #8e8e8e;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* =========================================================================
   Notice
   ========================================================================= */

.pifw-notice {
    padding: 12px 16px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    font-size: 14px;
    color: #856404;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 768px) {
    .pifw-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }

    .pifw-carousel-item {
        flex: 0 0 calc(50% - 2px);
    }

    .pifw-carousel-btn {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }

    .pifw-embed-wrapper {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .pifw-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2px;
    }

    .pifw-carousel-item {
        flex: 0 0 calc(80% - 2px);
    }

    .pifw-caption {
        display: none;
    }
}
