/**
 * Social Posts Display Styles
 * Supports grid, carousel, and masonry layouts
 */

/* ========================================
   Base Wrapper Styles
   ======================================== */
.wp-block-atk-social-posts {
    overflow: hidden;
}

.social-posts-wrapper {
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* ========================================
   Empty State / No Posts
   ======================================== */
.social-posts-empty {
    text-align: center;
    padding: 60px 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px dashed #ddd;
}

.social-posts-no-posts {
    margin: 0;
    font-size: 18px;
    color: #666;
    font-weight: 500;
}

/* ========================================
   Card Styles (shared across all layouts)
   ======================================== */
.social-post-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.social-post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Image Container */
.social-post-image {
    position: relative;
    /* 4:5 aspect ratio is better for social content (Instagram default)
       Less aggressive cropping than 1:1 for landscape images,
       better for portrait content and faces */
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: #f5f5f5;
}

.social-post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Center the crop point - good for faces/subjects */
    object-position: center center;
    transition: transform 0.3s ease;
}

.social-post-card:hover .social-post-image img {
    transform: scale(1.05);
}

.social-post-image a {
    display: block;
    width: 100%;
    height: 100%;
}

/* Logo Fallback Styling
   When no social image exists and we fall back to the site logo,
   use object-fit: contain to show the full logo without cropping,
   centered on a subtle background */
.social-post-image--logo-fallback {
    /* Slightly different background to look intentional */
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-post-image--logo-fallback img {
    /* Show full logo without cropping */
    object-fit: contain;
    /* Add padding so logo doesn't touch edges */
    padding: 20%;
    /* Don't scale up on hover - looks odd for logos */
    transition: opacity 0.3s ease;
}

.social-post-card:hover .social-post-image--logo-fallback img {
    /* Override the scale transform for logo fallbacks */
    transform: none;
    opacity: 0.85;
}

/* Video Icon Overlay */
.social-post-video-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    padding: 12px;
    color: #fff;
    opacity: 0.9;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.social-post-card:hover .social-post-video-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.social-post-video-icon svg {
    display: block;
}

/* Caption */
.social-post-caption {
    padding: 12px 16px;
    min-height: 60px;
    flex: 1;
}

.social-post-caption p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Meta Bar */
.social-post-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

/* Source Icon */
.social-post-source {
    display: flex;
    align-items: center;
    color: #666;
}

.social-post-source-instagram {
    color: #E4405F;
}

.social-post-source-facebook {
    color: #1877F2;
}

.social-post-source svg {
    display: block;
}

/* Engagement Stats */
.social-post-engagement {
    display: flex;
    align-items: center;
    gap: 12px;
}

.social-post-likes,
.social-post-comments {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #666;
}

.social-post-likes svg,
.social-post-comments svg {
    display: block;
    color: #999;
}

/* External Link */
.social-post-link {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease, background 0.2s ease;
}

.social-post-link:hover {
    color: #0073aa;
    background: #e6f3ff;
}

.social-post-link svg {
    display: block;
}

/* ========================================
   Grid Layout
   ======================================== */
.social-posts-grid {
    display: grid;
    gap: 24px;
}

.social-posts-grid.social-posts-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.social-posts-grid.social-posts-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.social-posts-grid.social-posts-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.social-posts-grid.social-posts-columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.social-posts-grid.social-posts-columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* ========================================
   Masonry Layout
   ======================================== */
.social-posts-masonry {
    column-gap: 24px;
}

.social-posts-masonry.social-posts-columns-2 {
    column-count: 2;
}

.social-posts-masonry.social-posts-columns-3 {
    column-count: 3;
}

.social-posts-masonry.social-posts-columns-4 {
    column-count: 4;
}

.social-posts-masonry.social-posts-columns-5 {
    column-count: 5;
}

.social-posts-masonry.social-posts-columns-6 {
    column-count: 6;
}

.social-posts-masonry .social-post-card {
    break-inside: avoid;
    margin-bottom: 24px;
}

/* Masonry cards don't need fixed aspect ratio */
.social-posts-masonry .social-post-image {
    aspect-ratio: unset;
}

.social-posts-masonry .social-post-image img {
    height: auto;
}

/* ========================================
   Carousel Layout
   ======================================== */
.social-posts-carousel {
    position: relative;
}

.social-posts-carousel .swiper {
    overflow: hidden;
    padding: 10px 0;
}

.social-posts-carousel .swiper-slide {
    height: auto;
}

/* Bottom Navigation Container */
.social-posts-carousel-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

/* Navigation Buttons */
.social-posts-carousel .swiper-button-prev,
.social-posts-carousel .swiper-button-next {
    position: static;
    width: 40px;
    height: 40px;
    margin: 0;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.social-posts-carousel .swiper-button-prev:hover,
.social-posts-carousel .swiper-button-next:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.social-posts-carousel .swiper-button-prev::after,
.social-posts-carousel .swiper-button-next::after {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

/* Pagination */
.social-posts-carousel .swiper-pagination {
    position: static;
    width: auto;
}

.social-posts-carousel .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: #ddd;
    opacity: 1;
    transition: background 0.2s ease, transform 0.2s ease;
}

.social-posts-carousel .swiper-pagination-bullet-active {
    background: #0073aa;
    transform: scale(1.2);
}

/* ========================================
   Responsive Breakpoints
   ======================================== */
@media (max-width: 1024px) {
    .social-posts-grid.social-posts-columns-4,
    .social-posts-grid.social-posts-columns-5,
    .social-posts-grid.social-posts-columns-6 {
        grid-template-columns: repeat(3, 1fr);
    }

    .social-posts-masonry.social-posts-columns-4,
    .social-posts-masonry.social-posts-columns-5,
    .social-posts-masonry.social-posts-columns-6 {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .social-posts-grid.social-posts-columns-3,
    .social-posts-grid.social-posts-columns-4,
    .social-posts-grid.social-posts-columns-5,
    .social-posts-grid.social-posts-columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .social-posts-masonry.social-posts-columns-3,
    .social-posts-masonry.social-posts-columns-4,
    .social-posts-masonry.social-posts-columns-5,
    .social-posts-masonry.social-posts-columns-6 {
        column-count: 2;
    }

    .social-posts-carousel .swiper-button-prev,
    .social-posts-carousel .swiper-button-next {
        width: 32px;
        height: 32px;
    }

    .social-posts-carousel .swiper-button-prev::after,
    .social-posts-carousel .swiper-button-next::after {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .social-posts-grid,
    .social-posts-grid.social-posts-columns-2,
    .social-posts-grid.social-posts-columns-3,
    .social-posts-grid.social-posts-columns-4,
    .social-posts-grid.social-posts-columns-5,
    .social-posts-grid.social-posts-columns-6 {
        grid-template-columns: 1fr;
    }

    .social-posts-masonry,
    .social-posts-masonry.social-posts-columns-2,
    .social-posts-masonry.social-posts-columns-3,
    .social-posts-masonry.social-posts-columns-4,
    .social-posts-masonry.social-posts-columns-5,
    .social-posts-masonry.social-posts-columns-6 {
        column-count: 1;
    }

    .social-post-caption {
        padding: 10px 12px;
    }

    .social-post-meta {
        padding: 10px 12px;
    }
}

/* ========================================
   Dark Mode Support (optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    .social-post-card {
        background: #1a1a1a;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .social-post-caption p {
        color: #e0e0e0;
    }

    .social-post-meta {
        background: #222;
        border-top-color: #333;
    }

    .social-post-likes,
    .social-post-comments,
    .social-post-source {
        color: #aaa;
    }

    .social-post-link {
        color: #aaa;
    }

    .social-post-link:hover {
        background: #333;
        color: #4fc3f7;
    }

    .social-posts-carousel .swiper-button-prev,
    .social-posts-carousel .swiper-button-next {
        background: #333;
    }

    .social-posts-carousel .swiper-button-prev::after,
    .social-posts-carousel .swiper-button-next::after {
        color: #fff;
    }

    .social-posts-carousel .swiper-pagination-bullet {
        background: #555;
    }

    .social-posts-carousel .swiper-pagination-bullet-active {
        background: #4fc3f7;
    }

    /* Logo fallback dark mode */
    .social-post-image--logo-fallback {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    }
}
