:root {
    --post-max-height: 628px;
}

@media screen and (max-width: 50em) {
    :root {
        --post-max-height: 350px;
    }
}

@media screen and (max-width: 40em) {
    :root {
        --post-max-height: 250px;
    }
}

#fb-posts-container {
    margin-bottom: 3em;
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.fb-post {
    border: 1px solid #ddd;
    padding: 15px;
    background-color: var(--color-bg-info);
    color: var(--color-text-primary);
    width: min(80%, 716px);
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-radius: 0.25em;
    box-shadow: 0 3px 0 var(--color-border-info);
}

.post-date {
    font-size: 0.9rem;
    opacity: .8;
}

.post-text {
    width: 100%;
    font-size: 1rem;
}

.post-content {
    display: flex;
    flex-wrap: wrap;
    height: var(--post-max-height); /* Use CSS variable */
    gap: 3px;
    overflow: hidden;
}

/* display 50/50 if there is only two images */
.post-gallery:has(img:first-child:nth-last-child(1)) {
    flex: 2 !important;
}
.post-gallery img:first-child:nth-last-child(1)
{
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: auto;
}

.post-image {
    flex: 2;
    height: 100%;
    overflow: hidden;
    position: relative; /* For absolute positioning of images */
    display: flex;
    align-content: center;
}

.post-gallery {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    height: 100%;
    overflow: hidden;
}

.post-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: auto;
    cursor: pointer;
}

.post-gallery img {
    flex: 1;
    width: 100%;
    min-height: 0;
    object-fit: cover;
    cursor: pointer;
}

/* Add this new container for the last image + overlay */
.more-images-container {
    position: relative;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

/* Make more-images an absolute overlay */
.more-images {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-weight: bold;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

/* Ensure the image fills its container */
.more-images-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* For expanded gallery */
.post-gallery.show-all .more-images-container {
    position: relative;
    flex: 1;
}

.post-gallery.show-all .more-images {
    display: none;
}
