/* ── Search Trigger Button (in header nav) ─────────────────────────────── */
.search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    height: 34px;
    padding: 0 0.5rem 0 0.65rem;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-family: var(--font-main);
    font-size: 0.85rem;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.search-trigger:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.18);
}

.search-trigger svg {
    width: 15px;
    height: 15px;
    display: block;
    flex-shrink: 0;
}

.search-trigger-label {
    line-height: 1;
}

.search-trigger-kbd {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-family: var(--font-main);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
}

.search-trigger-kbd .kbd-mod {
    font-size: 0.85em;
}

@media (max-width: 768px) {
    .search-trigger {
        height: 32px;
        width: 32px;
        padding: 0;
        justify-content: center;
        gap: 0;
    }
    .search-trigger-label,
    .search-trigger-kbd {
        display: none;
    }
}

/* ── Overlay (backdrop + panel) ────────────────────────────────────────── */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 12vh 1rem 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.search-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.search-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 12, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Panel ─────────────────────────────────────────────────────────────── */
.search-panel {
    position: relative;
    width: 100%;
    max-width: 640px;
    background: #12121e;
    border: 1px solid rgba(118, 87, 255, 0.25);
    border-radius: 14px;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.03),
        0 0 40px rgba(118, 87, 255, 0.18);
    overflow: hidden;
    transform: translateY(-8px) scale(0.98);
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-overlay.is-open .search-panel {
    transform: translateY(0) scale(1);
    animation: search-panel-glow 14s linear infinite;
    animation-delay: 0.2s;
}

@keyframes search-panel-glow {
    0% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            0px -22px 90px -10px rgba(118, 87, 255, 0.4);
    }
    12.5% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            16px -16px 90px -10px rgba(118, 87, 255, 0.42);
    }
    25% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            22px 0px 90px -10px rgba(118, 87, 255, 0.45);
    }
    37.5% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            16px 16px 90px -10px rgba(118, 87, 255, 0.42);
    }
    50% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            0px 22px 90px -10px rgba(118, 87, 255, 0.4);
    }
    62.5% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            -16px 16px 90px -10px rgba(118, 87, 255, 0.42);
    }
    75% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            -22px 0px 90px -10px rgba(118, 87, 255, 0.45);
    }
    87.5% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            -16px -16px 90px -10px rgba(118, 87, 255, 0.42);
    }
    100% {
        box-shadow:
            0 24px 64px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.03),
            0px -22px 90px -10px rgba(118, 87, 255, 0.4);
    }
}

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

.search-panel-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

.search-input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 1.05rem;
    padding: 0.15rem 0;
    caret-color: var(--accent-color);
}

.search-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.search-input::-webkit-search-cancel-button { display: none; }

.search-panel-hint {
    font-family: var(--font-main);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 7px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Results list (inside panel) ───────────────────────────────────────── */
.search-results {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.search-results::-webkit-scrollbar { width: 4px; }
.search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.search-result-item {
    display: block;
    padding: 0.875rem 1.125rem;
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.12s;
    cursor: pointer;
}

.search-results li:last-child .search-result-item {
    border-bottom: none;
}

.search-result-item:hover,
li[aria-selected="true"] .search-result-item {
    background: rgba(118, 87, 255, 0.12);
}

.search-result-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-section {
    display: block;
    font-size: 0.72rem;
    color: var(--accent-color);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.search-result-excerpt {
    display: -webkit-box;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-excerpt mark {
    background: none;
    color: #fff;
    font-weight: 600;
}

.search-no-results {
    padding: 1.5rem 1.125rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 600px) {
    .search-overlay { padding-top: 6vh; }
    .search-panel { border-radius: 12px; }
    .search-panel-input-row { padding: 0.75rem 0.875rem; }
    .search-input { font-size: 1rem; }
    .search-panel-hint { display: none; }
}
