.social-media-grid {
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 3px;
    margin-top: 12px;
    overflow: hidden;
    border-radius: 8px;
    background: #eef1f4;
}

.social-media-grid--single {
    display: flex;
    min-height: 180px;
    max-height: 560px;
    align-items: center;
    justify-content: center;
}

.social-media-grid--two,
.social-media-grid--three,
.social-media-grid--four {
    height: clamp(260px, 50vw, 420px);
}

.social-media-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
}

.social-media-grid--three {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
}

.social-media-grid--three .social-media-cell:first-child {
    grid-row: 1 / 3;
}

.social-media-grid--four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
}

.social-media-cell,
.post-image-slide {
    position: relative;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #eef1f4;
    color: inherit;
    cursor: zoom-in;
}

.social-media-cell {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.social-media-grid--single .social-media-cell {
    height: auto;
    min-height: 180px;
    max-height: 560px;
}

.social-media-image {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: cover;
    transition: transform 180ms ease;
}

.social-media-grid--single .social-media-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 560px;
    object-fit: contain;
}

.social-media-cell:hover .social-media-image {
    transform: scale(1.015);
}

.social-media-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.58);
    color: #fff;
    font-size: 1.75rem;
    font-weight: 800;
}

.social-media-fallback {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: #6b7280;
    font-size: 0.85rem;
    text-align: center;
}

.social-media-fallback i {
    font-size: 1.4rem;
}

.social-media-cell.is-error .social-media-image,
.post-image-slide.is-error .post-image-gallery-img {
    display: none;
}

.social-media-cell.is-error .social-media-fallback,
.post-image-slide.is-error .social-media-fallback {
    display: flex;
}

.post-image-gallery {
    position: relative;
    width: 100%;
    min-width: 0;
    margin-top: 14px;
}

.post-image-slider {
    display: flex;
    width: 100%;
    min-width: 0;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
}

.post-image-slider::-webkit-scrollbar {
    display: none;
}

.post-image-slide {
    display: flex;
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 500px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.post-image-slider .post-image-gallery-img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    flex: none !important;
    object-fit: contain !important;
    scroll-snap-align: none !important;
}

.post-image-gallery-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0;
    transform: translateY(-50%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.68);
    color: #fff;
    cursor: pointer;
}

.post-image-gallery-nav--prev {
    left: 10px;
}

.post-image-gallery-nav--next {
    right: 10px;
}

.post-image-gallery-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.post-image-gallery-counter {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.72);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.post-image-gallery--single .post-image-gallery-nav,
.post-image-gallery--single .post-image-gallery-counter {
    display: none;
}

@media (max-width: 640px) {
    .social-media-grid--single {
        min-height: 150px;
        max-height: 480px;
    }

    .social-media-grid--single .social-media-cell {
        min-height: 150px;
        max-height: 480px;
    }

    .social-media-grid--single .social-media-image {
        max-height: 480px;
    }

    .social-media-grid--two,
    .social-media-grid--three,
    .social-media-grid--four {
        height: 280px;
    }

    .post-image-gallery-nav {
        width: 34px;
        height: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .social-media-image,
    .post-image-slider {
        transition: none;
        scroll-behavior: auto;
    }
}
