/* ============================================================================
   _game-buildsource.css — "Kies je build" selector bar (console-scoped)
   ============================================================================
   A calm, prominent selector that sits full-width ABOVE the GPU/CPU/RAM grid
   inside the "Jouw systeem" card. It lets a visitor auto-fill their hardware
   from a PC-builder build (current localStorage build + saved REST builds).

   EVERY rule is scoped under `.fps-buildsource`, so it reuses the same
   `.dropdown-*` markup as the hardware fields without touching the shared,
   legacy `_dropdowns.css`. Tokens only (theme-vars + the `--fps-*` scale from
   `_game-hero.css`); depth comes from color-mix()/rgba-over-token so both
   light and dark themes stay correct. Alpine bindings are presentation-free.

   Sections:
     1. Layout (bar sits above the grid)
     2. Trigger (the closed selector button + build icon + chevron)
     3. Floating menu (detached popover)
     4. Options (rows, muted "· build name", manual reset, loading)
     5. Empty state (one quiet muted line linking to the builder)
   ============================================================================ */

/* ============================================================================
   1. LAYOUT — full-width bar above the GPU/CPU/RAM grid
   ========================================================================== */

.fps-buildsource {
    margin-bottom: var(--fps-gap);
}

.fps-buildsource__picker {
    position: relative;
}

.fps-buildsource .hardware-dropdown {
    position: relative;
    width: 100%;
}

/* ============================================================================
   2. TRIGGER — prominent selector button
   ----------------------------------------------------------------------------
   Slightly warmer than the neutral hardware triggers (a whisper of accent) so
   it reads as the primary shortcut, without shouting. Hover lifts the border
   toward the accent; open + focus draw a full accent ring.
   ========================================================================== */

.fps-buildsource .dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: var(--fps-control-h);
    padding: 0.5rem clamp(0.75rem, 1.5vw, 0.9375rem);
    background: color-mix(in srgb, var(--accent) 6%, var(--bg-secondary));
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--fps-fs-base);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    touch-action: manipulation;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.fps-buildsource .dropdown-trigger:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 9%, var(--bg-secondary));
}

.fps-buildsource .dropdown-trigger:focus,
.fps-buildsource .dropdown-trigger:focus-visible,
.fps-buildsource .dropdown-trigger.is-open {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Build icon (layers) leads the label. */
.fps-buildsource__icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.fps-buildsource .dropdown-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chevron: quiet at rest, rotates + accents when the menu is open. */
.fps-buildsource .dropdown-arrow {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.18s ease, color 0.15s ease;
}

.fps-buildsource .dropdown-trigger:hover .dropdown-arrow {
    color: var(--text-secondary);
}

.fps-buildsource .dropdown-trigger.is-open .dropdown-arrow {
    transform: rotate(180deg);
    color: var(--accent);
}

/* ============================================================================
   3. FLOATING MENU — detached, fully-rounded popover
   ========================================================================== */

.fps-buildsource .dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow: hidden;
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* Raise the field while its menu is open so the popover is never clipped. */
.fps-buildsource .hardware-dropdown:has(.is-open) {
    z-index: 9999;
}

/* ============================================================================
   4. OPTIONS — rows, muted "· build name", manual reset, loading
   ========================================================================== */

.fps-buildsource .dropdown-options {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.fps-buildsource .dropdown-options::-webkit-scrollbar {
    width: 8px;
}

.fps-buildsource .dropdown-options::-webkit-scrollbar-track {
    background: transparent;
}

.fps-buildsource .dropdown-options::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border: 2px solid var(--bg-modal);
    border-radius: 999px;
}

.fps-buildsource .dropdown-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 44px;
    padding: 0.5625rem clamp(0.75rem, 1.5vw, 1rem);
    background-color: transparent;
    border: none;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    color: var(--text-secondary);
    font-size: var(--fps-fs-sm);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.fps-buildsource .dropdown-option:last-child {
    border-bottom: none;
}

.fps-buildsource .dropdown-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Muted secondary "· build name" trailing the "Huidige build" label. */
.fps-buildsource__meta {
    color: var(--text-muted);
    font-weight: 600;
}

/* "Zelf samenstellen" reset — set apart on a top hairline shelf, quiet. */
.fps-buildsource__option--manual {
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
}

/* Loading line while saved builds are being fetched. */
.fps-buildsource__loading {
    padding: 0.5625rem clamp(0.75rem, 1.5vw, 1rem);
    color: var(--text-muted);
    font-size: var(--fps-fs-sm);
}

/* ============================================================================
   5. EMPTY STATE — one quiet muted line linking to the builder
   ========================================================================== */

.fps-buildsource__empty {
    margin: 0;
    font-size: var(--fps-fs-sm);
    color: var(--text-muted);
}

.fps-buildsource__empty a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.fps-buildsource__empty a:hover,
.fps-buildsource__empty a:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .fps-buildsource .dropdown-trigger,
    .fps-buildsource .dropdown-arrow,
    .fps-buildsource .dropdown-option {
        transition: none;
    }
}
