/* =============================================================================
   Hwaro Docs — Search palette (⌘K)
   Markup is built by assets/js/search.js.
   ============================================================================= */

#search-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    font-family: var(--font-sans);
}

.search-overlay {
    position: absolute;
    inset: 0;
    background: var(--scrim);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: search-fade 0.15s ease both;
}

.search-dialog {
    position: absolute;
    top: 14%;
    left: 50%;
    transform: translateX(-50%);
    width: min(92%, 640px);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: search-rise 0.18s ease both;
}

@keyframes search-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes search-rise {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

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

/* Head — bare input on a hairline-separated row. */
.search-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.search-head-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0;
    font-size: 0.95rem;
    font-family: var(--font-mono);
    background: transparent;
    color: var(--text);
    border: none;
    outline: none;
}

#search-input::placeholder {
    color: var(--text-muted);
}

.search-esc {
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color var(--transition), border-color var(--transition);
}

.search-esc:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* Body — scrollable result list. */
.search-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    max-height: min(56vh, 460px);
    padding: var(--space-2);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.search-body::-webkit-scrollbar {
    width: 5px;
}

.search-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

.search-group + .search-group {
    margin-top: var(--space-2);
}

.search-group-label {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 0.65rem 0.65rem 0.4rem;
}

/* Result rows — selection mirrors the sidebar's ember rail vocabulary. */
.search-result {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.search-result + .search-result {
    margin-top: 1px;
}

.search-result.selected {
    background: var(--primary-tint);
}

.search-result.selected::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    border-radius: 999px;
    background: var(--spark);
}

.search-result-icon {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-result.selected .search-result-icon {
    color: var(--primary);
}

.search-result-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-result-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result.selected .search-result-title {
    color: var(--primary);
}

.search-result-snippet {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result mark {
    background: var(--selection);
    color: var(--primary-strong);
    border-radius: 2px;
    padding: 0 1px;
}

.search-result-enter {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.12s ease;
}

.search-result.selected .search-result-enter {
    opacity: 1;
}

/* Empty / loading states. */
.search-empty {
    padding: 2.25rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.search-empty-query {
    font-family: var(--font-mono);
    color: var(--primary);
}

/* Foot — key hints + result count. */
.search-foot {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.55rem 1rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-muted);
}

.search-foot-hint {
    display: flex;
    align-items: center;
}

.search-foot kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    margin-right: 5px;
    font-family: inherit;
    font-size: 0.62rem;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    border-bottom-width: 1px;
}

.search-foot kbd + kbd {
    margin-left: -2px;
}

.search-foot-count {
    margin-left: auto;
    letter-spacing: 0.05em;
}

@media (max-width: 768px) {
    .search-dialog {
        top: 7%;
    }

    .search-foot-hint {
        display: none;
    }
}
