.optpl-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 50px;
    position: relative;

    &.optpl-container__filters-hidden,
    &.optpl-container__my-templates,
    &.optpl-container__favorites {
        grid-template-columns: 1fr;
    }
}

.optpl-templates__container {
    .optpl-templates__group-heading {
        margin: 0 0 40px 0 !important;
    }

    h3 {
        font-size: 24px !important;
        margin: 0 0 0 0 !important;
        position: relative;
        display: flex;
        justify-content: space-between;

        a {
            font-size: 14px;
        }
    }

    h4 {
        margin: 8px 0 0 0 !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        color: #666 !important;
    }

    .optpl-template-item__text h4 {
        color: #000 !important;
    }

    .optpl-templates__all {
        position: absolute;
        top: 7px;
        right: 0;
        font-size: 15px;
        color: $color--opui-primary;
    }
}

.optpl-templates__group {
    .optpl-templates__group-container {
        margin: 0 0 80px 0;
    }
}

.optpl-templates__list, .optpl-templates__related-list {
    ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        display: grid;
        gap: 20px;
    }

    li {
        margin: 0;
        padding: 0;
    }

    .optpl-template-item {
        border: 1px solid #EAECF0;
        border-radius: 10px;
        position: relative;
        padding: 16px;
        background: $color--opui-white;
        min-height: 100%;

        &.faded {
            .optpl-template-item__image-container, h4, .optpl-template-item__description, .optpl-template-item__tags {
                opacity: .5 !important;
            }
        }

        .optpl-template-item__image-container {
            opacity: 0;
            transition: opacity .5s linear;
        }

        figure {
            position: relative;
            width: 100%;
            overflow: hidden;
            border-radius: 10px;
            margin: 0 0 20px 0;
            background: cover no-repeat;
            background-size: cover;

            img {
                position: absolute;
                top: 0;
                transition: 1s ease-in-out;
                cursor: pointer;
                width: 100%;
                opacity: 0%;
            }

            &:hover {
                background-position: 0 100%;
            }
        }

        &.loaded figure, &.loaded .optpl-template-item__image-container {
            opacity: 1;
        }

        &.optpl-template-item__template figure {
            aspect-ratio: 2.8/3;
        }

        &.optpl-template-item__collection figure {
            aspect-ratio: 4.5/3;
        }

        &.optpl-template-item__pack figure {
            aspect-ratio: 4.5/3;
        }

        h4 {
            display: flex;
            justify-content: space-between;
            font-size: 16px !important;
            color: $color--opui-gray800;
            margin: 0 0 4px 0;
            align-items: baseline;
        }

        .optpl-template-item__price {
            background: $color--opui-gray200;
            font-size: 13px;
            padding: 3px 8px;
            color: $color--opui-gray600;
            border-radius: 30px;
        }

        p, .optpl-template-item__description {
            font-size: 14px !important;
            color: $color--opui-gray500;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            display: -webkit-box;
            overflow: hidden;
        }

        .optpl-template-item__tags {
            margin: 0 0 10px 0 !important;
        }

        .optpl-template-item__create-page {
            position: absolute;
            top: 22px;
            right: 22px;
            color: $color--opui-gray800;
            font-size: 26px;
            transition: all .5s ease-in-out;
            opacity: 0;

            &:hover {
                color: $color--opui-primary;
            }
        }
    }

    .optpl-template-item__mark {
        position: absolute;
        top: -10px;
        left: 20px;
    }

    .optpl-template-item__tag {
        font-size: 12px;
        padding: 2px 6px 2px 6px;
        border-radius: 4px;
        background: $color--opui-gray300;
        color: $color--opui-gray600;
    }

    .optpl-template-item__tag-new {
        background: #ecfdf3;
        color: #027a48;
    }

    .optpl-template-item__tag-collection {
        background: #f0f9ff;
        color: #026aa2;
    }

    .optpl-template-item__tag-collection {
        background: #f0f9ff;
        color: #026aa2;
    }

    .optpl-template-item__tag-trending {
        background: #f6ecfd;
        color: #7c3d9b;
    }
}

.optpl-templates__list-purchasable .optpl-view-tpl-btn {
    display: none !important;
}

.optpl-container.optpl-container__filters-hidden .optpl-templates__list ul,
.optpl-container.optpl-container__my-templates .optpl-templates__list ul,
.optpl-container.optpl-container_favorites .optpl-templates__list ul {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.optpl-templates__related-list ul {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.optpl-template-item__text {
    position: relative;
    min-height: 120px;

    h4 {
        line-height: 1.5em !important;
    }
}

.optpl-template-item__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,.6);
    padding: 20px;
    transition: all .5s ease-in-out;
    opacity: 0;
    display: grid;
    gap: 10px;
    align-content: center;

    &.optpl-template-item__overlay-template {
        .optpl-template-item__overlay-top {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
            gap: 10px;
        }

        div {
            display: grid;
        }

        a {
            display: block;
        }
    }

    .opui-btn {
        display: block;
        cursor: pointer;
    }

    .opui-btn-secondary {
        color: $color--opui-white !important;
        background: $color--opui-gray900 !important;
        border: 1px solid $color--opui-gray900 !important;
    }

    .opui-btn-outline {
        background: #fff !important;
        border: 1px solid $color--opui-gray900 !important;
    }
}

.optpl-template-item:hover .optpl-template-item__overlay {
    opacity: 1;
}

.optpl-template-item:hover .optpl-template-item__create-page {
    opacity: 1;
}

// Media query grid
@media (min-width: 650px) {
    .optpl-templates__related-list ul {
        grid-template-columns: 1fr 1fr 1fr;
    }
}
@media (min-width: 900px) {
    .optpl-templates__list  ul {
        grid-template-columns: 1fr 1fr;
    }
    .optpl-templates__related-list ul {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
    .optpl-templates__list  ul li:nth-child(n+7) {
        display: none;
    }
}
@media (min-width: 1200px) {
    .optpl-templates__list  ul {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .optpl-templates__related-list ul {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
    .optpl-templates__list  ul li:nth-child(n+7) {
        display: none;
    }
}
@media (min-width: 1600px) {
    .optpl-templates__list  ul {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
    .optpl-templates__list  ul li:nth-child(n+7) {
        display: block;
    }
    .optpl-templates__list  ul li:nth-child(n+9) {
        display: none;
    }
}
@media (min-width: 2100px) {
    .optpl-templates__list  ul {
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    }
    .optpl-templates__related-list ul {
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    }
    .optpl-templates__list  ul li:nth-child(n+6) {
        display: block;
    }
}
.optpl-is-sub-page {
    .optpl-templates__list  ul li {
        display: block !important;
    }
}

.optpl-templates__load-more {
    text-align: center;

    .opui-btn.opui-btn-outline {
        border-color: $color--opui-gray500 !important;
        cursor: pointer !important;
    }
}

.optpl-template-like {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgb(242, 245, 246);
    border-radius: 5px;
    border: none;
    height: 22px;
    aspect-ratio: 1/1;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity .5s ease-in-out;
    cursor: pointer;
    font-size: 12px !important;
    text-decoration: none !important;
    color: rgba(75, 85, 99, .8) !important;
    opacity: 0;
}

.optpl-template-like.liked {
    opacity: 1;
    background: rgb(254, 242, 242);
    color: rgba(185, 28, 28, .8) !important;
}

.optpl-template-item:hover .optpl-template-like {
    opacity: 1;
}

.optpl-details-related .optpl-template-like {
    display: none !important;
}
