/*!
 * Search+ 3.0 — facet chips inside the search overlay (CONTRACTS-WAVE2 §3).
 * Companion of assets/js/sp-facets.js. Budget: this file <= 6144 bytes.
 *
 * Loaded AFTER search-plus.css (a declared dependency) and reusing its tokens,
 * so a theme that re-tints the overlay re-tints the chips. Every token carries a
 * literal fallback in case only this stylesheet loads.
 *
 * Every selector carries two classes on purpose: the overlay's defensive reset
 * (`.sp-root *` — border: 0, background: none, outline: 0, animation: none)
 * has one-class specificity, so anything single-class here would lose to it.
 */

/* filter bar */

.sp-panel .sp-fx {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  flex: 0 0 auto;
  max-height: 30vh;
  overflow-y: auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--sp-border, #e2e5ea);
  background: var(--sp-bg, #fff);
  font-size: 13px;
  line-height: 1.2;
  overscroll-behavior: contain;
}

/* One facet: its label, then its values. */
.sp-panel .sp-fx-g {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
}

.sp-panel .sp-fx-l {
  color: var(--sp-muted, #5a616e);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* chips */

.sp-panel .sp-fx-c,
.sp-panel .sp-fx-x {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  max-width: 15em;
  padding: 4px 10px;
  border: 1px solid var(--sp-border-strong, #767b85); /* 1.4.11: the only boundary */
  border-radius: 999px;
  background: transparent;
  color: var(--sp-fg, #16181d);
  font-size: 13px;
  line-height: 1.25;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}

.sp-panel .sp-fx-t {
  overflow: hidden;
  max-width: 12em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-panel .sp-fx-n {
  color: var(--sp-muted, #5a616e);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sp-panel .sp-fx-c:hover,
.sp-panel .sp-fx-x:hover {
  border-color: var(--sp-accent, #0b53d6);
  background: var(--sp-accent-soft, rgba(11, 83, 214, .09));
}

/* Selected: the accent fills the chip and the foreground is the PANEL
   BACKGROUND, not white — white on the dark accent is 2.53:1, the worst ratio in
   the product; var(--sp-bg) is 7.16:1 dark, 6.52:1 light. The count lost its
   opacity: .8 (2.14:1) and inherits full strength now (A11Y-03). */
.sp-panel .sp-fx-c[aria-pressed="true"] {
  border-color: var(--sp-accent, #0b53d6);
  background: var(--sp-accent, #0b53d6);
  color: var(--sp-bg, #fff);
  font-weight: 600;
}

.sp-panel .sp-fx-c[aria-pressed="true"] .sp-fx-n {
  color: inherit;
}

.sp-panel .sp-fx-x {
  margin-inline-start: auto;
  border-style: dashed;
  color: var(--sp-muted, #5a616e);
}

/* Base rule is plain :focus (an unknown pseudo-class would invalidate a merged
   list), withdrawn from pointer focus below. The ring is INSET because the bar
   scrolls and the panel clips: an offset outline loses its edge chips (2.4.11). */
.sp-panel .sp-fx-c:focus,
.sp-panel .sp-fx-x:focus {
  outline: 2px solid transparent;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px var(--sp-accent, #0b53d6), inset 0 0 0 4px var(--sp-bg, #fff);
}

.sp-panel .sp-fx-c:focus:not(:focus-visible),
.sp-panel .sp-fx-x:focus:not(:focus-visible) {
  outline: 0;
  box-shadow: none;
}

/* filtered result list */

/* While filters are on, our list replaces the overlay's own. The overlay's
   regions are covered with a CLASS, never with their `hidden` attribute —
   that attribute belongs to search-plus.js alone. */
.sp-panel.sp-fx-on .sp-list,
.sp-panel.sp-fx-on .sp-foot {
  display: none;
}

.sp-panel .sp-fx-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Rows reuse the overlay's own .sp-row / .sp-thumb / .sp-title classes, so
   they are pixel-identical to the unfiltered list and need no styling here. */

.sp-panel .sp-fx-e {
  padding: 18px 14px;
  color: var(--sp-muted, #5a616e);
  font-size: 14px;
  text-align: center;
}

/* Loading placeholder: three shimmering row-height bars. */
.sp-panel .sp-fx-w {
  height: calc(var(--sp-row-h, 72px) * 2);
  background:
    linear-gradient(var(--sp-skel, #e9ecf1), var(--sp-skel, #e9ecf1)) 12px 16px / calc(100% - 24px) 14px no-repeat,
    linear-gradient(var(--sp-skel, #e9ecf1), var(--sp-skel, #e9ecf1)) 12px 46px / 60% 14px no-repeat,
    linear-gradient(var(--sp-skel, #e9ecf1), var(--sp-skel, #e9ecf1)) 12px 88px / calc(100% - 24px) 14px no-repeat;
  animation: sp-fx-pulse 1.1s ease-in-out 4; /* 2.2.2: stops itself at ~4.4 s */
}

@keyframes sp-fx-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

@media (prefers-reduced-motion: reduce) {
  .sp-panel .sp-fx-w {
    animation: none;
  }
  .sp-panel .sp-fx-c,
  .sp-panel .sp-fx-x {
    transition: none;
  }
}

/* mobile / sheet */

/* In the full-screen sheet the bar may not eat the results: it becomes one
   horizontally scrollable strip. */
@media (max-width: 781px) {
  .sp-panel.sp-sheet .sp-fx {
    flex-wrap: nowrap;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
    scrollbar-width: none;
  }
  .sp-panel.sp-sheet .sp-fx::-webkit-scrollbar {
    height: 0;
  }
  .sp-panel.sp-sheet .sp-fx-g {
    flex-wrap: nowrap;
  }
  .sp-panel.sp-sheet .sp-fx-x {
    margin-inline-start: 4px;
  }
  .sp-panel .sp-fx-c,
  .sp-panel .sp-fx-x {
    padding: 6px 12px; /* >= 32px touch target */
  }
}

/* Forced-colours mode: borders and the selected state must survive. */
@media (forced-colors: active) {
  .sp-panel .sp-fx-c,
  .sp-panel .sp-fx-x {
    border-color: ButtonBorder;
    color: ButtonText;
  }
  .sp-panel .sp-fx-c[aria-pressed="true"] {
    background: Highlight;
    color: HighlightText;
  }
}
