@import '../../../../assets/scss/abstracts/variables';
@import '../../../../assets/scss/abstracts/mixins';

@property --sh-query-posts-author-date {syntax: "<color>";inherits: true;initial-value: #878787;}
@property --sh-query-posts-author-by {syntax: "<color>";inherits: true;initial-value: #878787;}
@property --sh-query-posts-author-separator {syntax: "<color>";inherits: true;initial-value: #878787;}
@property --sh-query-posts-description {syntax: "<color>";inherits: true;initial-value: #111111;}
@property --sh-query-posts-input-bg {syntax: "<color>"; inherits: true; initial-value: #F6F7F8;}
@property --sh-query-posts-input-border {syntax: "<color>"; inherits: true; initial-value: #E5E5E5;}
@property --sh-query-posts-input-hover {syntax: "<color>"; inherits: true; initial-value: #f75858;}
@property --sh-query-posts-input-hover-c {syntax: "<color>"; inherits: true; initial-value: #ffffff;}
@property --sh-query-posts-title {syntax: "<color>"; inherits: true; initial-value: #0160ac;}

.rdg-blocks .sh-query-posts {
    .preview-thumbs {
        background-image: url('../images/rdg-sh-query-posts-template-preview.jpg');
    }

    width: calc(var(--vw, 1vw) * 100);
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    max-width: 99.55vw;

    .container.content {
        width: 100%;
        display: flex;
        flex-direction: column;
        padding-left: 20px;
        padding-right: 20px;
        container-type: inline-size;

        @include title;

        .filter {
            display: flex;
            margin-bottom: 2rem;
            gap: 1rem;

            @media (max-width: $breakpoint-md) {
                & {
                    flex-direction: column;
                }
            }

            .search {
                width: 40%;

                @media (max-width: $breakpoint-lg) {
                    & {
                        width: 30%;
                    }
                }

                @media (max-width: $breakpoint-md) {
                    & {
                        width: 100%;
                    }
                }

                #search {
                    width: 100%;
                }
            }

            .options {
                width: 60%;
                display: flex;
                flex-wrap: wrap;
                gap: 1rem;

                @media (max-width: $breakpoint-lg) {
                    & {
                        width: 70%;
                    }
                }

                @media (max-width: $breakpoint-md) {
                    & {
                        width: 100%;
                        justify-content: center;
                    }
                }
            }

            input, select {
                margin: 0;
                border-radius: 23px;
                height: 46px;
                box-sizing: border-box;
                border: 1px solid var(--sh-query-posts-input-border);
                background-color: var(--sh-query-posts-input-bg);
            }

            input {
                padding: 12px 20px;
            }
        }

        .results {
            display: flex;
            flex-wrap: wrap;
            gap: .3rem;
            margin-bottom: 1.2rem;

            a {
                padding: .3rem .7rem;
                border-radius: 23px;
                border: 1px solid var(--sh-query-posts-input-border);
                transition: .2s all;
                color: var(--color-black);

                &:hover {
                    background-color: var(--sh-query-posts-input-hover);
                    color: var(--sh-query-posts-input-hover-c);
                    cursor: pointer;
                }
            }
        }

        .container-query-posts {
            width: 100%;
            display: flex;
            gap: 25px;

            @container (max-width: 992px) {
                & {
                    gap: 15px;
                }
            }

            @container (max-width: 768px) {
                & {
                    flex-direction: column;
                }
            }

            a {
                color: var(--color-primary-dark-light);

                &:hover {
                    color: var(--color-primary);
                }
            }

            .query-post {
                position: relative;

                .post-link {
                    height: 100%;
                    position: absolute;
                    width: 100%;
                    z-index: 2;
                }

                .post-image {
                    img {
                        width: 100%;
                        height: 500px;
                        object-fit: cover;
                        object-position: top top;
                        border-radius: 16px;
                    }
                }

                .post-content {
                    .post-title {
                        margin-top: .5rem;
                        margin-bottom: 1rem;
                        color: var(--sh-query-posts-title);
                    }
                    
                    .post-author {
                        display: flex;
                        margin-bottom: .8rem;
                        gap: .3rem;
                        flex-wrap: wrap;

                        .author-icon {
                            display: flex;
                            align-items: center;
                        }

                        .author-date {
                            color: var(--sh-query-posts-author-date);
                        }

                        .author-by {
                            color: var(--sh-query-posts-author-by);
                        }

                        .author-name {
                            z-index: 9999;
                        }

                        .post-categories {
                            display: flex;
                            gap: .3rem;
                            z-index: 9999;
                        }

                        .author-separator {
                            color: var(--sh-query-posts-author-separator);
                        }
                    }

                    .post-description {
                        color: var(--sh-query-posts-description);
                    }
                }
            }

            .query-primary {
                &.size-primary {
                    width: 55%;

                    @container (max-width: 1200px) {
                        & {
                            width: 50%;
                        }
                    }

                    @container (max-width: 992px) {
                        & {
                            width: 60%;
                        }
                    }

                    @container (max-width: 768px) {
                        & {
                            width: 100%;
                        }
                    }
                }

                &.size-primary-full {
                    width: 100%;
                }

                .query-post {
                    .post-image {
                        margin-top: 0;
                    }
                    .post-content {
                        .post-description {
                            overflow: hidden;
                            display: -webkit-box;
                            -webkit-line-clamp: 4;
                            line-clamp: 4;
                            -webkit-box-orient: vertical;

                            @container (max-width: 768px) {
                                & {
                                    -webkit-line-clamp: 8;
                                    line-clamp: 8;
                                }
                            }
                        }
                    }
                }
            }

            .query-lists {
                display: flex;
                flex-direction: column;
                gap: 1.6rem;

                &.size-posts-list {
                    width: 45%;

                    @container (max-width: 1200px) {
                        & {
                            width: 50%;
                        }
                    }

                    @container (max-width: 992px) {
                        & {
                            width: 40%;
                            gap: .8rem;
                        }
                    }

                    @container (max-width: 768px) {
                        & {
                            width: 100%;
                        }
                    }
                }

                .query-post {
                    width: 100%;
                    display: flex;
                    gap: .8rem;
                    
                    @container (max-width: 992px) {
                        & {
                            gap: .5rem;
                        }
                    }

                    @container (max-width: 576px) {
                        & {
                            flex-direction: column;
                        }
                    }

                    .post-image {
                        width: 40%;
                        margin-top: 0;

                        @container (max-width: 576px) {
                            & {
                                width: 100%;
                            }
                        }

                        img {
                            width: 100%;
                            height: 160px;
                            object-fit: cover;
                            object-position: center center;
                            border-radius: 16px;
                        }
                    }

                    .post-content {
                        width: 60%;

                        @container (max-width: 576px) {
                            & {
                                width: 100%;
                            }
                        }

                        .post-title {
                            margin-top: 0;
                            margin-bottom: .4rem;
                            color: var(--sh-query-posts-title);

                            overflow: hidden;
                            display: -webkit-box;
                            -webkit-line-clamp: 2;
                            line-clamp: 2;
                            -webkit-box-orient: vertical;
                        }

                        .post-author {
                            margin-bottom: .6rem;
                        }

                        .post-description {
                            overflow: hidden;
                            display: -webkit-box;
                            -webkit-line-clamp: 4;
                            line-clamp: 4;
                            -webkit-box-orient: vertical;

                            @container (max-width: 992px) {
                                & {
                                    -webkit-line-clamp: 3;
                                    line-clamp: 3;
                                }
                            }

                            @container (max-width: 768px) {
                                & {
                                    -webkit-line-clamp: 4;
                                    line-clamp: 4;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

.acf-block-preview {
    .sh-query-posts {
        width: 100%;
        left: 0;
        right: 0;
        margin-left: 0;
        margin-right: 0;
    }
}
