/* ===== Custom properties (overridable by themes) ===== */
:root {
    --wcss-z-index: 999;
}

/* ===== Form layout ===== */
.wcss-search {
    position: relative;
    width: 100%;
}

.wcss-form {
    display: flex;
    margin: 0;
}

.wcss-input {
    flex: 1;
    min-width: 0;
    margin: 0;
    height: auto !important;
    box-sizing: border-box;
}

.wcss-submit {
    flex-shrink: 0;
    margin: 0;
}

/* ===== Results dropdown ===== */
.wcss-results {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    z-index: var(--wcss-z-index);
    max-height: 460px;
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 2rem 1rem;
}

.wcss-results.active {
    display: block;
}

/* ===== Result items ===== */
.wcss-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 1rem;
}

.wcss-result-item:hover,
.wcss-result-item.focused {
    background-color: rgba(0, 0, 0, 0.04);
}

.wcss-result-image {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    overflow: hidden;
}

.wcss-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wcss-result-content {
    flex: 1;
    min-width: 0;
}

.wcss-result-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.8rem;
}

.wcss-result-price {
    flex-shrink: 0;
    margin-left: auto;
    text-align: right;
}

.wcss-price-from,
.wcss-tax-label {
    font-size: 0.75em;
    font-weight: 400;
    opacity: 0.8;
    white-space: nowrap;
}

.wcss-tax-label {
    display: block;
}

/* ===== Group headers (shown when multiple post types) ===== */
.wcss-group-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.45);
    padding: 0.75rem 0 0.25rem;
}

.wcss-group:first-child .wcss-group-header {
    padding-top: 0;
}

/* ===== Footer ===== */
.wcss-footer {
    padding-top: 2rem;
}
.wcss-footer-link {
    margin: 0;
}

/* ===== Trigger icon ===== */
.wcss-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: auto;
    min-height: 0;
    margin: 0 !important;
    padding: 8px;
    border: 0;
    border-radius: 999px;
    background: none;
    box-shadow: none;
    color: inherit;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    transition: opacity .15s;
}
.wcss-trigger:hover { opacity: .75; }
.wcss-trigger:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.wcss-trigger svg { display: block; flex-shrink: 0; }

/* ===== Expanding field (desktop): [smart_search_icon expand="desktop"] ===== */
.wcss-expand {
    --wcss-expand-bg: #f0ebe5;
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    border-radius: 999px;
    background: transparent;
    transition: background-color .25s ease, color .25s ease;
}
.wcss-expand.is-open {
    background: var(--wcss-expand-bg);
    color: #111;
}
.wcss-expand.is-open .wcss-trigger:hover { opacity: .6; }

.wcss-expand__form {
    width: 0;
    overflow: hidden;
    visibility: hidden;
    transition: width .25s ease, visibility 0s linear .25s;
}
.wcss-expand.is-open .wcss-expand__form {
    width: min(var(--wcss-expand-width, 380px), 60vw);
    visibility: visible;
    transition: width .25s ease, visibility 0s;
}

.wcss-expand .wcss-input {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 8px 0 8px 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    color: inherit;
    line-height: 1.3;
    -webkit-appearance: none;
    appearance: none;
}
.wcss-expand .wcss-input:focus,
.wcss-expand .wcss-input:focus-visible,
.wcss-expand .wcss-input:active {
    /* Keep the beige pill when active; overrides theme input:focus styles. */
    border: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    color: inherit;
}
.wcss-expand .wcss-input::placeholder { color: inherit; opacity: .55; }
.wcss-expand .wcss-input::-webkit-search-cancel-button { display: none; }

/* Results panel under the field, exactly as wide as the expanded field. */
.wcss-expand .wcss-results {
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    width: auto;
    padding: 14px;
    border: 1px solid rgba(0, 0, 0, .06);
    border-radius: 16px;
    background: var(--wcss-expand-bg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
    color: #111;
    text-align: left;
}

.wcss-expand .wcss-result-item {
    margin: 0;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background-color .15s;
}
.wcss-expand .wcss-result-item + .wcss-result-item { margin-top: 2px; }
.wcss-expand .wcss-result-item:hover,
.wcss-expand .wcss-result-item.focused { background-color: rgba(0, 0, 0, .05); }
.wcss-expand .wcss-result-image {
    box-sizing: border-box;
    width: 60px;
    height: 60px;
    padding: 5px;
    border-radius: 10px;
    background: #fff;
}
.wcss-expand .wcss-result-image img { object-fit: contain; }
.wcss-expand .wcss-group-header { padding: 10px 10px 4px; }
.wcss-expand .wcss-loading,
.wcss-expand .wcss-no-results,
.wcss-expand .wcss-error { padding: 10px; opacity: .7; }
.wcss-expand .wcss-footer {
    margin-top: 6px;
    padding: 8px 2px 2px;
    border-top: 1px solid rgba(0, 0, 0, .08);
}

@media (prefers-reduced-motion: reduce) {
    .wcss-expand,
    .wcss-expand__form,
    .wcss-expand.is-open .wcss-expand__form { transition: none; }
}

/* Matched text in results: brand light blue instead of the browser's yellow. */
.wcss-results mark {
    padding: 0 1px;
    border-radius: 2px;
    background: #d2e7fe;
    color: inherit;
}

/* ===== Loading spinner (own, no theme dependency) ===== */
.wcss-loading {
    display: flex;
    align-items: center;
    gap: 10px;
}
.wcss-spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    opacity: .6;
    animation: wcss-spin .7s linear infinite;
}
@keyframes wcss-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .wcss-spinner { animation-duration: 2s; }
}

/* ===== Modal (native <dialog>) ===== */
.wcss-modal {
    border: none;
    border-radius: 12px;
    padding: 0;
    max-width: 680px;
    width: 100%;
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        overlay 0.2s ease allow-discrete,
        display 0.2s ease allow-discrete;
}

.wcss-modal:not(:has(.wcss-results.active)) {
    padding-bottom: 2rem;
}

/* Entry transition (from closed → open). */
@starting-style {
    .wcss-modal[open] {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* Exit transition (open → closing). */
.wcss-modal:not([open]) {
    opacity: 0;
    transform: translateY(-8px);
}

.wcss-modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    opacity: 1;
    transition:
        opacity 0.2s ease,
        overlay 0.2s ease allow-discrete,
        display 0.2s ease allow-discrete;
}

@starting-style {
    .wcss-modal[open]::backdrop {
        opacity: 0;
    }
}

.wcss-modal:not([open])::backdrop {
    opacity: 0;
}

.wcss-modal-inner {
    position: relative;
    width: 100%;
    padding: 2rem 2rem 0 2rem;
}

.wcss-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    padding: 0.25rem;
}

.wcss-modal .wcss-results {
    position: static;
    max-height: 500px;
    box-shadow: none;
}
