/* ═══════════════════════════════════════
   Search
   ═══════════════════════════════════════ */

/* — Tokens — */
#webko-swift-search-modal {
    --wss-text: currentColor;
    --wss-bg: #fff;
    --wss-results-bg: #f7f7f7;
    --wss-border: #d2d2d2;
    --wss-border-focus: #999;
    --wss-hover: rgba(0, 0, 0, 0.03);
    --wss-hairline: rgba(0, 0, 0, 0.08);
    --wss-mark: rgba(0, 0, 0, 0.06);
    --wss-backdrop: rgba(0, 0, 0, 0.45);
    --wss-shadow: 0 4px 40px rgba(0, 0, 0, 0.15);
    --wss-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --wss-pad: 20px;
    /* the card's own inset, shared so the results can reach past it */
    --wss-radius: 10px;
    --wss-radius-sm: 4px;
    --wss-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --wss-ease-in: cubic-bezier(0.4, 0, 0.7, 0.2);
}

/* — Reset — */
#webko-swift-search-modal,
#webko-swift-search-modal *,
#webko-swift-search-modal *::before,
#webko-swift-search-modal *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    font: inherit;
    color: inherit;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    outline: none;
    float: none;
    position: static;
    width: auto;
    height: auto;
    min-width: 0;
    max-width: none;
    max-height: none;
    overflow: visible;
    opacity: 1;
    transform: none;
    transition: none;
    animation: none;
}

/* — Overlay — */
#webko-swift-search-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px 0;
    overflow: hidden;
    pointer-events: none;
}

#webko-swift-search-modal[hidden] {
    display: none;
}

#webko-swift-search-modal.wss-open {
    pointer-events: auto;
}

/* — Backdrop — */
#webko-swift-search-modal .wss-modal__backdrop {
    position: fixed;
    inset: 0;
    background: var(--wss-backdrop);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 100ms var(--wss-ease-in);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: opacity;
}

#webko-swift-search-modal.wss-open .wss-modal__backdrop {
    opacity: 1;
    transition: opacity 160ms var(--wss-ease-out);
}

/* — Container — */
#webko-swift-search-modal .wss-modal__container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 800px;
    background: var(--wss-bg);
    border-radius: var(--wss-radius-sm);
    box-shadow: var(--wss-shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 25px var(--wss-pad);
    opacity: 0;
    transform: scale(0.97) translateY(-8px);
    transition: opacity 100ms var(--wss-ease-in), transform 100ms var(--wss-ease-in);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform, opacity;
}

#webko-swift-search-modal.wss-open .wss-modal__container {
    opacity: 1;
    transform: none;
    transition-duration: 160ms;
    transition-timing-function: var(--wss-ease-out);
}

/* — Header — */
#webko-swift-search-modal .wss-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#webko-swift-search-modal .wss-modal__label {
    font-size: 25px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.75px;
}

#webko-swift-search-modal .wss-modal__close {
    cursor: pointer;
    font-size: 14px;
    opacity: 0.3;
    transition: opacity 0.15s;
}

#webko-swift-search-modal .wss-modal__close:hover {
    opacity: 0.6;
}

/* — Search wrap — */
#webko-swift-search-modal .wss-modal__search-wrap {
    position: relative;
}

/* — Search field — */
#webko-swift-search-modal .wss-modal__search {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 45px;
    padding: 0 20px;
    border: 1px solid var(--wss-border);
    border-radius: var(--wss-radius-sm);
    box-shadow: var(--wss-shadow-sm);
    background: var(--wss-bg);
    cursor: text;
    transition: border-color 0.15s;
}

#webko-swift-search-modal .wss-modal__search:focus-within {
    border-color: var(--wss-border-focus);
}

#webko-swift-search-modal .wss-modal__icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.5;
    display: none;
}

#webko-swift-search-modal .wss-modal__input {
    flex: 1;
    width: 0;
    min-width: 0;
    font-size: 16px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
}

#webko-swift-search-modal .wss-modal__input::placeholder {
    color: var(--wss-text);
    opacity: 0.5;
}

#webko-swift-search-modal .wss-modal__input::-webkit-search-cancel-button,
#webko-swift-search-modal .wss-modal__input::-webkit-search-decoration {
    display: none;
}

/* — Arrow & clear — */
#webko-swift-search-modal .wss-modal__arrow,
#webko-swift-search-modal .wss-modal__clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 31px;
    height: 31px;
    flex-shrink: 0;
    opacity: 0.4;
}

#webko-swift-search-modal .wss-modal__arrow[hidden],
#webko-swift-search-modal .wss-modal__clear[hidden] {
    display: none;
}

#webko-swift-search-modal .wss-modal__arrow svg {
    width: 16px;
    height: 16px;
}

#webko-swift-search-modal .wss-modal__clear {
    cursor: pointer;
    transition: opacity 0.15s;
}

#webko-swift-search-modal .wss-modal__clear svg {
    width: 12px;
    height: 12px;
}

#webko-swift-search-modal .wss-modal__clear:hover {
    opacity: 0.6;
}

/* — Results — */
/*
 * The results continue the sheet the search field sits on, rather than being a second one
 * hanging below it. They used to be a grey panel of white cards, which drew a seam across
 * the modal at the point where the card ended and made every row a box to get through
 * before reading the next. One surface, hairlines between rows, and the eye runs down the
 * list instead of stepping over it.
 */
#webko-swift-search-modal .wss-modal__results {
    position: absolute;
    top: 100%;
    /* Out to the card's own edges rather than the field's: inset by the padding, the panel
       read as a narrower sheet stepping out from under a wider one, which is the seam this
       was meant to remove. */
    left: calc(-1 * var(--wss-pad));
    right: calc(-1 * var(--wss-pad));
    background: var(--wss-bg);
    border-top: 1px solid var(--wss-hairline);
    border-radius: 0 0 var(--wss-radius) var(--wss-radius);
    box-shadow: unset;
    padding: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 250px);
    overflow-y: auto;
    overflow-x: hidden;
    /* overflow-y:auto alone would compute overflow-x to auto and show a horizontal scrollbar */
    overscroll-behavior: contain;
    /* the page behind must not scroll when the list runs out */
    scrollbar-width: thin;
    scrollbar-color: var(--wss-border) transparent;
    z-index: 10;
}

#webko-swift-search-modal .wss-modal__results::-webkit-scrollbar {
    width: 10px;
}

#webko-swift-search-modal .wss-modal__results::-webkit-scrollbar-thumb {
    background: var(--wss-border);
    border: 3px solid var(--wss-bg);
    border-radius: 999px;
}

#webko-swift-search-modal .wss-modal__results:empty {
    display: none;
}

/* Eight pixels and a fade: enough to read as "this came from the field", little enough that
   a shopper typing quickly never waits for it. */
@media (prefers-reduced-motion: no-preference) {
    #webko-swift-search-modal .wss-modal__results {
        animation: wss-drop 140ms var(--wss-ease-out);
    }
}

@keyframes wss-drop {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* — Result card — */
#webko-swift-search-modal .wss-result {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
    padding: 11px var(--wss-pad);
    cursor: pointer;
    transition: background 0.1s;
}

#webko-swift-search-modal .wss-result+.wss-result {
    border-top: 1px solid var(--wss-hairline);
}

#webko-swift-search-modal .wss-result:hover,
#webko-swift-search-modal .wss-result:focus {
    background: var(--wss-hover);
}

/*
 * The keyboard's own row has to be findable at a glance, which a 3% wash is not. It keeps
 * the wash and adds a bar in the theme's own text colour, softened rather than picked: a
 * shop that has never heard of this plugin still gets a marker that belongs to its palette.
 */
#webko-swift-search-modal .wss-result[aria-selected="true"] {
    background: var(--wss-hover);
    box-shadow: inset 2px 0 0 color-mix(in srgb, currentColor 45%, transparent);
}

/* — Result title — */
#webko-swift-search-modal .wss-result__title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

/* — Result excerpt — */
/* Below the meta line in importance, so below it in weight: the excerpt was the widest and
   darkest line in the row, and it is the one nobody reads. */
#webko-swift-search-modal .wss-result__excerpt {
    font-size: 13px;
    line-height: 1.45;
    opacity: 0.6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#webko-swift-search-modal .wss-result__excerpt:empty {
    display: none;
}

/* — Product card — */
#webko-swift-search-modal .wss-result__image {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: var(--wss-radius-sm);
    overflow: hidden;
    background: var(--wss-results-bg);
    /* A white product shot on a white sheet needs an edge, or it floats. */
    box-shadow: inset 0 0 0 1px var(--wss-hairline);
}

#webko-swift-search-modal .wss-result__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#webko-swift-search-modal .wss-result__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-wrap: anywhere;
    /* long unbroken titles/SKUs must wrap instead of pushing past the price */
}

#webko-swift-search-modal .wss-result__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 10px;
    font-size: 12px;
    line-height: 1.4;
    opacity: 0.55;
}

#webko-swift-search-modal .wss-result__attrs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
}

#webko-swift-search-modal .wss-result__attr {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    background: #eef0f3;
    color: #1f2933;
    overflow-wrap: anywhere;
}

/* Aligned with the title rather than floating in the middle of the row: the name and what
   it costs are one thought, and tabular figures keep the column straight. */
#webko-swift-search-modal .wss-result__price {
    flex: 0 0 auto;
    padding-top: 1px;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

#webko-swift-search-modal .wss-result__price del {
    opacity: 0.5;
    font-weight: 400;
    margin-right: 6px;
    text-decoration: line-through;
}

#webko-swift-search-modal .wss-result__price ins {
    text-decoration: none;
}

#webko-swift-search-modal .wss-result--outofstock .wss-result__image img,
#webko-swift-search-modal .wss-result--outofstock .wss-result__title {
    opacity: 0.55;
}

@media (max-width: 600px) {
    #webko-swift-search-modal .wss-result {
        flex-wrap: wrap;
    }

    #webko-swift-search-modal .wss-result__price {
        flex-basis: 100%;
        text-align: right;
    }

    #webko-swift-search-modal .wss-result__excerpt {
        font-size: 12px;
    }

    #webko-swift-search-modal .wss-result__meta {
        font-size: 11px;
    }
}

#webko-swift-search-modal .wss-result__title mark,
#webko-swift-search-modal .wss-result__excerpt mark {
    background: var(--wss-mark);
    border-radius: 2px;
    box-shadow: 0 0 0 2px var(--wss-mark);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* — Correction banner — */
#webko-swift-search-modal .wss-modal__correction {
    font-size: 14px;
    line-height: 1.5;
    padding: 0 5px;
    opacity: 0.6;
}

/*
 * — Category suggestions, above the results —
 *
 * Pills rather than a list: they are shelves to step onto, not results to compare, and the
 * shopper should be able to take them in without reading down a column. They borrow the
 * theme's colours the same way everything else in the modal does; the count is what makes a
 * suggestion worth trusting, so it is present but quiet.
 */
/* — Ways of finishing what is being typed, above the categories — */
#webko-swift-search-modal .wss-modal__suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 12px 4px 0;
}

#webko-swift-search-modal .wss-modal__suggestions[hidden] {
    display: none;
}

/* Quieter than a category: a category is somewhere to go, a suggestion is only another
   way of saying the same thing. Dotted underline rather than a pill, so the two never
   read as one row of equal choices. */
#webko-swift-search-modal .wss-suggestion {
    appearance: none;
    background: none;
    border: 0;
    padding: 3px 2px;
    margin: 0;
    font: inherit;
    font-size: 14px;
    line-height: 1.3;
    color: inherit;
    cursor: pointer;
    opacity: 0.75;
    border-bottom: 1px dotted currentColor;
}

#webko-swift-search-modal .wss-suggestion:hover,
#webko-swift-search-modal .wss-suggestion:focus-visible {
    opacity: 1;
    border-bottom-style: solid;
}

#webko-swift-search-modal .wss-modal__categories {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
}

#webko-swift-search-modal .wss-modal__categories[hidden] {
    display: none;
}

#webko-swift-search-modal .wss-categories__heading {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 2%;
    text-transform: uppercase;
    opacity: 0.5;
    margin-right: 2px;
}

#webko-swift-search-modal .wss-category {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: 999px;
    font-size: 14px;
    line-height: 1.3;
    text-decoration: none;
}

#webko-swift-search-modal .wss-category:hover,
#webko-swift-search-modal .wss-category:focus-visible {
    border-color: currentColor;
}

#webko-swift-search-modal .wss-category__count {
    font-size: 12px;
    opacity: 0.55;
    font-variant-numeric: tabular-nums;
}

/* — "See all N results", below the result list — */
#webko-swift-search-modal .wss-modal__all {
    display: block;
    padding: 12px var(--wss-pad);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border-top: 1px solid var(--wss-hairline);
}

#webko-swift-search-modal .wss-modal__all:hover,
#webko-swift-search-modal .wss-modal__all:focus-visible {
    text-decoration: underline;
}

/*
 * The correction notice on the search results page. This one is NOT inside the modal, so
 * it cannot be scoped to it and cannot lean on the modal's own type. It borrows the
 * theme's font and sizing deliberately: it sits above the shop's product grid and should
 * read as part of that page, not as something the plugin pasted on top.
 */
.wss-page-correction {
    margin: 0 0 1em;
    opacity: 0.75;
}


/* — Empty state — */
#webko-swift-search-modal .wss-modal__empty {
    text-align: center;
    padding: 28px var(--wss-pad);
    opacity: 0.55;
    font-size: 14px;
}

/* — Screen-reader only — */
#webko-swift-search-modal .wss-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* — Reduced motion — */
@media (prefers-reduced-motion: reduce) {

    #webko-swift-search-modal .wss-modal__backdrop,
    #webko-swift-search-modal .wss-modal__container {
        transition: none;
    }

    #webko-swift-search-modal .wss-modal__container {
        transform: none;
    }
}

/* — Mobile — */
@media (max-width: 600px) {
    #webko-swift-search-modal {
        --wss-pad: 14px;
        padding: 8px 8px 0;
    }

    #webko-swift-search-modal .wss-modal__label {
        font-size: 20px;
    }

    #webko-swift-search-modal .wss-modal__results {
        max-height: calc(100dvh - 200px);
    }

    /* Skip animation — keyboard is the transition */
    #webko-swift-search-modal .wss-modal__backdrop,
    #webko-swift-search-modal .wss-modal__container {
        transition: none;
    }

    #webko-swift-search-modal .wss-modal__container {
        transform: none;
        opacity: 1;
    }

    #webko-swift-search-modal .wss-modal__backdrop {
        opacity: 1;
    }
}