/* Unified search overlay. Loaded globally from base.html so it works on every page. */

.search-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 0, 20, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    padding: 6rem 1rem 2rem;
    /* The modal itself is the scrollable region. `overscroll-behavior: contain`
       stops the scroll from chaining out to the page behind when the user
       reaches the top or bottom of the modal list — fixes the "scrolling
       inside the overlay also scrolls the page" bug on all browsers. */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Scroll lock — works on every browser. iOS Safari ignores `overflow: hidden`
   on body (the reason the modal leaked scroll into the page), so we also
   apply `position: fixed` which iOS does respect. Cross-platform belt +
   braces; no harm on desktop. Scroll position is preserved in JS so the
   page doesn't jump to top when the modal closes. */
body.search-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}

.search-modal-inner {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md, 1rem);
    border-bottom: 1px solid rgba(255, 0, 255, 0.3);
    padding-bottom: var(--spacing-md, 1rem);
}

.search-modal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.5rem, 4vw, 2rem);
    letter-spacing: 0.02em;
    -webkit-appearance: none;
    appearance: none;
}

/* Hide browser-native clear (X) button on search inputs so it doesn't double up with our modal close. */
.search-modal-input::-webkit-search-cancel-button,
.search-modal-input::-webkit-search-decoration,
.search-modal-input::-webkit-search-results-button,
.search-modal-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.search-modal-input::placeholder { color: rgba(255, 255, 255, 0.5); }

.search-modal-close {
    background: transparent;
    border: 1px solid rgba(255, 0, 255, 0.3);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-modal-close:hover {
    border-color: #ff00ff;
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

.search-modal-results {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    overflow-y: auto;
    padding-bottom: 4rem;
}

.search-modal-column { color: #fff; }

.search-modal-column-title {
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #00ffff;
    font-size: 0.85rem;
    margin: 0 0 0.5rem;
    border-bottom: 1px solid rgba(255, 0, 255, 0.2);
    padding-bottom: 0.25rem;
}

.search-result-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    transition: background 0.2s ease;
}

.search-result-row:hover {
    background: rgba(255, 0, 255, 0.08);
    color: #fff;
    text-decoration: none;
}

.search-result-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: rgba(20, 0, 30, 0.6);
    flex-shrink: 0;
}

.search-result-thumb-placeholder {
    border: 1px solid rgba(255, 0, 255, 0.2);
}

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

.search-result-name {
    font-weight: 600;
    color: #fff;
    overflow-wrap: anywhere;
}

.search-result-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
}

.search-modal-hint,
.search-modal-empty {
    grid-column: 1 / -1;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 2rem 0;
}

.search-modal-hint kbd {
    background: rgba(20, 0, 30, 0.8);
    border: 1px solid rgba(255, 0, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    margin: 0 2px;
    font-family: Arial, sans-serif;
    color: #fff;
}

@media (max-width: 768px) {
    .search-modal {
        padding: 4.5rem 0.75rem 1rem;
    }

    .search-modal-header {
        gap: 0.5rem;
        padding-bottom: 0.75rem;
    }

    .search-modal-input {
        font-size: 1.05rem;
        letter-spacing: 0;
        min-width: 0;
    }

    .search-modal-input::placeholder {
        font-size: 0.95rem;
    }

    .search-modal-close {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    .search-modal-results {
        gap: 1rem;
        padding-bottom: 2rem;
    }

    .search-modal-column-title {
        font-size: 0.78rem;
    }

    .search-result-name { font-size: 0.92rem; }
    .search-result-subtitle { font-size: 0.75rem; }

    .search-modal-hint { font-size: 0.9rem; padding: 1rem 0; }
    .search-modal-hint kbd { display: none; }
}
