/* [weave_search]: a search box with live results. Follows the same
   variables as the cards and the cart: --weave-accent, --weave-ink,
   --weave-surface, --weave-muted, --weave-radius, --weave-font. */

.weave-search {
    --_accent: var(--weave-accent, var(--weave-primary-color, #1f6f5c));
    --_ink: var(--weave-ink, #1b1b1b);
    --_surface: var(--weave-surface, #fff);
    --_muted: var(--weave-muted, #6b6b6b);
    --_radius: var(--weave-radius, 12px);
    --_line: color-mix(in srgb, var(--_ink) 14%, transparent);
    position: relative;
    display: block;
    width: 100%;
    max-width: var(--weave-search-width, 100%);
    margin: 0;
    color: var(--_ink);
    font-family: var(--weave-font, inherit);
}
.weave-search *, .weave-search *::before, .weave-search *::after { box-sizing: border-box; }
.weave-search__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.weave-search__box { position: relative; display: flex; align-items: center; }
.weave-search__icon { position: absolute; left: 14px; color: var(--_muted); pointer-events: none; }
.weave-search__input {
    width: 100%; margin: 0; padding: 11px 40px 11px 42px;
    font: inherit; font-size: 0.98rem; color: var(--_ink);
    background: var(--_surface); border: 1px solid var(--_line); border-radius: 999px;
    outline: none; transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none; appearance: none;
}
.weave-search__input::-webkit-search-cancel-button, .weave-search__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.weave-search__input::placeholder { color: var(--_muted); }
.weave-search__input:focus { border-color: var(--_accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--_accent) 18%, transparent); }
.weave-search__clear {
    position: absolute; right: 8px; width: 28px; height: 28px; padding: 0;
    border: 0; border-radius: 50%; background: none; color: var(--_muted);
    font: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.weave-search__clear:hover { background: color-mix(in srgb, var(--_ink) 7%, transparent); color: var(--_ink); }
.weave-search--loading .weave-search__icon { animation: weave-search-pulse 0.9s ease-in-out infinite; }
@keyframes weave-search-pulse { 50% { opacity: 0.35; } }

.weave-search__results {
    position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 8px);
    min-width: min(360px, 100vw - 32px);
    background: var(--_surface); color: var(--_ink);
    border: 1px solid var(--_line); border-radius: var(--_radius);
    box-shadow: 0 16px 48px rgb(0 0 0 / 0.14);
    padding: 6px; max-height: min(70vh, 520px); overflow: auto;
}
.weave-search--right .weave-search__results { left: auto; }
.weave-search__item {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
    padding: 8px 10px; border-radius: calc(var(--_radius) * 0.6);
    color: inherit; text-decoration: none; cursor: pointer;
}
.weave-search__item.is-active, .weave-search__item:hover { background: color-mix(in srgb, var(--_accent) 9%, transparent); }
.weave-search__img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: color-mix(in srgb, var(--_ink) 6%, transparent); display: block; }
.weave-search__img--page { display: flex; align-items: center; justify-content: center; color: var(--_accent); background: color-mix(in srgb, var(--_accent) 10%, transparent); }
.weave-search__go { font-size: 0.82rem; font-weight: 600; color: var(--_accent); white-space: nowrap; }
.weave-search__item--page + .weave-search__item:not(.weave-search__item--page) { margin-top: 4px; border-top: 1px solid var(--_line); border-radius: 0 0 calc(var(--_radius) * 0.6) calc(var(--_radius) * 0.6); padding-top: 12px; }
.weave-search__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.weave-search__name { font-weight: 600; font-size: 0.95rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weave-search__sub { font-size: 0.8rem; color: var(--_muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weave-search__price { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; font-size: 0.92rem; white-space: nowrap; }
.weave-search__price s { color: var(--_muted); font-size: 0.78rem; }
.weave-search__price b { font-weight: 700; }
.weave-search__empty { margin: 0; padding: 12px 10px; color: var(--_muted); font-size: 0.92rem; }
.weave-search__all {
    display: block; margin: 4px 0 0; padding: 11px 10px; border-top: 1px solid var(--_line);
    color: var(--_accent); font-weight: 600; font-size: 0.9rem; text-decoration: none; border-radius: 0 0 calc(var(--_radius) * 0.6) calc(var(--_radius) * 0.6);
}
.weave-search__all.is-active, .weave-search__all:hover { background: color-mix(in srgb, var(--_accent) 9%, transparent); }

/* Inline results: in the page flow, for a popup or a search page */
.weave-search--inline .weave-search__results { position: static; margin-top: 12px; padding: 0; border: 0; box-shadow: none; max-height: none; min-width: 0; }
.weave-search--inline .weave-search__item { padding: 10px 8px; }
.weave-search--inline .weave-search__all { margin-top: 8px; }
