/* The search box in the top bar and its list of suggestions (NavMenu.razor, js/site-search.js). A global file and not a scoped one: the
   list is drawn by the script, and scoped styles only reach elements that Blazor has drawn. */

.site-search {
    position: relative;
    /* Between the menus and the account menu on a wide screen; the nav-left rule `margin-right: auto` is cancelled below. */
    order: 2;
    flex: 1 1 14rem;
    min-width: 12rem;
    max-width: 26rem;
    margin-left: auto;
}

.top-nav .nav-left {
    order: 1;
    margin-right: 0;
}

.top-nav .nav-right {
    order: 3;
}

.site-search-input {
    width: 100%;
    height: 2.35rem;
    padding: 0 2.2rem 0 2.2rem;
    color: var(--lrex-fg);
    background-color: rgba(255, 255, 255, 0.05);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b98ad' stroke-width='1.6' stroke-linecap='round' viewBox='0 0 16 16'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6'/%3E%3Cpath d='m10.4 10.4 3.8 3.8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.7rem 50%;
    border: 1px solid var(--lrex-line);
    border-radius: 999px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.site-search-input::placeholder {
    color: var(--lrex-muted);
}

.site-search-input:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.site-search-input:focus {
    background-color: rgba(255, 255, 255, 0.09);
    border-color: var(--lrex-accent);
    box-shadow: 0 0 0 0.15rem rgba(var(--lrex-accent-rgb), 0.25);
}

/* The browser's own clear button for type=search is not styled the same everywhere, so it is left out. */
.site-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

/* ---------- The list ---------- */

.site-search-list {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    left: 0;
    z-index: 30;
    max-height: min(70vh, 32rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.25rem 0 0.4rem;
    color: var(--lrex-fg);
    background: var(--lrex-surface);
    border: 1px solid var(--lrex-line);
    border-radius: 0.6rem;
    box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.45);
}

.site-search-list[hidden] {
    display: none;
}

/* A little wider than the box on a wide screen, so the second line of a hit fits. */
@media (min-width: 641px) {
    .site-search-list {
        left: auto;
        width: max(100%, 24rem);
    }
}

/* Every kind has a heading and a line over it, so it is clear where one kind ends and the next begins. */
.ss-group + .ss-group {
    margin-top: 0.25rem;
    border-top: 1px solid var(--lrex-line);
}

.ss-heading {
    padding: 0.55rem 0.9rem 0.2rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lrex-muted);
}

.ss-hit {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.9rem;
    color: var(--lrex-fg);
    text-decoration: none;
}

.ss-hit:hover, .ss-hit.active {
    background: rgba(var(--lrex-accent-rgb), 0.14);
}

.ss-icon {
    flex: none;
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
}

.ss-icon.round {
    object-fit: cover;
    border-radius: 50%;
}

.ss-icon-empty {
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--lrex-muted);
    background: rgba(255, 255, 255, 0.07);
}

.ss-text {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.2;
}

.ss-title {
    overflow: hidden;
    font-size: 0.92rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ss-title mark {
    padding: 0;
    color: var(--lrex-accent);
    background: none;
    font-weight: 700;
}

.ss-sub {
    overflow: hidden;
    font-size: 0.74rem;
    color: var(--lrex-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ss-tip {
    margin: 0.3rem 0.9rem 0;
    padding-top: 0.45rem;
    border-top: 1px solid var(--lrex-line);
    font-size: 0.78rem;
    color: var(--lrex-muted);
}

.ss-all, .ss-clear {
    display: block;
    width: calc(100% - 1.8rem);
    margin: 0.45rem 0.9rem 0;
    padding: 0.4rem 0.6rem;
    color: var(--lrex-accent);
    background: none;
    border: 1px solid var(--lrex-line);
    border-radius: 0.4rem;
    font-size: 0.8rem;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.ss-all:hover, .ss-clear:hover {
    background: rgba(var(--lrex-accent-rgb), 0.1);
}

/* ---------- Phone: the box is a row of its own under the logo, always shown, and the list takes the whole width ---------- */

@media (max-width: 640px) {
    /* .topbar in front: the phone rules of NavMenu.razor.css (flex-wrap: nowrap, a minimum height) have the same weight as a bare
       .top-nav here, so this needs one more class to be sure to win. */
    .topbar .top-nav {
        flex-wrap: wrap;
        align-content: flex-start;
        align-items: center;
        row-gap: 0.1rem;
        min-height: 0;
        padding-block: 0.35rem 0.6rem;
    }

    .topbar .site-search {
        order: 10;
        flex: 1 0 100%;
        max-width: none;
        margin-left: 0;
    }

    .site-search-input {
        height: 2.6rem;
        /* 16 px stops iOS from zooming the page when the field gets the focus. */
        font-size: 1rem;
    }

    .site-search-list {
        max-height: 60vh;
    }

    .ss-hit {
        padding-block: 0.5rem;
    }
}
