/* =========================================================
   SCOTT PRICE MEDIA
   GLOBAL SEARCH PANEL v3

   Stable two-state interface:
   1. Compact Search
   2. Expanded Results
   ========================================================= */


/* =========================================================
   PANEL — COMPACT STATE
   ========================================================= */

.spm-global-search {
    --spm-search-card-radius: 1rem;
    --spm-search-panel-radius: 0 0 1.4rem 1.4rem;

    /*
     * Bootstrap Offcanvas uses this variable for height.
     * This gives us a predictable compact opening state.
     */
    --bs-offcanvas-height: 175px;

    height: var(--bs-offcanvas-height) !important;
    max-height: var(--bs-offcanvas-height);

    color: var(--bs-body-color);

    background:
        linear-gradient(
            135deg,
            color-mix(
                in srgb,
                var(--bs-body-bg) 94%,
                #6610f2 6%
            ),
            var(--bs-body-bg)
        );

    border-bottom:
        1px solid var(--bs-border-color-translucent);

    border-radius:
        var(--spm-search-panel-radius);

    box-shadow:
        0 1.25rem 3rem
        rgba(0, 0, 0, 0.3);

    overflow: hidden;

    transition:
        height 220ms ease,
        max-height 220ms ease;
}


/* =========================================================
   PANEL — RESULTS STATE
   ========================================================= */

.spm-global-search.spm-search-expanded {
    --bs-offcanvas-height: min(78dvh, 860px);

    height: var(--bs-offcanvas-height) !important;
    max-height: var(--bs-offcanvas-height);
}


/* =========================================================
   HEADER
   ========================================================= */

.spm-global-search .offcanvas-header {
    flex: 0 0 auto;

    padding:
        0.9rem
        clamp(1rem, 4vw, 3rem);

    border-bottom: none;
}


.spm-search-heading {
    display: flex;
    align-items: center;
    gap: 0.65rem;

    margin: 0;

    font-size: 1.15rem;
    font-weight: 700;
}


.spm-search-heading i {
    color: var(--spm-icon-color);
}


.spm-search-subtitle {
    margin: 0.15rem 0 0;

    color: var(--bs-secondary-color);

    font-size: 0.875rem;
}


/* =========================================================
   BODY
   ========================================================= */

.spm-global-search .offcanvas-body {
    flex: 1 1 auto;

    padding:
        1rem
        clamp(1rem, 4vw, 3rem);

    overflow: hidden;
}


/*
 * Scrolling is allowed only after actual results
 * have expanded the Search panel.
 */
.spm-global-search.spm-search-expanded
.offcanvas-body {
    overflow-y: auto;

    overscroll-behavior: contain;
}


.spm-search-inner {
    width: min(100%, 1160px);

    margin-inline: auto;
}


/* =========================================================
   SEARCH FORM
   ========================================================= */

.spm-search-form {
    margin: 0;
}


.spm-search-input-group {
    display: flex;
    gap: 0.65rem;
}


.spm-search-input-wrap {
    position: relative;

    flex: 1 1 auto;
}


.spm-search-input-icon {
    position: absolute;

    top: 50%;
    left: 1rem;

    z-index: 2;

    color: var(--spm-icon-color);

    pointer-events: none;

    transform: translateY(-50%);
}


#spmGlobalSearchInput {
    min-height: 3.4rem;

    padding-left: 2.8rem;

    color: var(--bs-body-color);

    background-color:
        var(--bs-body-bg);

    border:
        2px solid
        var(--bs-border-color-translucent);

    border-radius: 1rem;

    font-size: 1rem;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}


#spmGlobalSearchInput:focus {
    border-color: #6610f2;

    box-shadow:
        0 0 0 0.25rem
        rgba(102, 16, 242, 0.18);
}


.spm-search-submit {
    min-width: 7.5rem;
    min-height: 3.4rem;

    border-radius: 1rem;
}


/* =========================================================
   COMPACT STATUS
   ========================================================= */

/*
 * Reserved feedback area.
 *
 * Because its height is always reserved, typing/searching
 * does not change the geometry of the panel.
 */

.spm-search-compact-status {
    min-height: 1.35rem;

    margin-top: 0.45rem;

    color: var(--bs-secondary-color);

    font-size: 0.82rem;
}


/* =========================================================
   RESULTS AREA
   ========================================================= */

.spm-search-response {
    display: none;

    margin-top: 0.8rem;
}


.spm-global-search.spm-search-expanded
.spm-search-response {
    display: block;
}


/* =========================================================
   RESULT SUMMARY
   ========================================================= */

.spm-search-result-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;

    margin-bottom: 0.65rem;
}


.spm-search-status {
    margin: 0;

    color: var(--bs-secondary-color);

    font-size: 0.9rem;
}


/* =========================================================
   DYNAMIC FILTERS
   ========================================================= */

.spm-search-filters {
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;

    margin-bottom: 0.8rem;
}


.spm-search-filters.has-filters {
    display: flex;
}


.spm-search-filter {
    padding:
        0.4rem
        0.8rem;

    color: var(--bs-body-color);

    background: transparent;

    border:
        1px solid
        var(--bs-border-color-translucent);

    border-radius: 999px;

    font-size: 0.85rem;
    font-weight: 600;

    transition:
        color 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease;
}


.spm-search-filter:hover {
    border-color: #6610f2;
}


.spm-search-filter.active,
.spm-search-filter[aria-pressed="true"] {
    color: #fff;

    background-color: #6610f2;

    border-color: #6610f2;
}


.spm-search-filter:focus-visible {
    outline:
        3px solid
        var(--spm-nav-focus-color);

    outline-offset: 3px;
}


.spm-search-filter-count {
    margin-left: 0.25rem;

    opacity: 0.8;
}


/* =========================================================
   RESULTS
   ========================================================= */

.spm-search-results {
    display: grid;
    gap: 0.55rem;
}


.spm-search-result {
    display: grid;

    grid-template-columns:
        auto
        minmax(0, 1fr);

    gap: 0.8rem;

    padding: 0.75rem;

    color: inherit;

    background:
        color-mix(
            in srgb,
            var(--bs-body-bg) 95%,
            #6610f2 5%
        );

    border:
        1px solid
        var(--bs-border-color-translucent);

    border-radius:
        var(--spm-search-card-radius);

    text-decoration: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}


.spm-search-result:hover {
    color: inherit;

    border-color: #6610f2;

    box-shadow:
        0 0.4rem 1rem
        rgba(0, 0, 0, 0.12);
}


.spm-search-result:focus-visible {
    outline:
        3px solid
        var(--spm-nav-focus-color);

    outline-offset: 3px;
}


/* =========================================================
   RESULT THUMBNAIL
   ========================================================= */

.spm-search-result-thumb {
    width: 76px;
    height: 58px;

    overflow: hidden;

    background-color:
        var(--bs-secondary-bg);

    border-radius: 0.65rem;
}


.spm-search-result-thumb img {
    width: 100%;
    height: 100%;

    object-fit: cover;
}


/* =========================================================
   RESULT CONTENT
   ========================================================= */

.spm-search-result-body {
    min-width: 0;
}


.spm-search-result-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;

    margin-bottom: 0.2rem;
}


.spm-search-result-type {
    display: inline-flex;

    padding:
        0.12rem
        0.5rem;

    color: #fff;

    background-color: #6610f2;

    border-radius: 999px;

    font-size: 0.66rem;
    font-weight: 700;

    letter-spacing: 0.04em;

    text-transform: uppercase;
}


.spm-search-result-title {
    margin:
        0
        0
        0.15rem;

    color: var(--bs-body-color);

    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.25;
}


.spm-search-result-description {
    display: -webkit-box;

    margin: 0;

    overflow: hidden;

    color: var(--bs-secondary-color);

    font-size: 0.82rem;
    line-height: 1.4;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}


/* =========================================================
   EMPTY / ERROR
   ========================================================= */

.spm-search-message {
    padding: 1.4rem;

    text-align: center;

    border:
        1px solid
        var(--bs-border-color-translucent);

    border-radius:
        var(--spm-search-card-radius);

    background:
        color-mix(
            in srgb,
            var(--bs-body-bg) 95%,
            #6610f2 5%
        );
}


.spm-search-message h3 {
    margin-bottom: 0.35rem;

    font-size: 1.1rem;
}


.spm-search-message p {
    margin: 0;

    color: var(--bs-secondary-color);
}


/* =========================================================
   ACTIONS
   ========================================================= */

.spm-search-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;

    margin-top: 0.85rem;
}


.spm-search-load-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;

    min-width: 8.5rem;

    border-radius: 999px;
}


.spm-search-load-more[hidden] {
    display: none !important;
}


.spm-search-view-all {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;

    font-weight: 700;

    text-decoration: none;
}


.spm-search-view-all:hover {
    text-decoration: underline;
}


.spm-search-view-all[hidden] {
    display: none !important;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767.98px) {

    .spm-global-search {
        --bs-offcanvas-height: 215px;

        border-radius: 0;
    }


    .spm-global-search.spm-search-expanded {
        --bs-offcanvas-height: 92dvh;
    }


    .spm-global-search .offcanvas-header {
        padding:
            0.8rem
            1rem;
    }


    .spm-global-search .offcanvas-body {
        padding: 0.85rem 1rem;
    }


    .spm-search-input-group {
        flex-direction: column;
    }


    #spmGlobalSearchInput {
        min-height: 3rem;
    }


    .spm-search-submit {
        width: 100%;
        min-height: 2.8rem;
    }


    .spm-search-result-thumb {
        width: 62px;
        height: 50px;
    }


    .spm-search-result-description {
        -webkit-line-clamp: 1;
    }


    .spm-search-actions {
        flex-direction: column;

        align-items: stretch;
    }


    .spm-search-load-more,
    .spm-search-view-all {
        justify-content: center;

        width: 100%;

        padding: 0.7rem;
    }
}


/* =========================================================
   SHORT DESKTOP VIEWPORTS
   ========================================================= */

@media
(max-height: 750px)
and
(min-width: 768px) {

    .spm-global-search.spm-search-expanded {
        --bs-offcanvas-height: 96dvh;
    }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .spm-global-search,
    .spm-search-result,
    .spm-search-filter,
    #spmGlobalSearchInput {
        transition: none;
    }
}