/*
 * Mobile search — top bar + navy scrim (Version A). Markup:
 * src/components/mobile-search/mobile-search.php, behaviour: src/js/mobile-search.js.
 *
 * Everything is under .ism-search (or the two opener buttons), with no
 * .dgwt-wcas-* selectors, so there is no specificity fight with FiboSearch's
 * Pirx skin. Enqueued after style.css.
 */

/* ---------- header magnifier (phones only; the header field takes over from 768px)
 * !important because the theme has `button { display: flex !important }`. */
.ism-search-hbtn { display: none !important; }
@media (max-width: 767px) {
    header.header nav.nav { position: relative; }
    .ism-search-hbtn {
        position: absolute; right: 44px; top: 50%; transform: translateY(-50%);
        display: flex !important; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; margin: 0;
        border: 0; background: transparent; color: #172331; border-radius: 8px; cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .ism-search-hbtn svg { width: 22px; height: 22px; }
    .ism-search-hbtn:focus-visible { outline: 2px solid #172331; outline-offset: -2px; }
}

/* ---------- container + scrim */
.ism-search {
    --ism-ink: #172331; --ism-paper: #fff; --ism-paper-2: #f8f8f9; --ism-line: #f0f0f0; --ism-line-2: #d1d3d6;
    --ism-muted: #5b6573; --ism-field-line: #8a929c; --ism-chip: #e8eef5; --ism-chip-hover: #dbe4ee;
    --ism-sale: #b3202e; --ism-err-tint: #fff1f2; --ism-err-fg: #a61e2a;
    --ism-scrim: rgba(23, 35, 49, .52);
    --ism-ease-out: cubic-bezier(.2, .8, .2, 1); --ism-ease-in: cubic-bezier(.4, 0, 1, 1);
    position: fixed; inset: 0; z-index: 2147483000;
    color: var(--ism-ink); font-size: 16px; line-height: 1.5; text-align: left;
    pointer-events: none;
}
.ism-search[hidden] { display: none; }
.ism-search[data-open="true"] { pointer-events: auto; }
.ism-search *, .ism-search *::before, .ism-search *::after { box-sizing: border-box; }
.ism-search__scrim {
    position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
    background: var(--ism-scrim); opacity: 0; cursor: default;
    transition: opacity 150ms var(--ism-ease-in);
}
.ism-search[data-open="true"] .ism-search__scrim { opacity: 1; transition: opacity 200ms var(--ism-ease-out); }

/* ---------- sheet: bar + panel + foot are one surface */
.ism-search__sheet {
    position: absolute; left: 0; right: 0; top: var(--ism-kb-offset, 0px);
    display: flex; flex-direction: column;
    max-height: calc(var(--ism-vvh, 100vh) - 96px);
    background: var(--ism-paper); border-radius: 0 0 16px 16px;
    box-shadow: 0 12px 32px rgba(23, 35, 49, .24);
    transform: translateY(-16px); opacity: 0;
    transition: transform 150ms var(--ism-ease-in), opacity 150ms var(--ism-ease-in);
}
.ism-search[data-open="true"] .ism-search__sheet {
    transform: none; opacity: 1;
    transition: transform 200ms var(--ism-ease-out), opacity 200ms var(--ism-ease-out);
}

.ism-search__bar {
    position: relative; flex: none; display: flex; align-items: center; gap: 8px;
    min-height: 64px; margin: 0;
    padding: max(8px, env(safe-area-inset-top)) 8px 8px 12px;
}
.ism-search__field {
    position: relative; flex: 1; min-width: 0; height: 48px; display: flex; align-items: center;
    background: var(--ism-paper-2); border: 1px solid var(--ism-field-line); border-radius: 12px;
}
.ism-search__field:focus-within { border-color: var(--ism-ink); box-shadow: 0 0 0 1px var(--ism-ink); }
.ism-search__field > svg { position: absolute; left: 14px; width: 20px; height: 20px; color: var(--ism-ink); pointer-events: none; }
.ism-search .ism-search__input {
    -webkit-appearance: none; appearance: none; display: block;
    width: 100%; height: 100%; min-width: 0; margin: 0; padding: 0 44px;
    border: 0; border-radius: 12px; background: transparent; box-shadow: none; outline: 0;
    font: inherit; font-size: 16px; line-height: normal; color: var(--ism-ink);
}
.ism-search .ism-search__input::placeholder { color: var(--ism-muted); opacity: 1; }
.ism-search .ism-search__input::-webkit-search-cancel-button,
.ism-search .ism-search__input::-webkit-search-decoration { -webkit-appearance: none; }
.ism-search__clear {
    position: absolute; right: 2px; top: 1px; width: 44px; height: 44px; padding: 0; margin: 0;
    display: flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--ism-muted);
    border-radius: 12px; cursor: pointer;
}
.ism-search__clear[hidden] { display: none !important; }
.ism-search__clear svg { width: 18px; height: 18px; }
.ism-search__close {
    flex: none; height: 44px; margin: 0; padding: 0 8px; border: 0; background: none;
    font: inherit; font-size: 16px; font-weight: 500; color: var(--ism-ink);
    border-radius: 8px; cursor: pointer; white-space: nowrap; text-transform: none; letter-spacing: 0;
}
.ism-search__clear:focus-visible, .ism-search__close:focus-visible { outline: 2px solid var(--ism-ink); outline-offset: -4px; }

/* progress line under the bar while a request is in flight */
.ism-search__progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; overflow: hidden; opacity: 0; transition: opacity 150ms; }
.ism-search[data-state="loading"] .ism-search__progress,
.ism-search[data-state="refining"] .ism-search__progress { opacity: 1; }
.ism-search__progress::after {
    content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--ism-ink);
    animation: ism-slide 1.1s cubic-bezier(.4, 0, .2, 1) infinite;
}
@keyframes ism-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

.ism-search__panel {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--ism-line); padding: 8px 0 12px;
}
.ism-search[data-state="refining"] .ism-opt { opacity: .55; transition: opacity 150ms; }

/* ---------- sections + chips */
.ism-search .ism-sec { padding: 8px 16px 0; }
.ism-search .ism-sec + .ism-sec { margin-top: 8px; }
.ism-search .ism-sec__h {
    display: flex; align-items: center; justify-content: space-between; min-height: 32px; margin: 0;
    font-size: 13px; line-height: 1.3; font-weight: 700; color: var(--ism-muted); text-transform: none; letter-spacing: 0;
}
.ism-search .ism-taxbox[hidden] { display: none; }
.ism-search .ism-link {
    border: 0; background: none; margin: 0; padding: 8px 4px; min-height: 32px; cursor: pointer;
    font: inherit; font-size: 14px; font-weight: 500; color: var(--ism-ink);
    text-decoration: underline; text-underline-offset: 3px; border-radius: 6px;
}
.ism-search .ism-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 4px 0 8px; list-style: none; }
.ism-search .ism-chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 36px; max-width: 100%;
    margin: 0; padding: 0 14px; border: 0; border-radius: 999px;
    background: var(--ism-chip); color: var(--ism-ink);
    font: inherit; font-size: 15px; font-weight: 500; line-height: 1.2; text-decoration: none; text-transform: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.ism-search .ism-chip > span { overflow: hidden; text-overflow: ellipsis; }
.ism-search .ism-chip svg { width: 16px; height: 16px; flex: none; color: var(--ism-muted); }
.ism-search .ism-chip:hover { background: var(--ism-chip-hover); }
/* Category/brand chips in results: outlined so they read as destinations, not suggestions. */
.ism-search .ism-taxbox .ism-chip--tax { background: var(--ism-paper); box-shadow: inset 0 0 0 1.5px var(--ism-ink); font-weight: 500; }
.ism-search .ism-taxbox .ism-chip--tax svg { color: var(--ism-ink); }
.ism-search .ism-taxbox .ism-chip--tax b { font-weight: 700; }
.ism-search .ism-chip:focus-visible, .ism-search .ism-chip.is-active { outline: 2px solid var(--ism-ink); outline-offset: 1px; }

.ism-search .ism-hint {
    display: flex; align-items: center; gap: 12px; margin: 8px 16px 4px; padding: 12px;
    background: var(--ism-paper-2); border-radius: 8px; font-size: 15px;
}
.ism-search .ism-dots { display: flex; gap: 4px; flex: none; }
.ism-search .ism-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--ism-line-2); }
.ism-search .ism-dots i.on { background: var(--ism-ink); }

/* ---------- product rows */
.ism-search .ism-opt {
    display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 8px 16px;
    color: var(--ism-ink); text-decoration: none; cursor: pointer;
}
.ism-search .ism-opt + .ism-opt { border-top: 1px solid var(--ism-line); }
.ism-search .ism-opt:active { background: var(--ism-chip); }
.ism-search .ism-opt.is-active { background: var(--ism-chip); box-shadow: inset 3px 0 0 var(--ism-ink); }
.ism-search .ism-opt:focus-visible { outline: 2px solid var(--ism-ink); outline-offset: -2px; }
.ism-search .ism-opt__img {
    flex: none; width: 56px; height: 56px; border-radius: 8px; background: var(--ism-paper-2);
    display: grid; place-items: center; overflow: hidden;
}
.ism-search .ism-opt__img img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.ism-search .ism-opt__t { flex: 1; min-width: 0; }
.ism-search .ism-opt__n {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    font-size: 15px; line-height: 20px; overflow-wrap: anywhere;
}
.ism-search .ism-opt__n b { font-weight: 700; }
.ism-search .ism-opt__c { display: block; font-size: 13px; line-height: 18px; color: var(--ism-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ism-search .ism-opt__c[hidden] { display: none; }
.ism-search .ism-opt__p {
    flex: none; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
    font-size: 15px; line-height: 20px; font-weight: 700;
}
.ism-search .ism-opt__p ins { display: block; color: var(--ism-sale); text-decoration: none; background: none; }
.ism-search .ism-opt__p del { display: block; color: var(--ism-muted); font-size: 13px; font-weight: 400; }

/* ---------- skeleton, messages, buttons */
.ism-search .ism-sk { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 8px 16px; }
.ism-search .ism-sk + .ism-sk { border-top: 1px solid var(--ism-line); }
.ism-search .ism-sk i { display: block; background: var(--ism-line); border-radius: 6px; animation: ism-pulse 1.2s ease-in-out infinite alternate; }
.ism-search .ism-sk .a { width: 56px; height: 56px; border-radius: 8px; }
.ism-search .ism-sk .b { flex: 1; height: 14px; max-width: 200px; }
.ism-search .ism-sk .c { width: 48px; height: 14px; margin-left: auto; }
@keyframes ism-pulse { from { opacity: 1; } to { opacity: .45; } }

.ism-search .ism-msg { padding: 16px 16px 8px; }
.ism-search .ism-msg h3 { margin: 0 0 4px; font-size: 17px; line-height: 1.3; font-weight: 700; color: var(--ism-ink); overflow-wrap: anywhere; }
.ism-search .ism-msg p { margin: 0; font-size: 15px; color: var(--ism-muted); }
.ism-search .ism-msg--err { margin: 8px 16px; background: var(--ism-err-tint); border-radius: 8px; }
.ism-search .ism-msg--err h3 { color: var(--ism-err-fg); }

.ism-search .ism-search__btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; margin: 0; padding: 0 24px; border: 0; border-radius: 8px;
    background: var(--ism-ink); color: #fff; font: inherit; font-size: 16px; font-weight: 500;
    text-decoration: none; text-transform: none; white-space: nowrap; cursor: pointer;
}
.ism-search .ism-search__btn--ghost { background: var(--ism-paper); color: var(--ism-ink); box-shadow: inset 0 0 0 1px var(--ism-ink); }
.ism-search .ism-msg .ism-search__btn { margin-top: 12px; }
.ism-search .ism-search__btn:focus-visible { outline: 2px solid var(--ism-ink); outline-offset: 2px; }

.ism-search__foot {
    flex: none; padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--ism-line); background: var(--ism-paper); border-radius: 0 0 16px 16px;
}
.ism-search__foot[hidden] { display: none; }
.ism-search__foot .ism-search__btn { width: 100%; }

.ism-search__live { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
    .ism-search__sheet, .ism-search[data-open="true"] .ism-search__sheet { transform: none; transition: opacity 120ms linear; }
    .ism-search__scrim, .ism-search[data-open="true"] .ism-search__scrim { transition: opacity 120ms linear; }
    .ism-search__progress::after { animation: none; width: 100%; opacity: .5; }
    .ism-search .ism-sk i { animation: none; }
}

/* ---------- neutralise the theme's global button skin
 * style.css has `button { background-color: rgba(13,199,163,.8); min-width: 46px;
 * text-transform: uppercase; font-size: 12px; position: relative }` and a green
 * `button:hover` (0,1,1) that beats single-class rules — the scrim turned green
 * under the finger. Re-state every button's own background at higher specificity. */
.ism-search button, .ism-search-hbtn { min-width: 0; text-transform: none; letter-spacing: 0; }
.ism-search button.ism-search__scrim,
.ism-search button.ism-search__scrim:hover,
.ism-search button.ism-search__scrim:focus,
.ism-search button.ism-search__scrim:active { background-color: var(--ism-scrim); position: absolute; }
.ism-search button.ism-search__clear, .ism-search button.ism-search__clear:hover,
.ism-search button.ism-search__close, .ism-search button.ism-search__close:hover,
.ism-search button.ism-link, .ism-search button.ism-link:hover,
header.header .ism-search-hbtn, header.header .ism-search-hbtn:hover { background-color: transparent; }
.ism-search button.ism-search__close:hover { background-color: var(--ism-paper-2); }
.ism-search button.ism-chip { background-color: var(--ism-chip); color: var(--ism-ink); }
.ism-search button.ism-chip:hover { background-color: var(--ism-chip-hover); }
.ism-search button.ism-search__btn { background-color: var(--ism-ink); color: #fff; }
.ism-search button.ism-search__btn--ghost, .ism-search button.ism-search__btn--ghost:hover { background-color: var(--ism-paper); color: var(--ism-ink); }
.ism-search button.ism-search__btn:not(.ism-search__btn--ghost):hover { background-color: #22324a; }
