.posts {
    display: grid;
    gap: 1rem;
    /* Definiujemy szablon wierszy jako powtarzalny wzór */
    grid-template-columns: repeat(1, 1fr);
    grid-template-rows: repeat(auto-fill, repeat(1, 1fr));
}




.post:nth-child(3n+1) {
    background-color: var(--background);
}

.post:nth-child(3n+2) {
    background-color: var(--secondary);
}

.post:nth-child(3n+3) {
    background-color: var(--quaternary);
}






.post {
    background-color: var(--background);
    border-radius: 30px;
    overflow: hidden;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

}

.post:hover {
    box-shadow: var(--box-shadow);
}

.post__content {
    height: 100%;
    padding: 1rem 0.75rem;
    gap: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.post__link {
    display: grid;
    grid-template-columns: 1fr 1fr;
    transition: var(--transition);

}

.post__link:hover{
    transform: scale(1.1);

}



.post .post__img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    object-position: right top;
}

.post__title {
    margin: 0;
    padding: 0;
    color: var(--black);
    font-size: 0.825rem;
}


.post__taxonomy {
    background: var(--white);
    border-radius: 30px;
    padding: 0.15rem 0.5rem;
    display: inline-flex;
    font-size: 0.825rem;
    color: var(--black);
    gap: 0.25rem;
    line-height: 1rem;
    display: flex;
    align-items: center;
    margin:0;
}

.post__taxonomy .post__icon {
    align-items: center;
    padding: 0.1rem;
    width: 0.825rem;
    height: 0.825rem;
    margin-top: -2px;
}



.post__more {
    background-color: var(--white);
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 0.33rem 1rem;
    border-radius: 30px;
    color: var(--black);
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.post__more .icon {
    display: flex;
    width: 0.75rem;
    height: 0.75rem;
}


.posts__notfound {
    text-align: center;
    color: var(--primary);
}

@media screen and (min-width:668px) {
    .posts {
        gap: 2rem;
        /* Definiujemy szablon wierszy jako powtarzalny wzór */
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(auto-fill, repeat(2, 1fr));


    }



    .post__link {
        display: flex;
        flex-direction: column-reverse;
        height: 100%;
    }

    .post .post__img {
        object-fit: contain;
    }

}

@media screen and (min-width:1400px) {
    .posts {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(auto-fill, repeat(4, 1fr));

    }



    /* Ustawiamy zmienne dla poszczególnych cykli */
    .posts>.post:nth-child(n+1):nth-child(-n+8) {
        --n: 0;
    }

    .posts>.post:nth-child(n+9):nth-child(-n+16) {
        --n: 1;
    }

    .posts>.post:nth-child(n+17):nth-child(-n+24) {
        --n: 2;
    }

    .posts>.post:nth-child(n+25):nth-child(-n+32) {
        --n: 3;
    }

    .posts>.post:nth-child(n+33):nth-child(-n+40) {
        --n: 4;
    }

    .posts>.post:nth-child(n+49):nth-child(-n+48) {
        --n: 5;
    }

    .posts>.post:nth-child(n+57):nth-child(-n+56) {
        --n: 6;
    }

    .posts>.post:nth-child(n+65):nth-child(-n+64) {
        --n: 7;
    }

    /* i tak dalej dla większej liczby cykli */



    /* Użycie właściwości calc() do obliczenia pozycji wierszy */
    .posts>.post:nth-child(8n+1) {
        grid-area: calc(4 * var(--n, 0) + 1) / 1 / calc(4 * var(--n, 0) + 2) / 3;
    }

    .posts>.post:nth-child(8n+2) {
        grid-area: calc(4 * var(--n, 0) + 2) / 1 / calc(4 * var(--n, 0) + 3) / 3;
    }

    .posts>.post:nth-child(8n+3) {
        grid-area: calc(4 * var(--n, 0) + 1) / 3 / calc(4 * var(--n, 0) + 3) / 4;
    }

    .posts>.post:nth-child(8n+4) {
        grid-area: calc(4 * var(--n, 0) + 1) / 4 / calc(4 * var(--n, 0) + 3) / 5;
    }

    .posts>.post:nth-child(8n+5) {
        grid-area: calc(4 * var(--n, 0) + 3) / 1 / calc(4 * var(--n, 0) + 5) / 2;
    }

    .posts>.post:nth-child(8n+6) {
        grid-area: calc(4 * var(--n, 0) + 3) / 2 / calc(4 * var(--n, 0) + 5) / 3;
    }

    .posts>.post:nth-child(8n+7) {
        grid-area: calc(4 * var(--n, 0) + 3) / 3 / calc(4 * var(--n, 0) + 4) / 5;
    }

    .posts>.post:nth-child(8n+8) {
        grid-area: calc(4 * var(--n, 0) + 4) / 3 / calc(4 * var(--n, 0) + 5) / 5;
    }


    .posts>.post:nth-child(8n+3) .post__link,
    .posts>.post:nth-child(8n+4) .post__link,
    .posts>.post:nth-child(8n+5) .post__link,
    .posts>.post:nth-child(8n+6) .post__link {
        display: flex;
        flex-direction: column-reverse;
        height: 100%;
    }

    .post__link {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .post .post__img {
        height: 200px;
        object-fit: cover;
    }
}