/**
 * Search Overlay Styles (Mode A: live search)
 * Full viewport overlay with dimmed backdrop, scroll lock, preview cards
 */

/* Body scroll lock when overlay is open */
body.search-overlay-open {
    overflow: hidden;
}

/* Overlay wrapper: top set by JS to sit exactly below announcement + nav */
.search-overlay {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

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

/* Dimmed backdrop */
.search-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

/* Panel: full-width white area; inner .wrapper matches site content width */
.search-overlay-panel {
    position: relative;
    background: var(--color-bg-white, #fff);
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.search-overlay-panel__inner.wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Search Bar Form (inside panel) */
.search-overlay-panel .search-bar-form {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    flex-shrink: 0;
    border-bottom: 1px solid #eee;
}

.search-overlay-panel .search-bar-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.search-overlay-panel .search-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    color: #666;
    pointer-events: none;
}

.search-overlay-panel .search-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 24px;
    font-family: var(--font-body, inherit);
    color: var(--color-text, #242426);
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    background: var(--color-bg-white, #fff);
    outline: none;
    min-width: 0;
}

.search-overlay-panel .search-input:focus {
    border-color: var(--color-primary, #2563eb);
    outline: none;
}

/* Submit and close buttons removed: live search + ESC/backdrop close */

/* Results area: scrollable */
.search-results {
    padding: 16px 20px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 120px;
}

.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.search-results-count {
    font-size: 14px;
    color: var(--color-text, #242426);
}

.search-view-all {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary, #2563eb);
    text-decoration: none;
}

.search-view-all:hover {
    text-decoration: underline;
}

/* Product grid: same breakpoints and columns as shop page
 * 1 col → 2 → 3 → 4 per row by viewport
 */
.search-results-list {
    margin-top: 0;
}

.search-results-list ul.products {
    margin: 16px 0 0 0;
}

/* Explicit widths so grid fits one line per breakpoint (matches style.css product loop) */
.search-results-list ul.products li {
    box-sizing: border-box;
}

/* 1 column: default / small screens (matches theme up to 599px) */
.search-results-list ul.products li {
    width: 100%;
    margin-left: 0;
    clear: both;
}

/* 2 columns: 600px–749px (match theme) */
@media only screen and (min-width: 600px) and (max-width: 749px) {
    .search-results-list ul.products li {
        width: calc((100% - 20px) / 2);
        margin-left: 20px;
        clear: none;
    }

    .search-results-list ul.products li:nth-of-type(2n+1) {
        margin-left: 0;
        clear: both;
    }
}

/* 2 columns: 750px–999px */
@media only screen and (min-width: 750px) and (max-width: 999px) {
    .search-results-list ul.products li {
        width: calc((100% - 16px) / 2);
        margin-left: 16px;
        clear: none;
    }

    .search-results-list ul.products li:nth-of-type(2n+1) {
        margin-left: 0;
        clear: both;
    }
}

/* 3 columns: 1000px–1279px — show only 3 results (one row) */
@media only screen and (min-width: 1000px) and (max-width: 1279px) {
    .search-results-list ul.products li {
        width: calc((100% - 32px) / 3);
        margin-left: 16px;
        clear: none;
    }

    .search-results-list ul.products li:nth-of-type(3n+1) {
        margin-left: 0;
        clear: both;
    }

    .search-results-list ul.products li:nth-child(n+4) {
        display: none;
    }
}

/* 3 columns: 1280px–1899px — show only 3 results (one row) */
@media only screen and (min-width: 1280px) and (max-width: 1899px) {
    .search-results-list ul.products li {
        width: calc((100% - 48px) / 3);
        margin-left: 24px;
        clear: none;
    }

    .search-results-list ul.products li:nth-of-type(3n+1) {
        margin-left: 0;
        clear: both;
    }

    .search-results-list ul.products li:nth-child(n+4) {
        display: none;
    }
}

/* 4 columns: 1900px+ (wide screens) */
@media only screen and (min-width: 1900px) {
    .search-results-list ul.products li {
        width: calc((100% - 96px) / 4);
        margin-left: 32px;
        clear: none;
    }

    .search-results-list ul.products li:nth-of-type(4n+1) {
        margin-left: 0;
        clear: both;
    }
}

/* Loading state */
.search-loading {
    padding: 24px;
    text-align: center;
    color: #666;
}

.search-loading-text {
    font-size: 14px;
}

/* Empty state */
.search-empty {
    padding: 24px;
    text-align: center;
}

.search-empty-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--color-text, #242426);
}

.search-empty-hint {
    font-size: 14px;
    margin: 0;
    color: #666;
}

/* Placeholder (Type to search…) */
.search-placeholder {
    padding: 24px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.search-placeholder-text {
    display: block;
}

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

.header-icon.is-active {
    opacity: 0.7;
}

/* Mobile: full viewport, input pinned, results scroll */
@media only screen and (max-width: 999px) {
    .search-overlay-panel {
        max-height: 100vh;
    }

    .search-overlay-panel .search-bar-form {
        padding: 12px 16px;
        gap: 8px;
    }

    .search-overlay-panel .search-input {
        font-size: 16px;
        padding: 10px 12px;
    }

    .search-results {
        padding: 12px 16px 20px;
    }
}