/* Vinnvinn Typesense — shop layout */

.vvts-app {
    --vvts-gap: 1.5rem;
    --vvts-radius: 8px;
    --vvts-border: #e5e7eb;
    --vvts-muted: #6b7280;
    --vvts-fg: #111827;
    --vvts-accent: #111827;
    --vvts-sale: #dc2626;
    color: var(--vvts-fg);
    font-family: inherit;
    width: 100%;
    padding-block: 1.5rem;
    box-sizing: border-box;
}

/* When the shop block theme uses `is-layout-constrained` on main, our
   container already inherits the theme's content-width. Add `alignwide`
   programmatically if the theme is too narrow for a grid of facets + hits. */

.vvts-app *,
.vvts-app *::before,
.vvts-app *::after { box-sizing: border-box; }

.vvts-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: var(--vvts-gap);
}

.vvts-title {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1.2;
}

.vvts-searchbox .ais-SearchBox-form {
    position: relative;
    display: block;
}
/* Satellite theme draws its own magnifier via ::before — hide it, the
   real <button.ais-SearchBox-submit> already renders the icon. */
.vvts-searchbox .ais-SearchBox-form::before { content: none; }

/* Same problem in Algolia Autocomplete: outside CSS (theme/plugins) injects
   a duplicate magnifier via ::before on the form/label. The real icon lives
   in .aa-SubmitButton — suppress the extras. */
.aa-Form::before,
.aa-Form::after,
.aa-Label::before,
.aa-Label::after,
.aa-InputWrapperPrefix::before,
.aa-InputWrapperPrefix::after { content: none; }

.vvts-searchbox .ais-SearchBox-input {
    width: 100%;
    /* Left padding clears the submit (magnifier) icon, right clears reset/loading. */
    padding: 0.7rem 2.5rem;
    border: 1px solid var(--vvts-border);
    border-radius: var(--vvts-radius);
    font-size: 1rem;
    background: #fff;
}

.vvts-searchbox .ais-SearchBox-submit,
.vvts-searchbox .ais-SearchBox-reset {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.25rem;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--vvts-muted);
    cursor: pointer;
    line-height: 0;
}
.vvts-searchbox .ais-SearchBox-submit { left: 0.6rem; }
.vvts-searchbox .ais-SearchBox-reset { right: 0.6rem; }
.vvts-searchbox .ais-SearchBox-reset[hidden] { display: none; }

.vvts-searchbox .ais-SearchBox-submitIcon,
.vvts-searchbox .ais-SearchBox-resetIcon {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.vvts-searchbox .ais-SearchBox-loadingIndicator {
    position: absolute;
    top: 50%;
    right: 0.6rem;
    transform: translateY(-50%);
    color: var(--vvts-muted);
}

.vvts-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--vvts-gap);
    align-items: start;
}

@media (max-width: 768px) {
    .vvts-layout { grid-template-columns: 1fr; }
    .vvts-facets { order: 2; }
    .vvts-results { order: 1; }
}

.vvts-facets {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.vvts-facet h3 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--vvts-muted);
}

.vvts-clear-refinements {
    align-self: flex-start;
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--vvts-border);
    border-radius: var(--vvts-radius);
    cursor: pointer;
    font-size: 0.85rem;
}

.vvts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--vvts-muted);
    font-size: 0.9rem;
}

.vvts-hits .ais-Hits-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Override satellite theme's item chrome — the product card draws its own border */
.vvts-hits .ais-Hits-item,
.vvts-hits .vvts-hits__item {
    box-shadow: none;
    padding: 0;
    background: transparent;
    border: 0;
    width: auto;
    /* Flex container so the card inside stretches to the row height that
       CSS grid hands the <li> via align-items: stretch. */
    display: flex;
}

.vvts-product-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid var(--vvts-border);
    border-radius: var(--vvts-radius);
    overflow: hidden;
    background: #fff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.vvts-product-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.06); }

.vvts-product-card__link {
    color: inherit;
    text-decoration: none;
    /* Flex column so the body inside can absorb empty space and the
       add-to-cart button (sibling, outside the link) sits flush against
       the bottom of the card on every row. */
    display: flex;
    flex-direction: column;
    flex: 1;
}

.vvts-product-card .vvts-product-card__image {
    aspect-ratio: 1 / 1;
    width: 100%;
    overflow: hidden;
    background: #fff;
}
.vvts-product-card .vvts-product-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.vvts-product-card__body {
    padding: 0.75rem 0.85rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.vvts-product-card__title {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.3;
    /* Clamp to 2 lines and reserve 2 lines of height so 1-line and
       3-line titles don't make neighbouring cards visibly uneven. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(0.95rem * 1.3 * 2);
}

.vvts-product-card__price {
    font-weight: 600;
    margin: 0;
}

.vvts-sale-badge {
    display: inline-block;
    background: var(--vvts-sale);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-right: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.vvts-add-to-cart {
    margin-top: auto;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--vvts-accent);
    background: var(--vvts-accent);
    color: #fff;
    border-radius: var(--vvts-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.15s ease;
}
.vvts-add-to-cart[disabled] {
    background: transparent;
    color: var(--vvts-muted);
    border-color: var(--vvts-border);
    cursor: not-allowed;
}
.vvts-add-to-cart.is-loading { opacity: 0.6; pointer-events: none; }
.vvts-add-to-cart.is-added { background: #16a34a; border-color: #16a34a; }

.vvts-pagination {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.vvts-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--vvts-muted);
}

/* Dual-handle price range slider */
.vvts-range {
    position: relative;
    padding: 0.5rem 0 1.5rem;
}
.vvts-range__track {
    position: relative;
    height: 4px;
    background: var(--vvts-border);
    border-radius: 2px;
}
.vvts-range__fill {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--vvts-accent);
    border-radius: 2px;
}
.vvts-range__input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 24px;
    margin: 0;
    background: transparent;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
}
.vvts-range__input::-webkit-slider-thumb {
    pointer-events: all;
    appearance: none;
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--vvts-accent);
    cursor: grab;
}
.vvts-range__input::-moz-range-thumb {
    pointer-events: all;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--vvts-accent);
    cursor: grab;
}
.vvts-range__input::-webkit-slider-runnable-track,
.vvts-range__input::-moz-range-track { background: transparent; height: 24px; }
.vvts-range__values {
    margin-top: 0.6rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--vvts-muted);
}

/* react-instantsearch class fallbacks */
.vvts-hits__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; list-style: none; margin: 0; padding: 0; }
.vvts-hits__item { display: flex; }
.vvts-refinement-list__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.vvts-refinement-list__label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.9rem; }
.vvts-refinement-list__count { margin-left: auto; color: var(--vvts-muted); font-size: 0.8rem; }
.vvts-refinement-list__show-more { margin-top: 0.5rem; background: none; border: none; color: var(--vvts-accent); cursor: pointer; padding: 0; font-size: 0.85rem; }
.vvts-refinement-list__search { width: 100%; }
.vvts-pagination__list { display: flex; gap: 0.4rem; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.vvts-pagination__item { border-radius: 4px; }
.vvts-pagination__link { padding: 0.4rem 0.7rem; border: 1px solid var(--vvts-border); border-radius: 4px; text-decoration: none; color: inherit; display: inline-block; }
.vvts-pagination__item--selected .vvts-pagination__link { background: var(--vvts-accent); color: #fff; border-color: var(--vvts-accent); }
.vvts-clear__button { padding: 0.4rem 0.75rem; background: transparent; border: 1px solid var(--vvts-border); border-radius: var(--vvts-radius); cursor: pointer; font-size: 0.85rem; }
.vvts-clear__button--disabled { opacity: 0.5; cursor: not-allowed; }

/* Autocomplete theme overrides — bigger by default, neutral colors that
   prefer the active block-theme tokens (--wp--preset--color--*) when present
   and fall back to the plugin's neutral accent palette. */
:root {
    /* Sizing */
    --aa-base-unit: 17;
    --aa-input-height: 52px;
    --aa-search-input-height: 52px;
    --aa-icon-size: 22px;
    --aa-spacing: 14px;
    --aa-detached-modal-max-width: 760px;
    --aa-detached-modal-max-height: 80vh;
    --aa-panel-max-height: 70vh;

    /* Colors — replace the purple defaults with neutral gray RGB tuples.
       (CSS can't plug a theme hex into an `--aa-*-rgb` triplet, so we use
       neutral fallbacks here and pull theme tokens on individual properties
       below where it's possible.) */
    --aa-text-color-rgb: 17, 24, 39;
    --aa-muted-color-rgb: 107, 114, 128;
    --aa-icon-color-rgb: 107, 114, 128;
    --aa-input-border-color-rgb: 209, 213, 219;
    --aa-input-border-color-alpha: 1;
    --aa-primary-color-rgb: 17, 24, 39;
    --aa-primary-color-alpha: 0.15;
    --aa-selected-color-rgb: 17, 24, 39;
    --aa-selected-color-alpha: 0.05;
}

/* Use theme tokens where we can — these resolve to the active block theme's
   palette on themes that expose them, and fall back to the plugin defaults. */
.aa-Form { border-color: var(--vvts-border); }
.aa-Form:focus-within {
    border-color: var(--wp--preset--color--contrast, var(--vvts-accent));
    box-shadow: none;
}
.aa-Input { font-size: 1rem; color: var(--wp--preset--color--contrast, var(--vvts-fg)); }
.aa-Panel,
.aa-DetachedContainer { font-size: 1rem; }
.aa-Item mark { color: inherit; background: var(--wp--preset--color--base-2, #fef9c3); }

/* Lift the panel + detached overlay above sticky/fixed site headers. */
.aa-Panel { z-index: 100000; }
.aa-DetachedOverlay,
.aa-DetachedContainer { z-index: 100001; }

/* Autocomplete custom item styling */
.vvts-ac-product { display: flex; align-items: center; gap: 0.85rem; text-decoration: none; color: inherit; padding: 0.5rem 0; }
.vvts-ac-product-img { width: 52px; height: 52px; flex: 0 0 52px; object-fit: cover; border-radius: 4px; background: #f4f4f5; display: block; }
.vvts-ac-product-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.vvts-ac-product-name { font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vvts-ac-product-price { font-size: 0.9rem; color: var(--vvts-muted); }
.vvts-ac-cat { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; font-size: 0.95rem; }
.vvts-ac-cat-count { margin-left: auto; color: var(--vvts-muted); font-size: 0.85rem; }

/* Pills */
.vvts-pills__items { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.vvts-pill {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--vvts-border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.vvts-pill:hover { border-color: var(--vvts-accent); }
.vvts-pill.is-active { background: var(--vvts-accent); border-color: var(--vvts-accent); color: #fff; }
.vvts-pill__count { color: var(--vvts-muted); font-size: 0.75rem; }
.vvts-pill.is-active .vvts-pill__count { color: rgba(255,255,255,0.7); }

/* Color swatches */
.vvts-swatches__items { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.vvts-swatch {
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    background: none; border: none; padding: 0; cursor: pointer;
    font-size: 0.7rem; color: var(--vvts-muted);
    max-width: 56px;
}
.vvts-swatch__dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid var(--vvts-border);
    background: #f9fafb;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 600; color: var(--vvts-fg);
    transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}
.vvts-swatch:hover .vvts-swatch__dot { transform: scale(1.08); }
.vvts-swatch.is-active .vvts-swatch__dot {
    border-color: var(--vvts-accent);
    box-shadow: 0 0 0 2px #fff inset, 0 0 0 3px var(--vvts-accent);
}
.vvts-swatch__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Dropdown */
.vvts-dropdown {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--vvts-border);
    border-radius: 4px;
    background: #fff;
}

/* SearchableList search input */
.vvts-refinement-list__search { width: 100%; margin-bottom: 0.5rem; }
.vvts-refinement-list__search-input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--vvts-border);
    border-radius: 4px;
    background: #fff;
    font-size: 0.85rem;
}
.vvts-refinement-list__empty { font-size: 0.85rem; color: var(--vvts-muted); padding: 0.3rem 0; }

/* Active filters bar */
.vvts-active-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}
.vvts-current-refinements__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    list-style: none;
    padding: 0;
    margin: 0;
}
.vvts-current-refinements__item { display: flex; align-items: center; gap: 0.3rem; }
.vvts-current-refinements__label {
    font-size: 0.78rem;
    color: var(--vvts-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.25rem;
}
.vvts-current-refinements__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.4rem 0.25rem 0.6rem;
    border: 1px solid var(--vvts-border);
    border-radius: 999px;
    background: #fff;
    font-size: 0.8rem;
}
.vvts-current-refinements__chip-label { white-space: nowrap; }
.vvts-current-refinements__chip-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--vvts-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.15rem;
}
.vvts-current-refinements__chip-delete:hover { color: var(--vvts-fg); }
.vvts-active-filters__clear {
    margin-left: auto;
    padding: 0.3rem 0.7rem;
    background: transparent;
    border: 1px solid var(--vvts-border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.8rem;
}
.vvts-active-filters__clear:hover { background: #f9fafb; }

/* Collapsible facet sections */
.vvts-facet__toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    padding: 0 0 0.4rem 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
    color: var(--vvts-muted);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.vvts-facet__title { flex: 1; }
.vvts-facet__chevron {
    color: var(--vvts-muted);
    transition: transform 0.15s ease;
    font-size: 0.8rem;
}
.vvts-facet.is-collapsed .vvts-facet__chevron { transform: rotate(-90deg); }
.vvts-facet h3 { display: none; } /* legacy h3 replaced by button */

/* Hierarchical menu */
.vvts-hierarchical, .vvts-hierarchical ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.vvts-hierarchical ul { padding-left: 1rem; margin-top: 0.15rem; }
.vvts-hierarchical__link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;
}
.vvts-hierarchical__link:hover { background: #f3f4f6; }
.vvts-hierarchical__item.is-refined > .vvts-hierarchical__link {
    background: #f3f4f6;
    font-weight: 600;
}
.vvts-hierarchical__count { color: var(--vvts-muted); font-size: 0.8rem; }

/* Mobile filter toggle button (hidden on desktop) */
.vvts-mobile-filter-toggle {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    background: #fff;
    border: 1px solid var(--vvts-border);
    border-radius: var(--vvts-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}
.vvts-mobile-filter-toggle__count {
    background: var(--vvts-accent);
    color: #fff;
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    font-size: 0.75rem;
    margin-left: 0.2rem;
}

/* Mobile drawer (hidden on desktop) */
.vvts-drawer { display: none; }

@media (max-width: 768px) {
    .vvts-layout { grid-template-columns: 1fr; }
    .vvts-facets { display: none; } /* hide sidebar on mobile — drawer takes over */
    .vvts-mobile-filter-toggle { display: inline-flex; }

    .vvts-drawer {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1000;
        pointer-events: none;
    }
    .vvts-drawer__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.45);
        opacity: 0;
        transition: opacity 0.25s ease;
        pointer-events: none;
    }
    .vvts-drawer.is-open { pointer-events: auto; }
    .vvts-drawer.is-open .vvts-drawer__backdrop { opacity: 1; pointer-events: auto; }
    .vvts-drawer__panel {
        position: absolute;
        top: 0; bottom: 0; left: 0;
        width: 88vw;
        max-width: 380px;
        background: #fff;
        display: flex;
        flex-direction: column;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(.2,.7,.3,1);
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    }
    .vvts-drawer.is-open .vvts-drawer__panel { transform: translateX(0); }
    .vvts-drawer__header {
        display: flex; align-items: center; justify-content: space-between;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid var(--vvts-border);
    }
    .vvts-drawer__header h2 { margin: 0; font-size: 1.05rem; }
    .vvts-drawer__close {
        background: none;
        border: none;
        font-size: 1.6rem;
        line-height: 1;
        cursor: pointer;
        padding: 0;
        color: var(--vvts-muted);
    }
    .vvts-drawer__body {
        flex: 1;
        overflow-y: auto;
        padding: 1rem 1.25rem 6rem;
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }
    .vvts-drawer__footer {
        position: absolute;
        left: 0; right: 0; bottom: 0;
        padding: 0.85rem 1.25rem;
        background: #fff;
        border-top: 1px solid var(--vvts-border);
    }
    .vvts-drawer__apply {
        width: 100%;
        padding: 0.8rem 1rem;
        background: var(--vvts-accent);
        color: #fff;
        border: none;
        border-radius: var(--vvts-radius);
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
    }
}
