/*
 * TTF Nav: search within a listing (ttf-nav/listing-search.php; design docs/design/listing-search.md).
 *
 * The field "Search in {scope}": the magnifier (it submits), the box, and an × while a search is active (the bar's
 * own rule: a ticked filter carries its ×). In the filter bar (filters.php) it comes first in the row on a desktop,
 * on the line under the filter buttons on tablets, and on its own full-width line at the top on phones; it takes the
 * bar's pill look (white with a thin line on a desktop, the grey fill below 1,024 px). In the theme's grey toolbar
 * (car, car × category, make and model pages) it comes first, white; below 1,024 px on a line of its own. Then the
 * note when AWS's spelling fallback found the matches, and the lines of a search that found nothing.
 * Class prefix ttf-ls.
 */

.ttf-ls {
    --ttf-ls-ink: var(--color-text-primary, #212529);
    --ttf-ls-muted: var(--color-text-description, #868E96);
    --ttf-ls-line: var(--color-info-dark, #DEE2E6);
    --ttf-ls-soft: var(--color-info-light, #F1F3F5);
    --ttf-ls-red: var(--color-primary, #EF233C);
    --ttf-ls-font: var(--theme-primary-font, "Krub", sans-serif);
    position: relative;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    height: 2.5rem;
    margin: 0;
    border: 1px solid var(--ttf-ls-line);
    border-radius: 999px;
    background: #fff;
    color: var(--ttf-ls-ink);
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.ttf-ls:hover { border-color: var(--ttf-ls-ink); }
.ttf-ls:focus-within { border-color: var(--ttf-ls-ink); box-shadow: 0 0 0 3px rgba(33, 37, 41, .1); }
/* A search is active: the ticked filter's ink line. */
.ttf-ls.is-on { border-color: var(--ttf-ls-ink); box-shadow: inset 0 0 0 .5px var(--ttf-ls-ink); }
.ttf-ls.is-on:focus-within { box-shadow: inset 0 0 0 .5px var(--ttf-ls-ink), 0 0 0 3px rgba(33, 37, 41, .1); }

.ttf-ls button.ttf-ls__go {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.6rem;
    height: 100%;
    margin: 0;
    padding: 0 0 0 .3rem;
    border: 0;
    border-radius: 999px 0 0 999px;
    background: transparent;
    color: var(--ttf-ls-ink);
    box-shadow: none;
    cursor: pointer;
}
.ttf-ls button.ttf-ls__go:hover { background: transparent; color: var(--ttf-ls-red); }
.ttf-ls button.ttf-ls__go:focus-visible { outline: 2px solid var(--ttf-ls-red); outline-offset: -2px; }

.ttf-ls input.ttf-ls__q {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0 1rem 0 .2rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--ttf-ls-ink);
    font: 400 .875rem/1.2 var(--ttf-ls-font);
    letter-spacing: 0;
    text-overflow: ellipsis;
    -webkit-appearance: none;
    appearance: none;
    outline: 0;
}
.ttf-ls input.ttf-ls__q::placeholder { color: var(--ttf-ls-muted); opacity: 1; }
.ttf-ls input.ttf-ls__q::-webkit-search-cancel-button,
.ttf-ls input.ttf-ls__q::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.ttf-ls.is-on input.ttf-ls__q { padding-right: .25rem; font-weight: 600; }

.ttf-ls a.ttf-ls__x {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.9rem;
    height: 1.9rem;
    margin: 0 .3rem 0 0;
    border-radius: 50%;
    color: var(--ttf-ls-ink);
    text-decoration: none;
}
.ttf-ls a.ttf-ls__x:hover { background: var(--ttf-ls-soft); color: var(--ttf-ls-red); }
.ttf-ls a.ttf-ls__x:focus-visible { outline: 2px solid var(--ttf-ls-red); outline-offset: 1px; }

/* ---- In the filter bar ---------------------------------------------------------------------------------------- */

/* A desktop: first in the row, before the filter buttons (they scroll beside it), the count and "Sort by" right. */
.ttf-fbar__row > .ttf-ls { flex: 0 1 18rem; min-width: 12rem; }

/* Tablets: the buttons keep the first line, the field leads the line under them. Phones and tablets: the pills'
   grey fill, 48 px high, 16 px text (no zoom on focus in iOS). */
@media (max-width: 1023.98px) {
    .ttf-fbar__row > .ttf-fbar__scroll { order: -1; }
    .ttf-fbar__row > .ttf-ls { flex: 1 1 14rem; min-width: 0; }
    .ttf-fbar .ttf-ls { height: 3rem; border: 0; background-color: var(--ttf-ls-soft); }
    .ttf-fbar .ttf-ls:hover { border: 0; background-color: #E6E9EC; }
    .ttf-fbar .ttf-ls:focus-within { box-shadow: inset 0 0 0 1px var(--ttf-ls-ink); }
    .ttf-fbar .ttf-ls.is-on { box-shadow: inset 0 0 0 1.5px var(--ttf-ls-ink); }
    .ttf-fbar .ttf-ls input.ttf-ls__q { font-size: 1rem; }
    .ttf-fbar .ttf-ls button.ttf-ls__go { width: 2.9rem; }
    .ttf-fbar .ttf-ls a.ttf-ls__x { width: 2.3rem; height: 2.3rem; }
}
/* Phones: the field on a line of its own at the top of the bar, the count and "Sort by" under it. */
@media (max-width: 767.98px) {
    .ttf-fbar__row > .ttf-ls { flex: 1 1 100%; order: -2; }
}

/* ---- In the theme's toolbar (car, car × category, make and model pages) ------------------------------------------ */

.before-shop-loop:has(> .ttf-ls) { align-items: center; padding-top: 10px; padding-bottom: 10px; }
.before-shop-loop > .ttf-ls { flex: 0 1 18rem; min-width: 12rem; margin-right: 1.25rem; }
@media (max-width: 1023.98px) {
    .before-shop-loop:has(> .ttf-ls) { flex-wrap: wrap; row-gap: .6rem; }
    .before-shop-loop > .ttf-ls { flex: 1 1 100%; min-width: 0; height: 3rem; margin-right: 0; }
    .before-shop-loop > .ttf-ls input.ttf-ls__q { font-size: 1rem; }
}

/* ---- Notes ------------------------------------------------------------------------------------------------------ */

/* AWS's spelling fallback found the matches. */
.ttf-ls-note { margin: -.35rem 0 1.1rem; color: var(--color-text-description, #868E96); font-size: .875rem; line-height: 1.4; }

/* A search that found nothing: the field where no bar carries it, the line, and the two ways on. */
.ttf-ls-none { margin: .5rem 0 2.5rem; }
.ttf-ls-none > .ttf-ls { max-width: 28rem; margin-bottom: 1.25rem; }
.ttf-ls-none__t { margin: 0 0 1rem; color: var(--color-text-primary, #212529); font-size: 1.125rem; font-weight: 600; line-height: 1.35; }
.ttf-ls-none__a { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0; }
.ttf-ls-none__a a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 1.25rem;
    border: 1px solid var(--color-text-primary, #212529);
    border-radius: 999px;
    color: var(--color-text-primary, #212529);
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}
.ttf-ls-none__a a:hover { background: var(--color-info-light, #F1F3F5); color: var(--color-text-primary, #212529); }
.ttf-ls-none__a a.ttf-ls-none__shop { background: var(--color-text-primary, #212529); color: #fff; }
.ttf-ls-none__a a.ttf-ls-none__shop:hover { background: #000; color: #fff; }
.ttf-ls-none__a a:focus-visible { outline: 2px solid var(--color-primary, #EF233C); outline-offset: 2px; }
