/* =============================================================
   Search Toggle & AJAX Results — modal version
   All colors come from theme design tokens (CSS custom properties).
   This plugin defines no colors of its own — it only references
   theme variables, so it automatically adapts to whatever scheme
   (light/dark/custom preset) is currently active.
   ============================================================= */

/* ---- Toggle button — visually consistent with other nav icons
   (.menu-toggle, .novapulse-dark-toggle) ---- */
.sta-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    color: var(--nav-text, inherit);
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}
body.scheme-light .sta-search-toggle {
    border-color: transparent;
}
.sta-search-toggle:hover,
.sta-search-toggle:focus-visible {
    color: var(--nav-hover, var(--link-color));
    background-color: var(--link-color-soft);
    border-color: var(--link-color);
    outline: none;
}
.sta-search-toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* ---- Lock page scrolling while the modal is open ---- */
body.sta-modal-open {
    overflow: hidden;
}

/* =============================================================
   OVERLAY — moved by JS to be a direct child of <body>, so it
   ends up above absolutely everything (including ads/iframes,
   which often create their own stacking context). An extremely
   high z-index guarantees priority over typical ad-network
   z-index values (usually 999999 or lower).
   ============================================================= */
.sta-search-overlay {
    /* Height reserved at the top/bottom for fixed ad banners —
       overridden inline via the shortcode [search_toggle ads_offset="…"] */
    --sta-ads-offset: 200px;

    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Blur + dim of the ENTIRE background (including the top/bottom
       strips where fixed ads usually live), built from a theme color —
       the tint automatically matches the current color scheme */
    background: color-mix(in srgb, var(--heading-color) 55%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s ease, visibility 0s linear .25s;
}
.sta-search-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity .25s ease;
}

/* ---- Modal window — 90% width / height, but never overlaps the
   top/bottom zones reserved for fixed ads (--sta-ads-offset) ---- */
.sta-search-modal {
    width: 90vw;
    height: 90vh;
    max-width: 1100px;
    max-height: calc(100vh - (var(--sta-ads-offset) * 2));
    display: flex;
    flex-direction: column;
    overflow: hidden;

    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);

    transform: scale(.96);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
}
.sta-search-overlay.is-open .sta-search-modal {
    transform: scale(1);
    opacity: 1;
}

@media (max-width: 640px) {
    .sta-search-modal {
        width: 95vw;
        height: 92vh;
        max-height: calc(100vh - (var(--sta-ads-offset) * 2));
    }
}

/* ---- Modal header: search input + close button ---- */
.sta-search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.sta-search-modal .sta-search-input {
    flex: 1;
    min-width: 0;
    padding: 12px 4px;
    font-size: 20px;
    font-family: inherit;
    font-weight: 500;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: none !important;
    color: var(--input-text, var(--heading-color));
    outline: none;
}
.sta-search-input::placeholder {
    color: var(--input-placeholder, var(--body-text));
    opacity: .6;
}

.sta-search-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    color: var(--body-text, inherit);
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.sta-search-close:hover,
.sta-search-close:focus-visible {
    color: var(--nav-hover, var(--link-color));
    background-color: var(--link-color-soft);
    border-color: var(--link-color);
    outline: none;
}

/* =============================================================
   RESULTS LIST — minimalist: no divider lines, just a subtle
   rounded hover background and a small "type" label per row.
   ============================================================= */
.sta-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sta-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--btn-radius);
    text-decoration: none;
    color: var(--heading-color, inherit);
    transition: background-color .15s ease;
}
.sta-result-item:hover,
.sta-result-item:focus-visible {
    background-color: var(--link-color-soft);
    outline: none;
}
.sta-result-title {
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sta-result-type {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 3px 9px;
    border-radius: 999px;
    color: var(--link-color);
    background: var(--link-color-soft);
}

/* ---- Messages (no results / error / searching) ---- */
.sta-search-message {
    padding: 40px 16px;
    text-align: center;
    font-size: 15px;
    color: var(--body-text, inherit);
    opacity: .75;
}
.sta-search-message.sta-error {
    color: #c0392b;
    opacity: 1;
}
