/*
 * Styling for the hub's cross-book search (see global-search.js).
 * Everything is expressed in mdBook's own theme variables so the widget
 * follows light/rust/coal/navy/ayu without a second palette to maintain.
 */

/*
 * Hide mdBook's built-in search on the hub. The hub book is one page, so its
 * index holds four sections — searching "llm" there returns a single hit from
 * this page's own table, which reads as "the global search is broken". The box
 * below is the one that searches the books; leaving a second, near-empty search
 * field on the same page only invites the mistake. (Per-book search inside each
 * track is untouched — this stylesheet is loaded by the hub alone.)
 */
#search-wrapper,
#search-toggle,
#mdbook-search-wrapper,
#mdbook-search-toggle {
    display: none !important;
}

#global-search {
    margin: 1.5rem 0 2rem;
}

#global-search .gs-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#global-search #gs-input {
    flex: 1 1 22rem;
    min-width: 0;
    padding: 0.6rem 0.8rem;
    font-size: 1.05rem;
    color: var(--searchbar-fg, var(--fg));
    background-color: var(--searchbar-bg, var(--bg));
    border: 1px solid var(--searchbar-border-color, var(--table-border-color));
    border-radius: 5px;
    outline: none;
}

#global-search #gs-input:focus {
    border-color: var(--links);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--links) 30%, transparent);
}

#global-search #gs-book {
    flex: 0 1 auto;
    max-width: 18rem;
    padding: 0.6rem 0.5rem;
    color: var(--searchbar-fg, var(--fg));
    background-color: var(--searchbar-bg, var(--bg));
    border: 1px solid var(--searchbar-border-color, var(--table-border-color));
    border-radius: 5px;
}

#global-search .gs-status {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.75;
}

#global-search .gs-toggle,
#global-search .gs-more {
    font: inherit;
    color: var(--links);
    background: none;
    border: 1px solid var(--table-border-color);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    cursor: pointer;
}

#global-search .gs-more {
    margin-top: 0.75rem;
    padding: 0.4rem 0.9rem;
}

#global-search .gs-toggle:hover,
#global-search .gs-more:hover {
    border-color: var(--links);
}

#global-search .gs-results {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
}

#global-search .gs-hit {
    margin: 0 0 0.35rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 5px;
}

#global-search .gs-hit a {
    display: block;
    padding: 0.55rem 0.7rem;
    color: inherit;
    text-decoration: none;
    border-radius: 5px;
}

#global-search .gs-hit a:hover,
#global-search .gs-hit a.gs-selected {
    background-color: var(--quote-bg, var(--sidebar-bg));
}

#global-search .gs-hit-head {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#global-search .gs-badge {
    flex: 0 0 auto;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--table-border-color);
    border-radius: 3px;
    opacity: 0.8;
}

#global-search .gs-hit-title {
    color: var(--links);
    font-weight: 600;
}

#global-search .gs-hit-crumbs {
    font-size: 0.8rem;
    opacity: 0.65;
    margin-top: 0.15rem;
}

#global-search .gs-hit-teaser {
    font-size: 0.88rem;
    opacity: 0.9;
    margin-top: 0.3rem;
    line-height: 1.45;
}

#global-search mark {
    background-color: var(--search-mark-bg, #e3ff54);
    /* Not `inherit`: every theme's mark colour is a pale wash, so inheriting the
     * body colour puts light grey on pale blue and the matched word vanishes.
     * Dark ink is legible on all four themes' highlight colours. */
    color: #14161a;
    padding: 0 1px;
    border-radius: 2px;
}

#global-search .gs-empty {
    list-style: none;
    opacity: 0.7;
    padding: 0.5rem 0;
}

@media (max-width: 700px) {
    #global-search #gs-book { flex: 1 1 100%; max-width: none; }
    #global-search .gs-badge { max-width: 10rem; }
}
