/**
 * Digitalize Hub — Live Search dropdown styles.
 *
 * v3.9.0 — W2F-BSF (item 29).
 *
 * The spec suggested ~30 lines; this file ships ~150 lines because we
 * need: empty + loading + error states, keyboard-active focus styles,
 * spinner keyframes, a responsive cap on small screens, and explicit
 * fallback values for every CSS variable so the dropdown reads
 * correctly even before the theme's inline :root vars are emitted.
 *
 * Every color / radius / shadow uses the theme's CSS variables
 * (--bg-card, --border, --text, --text-muted, --accent, --radius,
 * --ease) so the dropdown inherits the user's Theme Options overrides
 * automatically. Dark mode just works because functions.php emits the
 * same vars under html.dh-mode-dark / body.dh-mode-dark.
 */

/* The form wrapper becomes the positioning context for the dropdown. */
.dh-search,
.dh-search-form {
    position: relative;
}

/* The dropdown — absolute, full-width of the form, below the input. */
.dh-live-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: var(--bg-card, #fbfaf6);
    border: 1px solid var(--border, #e6e3da);
    border-radius: var(--radius, 16px);
    box-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    max-height: 60vh;
    overflow-y: auto;
    padding: 6px;
    color: var(--text, #1a1a1f);
}

.dh-live-search-results[hidden] { display: none; }

/* Each result row — flexbox so the thumbnail aligns with the title. */
.dh-live-search-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dh-live-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm, 11px);
    cursor: pointer;
    transition: background 0.15s var(--ease, ease);
}

/* Keyboard-active highlight (ArrowUp/Down). */
.dh-live-search-item.is-active,
.dh-live-search-item:hover {
    background: var(--accent-soft, #fce8e4);
}

.dh-live-search-item.is-active {
    outline: 2px solid var(--accent, #d8402a);
    outline-offset: -2px;
}

.dh-live-search-thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-alt, #f7f5f0);
}

.dh-live-search-thumb--placeholder {
    display: inline-block;
}

.dh-live-search-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.dh-live-search-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text, #1a1a1f);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dh-live-search-excerpt {
    font-size: 0.8rem;
    color: var(--text-muted, #6a6a78);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dh-live-search-meta {
    font-size: 0.7rem;
    color: var(--text-muted, #6a6a78);
    text-transform: capitalize;
}

/* Empty + loading + error states. */
.dh-live-search-empty,
.dh-live-search-loading,
.dh-live-search-error {
    margin: 0;
    padding: 14px 12px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted, #6a6a78);
}

.dh-live-search-loading::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    border: 2px solid var(--border, #e6e3da);
    border-top-color: var(--accent, #d8402a);
    border-radius: 50%;
    vertical-align: middle;
    animation: dh-live-search-spin 0.7s linear infinite;
}

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

/* Small screens: cap the dropdown width so it doesn't overflow the viewport. */
@media (max-width: 600px) {
    .dh-live-search-results {
        max-width: calc(100vw - 32px);
    }
}
