/**
 * The Keepers Product Search: the suggestions list.
 *
 * Colours, font and corners follow the theme's presets (with plain
 * fallbacks), so it matches the shop without settings.
 */
.tkps-box {
    --tkps-bg: var(--wp--preset--color--custom-white, #fff);
    --tkps-text: var(--wp--preset--color--custom-primary, #1d3b2f);
    --tkps-muted: var(--wp--preset--color--custom-primary-50, #6b7c74);
    --tkps-line: var(--wp--preset--color--custom-primary-10, #e7ecea);
    --tkps-hover: var(--wp--preset--color--custom-primary-10, #f1f4f3);
    --tkps-radius: var(--border-radius-md, 10px);

    position: fixed;
    z-index: 100000;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    background: var(--tkps-bg);
    color: var(--tkps-text);
    border: 1px solid var(--tkps-line);
    border-radius: var(--tkps-radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.35;
    text-align: left;
}

.tkps-box[hidden] {
    display: none;
}

.tkps-head {
    padding: 10px 10px 4px;
    /* Same size as the prices */
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--tkps-text);
}

.tkps-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 10px;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}

.tkps-option:hover,
.tkps-option.is-active {
    background: var(--tkps-hover);
    color: inherit;
    text-decoration: none;
}

.tkps-option mark {
    background: none;
    color: inherit;
    font-weight: 700;
}

.tkps-product__img {
    flex: none;
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--tkps-line);
}

.tkps-product__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tkps-product__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tkps-product__maker,
.tkps-term__count {
    font-size: 13px;
    color: var(--tkps-muted);
}

.tkps-product__badge {
    align-self: flex-start;
    margin-top: 3px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--tkps-line);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    line-height: 1.5;
}

.tkps-product__price {
    flex: none;
    font-size: 13px;
    white-space: nowrap;
}

.tkps-product__price del {
    color: var(--tkps-muted);
    margin-right: 4px;
}

.tkps-product__price ins {
    text-decoration: none;
}

.tkps-term__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tkps-term__img {
    flex: none;
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
}

.tkps-all {
    position: relative;
    justify-content: center;
    margin-top: 9px;
    border-radius: 6px;
    padding: 10px;
    font-weight: 600;
}

/* Line above "Show all results", apart from its rounded hover */
.tkps-all::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 0;
    right: 0;
    border-top: 1px solid var(--tkps-line);
}

.tkps-none {
    padding: 12px 10px;
    color: var(--tkps-muted);
}

@media (max-width: 600px) {
    .tkps-box {
        font-size: 14px;
    }

    .tkps-product__img {
        width: 40px;
        height: 40px;
    }
}

/* While suggestions are on their way */
.tkps-box.is-stale .tkps-option {
    opacity: 0.55;
    transition: opacity 0.15s;
}

.tkps-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    color: var(--tkps-muted);
}

.tkps-loading::before,
.tkps-spinner {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    box-sizing: border-box;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: tkps-spin 0.7s linear infinite;
}

.tkps-spinner {
    position: fixed;
    z-index: 100001;
    color: var(--wp--preset--color--custom-primary-50, #6b7c74);
    pointer-events: none;
}

.tkps-spinner[hidden] {
    display: none;
}

@keyframes tkps-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tkps-loading::before,
    .tkps-spinner {
        animation-duration: 2s;
    }
}

/* ── Full-screen search (setting "Full-screen search") ──
 * A dialog floating over the page, which shows through a dimmed backdrop.
 * Its controls are styled with enough weight that theme rules for forms,
 * inputs and buttons (e.g. on product pages) do not move them. */
html.tkps-overlay-open,
html.tkps-overlay-open body {
    overflow: hidden;
}

.tkps-overlay {
    --tkps-bg: var(--wp--preset--color--custom-white, #fff);
    --tkps-text: var(--wp--preset--color--custom-primary, #1d3b2f);
    --tkps-muted: var(--wp--preset--color--custom-primary-50, #6b7c74);
    --tkps-line: var(--wp--preset--color--custom-primary-10, #e7ecea);
    --tkps-hover: var(--wp--preset--color--custom-primary-10, #f1f4f3);
    --tkps-radius: var(--border-radius-md, 10px);
    --tkps-gap: 12px;

    position: fixed;
    inset: 0;
    z-index: 100000;
    font-family: inherit;
    text-align: left;
}

.tkps-overlay[hidden] {
    display: none;
}

.tkps-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 28, 24, 0.38);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: tkps-fade-in 0.2s ease-out both;
}

.tkps-overlay__panel {
    position: absolute;
    /* Above the phone's keyboard: --tkps-vh / --tkps-vt follow the visible area. */
    top: calc(var(--tkps-vt, 0px) + max(var(--tkps-gap), env(safe-area-inset-top)));
    left: var(--tkps-gap);
    right: var(--tkps-gap);
    max-height: calc(var(--tkps-vh, 100dvh) - var(--tkps-gap) * 2 - env(safe-area-inset-top));
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    background: var(--tkps-bg);
    color: var(--tkps-text);
    border-radius: calc(var(--tkps-radius) + 4px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22), 0 4px 14px rgba(0, 0, 0, 0.1);
    transform-origin: top center;
    animation: tkps-panel-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.05) both;
}

.tkps-overlay.is-closing .tkps-overlay__backdrop {
    animation: tkps-fade-out 0.16s ease-in both;
}

.tkps-overlay.is-closing .tkps-overlay__panel {
    animation: tkps-panel-out 0.16s ease-in both;
}

@keyframes tkps-fade-in {
    from { opacity: 0; }
}

@keyframes tkps-fade-out {
    to { opacity: 0; }
}

@keyframes tkps-panel-in {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.97);
    }
}

@keyframes tkps-panel-out {
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tkps-overlay__backdrop,
    .tkps-overlay__panel {
        animation: none !important;
    }
}

.tkps-overlay .tkps-overlay__bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 10px 8px 10px 10px;
    border: 0;
    border-bottom: 1px solid var(--tkps-line);
    background: none;
    box-shadow: none;
    flex: none;
}

.tkps-overlay .tkps-overlay__field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    height: 46px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--tkps-line);
    border-radius: var(--tkps-radius);
    background: var(--tkps-hover);
    font-size: inherit;
    font-weight: normal;
    line-height: 1;
}

.tkps-overlay .tkps-overlay__field:focus-within {
    border-color: var(--tkps-muted);
    background: var(--tkps-bg);
}

.tkps-overlay .tkps-overlay__icon {
    flex: none;
    display: block;
    color: var(--tkps-muted);
}

.tkps-overlay .tkps-overlay__input {
    flex: 1;
    min-width: 0;
    width: auto;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font: inherit;
    /* 16px or more: phones do not zoom into the field. */
    font-size: 17px;
    line-height: normal;
    -webkit-appearance: none;
    appearance: none;
}

/* One X only: the browser's own "clear" button would sit next to the close button. */
.tkps-overlay .tkps-overlay__input::-webkit-search-cancel-button,
.tkps-overlay .tkps-overlay__input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

/* Close: an X, the same height as the field */
.tkps-overlay .tkps-overlay__close {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    box-shadow: none;
    color: inherit;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tkps-overlay .tkps-overlay__close:hover,
.tkps-overlay .tkps-overlay__close:focus-visible {
    background: var(--tkps-hover);
    color: inherit;
}

.tkps-overlay .tkps-overlay__close svg {
    display: block;
}

.tkps-overlay__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 4px 6px;
}

.tkps-overlay__body:has(.tkps-box--inline[hidden]) {
    padding: 0;
}

/* "Show all results": the main action, always at the bottom of the dialog */
.tkps-overlay__foot {
    flex: none;
    padding: 10px;
    border-top: 1px solid var(--tkps-line);
}

.tkps-overlay__foot[hidden] {
    display: none;
}

.tkps-overlay .tkps-overlay__submit {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 12px 16px;
    border: 0;
    border-radius: var(--tkps-radius);
    background: var(--wp--preset--color--custom-primary, #1d3b2f);
    box-shadow: none;
    color: var(--wp--preset--color--custom-white, #fff);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
}

.tkps-overlay .tkps-overlay__submit:hover,
.tkps-overlay .tkps-overlay__submit:focus-visible {
    opacity: 0.9;
}

/* The list inside it: part of the dialog, not floating */
.tkps-box.tkps-box--inline {
    position: static;
    max-height: none !important;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: none;
}

.tkps-box--inline .tkps-option {
    padding-top: 9px;
    padding-bottom: 9px;
}
