.algo-search {
    position: relative;
    isolation: isolate;
    z-index: 100;
}

[data-search-close] {
    position: absolute;
    top: 0;
    right: 0;
    margin: 1rem var(--_side-padding);
}

.ais-SearchBox {
    .ais-SearchBox-form {
        display: block;
        position: relative;
        margin-block: 0;
        width: 100%;
        z-index: 50;

        .ais-SearchBox-input {
            background: #ffffff;
            padding-inline: 1rem 2.5rem;
            width: 100%;
            max-width: 100%;
            border-radius: 5px 7px 7px 5px;
        }

        .ais-SearchBox-submit {
            color: var(--color-link, inherit);
            position: absolute;
            right: 0;
            top: 0;
            bottom: 0;
            width: 2.5rem;
            padding: 0.5em 0.75em 0.5em 0.5em;
            flex-shrink: 0;
        }

        .ais-SearchBox-submitIcon {
            flex-shrink: 0;
            height: 1rem;
            width: 1rem;
        }

        .ais-SearchBox-reset {
            display: none;
            position: absolute;
            right: 5rem;
            top: 0;
            bottom: 0;
            margin: auto;

        }
    }
}

@media (min-width: 769px) {
    .ai-SearchBox {
        .ais-SearchBox-input {
            width: auto;
        }
    }
}

@media (min-width: 1024px) {
    [data-search-close] {
        margin: 1.75rem var(--_side-padding);
    }
}

.algo-results {
    --color-bg: #000c;
    --color-copy: #ffffff;
    --color-text: #ffffff;
    --_top-padding: 5rem;
    --_side-padding: 0.875rem;
    display: none;
    z-index: 0;
    position: fixed;
    inset: 0;
    padding: var(--_top-padding) var(--_side-padding) 9rem;
    overflow: hidden;
    background-color: var(--color-bg);
    color: var(--color-copy);

    @media (min-width: 769px) {
        --_side-padding: 6%;
    }

    &[data-active] {
        display: block;
    }

    .algo-noresults {
        grid-column: 1/-1;
        text-align: center;
    }
}

.ais-Hits {
    height: 100%;
    overflow: auto;
    overscroll-behavior: contain;

    &.scrollbar-visible {
        padding: 0 0.75rem 0 0;
    }

    /* Width */
    &::-webkit-scrollbar {
        width: 1rem;
    }

    /* Track */
    &::-webkit-scrollbar-track {
        background: var(--color-bg);
        margin-left: 1rem;
    }

    /* Handle */
    &::-webkit-scrollbar-thumb {
        background: var(--btn-text);
    }

    /* Handle on hover */
    &::-webkit-scrollbar-thumb:hover {
        background: var(--color-copy);
    }

    .ais-Hits-list {
        display: grid;
        gap: 0.75rem;
        grid-template-columns: repeat(auto-fill, minmax(min(45%, 100%), 1fr));
        align-items: start;
        padding-block: 0;
    }

    .ais-Hits-item {
        container: search-result / inline-size;
        height: 100%;
    }

    &.ais-Hits--empty {
        align-items: center;
        display: flex;
        justify-content: center;
        height: 100%;
    }
}

.view-all-results-container {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem 0 0;
}

@media (min-width: 528px) {
    .ais-Hits {
        .ais-Hits-list {
            grid-template-columns: repeat(auto-fill, minmax(min(20ch, 100%), 1fr));
        }
    }
}

@media (min-width: 769px) {
    .algo-results {
        --_top-padding: 7rem;
        --_side-padding: 6%;
    }

    .ais-Hits {
        &.scrollbar-visible {
            padding: 0 2rem 0 0;
        }

        .ais-Hits-list {
            gap: 1rem;
            grid-template-columns: repeat(auto-fill, minmax(min(30ch, 100%), 1fr));
        }
    }

    .card--search {
        .card-title {
            font-size: clamp(1.375rem, 1.146vw, 1.375rem); /* .text-h4 */
        }
    }
}


.card--search {
    cursor: pointer;
    height: 100%;
    transition: transform 400ms ease, filter 200ms ease;

    &:active {
        transform: translateY(0.1rem);
        filter: brightness(0.96);
        transition-duration: 100ms;
    }
}

@media (hover: hover) {
    .card--search:hover {
        transform: translateY(-0.25rem);
        filter: brightness(1.05);
    }
}

@container search-result (min-width: 35ch) {
    .card--search {
        flex-direction: row;

        .card-thumb {
            align-self: start;
        }
    }
}
