/*
 * Instant search widget.
 *
 * Lifted verbatim from the static site's includes/components/instant_search_*.php, which each
 * carried their own copy of these rules inline. It lives in its own file rather than in style.css
 * because style.css is shared byte-for-byte with the static tree and must not diverge; only the
 * listing pages pull this in.
 *
 * The keyboard and status rules at the bottom are new — the original had no keyboard navigation
 * and nothing to show while a request was in flight, because it had no requests to make.
 */

.instant-search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.instant-search-container {
    position: relative;
}

/* Inside a hero the widget sits in a box that has its own margin: the old home page never loaded this file, so the button below the
   search was 1.5 rem down, not the 2 rem this margin would win (#199). */
.hero .instant-search-wrapper {
    margin-bottom: 0;
}

.instant-search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-gold);
    font-size: 1rem;
    z-index: 2;
}

.instant-search-input {
    width: 100%;
    padding: 1rem 3rem;
    background: rgba(40, 40, 40, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 30px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.instant-search-input:focus {
    outline: none;
    border-color: var(--color-gold);
    background: rgba(45, 45, 45, 0.9);
}

.instant-search-clear {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-gold);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.instant-search-clear.show {
    opacity: 1;
    display: block !important;
}

.instant-search-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.instant-search-results {
    padding: 0.5rem;
}

.instant-search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: 10px;
    text-decoration: none;
    color: #fff;
    transition: background 0.2s ease;
}

.instant-search-result-item:hover,
.instant-search-result-item.is-active {
    background: rgba(212, 175, 55, 0.15);
}

.instant-search-result-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(212, 175, 55, 0.3);
    flex-shrink: 0;
}

.instant-search-result-info {
    flex: 1;
    min-width: 0;
}

.instant-search-result-title {
    font-weight: 600;
    font-size: 1rem;
    color: #fff;
}

.instant-search-result-subtitle {
    font-size: 0.85rem;
    color: #888;
}

.instant-search-result-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--color-gold);
    margin-top: 0.2rem;
}

.instant-search-no-results {
    padding: 2rem;
    text-align: center;
    color: #888;
}

/* Long names must not push the meta line out of the dropdown on a narrow screen. */
.instant-search-result-title,
.instant-search-result-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Shown while a request is in flight, and when one fails. The original filtered an array it
   already had, so it needed neither. */
.instant-search-status {
    padding: 1.5rem;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

.instant-search-status .fa-spinner {
    color: var(--color-gold);
}

@media (max-width: 768px) {
    .instant-search-input {
        padding: 0.85rem 2.75rem;
        font-size: 0.95rem;
    }

    .instant-search-dropdown {
        max-height: 60vh;
    }

    .instant-search-result-meta {
        gap: 0.75rem;
    }
}
