/* assets/components/typeahead.css — reusable typeahead/autocomplete widget (P3 Phase 1A).
 *
 * Companion to assets/components/typeahead.js. Pure widget: pages inject
 * the data source (Array | Function | URL) and field mappings via config.
 *
 * Used by: trial-setup.html Step 3 (NAICS/CPV/PSC/GSIN/UNSPSC/country
 * pickers); profile-update.html (same fields); future subscriber-portal.html.
 *
 * Accessibility:
 *   - role="combobox" / aria-expanded / aria-controls on the input
 *   - role="listbox" on the dropdown
 *   - role="option" / aria-selected on each item
 *   - aria-activedescendant tracks keyboard highlight
 *   - ESC closes; ArrowUp/Down moves highlight; Enter selects; Tab closes.
 *
 * Palette per CLAUDE.md: teal text #007A62 (links/active), accent #00D4AA
 * (focus + selected glow), DM Sans body font.
 */

/* ── Input wrapper — relative for absolute dropdown ─────────────── */
.bc-ta-wrap {
    position: relative;
}

/* ── Dropdown list ──────────────────────────────────────────────── */
.bc-ta-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
    margin-top: 2px;
    background: #172440;
    border: 1px solid rgba(0, 212, 170, 0.25);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    font-family: 'DM Sans', sans-serif;
    /* Hidden until input gains focus + has matches */
    display: none;
}

.bc-ta-list.is-open {
    display: block;
}

/* ── List items ─────────────────────────────────────────────────── */
.bc-ta-item {
    /* 44px tap target per WCAG 2.5.5 + mobile-first charter */
    min-height: 44px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: #9BBBD8;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: background-color 120ms ease;
}

.bc-ta-item:last-child {
    border-bottom: none;
}

.bc-ta-item:hover,
.bc-ta-item.is-active {
    background: rgba(0, 212, 170, 0.12);
    color: #00D4AA;
}

.bc-ta-item .bc-ta-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #00D4AA;
    flex-shrink: 0;
    /* Reserve fixed width so labels align across rows */
    min-width: 70px;
}

.bc-ta-item .bc-ta-label {
    color: #9BBBD8;
    flex: 1;
    /* Truncate gracefully if label too long */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bc-ta-item:hover .bc-ta-label,
.bc-ta-item.is-active .bc-ta-label {
    color: #F0F6FF;
}

/* ── Empty + loading states ────────────────────────────────────── */
.bc-ta-empty,
.bc-ta-loading {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: #7A9CC0;
    font-style: italic;
    text-align: center;
}

.bc-ta-loading::after {
    content: ' …';
}

/* ── Focus ring — js-mouse-user pattern (canonical) ────────────── */
body.js-mouse-user .bc-ta-item:focus {
    outline: none;
}

.bc-ta-item:focus-visible {
    outline: 2px solid #00D4AA;
    outline-offset: -2px;
}

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .bc-ta-list {
        max-height: 220px;
    }

    .bc-ta-item {
        font-size: 0.95rem;
        padding: 12px 14px;
    }

    .bc-ta-item .bc-ta-code {
        min-width: 60px;
        font-size: 0.78rem;
    }
}

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .bc-ta-item {
        transition: none;
    }
}
