/* ==========================================================================
   Zimbora – Fullscreen Product Search Block
   ========================================================================== */

/* ---- Block trigger button ------------------------------------------------ */
.zimbora-fsearch {
    display: inline-flex;
    align-items: center;
}

.zimbora-fsearch__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    line-height: 1;
    border-radius: 4px;
    transition: opacity 0.15s ease;
}

.zimbora-fsearch__trigger:hover,
.zimbora-fsearch__trigger:focus-visible {
    opacity: 0.65;
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ---- Prevent scroll when overlay is open --------------------------------- */
body.zimbora-fsearch-open {
    overflow: hidden;
}

/* ---- Fullscreen overlay -------------------------------------------------- */
.zimbora-fsearch__overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    background: rgba( 255, 255, 255, 0.96 );
    backdrop-filter: blur( 8px );
    -webkit-backdrop-filter: blur( 8px );
    animation: zimb-fsearch-in 0.22s ease both;
    overflow-y: auto;
    color: var( --wp--preset--color--contrast, #111 );
}

.zimbora-fsearch__overlay[hidden] {
    display: none;
}

.zimbora-fsearch__overlay--closing {
    animation: zimb-fsearch-out 0.22s ease both;
}

@keyframes zimb-fsearch-in {
    from { opacity: 0; transform: translateY( -12px ); }
    to   { opacity: 1; transform: translateY( 0 ); }
}

@keyframes zimb-fsearch-out {
    from { opacity: 1; transform: translateY( 0 ); }
    to   { opacity: 0; transform: translateY( -12px ); }
}

/* ---- Overlay header (input + close) ------------------------------------- */
.zimbora-fsearch__overlay-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp( 1rem, 2vw, 1.5rem ) clamp( 1rem, 5vw, 4rem );
    background: inherit;
    border-bottom: 1px solid rgba( 0, 0, 0, 0.08 );
    /* needed so the absolute close button is positioned relative to the header */
    position: relative;
}

/* ---- Search input row ---------------------------------------------------- */
.zimbora-fsearch__input-wrap {
    width: min( 900px, 100% );
    display: flex;
    align-items: center;
    gap: clamp( 0.55rem, 1vw, 0.75rem );
    background: rgba( 0, 0, 0, 0.05 );
    border-radius: 9999px;
    padding: clamp( 0.75rem, 1.4vw, 1rem ) clamp( 1.1rem, 2vw, 1.75rem );
    box-sizing: border-box;
    min-height: clamp( 3rem, 5.2vw, 3.5rem );
    border: 1px solid rgba( 0, 0, 0, 0.08 );
}

.zimbora-fsearch__input-icon {
    flex-shrink: 0;
    color: rgba( 0, 0, 0, 0.56 );
}

.zimbora-fsearch__input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: clamp( 1.05rem, 1.55vw, 1.35rem );
    line-height: 1.35;
    color: inherit;
    outline: none;
    min-width: 0;
    width: 100%;
    font-family: var( --wp--preset--font-family--system-font, inherit );
    font-weight: 400;
    /* remove browser default search cancel button */
    -webkit-appearance: none;
    appearance: none;
}

.zimbora-fsearch__input::placeholder {
    color: rgba( 0, 0, 0, 0.5 );
}

.zimbora-fsearch__input::-webkit-search-cancel-button {
    display: none;
}

/* ---- Close button -------------------------------------------------------- */
.zimbora-fsearch__close {
    position: absolute;
    right: clamp( 0.85rem, 2.4vw, 2rem );
    top: 50%;
    transform: translateY( -50% );
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp( 2.2rem, 3vw, 2.5rem );
    height: clamp( 2.2rem, 3vw, 2.5rem );
    padding: 0;
    background: transparent;
    border: 1px solid rgba( 0, 0, 0, 0.12 );
    border-radius: 50%;
    cursor: pointer;
    color: inherit;
    transition: background 0.15s ease;
}

.zimbora-fsearch__close:hover,
.zimbora-fsearch__close:focus-visible {
    background: rgba( 0, 0, 0, 0.06 );
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ---- Results area -------------------------------------------------------- */
.zimbora-fsearch__results {
    flex: 1;
    padding: clamp( 1.2rem, 2.6vw, 2.5rem ) clamp( 1rem, 3vw, 2rem ) clamp( 2rem, 4vw, 3rem );
    max-width: 1540px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ---- Status messages ----------------------------------------------------- */
.zimbora-fsearch__message {
    text-align: center;
    color: rgba( 0, 0, 0, 0.62 );
    margin: clamp( 2rem, 6vw, 3.25rem ) 0;
    font-size: var( --wp--preset--font-size--medium, 1rem );
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    grid-column: 1 / -1;
    width: 100%;
}

/* Spinner */
.zimbora-fsearch__spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba( 0, 0, 0, 0.15 );
    border-top-color: #333;
    border-radius: 50%;
    animation: zimb-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes zimb-spin {
    to { transform: rotate( 360deg ); }
}

/* ---- Product grid (mirrors category-blocks grid) ------------------------- */
.zimbora-fsearch__grid {
    display: grid;
    grid-template-columns: repeat( 4, minmax( 0, 1fr ) );
    gap: clamp( 1rem, 2vw, 1.75rem );
}

/* ---- Product card -------------------------------------------------------- */
.zimbora-fsearch__card {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.zimbora-fsearch__card-link {
    display: flex;
    flex-direction: column;
    flex: 1;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 8px;
    overflow: hidden;
    background: rgba( 255, 255, 255, 0.9 );
}

.zimbora-fsearch__card-link:hover,
.zimbora-fsearch__card-link:focus-visible {
    transform: translateY( -2px );
    box-shadow: 0 10px 30px rgba( 0, 0, 0, 0.1 );
    outline: none;
}

/* Product image */
.zimbora-fsearch__card-image {
    width: 100%;
    aspect-ratio: 3 / 4;
    background-color: #d9d9d9;
    background-image: var( --zimb-img, none );
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.3s ease;
    transform-origin: center;
}

.zimbora-fsearch__card-link:hover .zimbora-fsearch__card-image,
.zimbora-fsearch__card-link:focus-visible .zimbora-fsearch__card-image {
    transform: scale( 1.03 );
}

.zimbora-fsearch__card-image--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
}

/* Card body */
.zimbora-fsearch__card-body {
    padding: 0.9rem 0.2rem 0.2rem;
}

.zimbora-fsearch__card-name {
    margin: 0 0 0.4rem;
    font-size: var( --wp--preset--font-size--small, 0.95rem );
    font-family: var( --wp--preset--font-family--system-font, inherit );
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.zimbora-fsearch__card-price {
    margin: 0;
    font-size: var( --wp--preset--font-size--small, 0.9rem );
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    line-height: 1.45;
}

.zimbora-fsearch__price-was {
    color: #999;
    text-decoration: line-through;
    font-weight: 400;
}

.zimbora-fsearch__price-now {
    color: #b42318;
    font-weight: 700;
    text-decoration: none;
    font-style: normal;
}

.zimbora-fsearch__price-amount {
    font-weight: 600;
}

/* ---- Editor preview (block canvas) --------------------------------------- */
.zimbora-fsearch-editor-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed rgba( 0, 0, 0, 0.15 );
    border-radius: 6px;
    background: rgba( 0, 0, 0, 0.02 );
}

.zimbora-fsearch-editor-preview__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.zimbora-fsearch-editor-preview__icon {
    opacity: 0.5;
}

.zimbora-fsearch-editor-preview__label {
    font-size: var( --wp--preset--font-size--small, 0.9rem );
    font-weight: 600;
}

.zimbora-fsearch-editor-preview__meta {
    font-size: var( --wp--preset--font-size--x-small, 0.78rem );
    color: #777;
}

/* ---- Responsive ---------------------------------------------------------- */
@media ( max-width: 1200px ) {
    .zimbora-fsearch__grid {
        grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
    }
}

@media ( max-width: 782px ) {
    .zimbora-fsearch__overlay-header {
        padding: 0.9rem 0.9rem;
    }

    .zimbora-fsearch__results {
        padding: 1rem 0.9rem 1.5rem;
    }

    .zimbora-fsearch__grid {
        grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
        gap: 0.8rem;
    }

    .zimbora-fsearch__input-wrap {
        width: calc( 100% - 2.8rem );
    }

    .zimbora-fsearch__close {
        right: 0.9rem;
    }
}

@media ( max-width: 480px ) {
    .zimbora-fsearch__grid {
        grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
        gap: 0.65rem;
    }

    .zimbora-fsearch__input {
        font-size: 1rem;
    }
}
