/* Gallery styles */
.post-main-image {
    float: right;
    width: 50%;
    max-width: 500px;
    margin: 0 0 var(--spacing-md) var(--spacing-md);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.excerpt-content .post-main-image {
    float: left;
    width: 50%;
    max-width: 300px;
    margin: 0 var(--spacing-md) var(--spacing-xs) 0;
}

.post-gallery {
    margin-top: var(--spacing-lg);
    display: grid;
    gap: var(--spacing-md);
    width: 100%;
}

.gallery-single { grid-template-columns: 1fr; }
.gallery-two { 
    display: flex;
    gap: var(--spacing-md);
}
.gallery-two .gallery-image {
    width: calc(50% - var(--spacing-md) / 2);
    height: auto;
}
.gallery-three { grid-template-columns: repeat(3, 1fr); }
.gallery-four { grid-template-columns: repeat(4, 1fr); }

.gallery-feature-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.gallery-feature-grid .gallery-image:first-child {
    grid-column: span 2;
    grid-row: span 2;
}

.gallery-quad { grid-template-columns: repeat(4, 1fr); }
.gallery-triple { grid-template-columns: repeat(3, 1fr); }

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: block;
}

.post-main-image {
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: block;
    /* Az első definícióból megtartjuk a float, width, max-width tulajdonságokat */
}

.gallery-image:hover,
.post-main-image:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.post-card.animate-left .gallery-image,
.post-card.animate-right .gallery-image,
.post-card.animate-left .post-main-image,
.post-card.animate-right .post-main-image {
    animation: buildImage 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: 0.3s;
}

.post-card.animate-left .gallery-image:nth-child(2),
.post-card.animate-right .gallery-image:nth-child(2) {
    animation-delay: 0.4s;
}
.post-card.animate-left .gallery-image:nth-child(3),
.post-card.animate-right .gallery-image:nth-child(3) {
    animation-delay: 0.5s;
}
.post-card.animate-left .gallery-image:nth-child(4),
.post-card.animate-right .gallery-image:nth-child(4) {
    animation-delay: 0.6s;
}
.post-card.animate-left .gallery-image:nth-child(n+5),
.post-card.animate-right .gallery-image:nth-child(n+5) {
    animation-delay: 0.7s;
}

.gallery-rectangle { aspect-ratio: 16/9; }
.gallery-square { aspect-ratio: 1/1; }

.excerpt-content .post-gallery { display: none; }

/* Új CSS az első fotó és szöveg közös elrendezéséhez */
.content-with-first-image {
    position: relative;
    overflow: hidden; /* clearfix a float-hoz */
}

.content-with-first-image::after {
    content: "";
    display: table;
    clear: both;
}

.content-text {
    line-height: 1.8;
    text-align: justify;
}

.content-with-first-image .post-main-image {
    height: auto; /* Az arányok megtartása */
}

/* Desktop csak: fejléc háttér esetén eltérő kezelés */
@media (min-width: 769px) {
    .content-with-first-image .image-container.header-media-container {
        float: right;
        width: 50%;
        max-width: 500px;
        margin: 0 0 var(--spacing-md) var(--spacing-md);
    }

    .content-with-first-image .image-container.header-media-container .post-main-image {
        float: none;
        width: 100%;
        max-width: none;
        margin: 0;
    }
    
    /* Fejléc háttér esetén teljes szélességű, gap nélküli média stack */
    .post-card.is-header-background .post-gallery {
        margin-top: 0;
        gap: 0;
        display: block;
    }
    
    .post-card.is-header-background .header-media-wrapper {
        position: relative;
        width: 100%;
        display: block;
        overflow: hidden;
    }
    
    .post-card.is-header-background .post-gallery .gallery-image,
    .post-card.is-header-background .post-gallery .gallery-video {
        width: 100%;
        border-radius: 0;
        margin: 0;
        display: block;
        height: auto;
        aspect-ratio: unset;
    }
    
    .post-card.is-header-background .post-gallery .gallery-video video {
        border-radius: 0;
        width: 100%;
        height: auto;
        object-fit: cover;
    }
    
    .post-card.is-header-background .post-main-image {
        border-radius: 0;
        width: 100%;
        max-width: none;
        margin: 0;
        float: none;
        display: block;
    }
    
    .post-card.is-header-background .content-with-first-image .post-main-image {
        float: none;
        width: 100%;
        max-width: none;
        margin: 0;
    }
}

/* Mobil nézet - stack elrendezés */
@media (max-width: 768px) {
    .post-main-image {
        margin: 0 0 var(--spacing-md) var(--spacing-md);
    }
    
    .gallery-four,
    .gallery-feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .gallery-three {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .gallery-two {
        flex-direction: row;
    }

    .content-with-first-image .post-main-image {
        float: none;
        width: 100%;
        max-width: none;
        margin: 0 0 var(--spacing-md) 0;
        display: block;
    }
    
    .content-text {
        clear: both;
    }
    
    /* Mobil nézetben is fejléc háttér specifikus stílusok */
    .post-card.is-header-background .post-gallery {
        margin-top: 0;
        gap: 0;
    }
    
    .post-card.is-header-background .header-media-wrapper {
        position: relative;
        width: 100%;
        display: block;
        overflow: hidden;
    }
    
    .post-card.is-header-background .content-with-first-image .post-main-image {
        margin: 0;
        width: 125%;
        margin-left: -12.5%;
    }
}

@media (max-width: 480px) {
    .excerpt-content .content-wrapper {
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-md);
    }

    .excerpt-content .post-main-image {
        flex: 0 0 300px;
        float: none;
        margin: 0;
    }

    .excerpt-content .text-content {
        flex: 1;
        min-width: 200px;
    }
    
    .gallery-two {
        flex-direction: column;
    }
    
    .gallery-two .gallery-image {
        width: 100%;
    }
    
    .gallery-three,
    .gallery-four,
    .gallery-feature-grid {
        grid-template-columns: 1fr;
    }
    
    .gallery-feature-grid .gallery-image:first-child {
        grid-column: auto;
        grid-row: auto;
    }
}