/* Natural-language search: sparkle icon, "thinking" state, and the
   note under the listings bar after an AI search. Bar layout stays in each bar's CSS. */

.nl-search-icon {
    display: inline-block;
    vertical-align: -0.125em;
    color: #4f7fa8;
    transform-origin: center;
}

[data-nl-thinking] .nl-search-icon {
    animation: nl-search-pulse 0.9s ease-in-out infinite alternate;
}

[data-nl-thinking] button[type="submit"] {
    cursor: progress;
}

/* The Search button's magnifier becomes a spinner while a search runs. */
[data-nl-thinking] button[type="submit"] .fa-search {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    box-sizing: border-box;
    vertical-align: -0.125em;
    animation: nl-search-spin 0.7s linear infinite;
}

[data-nl-thinking] button[type="submit"] .fa-search::before {
    content: "";
}

@keyframes nl-search-spin {
    to { transform: rotate(360deg); }
}

/* ---- The loading line along the bottom of the search pill ----------------
   nl-search-client.js adds one .nl-progress to the bar's pill
   ([data-nl-progress-host]) and moves it through data-phase:
   start (a quick first step) -> wait (creeps toward 85%) -> done (full) ->
   leaving (full, glowing, while the next page loads). No phase: hidden. */
[data-nl-progress-host] {
    position: relative;
}

.nl-progress {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 2;
}

.nl-progress[data-phase] {
    opacity: 1;
}

/* A soft light sweeping across the bar: the search is being read. */
.nl-progress::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40%;
    background: linear-gradient(90deg, rgba(53, 101, 140, 0), rgba(53, 101, 140, 0.07), rgba(53, 101, 140, 0));
    transform: translateX(-100%);
}

.nl-progress[data-phase]::before {
    animation: nl-search-sweep 1.4s ease-in-out infinite;
}

.nl-progress__fill {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(90deg, #4f7fa8, #1f6feb);
    box-shadow: 0 0 6px rgba(31, 111, 235, 0.45);
    transition: width 0.25s ease-out;
}

.nl-progress[data-phase="start"] .nl-progress__fill { width: 18%; }

.nl-progress[data-phase="wait"] .nl-progress__fill {
    width: 88%;
    /* Fast at first, then slower and slower: it never looks stuck. */
    transition: width 4.5s cubic-bezier(0.08, 0.7, 0.2, 1);
}

.nl-progress[data-phase="done"] .nl-progress__fill,
.nl-progress[data-phase="leaving"] .nl-progress__fill {
    width: 100%;
    transition: width 0.2s ease-out;
}

.nl-progress[data-phase="leaving"] .nl-progress__fill {
    background: linear-gradient(90deg, #4f7fa8, #1f6feb, #8ab4ff, #1f6feb, #4f7fa8);
    background-size: 200% 100%;
    animation: nl-search-glow 1.1s linear infinite;
}

@keyframes nl-search-sweep {
    from { transform: translateX(-100%); }
    to { transform: translateX(260%); }
}

@keyframes nl-search-glow {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

.nl-sr-status {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@keyframes nl-search-pulse {
    from { opacity: 0.35; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    [data-nl-thinking] .nl-search-icon {
        animation: none;
        opacity: 0.6;
    }

    [data-nl-thinking] button[type="submit"] .fa-search {
        animation: none;
        border-right-color: currentColor;
        opacity: 0.6;
    }

    .nl-progress::before,
    .nl-progress[data-phase]::before {
        animation: none;
        display: none;
    }

    .nl-progress[data-phase] .nl-progress__fill {
        width: 60%;
        transition: none;
        animation: none;
    }
}

.nl-search-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin: 8px 16px 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #444;
}

.nl-search-banner[hidden] {
    display: none;
}

.nl-search-banner__ignored {
    color: #777;
}

.nl-search-alternative {
    padding: 0;
    border: 0;
    background: none;
    color: #35658c;
    font: inherit;
    text-align: left;
    text-decoration: underline;
    cursor: pointer;
}

.nl-search-alternative:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}
