/*
 * PenguBIN filter bar.
 *
 * The first row is what almost everyone needs: search, sort and platform.
 * The second is the four filters people reach for most. Everything else sits
 * behind "More filters", and whatever is switched on comes back as a chip that
 * says what it is and can be clicked off. Colours come only from the brand
 * tokens; lime marks focus, selection and the one active state.
 */

.fb { margin: 24px 0 16px; padding: 12px; background: var(--pb-surface); border: 1px solid var(--pb-border); border-radius: var(--pb-radius); }
.fb-top, .fb-quick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fb-quick { margin-top: 8px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fb svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Search */
.fb-search { position: relative; flex: 1 1 280px; min-width: 0; display: flex; align-items: center; }
.fb-search svg { position: absolute; left: 14px; color: var(--pb-text-muted); pointer-events: none; }
.fb-search input { width: 100%; height: 44px; padding: 0 16px 0 40px; background: var(--pb-bg); border: 1px solid var(--pb-border);
    border-radius: var(--pb-radius-pill); color: var(--pb-text); font: 400 14px var(--pb-font); }
.fb-search input::placeholder { color: var(--pb-text-muted); }
.fb-search input:focus { outline: none; border-color: var(--pb-accent); box-shadow: 0 0 0 3px var(--pb-accent-tint); }

/* The picker button, and the plain select it stands in for (the select is what
   shows if scripts are off, styled to match rather than with the OS arrow). */
.pk { position: relative; }
.pk-btn, .fb select, .fb-more-btn, .pk-range > summary {
    display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px 0 16px; max-width: 260px;
    background: var(--pb-bg); border: 1px solid var(--pb-border); border-radius: var(--pb-radius-pill);
    color: var(--pb-text); font: 500 13px var(--pb-font); cursor: pointer; white-space: nowrap; list-style: none;
    transition: border-color .15s ease, background-color .15s ease; }
.fb select { appearance: none; -webkit-appearance: none; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239A9FA6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 14px; }
.pk-range > summary::-webkit-details-marker { display: none; }
.pk-btn:hover, .fb select:hover, .fb-more-btn:hover, .pk-range > summary:hover { border-color: var(--pb-text-muted); }
.pk-btn:focus-visible, .fb select:focus-visible, .fb-more-btn:focus-visible, .pk-range > summary:focus-visible,
.seg input:focus-visible + span, .fb-switch input:focus-visible + span { outline: none; border-color: var(--pb-accent); box-shadow: 0 0 0 3px var(--pb-accent-tint); }

.pk-btn .lbl, .pk-range > summary .lbl { color: var(--pb-text-muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.pk-btn .val { overflow: hidden; text-overflow: ellipsis; }
.pk-btn .chev, .pk-range > summary .chev, .fb-more-btn .chev { color: var(--pb-text-muted); width: 14px; height: 14px; transition: transform .15s ease; }
.pk-btn[aria-expanded="true"] .chev, .pk-range[open] > summary .chev, .fb-more-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.pk-btn.on, .pk-range.on > summary, .fb select.on { border-color: var(--pb-accent-line); background: var(--pb-accent-tint); }
.pk-btn.on .lbl, .pk-range.on > summary .lbl { color: var(--pb-accent); }
.pk-btn img, .pk-opt img { width: 20px; height: 20px; object-fit: contain; flex: none; }

/* The list that opens under a picker */
.pk-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 240px; max-width: 320px;
    background: var(--pb-surface); border: 1px solid var(--pb-border); border-radius: var(--pb-radius);
    box-shadow: var(--pb-shadow); overflow: hidden; }
.pk-pop[hidden] { display: none; }
.pk-pop.right { left: auto; right: 0; }
.pk-find { display: block; padding: 8px; border-bottom: 1px solid var(--pb-border); }
.pk-find input { width: 100%; height: 38px; padding: 0 12px; background: var(--pb-bg); border: 1px solid var(--pb-border);
    border-radius: 10px; color: var(--pb-text); font: 400 13px var(--pb-font); }
.pk-find input:focus { outline: none; border-color: var(--pb-accent); }
.pk-list { max-height: 320px; overflow-y: auto; overscroll-behavior: contain; padding: 6px; margin: 0; list-style: none; }
.pk-group { padding: 10px 10px 4px; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--pb-text-muted); }
.pk-opt { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: 8px;
    font-size: 13px; color: var(--pb-text); cursor: pointer; }
.pk-opt .n { margin-left: auto; font-size: 11px; color: var(--pb-text-muted); font-variant-numeric: tabular-nums; }
.pk-opt .tick { width: 14px; height: 14px; color: var(--pb-accent); visibility: hidden; }
.pk-opt[aria-selected="true"] .tick { visibility: visible; }
.pk-opt[aria-selected="true"] { color: var(--pb-accent); }
.pk-opt.active { background: var(--pb-bg); }
.pk-opt .ph { width: 20px; height: 20px; flex: none; }
.pk-none { padding: 16px 10px; font-size: 13px; color: var(--pb-text-muted); }

/* Rating: a few common bands, or type your own */
.pk-range { position: relative; }
.pk-range .pk-pop { padding: 12px; min-width: 260px; }
.pk-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pk-presets button { height: 32px; padding: 0 12px; background: var(--pb-bg); border: 1px solid var(--pb-border);
    border-radius: var(--pb-radius-pill); color: var(--pb-text); font: 600 12px var(--pb-font); cursor: pointer; }
.pk-presets button:hover, .pk-presets button.on { border-color: var(--pb-accent); color: var(--pb-accent); }
.pk-between { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--pb-text-muted); }
.pk-between input, .fb-stats input { width: 72px; height: 38px; padding: 0 10px; background: var(--pb-bg); border: 1px solid var(--pb-border);
    border-radius: 10px; color: var(--pb-text); font: 500 14px var(--pb-font); text-align: center; -moz-appearance: textfield; }
.pk-between input:focus, .fb-stats input:focus { outline: none; border-color: var(--pb-accent); }

/* More filters */
.fb-more-btn em { font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px; background: var(--pb-accent); color: var(--pb-on-accent); font-size: 11px; font-weight: 700; }
.fb-panel { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(440px, 1.9fr) minmax(240px, .9fr); gap: 20px 28px;
    margin-top: 12px; padding: 16px 4px 4px; border-top: 1px solid var(--pb-border); }
.fb-panel[hidden] { display: none; }
.fb-sec h3 { margin: 0 0 10px; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--pb-text-muted); }
.fb-sec .line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.fb-sec .line > .cap { width: 100%; font-size: 12px; color: var(--pb-text-muted); }

/* Segmented choices (skills, weak foot, platform...) are real radio buttons */
.seg { display: inline-flex; gap: 3px; padding: 3px; margin: 0; border: 1px solid var(--pb-border); border-radius: var(--pb-radius-pill); background: var(--pb-bg); }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: var(--pb-radius-pill);
    font-size: 12px; font-weight: 600; color: var(--pb-text-muted); white-space: nowrap; }
.seg input:checked + span { background: var(--pb-surface); color: var(--pb-accent); border-color: var(--pb-border); }
.seg label:hover span { color: var(--pb-text); }
.fb-top .seg span { height: 36px; font-weight: 700; letter-spacing: .08em; font-size: 11px; }

.fb-switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--pb-text); cursor: pointer; }
.fb-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fb-switch span { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--pb-bg); border: 1px solid var(--pb-border); transition: background-color .15s ease; }
.fb-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--pb-text-muted); transition: transform .15s ease, background-color .15s ease; }
.fb-switch input:checked + span { background: var(--pb-accent-tint); border-color: var(--pb-accent-line); }
.fb-switch input:checked + span::after { transform: translateX(16px); background: var(--pb-accent); }

.fb-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.fb-stats label { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--pb-text-muted); }
.fb-stats input { width: 100%; padding: 0 4px; text-align: center; }
.fb-stats input::placeholder { color: var(--pb-text-muted); opacity: .5; }
.fb-pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.fb-pairs > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fb-pairs .cap { font-size: 12px; color: var(--pb-text-muted); }
.fb-pairs .seg { align-self: flex-start; max-width: 100%; }
.fb-pairs > div:last-child { grid-column: 1 / -1; }
.fb-pairs .seg span { padding: 0 11px; }
@media (max-width: 1100px) { .fb-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); } .fb-panel > .fb-sec:nth-child(2) { grid-row: span 2; } }

.fb-apply { margin-top: 12px; height: 40px; padding: 0 22px; border: 1px solid var(--pb-accent); background: var(--pb-accent-tint); color: var(--pb-accent);
    border-radius: var(--pb-radius-pill); font: 700 11px var(--pb-font); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; }

/* Results head: the count and the chips */
.res-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 4px 0 14px; }
.res-count { margin: 0; font-size: 13px; color: var(--pb-text-muted); font-variant-numeric: tabular-nums; }
.res-count b { color: var(--pb-text); font-weight: 700; }
.res-count span { margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px 0 12px; border-radius: 999px;
    background: var(--pb-surface); border: 1px solid var(--pb-border); font-size: 12px; color: var(--pb-text); text-decoration: none; }
.chip .k { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--pb-text-muted); }
.chip .x { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; color: var(--pb-text-muted); }
.chip:hover { border-color: var(--pb-accent); }
.chip:hover .x { color: var(--pb-accent); }
.chip.clear { border-style: dashed; color: var(--pb-text-muted); padding: 0 12px; }

/* While new results load: keep the old ones, dimmed, so nothing jumps */
#pbres { transition: opacity .15s ease; }
#pbres.loading { opacity: .45; pointer-events: none; }

.empty { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 48px 24px; text-align: center; color: var(--pb-text-muted);
    background: var(--pb-surface); border: 1px solid var(--pb-border); border-radius: var(--pb-radius); }
.empty b { color: var(--pb-text); font-size: 15px; }
.empty a { color: var(--pb-accent); }

/* Phones: pickers fill the row two to a line, and a list opens as a sheet
   from the bottom of the screen where a thumb can reach it. */
.pk-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .55); }
.pk-backdrop[hidden] { display: none; }
.pk-sheet-head { display: none; }

@media (max-width: 720px) {
    .fb { padding: 10px; }
    .fb-search { flex-basis: 100%; }
    .fb-top > .pk, .fb-top > select { flex: 1 1 auto; }
    .fb-quick > .pk, .fb-quick > select, .fb-quick > .pk-range, .fb-quick > .fb-more-btn { flex: 1 1 calc(50% - 4px); min-width: 0; }
    .pk-btn, .fb select, .fb-more-btn, .pk-range > summary { width: 100%; max-width: none; }
    .pk-btn .val { flex: 1; text-align: left; }
    .fb-panel { grid-template-columns: 1fr; }

    .pk-pop { position: fixed; top: auto; left: 0; right: 0; bottom: 0; max-width: none; min-width: 0;
        border-radius: 16px 16px 0 0; max-height: 75dvh; display: flex; flex-direction: column; }
    .pk-pop .pk-list { max-height: none; flex: 1; }
    .pk-opt { min-height: 44px; }
    .pk-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--pb-border);
        font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--pb-text-muted); }
    .pk-sheet-head button { height: 36px; padding: 0 14px; border: 1px solid var(--pb-border); border-radius: var(--pb-radius-pill);
        background: var(--pb-bg); color: var(--pb-text); font: 600 12px var(--pb-font); }
    .fb-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .pk-btn, .chev, .fb-switch span, .fb-switch span::after, #pbres { transition: none !important; }
}
