/* ============================================================================
   PACE Inline Search Overlay
   ============================================================================ */

.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 1rem 1rem;
}

.search-overlay.is-open {
    display: flex;
    animation: searchOverlayFadeIn 0.15s ease-out;
}

@keyframes searchOverlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.search-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.search-overlay-panel {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.3), 0 10px 20px -5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(0);
    animation: searchPanelIn 0.18s ease-out;
}

@keyframes searchPanelIn {
    from { transform: translateY(-12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- Input row --- */
.search-overlay-inputwrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.search-overlay-icon {
    color: #6b7280;
    flex-shrink: 0;
}

.search-overlay-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-family: inherit;
    color: #111827;
    outline: none;
    padding: 0.25rem 0;
    min-width: 0;
}

.search-overlay-input::placeholder {
    color: #9ca3af;
}

/* Remove browser default search clear button (we have our own close) */
.search-overlay-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.search-overlay-esc {
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-weight: 500;
}

.search-overlay-close {
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.search-overlay-close:hover {
    color: #111827;
    background: #f3f4f6;
}

/* --- Body / scroll area --- */
.search-overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    min-height: 120px;
}

/* --- Empty state (recent + popular) --- */
.search-overlay-section {
    padding: 0.75rem 1rem;
}

.search-overlay-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.search-overlay-chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.search-overlay-chip {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    color: #374151;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.search-overlay-chip:hover {
    background: #eff6ff;
    border-color: #dbeafe;
    color: #1d4ed8;
}

/* --- Result groups --- */
.search-overlay-group {
    padding: 0.5rem 0;
}

.search-overlay-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 1rem 0.375rem;
}

.search-overlay-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-overlay-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s ease, border-color 0.1s ease;
}

.search-overlay-item:hover,
.search-overlay-item.is-active {
    background: #eff6ff;
    border-left-color: #2563eb;
}

.search-overlay-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

.search-overlay-item-desc {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.4;
    margin-top: 0.125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-overlay-item mark,
.search-overlay-item-desc mark {
    background: #fef3c7;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* --- View-all + no-results --- */
.search-overlay-viewall {
    padding: 0.75rem 1rem;
    border-top: 1px solid #f3f4f6;
    margin-top: 0.25rem;
}

.search-overlay-viewall a {
    color: #2563eb;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.search-overlay-viewall a:hover {
    text-decoration: underline;
}

.search-overlay-noresults {
    padding: 2rem 1rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.9rem;
}

.search-overlay-noresults a {
    color: #2563eb;
    text-decoration: none;
}

.search-overlay-noresults a:hover {
    text-decoration: underline;
}

/* --- Footer keyboard hints --- */
.search-overlay-footer {
    display: flex;
    gap: 1.25rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 0.7rem;
    color: #6b7280;
}

.search-overlay-footer kbd {
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 3px;
    padding: 0 0.3rem;
    font-size: 0.7rem;
    color: #374151;
    margin-right: 0.25rem;
}

/* --- Mobile: fullscreen --- */
@media (max-width: 640px) {
    .search-overlay {
        padding: 0;
        align-items: stretch;
    }
    .search-overlay-panel {
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
    .search-overlay-esc {
        display: none;
    }
    .search-overlay-footer {
        display: none; /* on-screen keyboard hides the hints anyway */
    }
}

@media (prefers-reduced-motion: reduce) {
    .search-overlay.is-open,
    .search-overlay-panel {
        animation: none;
    }
}
