/* ============================================ */
/*              Search Modal (Cmd+K)            */
/* ============================================ */

/* Overlay */
.search-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100002;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.search-modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* Modal Container */
.search-modal {
    background: var(--surface-white);
    width: 90%;
    max-width: 640px;
    max-height: 70vh;
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: transform 0.2s;
}

.search-modal-overlay.open .search-modal {
    transform: translateY(0) scale(1);
}

/* Header */
.search-modal-header {
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.search-modal-input-wrapper {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 0.75rem;
}

.search-modal-icon {
    color: var(--text-muted);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.search-modal-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-family: inherit;
    color: var(--text-main);
    outline: none;
    min-width: 0;
}

.search-modal-input::placeholder {
    color: var(--text-muted);
}

.search-modal-kbd {
    background: var(--bg-off-white);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: inherit;
    flex-shrink: 0;
}

/* Filter Chips */
.search-modal-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0 1.25rem 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.search-modal-filters::-webkit-scrollbar {
    display: none;
}

.search-filter-chip {
    background: var(--bg-off-white);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    padding: 0.3rem 0.85rem;
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.search-filter-chip:hover {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.search-filter-chip.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: #fff;
}

/* Results Body */
.search-modal-body {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
}

/* Result Count */
.search-modal-count {
    padding: 0.5rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Individual Result */
.search-modal-result {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.1s;
    text-decoration: none;
    color: var(--text-main);
}

.search-modal-result:hover,
.search-modal-result.keyboard-focus {
    background: var(--bg-off-white);
}

.search-modal-result-icon {
    color: var(--accent-gold);
    font-size: 0.9rem;
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.search-modal-result-content {
    flex: 1;
    min-width: 0;
}

.search-modal-result-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

.search-modal-result-title mark {
    background: rgba(217, 119, 6, 0.2);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.search-modal-result-excerpt {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-modal-result-excerpt mark {
    background: rgba(217, 119, 6, 0.15);
    color: var(--text-main);
    padding: 0 1px;
    border-radius: 2px;
}

.search-modal-result-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.search-modal-section-tag {
    font-size: 0.7rem;
    text-transform: uppercase;
    background: var(--primary-blue);
    color: #fff;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

/* Sub-results (headings within a page) */
.search-modal-subresult {
    padding: 0.5rem 1.25rem 0.5rem 3rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.1s;
    text-decoration: none;
}

.search-modal-subresult:hover,
.search-modal-subresult.keyboard-focus {
    background: var(--bg-off-white);
    color: var(--text-main);
}

.search-modal-subresult i {
    font-size: 0.7rem;
    color: var(--accent-gold);
}

/* "Show more" button */
.search-modal-more {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: none;
    border: none;
    border-top: 1px solid var(--border-subtle);
    color: var(--primary-blue);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: center;
}

.search-modal-more:hover {
    background: var(--bg-off-white);
}

/* Empty state */
.search-modal-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.search-modal-empty i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
    color: var(--border-subtle);
}

/* Hint / default state */
.search-modal-hint {
    padding: 2rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.search-modal-hint i {
    color: var(--accent-gold);
    margin-right: 0.25rem;
}

/* Loading spinner */
.search-modal-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.search-modal-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: search-spin 0.6s linear infinite;
}

@keyframes search-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .search-modal-spinner {
        animation: none;
    }
}

/* Footer */
.search-modal-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 0.6rem 1.25rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-off-white);
    flex-shrink: 0;
}

.search-modal-footer kbd {
    background: var(--surface-white);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    font-size: 0.7rem;
    font-family: inherit;
    margin-right: 0.25rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .search-modal-overlay {
        padding-top: 5vh;
    }

    .search-modal {
        width: 95%;
        max-height: 80vh;
    }

    .search-modal-footer {
        display: none;
    }
}

/* Header search keyboard shortcut hint */
.header-search-kbd {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-white);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: inherit;
    pointer-events: none;
}
