/**
 * bw_search frontend styles.
 *
 * Colours are custom properties so the host layout can adapt the appearance
 * from its own stylesheet without overriding rules. Text colours inherit
 * from the surrounding page.
 */

.bwsearch {
    --bwsearch-accent: #1268ff;
    --bwsearch-accent-text: #ffffff;
    --bwsearch-border: #dce5f1;
    --bwsearch-surface: #ffffff;
    --bwsearch-surface-alt: #f5f8fc;
    --bwsearch-radius: 12px;
}

.bwsearch-container {
    width: 100%;
    max-width: 900px;
    margin-inline: auto;
}

/* Search form --------------------------------------------------------------- */

.bwsearch__label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.65;
}

/*
 * Own stacking context above the page content: sections further down create
 * their own contexts and would otherwise cover the suggestion list.
 */
.bwsearch__field {
    position: relative;
    z-index: 30;
    display: flex;
    gap: 10px;
}

.bwsearch__icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.55;
    pointer-events: none;
}

.bwsearch__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 52px;
    padding: 0 16px 0 46px;
    border: 1px solid var(--bwsearch-border);
    border-radius: var(--bwsearch-radius);
    background: var(--bwsearch-field, var(--bwsearch-surface));
    color: inherit;
    font: inherit;
}

.bwsearch__input:focus {
    outline: none;
    border-color: var(--bwsearch-accent);
    box-shadow: 0 0 0 3px rgba(18, 104, 255, 0.15);
}

.bwsearch__submit {
    flex: 0 0 auto;
    padding: 0 26px;
    border: 0;
    border-radius: var(--bwsearch-radius);
    background: var(--bwsearch-accent);
    color: var(--bwsearch-accent-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: filter 180ms;
}

.bwsearch__submit:hover {
    filter: brightness(1.08);
}

/* Autocomplete -------------------------------------------------------------- */

.bwsearch__suggestions {
    position: absolute;
    z-index: 31;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--bwsearch-border);
    border-radius: var(--bwsearch-radius);
    /* Deliberately the solid surface: content scrolls beneath the list, a
       translucent panel would let it shine through. */
    background: var(--bwsearch-surface);
    box-shadow: 0 18px 44px rgba(3, 25, 51, 0.18);
}

.bwsearch__suggestions[hidden] {
    display: none;
}

.bwsearch__suggestion {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.92rem;
    cursor: pointer;
}

.bwsearch__suggestion:hover,
.bwsearch__suggestion.is-active {
    background: var(--bwsearch-accent);
    color: var(--bwsearch-accent-text);
}

/* Result rows inside the dropdown, below the word suggestions. */
.bwsearch__suggestion--result {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--bwsearch-border);
    border-radius: 0;
}

.bwsearch__suggestion--result:first-child {
    border-top: 0;
}

.bwsearch__suggestiontype {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(18, 104, 255, 0.16);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bwsearch-accent);
}

.bwsearch__suggestion--all {
    border-top: 1px solid var(--bwsearch-border);
    border-radius: 0;
    text-align: center;
    font-weight: 700;
    color: var(--bwsearch-accent);
}

/* Popular searches before the first input. */
.bwsearch__popular {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
}

.bwsearch__popularlabel {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.65;
}

.bwsearch__didyoumean {
    display: block;
    margin-top: 10px;
}

.bwsearch__didyoumean a {
    color: var(--bwsearch-accent);
    font-weight: 700;
}

/* Meta line and facets ------------------------------------------------------ */

.bwsearch__meta {
    margin-top: 26px;
}

.bwsearch__count {
    margin: 0 0 14px;
    font-size: 0.92rem;
    opacity: 0.8;
}

.bwsearch__facets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.bwsearch__facet {
    padding: 8px 14px;
    border: 1px solid var(--bwsearch-border);
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
    color: inherit;
    transition: border-color 200ms, background 200ms, color 200ms;
}

.bwsearch__facet:hover {
    border-color: var(--bwsearch-accent);
}

.bwsearch__facet.is-active {
    border-color: var(--bwsearch-accent);
    background: var(--bwsearch-accent);
    color: var(--bwsearch-accent-text);
}

/* Results ------------------------------------------------------------------- */

.bwsearch__results {
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bwsearch__resultlink {
    display: block;
    padding: 18px 20px;
    border: 1px solid var(--bwsearch-border);
    border-radius: var(--bwsearch-radius);
    background: var(--bwsearch-panel, var(--bwsearch-surface));
    text-decoration: none;
    color: inherit;
    transition: border-color 200ms, transform 200ms, box-shadow 200ms;
}

.bwsearch__resultlink:hover {
    border-color: var(--bwsearch-accent);
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(3, 25, 51, 0.08);
}

/* With a preview image the card becomes two columns. */
.bwsearch__resultlink--media {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.bwsearch__resultimage {
    flex: 0 0 96px;
    overflow: hidden;
    border-radius: 10px;
}

.bwsearch__resultimage img {
    display: block;
    width: 96px;
    height: 72px;
    object-fit: cover;
}

.bwsearch__resultbody {
    display: block;
    min-width: 0;
}

.bwsearch__facet--near {
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    background: transparent;
    cursor: pointer;
}

.bwsearch__facet--near[disabled] {
    opacity: 0.5;
    cursor: wait;
}

.bwsearch__distance {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--bwsearch-accent);
}

/* Mobile layout: keep the icon anchored to the input instead of centering it
   against a wrapped form row. These rules intentionally live in the search
   extension because its stylesheet is loaded after the site theme. */
.frame-type-bwsearch_search .frame-group-container,
.frame-type-bwsearch_search .frame-group-inner,
.frame-type-bwsearch_search .bwsearch-container {
    min-width: 0;
    max-width: 100%;
}

.bwsearch__field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
}

.bwsearch__icon {
    top: 26px;
    width: 18px;
    height: 18px;
    margin: 0;
    transform: translateY(-50%);
}

.bwsearch__input {
    grid-column: 1;
    width: 100%;
}

.bwsearch__submit {
    grid-column: 2;
    min-height: 52px;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .bwsearch-container {
        padding-inline: 0;
    }

    .bwsearch__field {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .bwsearch__input,
    .bwsearch__submit {
        grid-column: 1;
    }

    .bwsearch__submit {
        width: 100%;
        padding-inline: 18px;
    }

    .bwsearch__suggestions {
        top: calc(100% + 6px);
    }

    .bwsearch__popular {
        align-items: flex-start;
    }

    .bwsearch__popularlabel {
        flex-basis: 100%;
    }

    .bwsearch__resultlink--media {
        display: block;
    }

    .bwsearch__resultimage {
        margin-bottom: 12px;
    }
}

.bwsearch__resulttype {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bwsearch-accent);
}

.bwsearch__resulttitle {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.35;
}

.bwsearch__resultteaser {
    margin: 6px 0 0;
    font-size: 0.9rem;
    line-height: 1.55;
    opacity: 0.75;
}

/* Matched terms in title and snippet. */
.bwsearch mark {
    padding: 0 2px;
    border-radius: 4px;
    background: rgba(18, 104, 255, 0.22);
    color: inherit;
    font-weight: 700;
}

.bwsearch__empty {
    margin-top: 24px;
    padding: 32px;
    border: 1px dashed var(--bwsearch-border);
    border-radius: var(--bwsearch-radius);
    text-align: center;
    opacity: 0.8;
}

/* Pager --------------------------------------------------------------------- */

.bwsearch__pager {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 24px;
}

.bwsearch__page {
    min-width: 38px;
    padding: 8px 0;
    border: 1px solid var(--bwsearch-border);
    border-radius: 10px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: inherit;
}

.bwsearch__page:hover {
    border-color: var(--bwsearch-accent);
}

.bwsearch__page.is-active {
    border-color: var(--bwsearch-accent);
    background: var(--bwsearch-accent);
    color: var(--bwsearch-accent-text);
}

@media (max-width: 560px) {
    .bwsearch__field {
        flex-wrap: wrap;
    }

    .bwsearch__submit {
        flex: 1 1 100%;
        height: 48px;
    }
}
