body.battery-finder-results-page {
    /*
     * The theme's header fades to transparent over a hero image and only turns solid black once you scroll.
     * The search results page has no hero, so start it black.
     */
    header.site-header.wrapper.flex::before {
        background-color: #000;
    }

    /* the search form sits flush under the header: the header is fixed and 186px tall down to 1200px wide, then in the page flow */
    .battery-finder-search-results {
        padding-top: 186px;

        @media (max-width: 1199px) {
            padding-top: 0;
        }
    }
}

/*
 * Search form at the top of the search results page.
 * The theme styles the form for the black footer band (.battery-finder-section),
 * this lightens it to the page's gray.
 */
.battery-finder-section.battery-finder-section--results {
    /* own stacking context so the faded steps (z-index: -1) stay above the background */
    position: relative;
    z-index: 0;
    align-self: center;
    width: 100vw;
    max-width: none;
    margin: 0 0 60px;
    background: #000;
    border-top: 2px solid #222;
    color: #f7f7f7;

    @media (max-width: 768px) {
        margin-bottom: 40px;
    }

    .content {
        position: relative;
        min-height: 0;
        padding: 35px 30px 25px;

        @media (max-width: 992px) {
            padding-top: 30px;
        }
    }

    /*
     * Open: the form, with Hide search at the top right. Closed: a bar with the current search and Change.
     * Starts open on desktop and closed on phones (768px and under, where the fields stack),
     * once a button is clicked the JS sets is-expanded or is-collapsed and that wins.
     *
     * Each one sits in a .battery-finder-collapse wrapper: a one-row grid whose row animates between
     * 0fr (closed) and 1fr (its full height). visibility hides the closed one from the keyboard and screen
     * readers, and flips at the end of a close and the start of an open.
     */
    .battery-finder-collapse {
        /* the easing starts and ends gently (plain ease front-loads the motion, which looks jerky over 700px on phones) */
        --collapse-easing: cubic-bezier(0.4, 0, 0.2, 1);

        display: grid;
        grid-template-rows: 1fr;
        opacity: 1;
        visibility: visible;
        transition:
            grid-template-rows 0.35s var(--collapse-easing),
            opacity 0.35s var(--collapse-easing),
            visibility 0.35s;

        > div {
            min-height: 0;
            overflow: hidden;
        }

        @media (prefers-reduced-motion: reduce) {
            transition: none;
        }
    }

    /*
     * The closed bar's contents fade on their own timing instead of with the wrapper: the bar is short,
     * so its shrinking edge would otherwise cut through the icon and text while they're still half visible.
     * Hiding: fade out fast, before the edge gets to them. Showing: fade in once the bar has mostly grown.
     * (A transition uses the timing of the state it's going to.)
     */
    .battery-finder-collapse--summary {
        grid-template-rows: 0fr;
        visibility: hidden;

        .battery-finder-search-summary {
            opacity: 0;
            transition: opacity 0.12s ease-out;
        }
    }

    @media (max-width: 768px) {
        &:not(.is-expanded) {
            .battery-finder-collapse--form {
                grid-template-rows: 0fr;
                opacity: 0;
                visibility: hidden;
            }

            .battery-finder-collapse--summary {
                grid-template-rows: 1fr;
                visibility: visible;

                .battery-finder-search-summary {
                    opacity: 1;
                    transition: opacity 0.2s ease-in 0.15s;
                }
            }
        }
    }

    &.is-collapsed {
        .battery-finder-collapse--form {
            grid-template-rows: 0fr;
            opacity: 0;
            visibility: hidden;
        }

        .battery-finder-collapse--summary {
            grid-template-rows: 1fr;
            visibility: visible;

            .battery-finder-search-summary {
                opacity: 1;
                transition: opacity 0.2s ease-in 0.15s;
            }
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .battery-finder-collapse--summary .battery-finder-search-summary {
            transition: none !important;
        }
    }

    .battery-finder-search-summary {
        display: flex;
        align-items: center;
        gap: 12px;
        /* lined up with the results' edges (30px page padding, the 1600px max width on wide screens, 16px on phones) */
        padding: 10px max(30px, calc((100vw - 1600px) / 2));

        @media (max-width: 768px) {
            padding-inline: 16px;
        }

        /* dashboard battery warning light: the logo's red outline with a faint glow */
        svg {
            flex: none;
            color: #E22726;
            filter: drop-shadow(0 0 2px rgba(226, 39, 38, 0.7));
        }
    }

    .battery-finder-search-summary__text {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        /* the theme centers text in this section */
        text-align: left;
        font-weight: 600;
    }

    .battery-finder-search-toggle {
        display: inline-flex;
        flex: none;
        align-items: center;
        gap: 8px;
        height: 32px;
        padding: 0 12px;
        background: none;
        border: 1px solid #f7f7f7;
        border-radius: 4px;
        color: #f7f7f7;
        font: inherit;
        font-size: 14px;
        cursor: pointer;

        &:hover {
            background: #f7f7f7;
            color: #000;
        }

        /* chevron: down on Change, up on Hide search */
        &::after {
            content: '';
            width: 7px;
            height: 7px;
            border-right: 2px solid currentColor;
            border-bottom: 2px solid currentColor;
            transform: translateY(-2px) rotate(45deg);
        }
    }

    /* on the line with the Search by Battery link, at the results' right edge. On phones, its own line under the link */
    /*
     * Top right, the same spot as Change in the closed bar. Beside the fields from 1200px up,
     * below that the fields fill the width so it gets its own row above them.
     */
    .battery-finder-search-toggle--close {
        position: absolute;
        top: 10px;
        right: max(30px, calc((100vw - 1600px) / 2));

        &::after {
            transform: translateY(2px) rotate(-135deg);
        }

        @media (max-width: 1199px) {
            position: static;
            display: flex;
            width: fit-content;
            margin: 0 0 15px auto;
        }

        /* the closed bar's Change sits 16px from the edge on phones, the form 30px */
        @media (max-width: 768px) {
            margin-right: -14px;
        }
    }

    @media (max-width: 1199px) {
        .content:has(> .battery-finder-search-toggle--close) {
            padding-top: 10px;
        }
    }


    .battery-finder__form {
        position: relative;
        /* room for the switch link below the fields */
        padding: 0 0 45px;
    }

    .input-wrapper {
        opacity: 0.45;

        &.is-active {
            opacity: 1;
        }
    }

    .battery-finder__label {
        color: #f7f7f7;
    }

    .battery-finder__select,
    .battery-finder__input {
        background-color: #FFF;
        border: 1px solid #AAA;
        color: #222;
    }

    /* absolutely positioned like the theme, so it's centered under the fields and only as wide as its text */
    .battery-finder__switch {
        bottom: 0;
        padding: 4px 8px;
        color: #AAA;
    }
}
