/**
 * Spotlight Search — component styles.
 *
 * Scoping: everything lives under the .spx- namespace (no shared selectors
 * with the legacy space-v3-search / space-search-modal engine). Multi-instance
 * safe: no bare element selectors, no IDs. Fonts inherit the page; surfaces
 * carry their own ink for guaranteed contrast; the accent and radius come from
 * the site (--primary-button-color / --border-radius). Dark mode keys off
 * body.dark-mode (the platform convention — there is no prefers-color-scheme
 * support on dealership sites).
 */

.spx,
.spx *,
.spx *::before,
.spx *::after {
    box-sizing: border-box;
}

.spx {
    /* ---- tokens ---------------------------------------------------- */
    --spx-radius: var(--border-radius, 10px);
    --spx-accent: var(--primary-button-color, var(--primary-color, #3b6cf6));
    --spx-ink: #191b20;
    --spx-dim: rgba(25, 27, 32, 0.78);
    --spx-faint: rgba(25, 27, 32, 0.5);
    --spx-surface: #ffffff;
    --spx-soft: rgba(25, 27, 32, 0.05);
    --spx-line: rgba(25, 27, 32, 0.12);
    --spx-panel-bg: rgba(255, 255, 255, 0.86);
    --spx-cursor-bg: color-mix(in srgb, var(--spx-accent) 9%, transparent);
    --spx-ring: color-mix(in srgb, var(--spx-accent) 16%, transparent);
    --spx-shadow-rest: 0 1px 2px rgba(16, 20, 30, 0.06);
    --spx-shadow-focus: 0 14px 34px -14px rgba(16, 20, 30, 0.22);
    --spx-shadow-panel: 0 28px 70px -18px rgba(16, 20, 30, 0.3), 0 6px 20px -8px rgba(16, 20, 30, 0.16);

    position: relative;
    width: 100%;
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

body.dark-mode .spx {
    --spx-ink: #f2f3f6;
    --spx-dim: rgba(242, 243, 246, 0.82);
    --spx-faint: rgba(242, 243, 246, 0.55);
    --spx-surface: #1c1d22;
    --spx-soft: rgba(242, 243, 246, 0.07);
    --spx-line: rgba(242, 243, 246, 0.14);
    --spx-panel-bg: rgba(25, 26, 31, 0.88);
    --spx-cursor-bg: color-mix(in srgb, var(--spx-accent) 16%, transparent);
    --spx-ring: color-mix(in srgb, var(--spx-accent) 24%, transparent);
    --spx-shadow-rest: 0 1px 2px rgba(0, 0, 0, 0.4);
    --spx-shadow-focus: 0 14px 34px -12px rgba(0, 0, 0, 0.55);
    --spx-shadow-panel: 0 28px 70px -16px rgba(0, 0, 0, 0.65), 0 6px 20px -8px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

.spx-shell {
    position: relative;
    max-width: var(--spx-max, 720px);
    margin-inline: auto;
}

/* ---- field --------------------------------------------------------- */

.spx-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding-inline: 18px 14px;
    background: var(--spx-surface);
    color: var(--spx-ink);
    /* Accent-washed resting border: enough of the site primary to make the
       field read as the page's search, a ramp (rest 38% → hover 62% → focus
       full) so interaction visibly deepens it. */
    border: 1px solid color-mix(in srgb, var(--spx-accent) 38%, var(--spx-line));
    border-radius: var(--spx-radius);
    box-shadow: var(--spx-shadow-rest);
    cursor: text;
    transition:
        border-color 0.25s ease,
        box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.25s ease;
}

.spx--compact .spx-field { height: 46px; padding-inline: 14px 10px; gap: 10px; }
.spx--large   .spx-field { height: 66px; padding-inline: 22px 16px; gap: 14px; }

.spx-field:hover {
    border-color: color-mix(in srgb, var(--spx-accent) 62%, var(--spx-line));
}

.spx-field:focus-within {
    border-color: color-mix(in srgb, var(--spx-accent) 75%, transparent);
    box-shadow: 0 0 0 4px var(--spx-ring), var(--spx-shadow-focus);
    transform: translateY(-1px);
}

.spx[data-shake] .spx-field {
    animation: spx-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ---- leading icon / spinner ---------------------------------------- */

.spx-icon {
    position: relative;
    flex: none;
    width: 21px;
    height: 21px;
    /* The magnifier carries the site primary at rest — it marks the field as
       search from across the page. */
    color: var(--spx-accent);
    transition: color 0.25s ease;
}

.spx-field:focus-within .spx-icon { color: var(--spx-accent); }

.spx-icon svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.22s ease, transform 0.32s cubic-bezier(0.34, 1.3, 0.4, 1);
}

.spx-icon-spin { opacity: 0; transform: scale(0.55) rotate(-90deg); }

.spx[data-busy] .spx-icon-glass { opacity: 0; transform: scale(0.55); }
.spx[data-busy] .spx-icon-spin  {
    opacity: 1;
    transform: none;
    animation: spx-rot 0.8s linear infinite;
    color: var(--spx-accent);
}

/* ---- input + typewriter overlay ------------------------------------ */

.spx-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    height: 100%;
}

.spx .spx-field .spx-input {
    all: unset;
    flex: 1;
    min-width: 0;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0;
    font: inherit;
    font-size: 16px;
    color: var(--spx-ink);
    caret-color: var(--spx-accent);
    cursor: text;
}

.spx--compact .spx-field .spx-input { font-size: 15px; }
.spx--large   .spx-field .spx-input { font-size: 18px; }

.spx .spx-field .spx-input::placeholder {
    color: var(--spx-faint);
    opacity: 1;
    transition: color 0.2s ease;
}

/* Native placeholder yields to the typewriter overlay */
.spx[data-tw] .spx-field .spx-input::placeholder { color: transparent; }

.spx .spx-field .spx-input::-webkit-search-cancel-button,
.spx .spx-field .spx-input::-webkit-search-decoration { display: none; }

.spx-type {
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: baseline;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
    color: var(--spx-faint);
    font-size: 16px;
}

.spx--compact .spx-type { font-size: 15px; }
.spx--large   .spx-type { font-size: 18px; }

.spx[data-tw] .spx-type { display: flex; }

.spx-type-text { transition: opacity 0.3s ease; }

.spx-type-caret {
    flex: none;
    width: 1.5px;
    height: 1.05em;
    margin-left: 2px;
    background: currentColor;
    align-self: center;
    animation: spx-blink 1.1s steps(2, start) infinite;
}

/* ---- clear + enter hint -------------------------------------------- */

.spx-clear {
    all: unset;
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: calc(var(--spx-radius) * 0.6);
    color: var(--spx-dim);
    cursor: pointer;
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.4, 0.4, 1), background-color 0.15s ease;
}

.spx-clear svg { width: 14px; height: 14px; }

.spx[data-has-text] .spx-clear {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.spx-clear:hover { background: var(--spx-soft); color: var(--spx-ink); }

.spx-enter {
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--spx-line);
    border-radius: calc(var(--spx-radius) * 0.6);
    color: var(--spx-faint);
    opacity: 0;
    transform: translateX(4px);
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), color 0.2s, border-color 0.2s;
}

.spx-enter svg { width: 12px; height: 12px; }

.spx[data-has-text][data-open] .spx-enter {
    opacity: 1;
    transform: none;
}

.spx[data-submitting] .spx-enter {
    color: var(--spx-accent);
    border-color: color-mix(in srgb, var(--spx-accent) 45%, transparent);
}

/* ---- progress beam ------------------------------------------------- */

.spx-beam {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.spx-beam::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--spx-accent), transparent);
}

.spx[data-submitting] .spx-beam { opacity: 1; }
.spx[data-submitting] .spx-beam::before { animation: spx-beam 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite; }

/* ---- panel --------------------------------------------------------- */

.spx-panel {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 10px);
    z-index: 120;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(0.985);
    transform-origin: top center;
    transition:
        opacity 0.2s ease,
        transform 0.26s cubic-bezier(0.4, 0, 0.6, 1),
        visibility 0s linear 0.26s;
}

.spx[data-open] .spx-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition:
        opacity 0.22s ease,
        transform 0.36s cubic-bezier(0.34, 1.35, 0.4, 1),
        visibility 0s;
}

.spx-panel-clip {
    overflow: hidden;
    border-radius: var(--spx-radius);
    border: 1px solid var(--spx-line);
    background: var(--spx-panel-bg);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    backdrop-filter: blur(22px) saturate(1.5);
    box-shadow: var(--spx-shadow-panel);
    transition: height 0.3s cubic-bezier(0.3, 1, 0.35, 1);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .spx-panel-clip { background: var(--spx-surface); }
}

.spx-panel-inner {
    max-height: min(64dvh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--spx-ink) 22%, transparent) transparent;
    color: var(--spx-ink);
}

/* Keep the open panel above later page sections (paint order). */
.sd-comp:has(.spx[data-open]) {
    position: relative;
    z-index: 130;
}

/* ---- sections ------------------------------------------------------ */

.spx-list {
    position: relative;
    padding: 7px;
}

.spx-sec[hidden] { display: none; }

.spx-sec-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 11px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--spx-dim);
    opacity: 0.9;
}

.spx-sec + .spx-sec .spx-sec-head { padding-top: 13px; }

.spx-recent-clear {
    all: unset;
    margin-left: auto;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    color: var(--spx-faint);
    cursor: pointer;
    padding: 2px 7px;
    border-radius: calc(var(--spx-radius) * 0.6);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.spx-recent-clear:hover { color: var(--spx-ink); background: var(--spx-soft); }

.spx-sparkle {
    width: 13px;
    height: 13px;
    color: var(--spx-accent);
    animation: spx-pulse 2.6s ease-in-out infinite;
}

/* ---- rows + floating cursor ---------------------------------------- */

.spx-cursor {
    position: absolute;
    inset-inline: 7px;
    top: 0;
    height: 0;
    border-radius: calc(var(--spx-radius) * 0.65);
    background: var(--spx-cursor-bg);
    opacity: 0;
    pointer-events: none;
    transition:
        top 0.18s cubic-bezier(0.3, 0.9, 0.3, 1.15),
        height 0.18s cubic-bezier(0.3, 0.9, 0.3, 1.15),
        opacity 0.15s ease;
}

.spx-cursor[data-on] { opacity: 1; }

.spx-row {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: calc(var(--spx-radius) * 0.65);
    color: var(--spx-dim);
    cursor: pointer;
    animation: spx-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--i, 0) * 24ms);
    transition: color 0.15s ease;
}

.spx-row { color: var(--spx-ink); }
.spx-row[aria-selected="true"] { color: var(--spx-ink); }

.spx-row-icon {
    flex: none;
    width: 17px;
    height: 17px;
    color: var(--spx-faint);
    transition: color 0.15s ease, transform 0.2s ease;
}

.spx-row-icon svg { width: 100%; height: 100%; display: block; }

.spx-row[aria-selected="true"] .spx-row-icon { color: var(--spx-accent); }

.spx-row-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14.5px;
}

.spx-row-label b {
    font-weight: 650;
    color: var(--spx-ink);
}

.spx-badge {
    flex: none;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 3px 7px;
    border: 1px solid var(--spx-line);
    border-radius: calc(var(--spx-radius) * 0.55);
    color: var(--spx-dim);
    background: var(--spx-soft);
}

.spx-badge--ai {
    color: var(--spx-accent);
    border-color: color-mix(in srgb, var(--spx-accent) 30%, transparent);
    background: color-mix(in srgb, var(--spx-accent) 8%, transparent);
    text-transform: none;
    letter-spacing: 0.03em;
}

.spx-row-go {
    flex: none;
    width: 14px;
    height: 14px;
    color: var(--spx-accent);
    opacity: 0;
    transform: translateX(-5px);
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.spx-row-go svg { width: 100%; height: 100%; display: block; }

.spx-row[aria-selected="true"] .spx-row-go { opacity: 1; transform: none; }

.spx-row-x {
    all: unset;
    flex: none;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--spx-faint);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.spx-row-x svg { width: 11px; height: 11px; display: block; }

.spx-row:hover .spx-row-x,
.spx-row[aria-selected="true"] .spx-row-x { opacity: 1; }

.spx-row-x:hover { background: var(--spx-soft); color: var(--spx-ink); }

@media (pointer: coarse) {
    .spx-row-x { opacity: 1; }
}

/* ---- AI skeleton --------------------------------------------------- */

.spx-skel {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 44px;
    padding: 10px 12px;
    animation: spx-in 0.3s ease both;
}

.spx-skel-dot,
.spx-skel-bar {
    position: relative;
    overflow: hidden;
    background: var(--spx-soft);
    border-radius: 6px;
}

.spx-skel-dot { flex: none; width: 17px; height: 17px; border-radius: 50%; }
.spx-skel-bar { height: 12px; }

.spx-skel-dot::after,
.spx-skel-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--spx-ink) 8%, transparent) 50%, transparent 80%);
    animation: spx-shimmer 1.5s ease-in-out infinite;
}

/* ---- state slot (empty / searching) -------------------------------- */

.spx-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 22px 16px;
    text-align: center;
    font-size: 13.5px;
    color: var(--spx-dim);
    animation: spx-in 0.3s ease both;
}

.spx-state[hidden] { display: none; }

.spx-state-title { font-weight: 600; color: var(--spx-ink); font-size: 14px; }

.spx-state-hint { font-size: 12.5px; color: var(--spx-faint); }

.spx-state .spx-icon-spin {
    position: static;
    width: 20px;
    height: 20px;
    opacity: 1;
    transform: none;
    color: var(--spx-accent);
    animation: spx-rot 0.8s linear infinite;
    margin-bottom: 4px;
}

/* ---- quick chips --------------------------------------------------- */

.spx-sec-quick { padding: 0 7px 9px; }

.spx-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 4px 11px 6px;
}

.spx-chip {
    all: unset;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 500;
    color: var(--spx-ink);
    background: var(--spx-soft);
    border: 1px solid transparent;
    border-radius: calc(var(--spx-radius) * 1.1);
    cursor: pointer;
    animation: spx-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--i, 0) * 20ms);
    transition:
        color 0.15s ease,
        border-color 0.2s ease,
        background-color 0.2s ease,
        transform 0.25s cubic-bezier(0.34, 1.4, 0.4, 1);
}

.spx-chip:hover,
.spx-chip:focus-visible {
    color: var(--spx-ink);
    border-color: color-mix(in srgb, var(--spx-accent) 40%, transparent);
    background: color-mix(in srgb, var(--spx-accent) 9%, transparent);
    transform: translateY(-1px);
}

.spx-chip:active { transform: translateY(0) scale(0.97); }

.spx-chip-count {
    font-size: 11px;
    color: var(--spx-faint);
}

/* ---- footer hints -------------------------------------------------- */

.spx-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 14px;
    border-top: 1px solid var(--spx-line);
    font-size: 11px;
    color: var(--spx-faint);
}

.spx-foot-hint { display: inline-flex; align-items: center; gap: 4px; }

.spx-key {
    display: inline-grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font: inherit;
    font-size: 10px;
    color: var(--spx-dim);
    background: var(--spx-soft);
    border: 1px solid var(--spx-line);
    border-bottom-width: 2px;
    border-radius: 5px;
}

@media (pointer: coarse) {
    .spx-foot { display: none; }
    .spx-enter { display: none; }
}

/* ---- theme button reset -------------------------------------------- */
/* `all: unset` on the base rules loses to any theme that styles buttons at
   higher specificity — bb-theme's compiled skin gives bare `button` a border
   and an accent background (theme.less), and `.fl-page button` out-specifies
   a lone class. Re-assert the element+class form for every control that is
   meant to read as a bare glyph, in the resting AND interactive states.
   .spx-chip is excluded: its border is real, and it earns one on hover. */
button.spx-clear,
button.spx-clear:hover,
button.spx-clear:focus,
button.spx-clear:focus-visible,
button.spx-clear:active,
button.spx-recent-clear,
button.spx-recent-clear:hover,
button.spx-recent-clear:focus,
button.spx-recent-clear:focus-visible,
button.spx-recent-clear:active,
button.spx-row-x,
button.spx-row-x:hover,
button.spx-row-x:focus,
button.spx-row-x:focus-visible,
button.spx-row-x:active {
    border: none;
    outline: none;
    box-shadow: none;
    text-transform: none;
    text-shadow: none;
    min-height: 0;
    min-width: 0;
}
/* Resting state carries no fill; the hover fills below are the intended ones. */
button.spx-clear,
button.spx-recent-clear,
button.spx-row-x {
    background: none;
}
button.spx-clear:hover,
button.spx-clear:focus-visible,
button.spx-row-x:hover,
button.spx-row-x:focus-visible,
button.spx-recent-clear:hover,
button.spx-recent-clear:focus-visible {
    background: var(--spx-soft);
    color: var(--spx-ink);
}
/* The chip keeps its own border, but never a theme's background or shadow. */
button.spx-chip,
button.spx-chip:focus,
button.spx-chip:active {
    background: var(--spx-soft);
    box-shadow: none;
    outline: none;
    text-transform: none;
    text-shadow: none;
    min-height: 0;
}
button.spx-chip:hover,
button.spx-chip:focus-visible {
    background: color-mix(in srgb, var(--spx-accent) 9%, transparent);
}

/* ---- a11y live region ---------------------------------------------- */

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

/* ---- responsive ---------------------------------------------------- */

@media (max-width: 640px) {
    .spx-field { height: 52px; padding-inline: 14px 10px; gap: 10px; }
    .spx--compact .spx-field { height: 46px; }
    .spx--large .spx-field { height: 58px; }
    .spx--large .spx-field .spx-input,
    .spx--large .spx-type { font-size: 16px; }
    .spx-panel { top: calc(100% + 8px); }
    .spx-panel-inner { max-height: min(52dvh, 440px); }
    .spx-row { min-height: 46px; }
}

@media (pointer: coarse) {
    /* Never below 16px on touch — prevents iOS focus zoom. */
    .spx--compact .spx-field .spx-input,
    .spx--compact .spx-type { font-size: 16px; }
}

/* ---- motion -------------------------------------------------------- */

@keyframes spx-in {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: none; }
}

@keyframes spx-blink {
    50% { opacity: 0; }
}

@keyframes spx-rot {
    to { transform: rotate(360deg); }
}

@keyframes spx-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.86); }
}

@keyframes spx-shimmer {
    to { transform: translateX(100%); }
}

@keyframes spx-beam {
    0%   { left: -45%; }
    100% { left: 105%; }
}

@keyframes spx-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

@media (prefers-reduced-motion: reduce) {
    .spx *,
    .spx *::before,
    .spx *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .spx-type-caret { animation: none; opacity: 0.7; }
}
