/* =====================================================
   search-overlay.css — Apple Spotlight-style search
   Lazy-loaded. ~2KB unminified.
   ===================================================== */

/* ── Overlay (hidden by default) ───────────────────── */
#search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}

#search-overlay.visible {
    display: flex;
}

/* ── Dark backdrop ─────────────────────────────────── */
#search-overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    animation: searchFadeIn 0.2s ease;
}

@keyframes searchFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Search box ────────────────────────────────────── */
#search-overlay-box {
    position: relative;
    width: 90%;
    max-width: 580px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: searchSlideDown 0.25s ease;
}

@keyframes searchSlideDown {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Input row ─────────────────────────────────────── */
#search-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ac6-border);
}

#search-input-icon {
    width: 20px;
    height: 20px;
    color: #999;
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.05rem;
    color: #222;
    background: transparent;
    font-family: inherit;
}

#search-input::placeholder {
    color: #aaa;
}

/* Remove the browser-native clear button on search inputs */
#search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

#search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--ac6-surface-subtle);
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

#search-close:hover {
    background: var(--ac6-border);
}

#search-close svg {
    width: 14px;
    height: 14px;
    color: var(--ac6-text-muted);
}

/* ── Results area ──────────────────────────────────── */
#search-results {
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Group labels (Courses / Found in content) */
.search-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 16px 4px;
}

/* Each result row */
.search-result-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 16px;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
    cursor: pointer;
    flex-wrap: wrap;
}

.search-result-item:hover,
.search-result-item.active {
    background: #f4f4f5;
}

/* Ref badge */
.search-result-ref {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ac6-primary, #0288d1);
    background: #edf4f9;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Title */
.search-result-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: #222;
    flex: 1;
    min-width: 0;
}

.search-result-title mark {
    background: #fff3bf;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* Subtitle / context */
.search-result-sub {
    font-size: 0.78rem;
    color: #888;
    width: 100%;
    padding-left: calc(7px + 10px); /* align under title (badge width + gap) */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Empty / error message */
.search-msg {
    padding: 24px 16px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* ── Bottom hint bar ───────────────────────────────── */
#search-hint {
    display: flex;
    gap: 12px;
    padding: 8px 16px;
    border-top: 1px solid var(--ac6-border);
    font-size: 0.7rem;
    color: #aaa;
    background: var(--ac6-surface-subtle);
}

#search-hint kbd {
    display: inline-block;
    font-family: inherit;
    font-size: 0.68rem;
    background: var(--ac6-border);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--ac6-text-muted);
}

/* ── Inline search (desktop) ───────────────────────── */
.search-inline {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ac6-surface-subtle, #f4f4f5);
    border: 1px solid var(--ac6-border, #e0e0e0);
    border-radius: 8px;
    padding: 6px 12px;
    min-width: 220px;
    max-width: 280px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-inline:focus-within {
    border-color: var(--ac6-primary, #0288d1);
    box-shadow: 0 0 0 3px rgba(2,136,209,0.12);
    background: #fff;
}

.search-inline-icon {
    width: 16px;
    height: 16px;
    color: #999;
    flex-shrink: 0;
}

#search-inline-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.88rem;
    color: #222;
    font-family: inherit;
    width: 100%;
}

#search-inline-input::placeholder { color: #aaa; }
#search-inline-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-inline-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 360px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 1px solid var(--ac6-border, #e0e0e0);
    z-index: 9999;
    max-height: 400px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Mobile: hide inline, show icon button */
.search-trigger-mobile { display: none; }

@media (max-width: 768px) {
    .search-inline { display: none; }
    .search-trigger-mobile { display: flex; }
}

/* ── Mobile ────────────────────────────────────────── */
@media (max-width: 600px) {
    #search-overlay {
        padding-top: 0;
        align-items: stretch;
    }

    #search-overlay-box {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        height: 100%;
        max-height: 100%;
    }

    #search-results {
        max-height: calc(100vh - 120px);
    }

    #search-hint {
        display: none;
    }
}
