/* ─────────────────────────────────────────────────────────────
   Alpine — Directory Filter
   Prefix: .am-filter
   ───────────────────────────────────────────────────────────── */
.am-filter {
  --am-navy: #003469;
  --am-navy-hover: #0a4a86;
  --am-sky: #00addc;
  --am-border: #dce4ef;
  --am-text-mid: #4a5568;
  --am-pill-radius: var(--oe-border-radius-base);
  font-family: 'Poppins', 'Segoe UI', Arial, sans-serif;
  position: relative;
}
.am-filter.is-sticky { position: sticky; z-index: 800; }
/* Full-bleed background: the pills/search stay aligned to the page container,
   but the white bar + bottom border span the whole viewport width. Centred on
   the block, so it lines up with the site's centred content column. */
.am-filter::before {
  content: ""; position: absolute; z-index: 0;
  top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%);
  background: var(--oe-color-muted); border-bottom: 1px solid var(--am-border);
}
.am-filter__inner,
.am-filter__noresults { position: relative; z-index: 1; }

/* Search sits to the RIGHT of the pills on desktop; stacks under on mobile. */
.am-filter__inner {
  display: flex; align-items: center; gap: var(--oe-spacing-medium);
  padding: var(--oe-spacing-xsmall) 0; flex-wrap: nowrap;
}
.am-filter__pills-wrap { flex: 1 1 auto; min-width: 0; position: relative; }
.am-filter__pills { display: flex; gap: 10px; flex-wrap: wrap; }
.am-filter__search { flex: 0 0 auto; position: relative; }
.am-filter__search input[type="search"] { background: #FFFFFF; }

/* Pills */
.am-filter__pill {
  border: 1.5px solid var(--am-border); background: #fff; color: var(--am-text-mid);
  font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 18px;
  border-radius: var(--am-pill-radius); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  flex: 0 0 auto; white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

/* Hover on a NON-selected pill: light tint + navy text — distinct from the
   selected (navy) state, so a just-deselected pill never still looks selected. */
.am-filter__pill:hover:not(.is-active) {
  background: rgba(0, 173, 220, .10); border-color: var(--am-sky); color: var(--am-navy);
}
/* Active (selected) */
.am-filter__pill.is-active {
  background: var(--am-navy); border-color: var(--am-navy); color: #fff;
}
.am-filter__pill.is-active:hover { background: var(--am-navy-hover); border-color: var(--am-navy-hover); }
.am-filter__pill.is-active .am-filter__count { background: rgba(255, 255, 255, .2); color: #fff; }

/* Keep the pill shape identical in every state; give focus a rounded ring
   (some themes force a square UA outline on :focus otherwise). */
.am-filter__pill:focus { outline: none; }
.am-filter__pill:focus-visible {
  outline: 2px solid var(--am-sky); outline-offset: 2px; border-radius: var(--am-pill-radius);
}
.am-filter__count {
  font-size: 11px; font-weight: 700; background: rgba(0, 173, 220, .15); color: var(--am-navy);
  border-radius: 20px; padding: 1px 8px; transition: background .18s ease, color .18s ease;
}

/* Search */
.am-filter__search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.am-filter__search input {
  width: 260px; max-width: 100%; font-family: inherit; font-size: 14px; color: #1a2332;
  border: 1.5px solid var(--am-border); border-radius: var(--am-pill-radius); padding: 11px 16px 11px 42px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.am-filter__search input:focus { border-color: var(--am-sky); box-shadow: 0 0 0 4px rgba(0, 173, 220, .12); }
.am-filter__search input::placeholder { color: #9aa8b8; }

/* No results */
.am-filter__noresults { text-align: center; padding: 28px 0 4px; color: var(--am-text-mid); font-size: 15px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .am-filter__pill, .am-filter__count, .am-filter__search input { transition: none; }
}

/* Mobile: stack the search under the pills, full width, and turn the pills into
   a single horizontal scroller with edge fades that show where more pills are. */
@media (max-width: 640px) {
  .am-filter__inner { flex-direction: column; align-items: stretch; gap: var(--oe-spacing-xsmall); }
  .am-filter__search { width: 100%; }
  .am-filter__search input { width: 100%; }

  .am-filter__pills-wrap { width: 100%; }
  .am-filter__pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;            /* Firefox */
    padding-bottom: 2px;
  }
  .am-filter__pills::-webkit-scrollbar { display: none; }  /* Safari/Chrome */

  /* Edge fades — pinned to the non-scrolling wrapper, toggled by JS. */
  .am-filter__pills-wrap::before,
  .am-filter__pills-wrap::after {
    content: ""; position: absolute; top: 0; bottom: 0; width: 36px;
    pointer-events: none; z-index: 2; opacity: 0; transition: opacity .2s ease;
  }
  .am-filter__pills-wrap::before { left: 0; background: linear-gradient(90deg, #fff 20%, rgba(255, 255, 255, 0)); }
  .am-filter__pills-wrap::after  { right: 0; background: linear-gradient(270deg, #fff 20%, rgba(255, 255, 255, 0)); }
  .am-filter__pills-wrap.can-left::before  { opacity: 1; }
  .am-filter__pills-wrap.can-right::after  { opacity: 1; }
}
