/* ============================================================
   SHARED FILTER BAR  (.br-*)
   Canonical search(+clear) + sort row used by Browse requests
   (proposals/requests.html) and the provider Projects page
   (providers/projects.html). ONE source, per the no-duplication rule.
   Tab strips are NOT here: every page uses .fk-tabs / .fk-tab from
   form-kit.css. This file used to carry a near-identical copy.
   The search field is the form-kit .fk-search (+ .fk-search-clear) and the
   sort wraps a form-kit menu-select (.fk-menu) — both from form-kit.css.
   ============================================================ */

.br-filter-bar { display: grid; gap: 10px; margin-bottom: 18px; }

.br-find-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}
/* The search takes the slack; every control keeps its natural width beside it. */
.br-find-row > .fk-search { flex: 1 1 14rem; min-width: 0; }

/* Sort pill — wraps the shared form-kit menu-select. */
.br-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--color-surface-flat);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  position: relative;
  white-space: nowrap;
  transition: border-color 160ms var(--ease-out);
}
.br-sort:focus-within { border-color: rgba(13, 155, 110, 0.45); }
.br-sort > label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fg-2);
  white-space: nowrap;
}
.br-sort .fk-menu-trigger { font-size: 0.9rem; }
/* No-JS fallback: the bare <select> before form-kit upgrades it. */
.br-sort select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--fg-1);
  padding: 12px 4px;
  cursor: pointer;
  outline: none;
}
/* Compact sort icon (shown only on phones — see the ≤560 rule below). */
.br-sort-ico { display: none; }

/* Phone (<=560px): `.is-compact` collapses the sort to an icon button, for a
   control squeezed beside a search box on a narrow screen.
   OPT-IN, and it did not used to be. Automatic, it fired on any `.br-sort` on a
   phone, including ones with a whole row to themselves -- which renders as an
   empty box with an arrow in it and the chosen order nowhere on screen. That
   caught the directory's filter panel once and needed six lines of CSS to undo;
   this is the same fix made once, at the rule. One page asks for it. */
@media (max-width: 560px) {
  .br-sort.is-compact {
    width: 46px;
    padding: 0;
    justify-content: center;
  }
  .br-sort.is-compact > label { display: none; }
  .br-sort.is-compact .br-sort-ico {
    display: inline-flex;
    color: var(--fg-2);
    font-size: 1.05rem;
    pointer-events: none;
  }
  .br-sort.is-compact .fk-menu { position: absolute; inset: 0; }
  .br-sort.is-compact .fk-menu-trigger { width: 100%; height: 100%; padding: 0; justify-content: center; }
  .br-sort.is-compact .fk-menu-value,
  .br-sort.is-compact .fk-menu-chev { display: none; }
  .br-sort.is-compact select { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; opacity: 0; }
}


/* ============================================================
   SHARED FILTER RAIL / SHEET  (.dir-*)
   Desktop: a sticky sidebar of checkbox groups. Phone (<=980px): the same
   markup becomes an off-canvas sheet opened from .dir-filters-btn.
   Moved here from provider_directory.css so the Directory and Browse
   requests pages share ONE rail instead of two lookalikes. The `dir-`
   prefix is historical -- it is the shared filter prefix now, not a
   directory-only one.
   Behaviour (sheet open/close, clear-group) lives in js/filter-sheet.js;
   both pages must keep the ids it binds to: dir-filters, dir-filters-btn,
   dir-filters-close, dir-filter-scrim.
   ============================================================ */
/* ── Layout ── */
.dir-layout {
  display: grid;
  grid-template-columns: 300px minmax(0,1fr);
  gap: 20px;
  align-items: start;
}

/* ── Filter rail ── */
.dir-filters {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background: white;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 20px;
  padding: 6px var(--space-6) 20px;
  box-shadow: 0 1px 4px rgba(15,23,42,.06);
  box-sizing: border-box;
  min-width: 0;
}
.dir-filters::-webkit-scrollbar { width: 5px; }
.dir-filters::-webkit-scrollbar-thumb { background: rgba(15,23,42,.12); border-radius: 999px; }
.dir-filters::-webkit-scrollbar-track { background: transparent; }

.dir-filters * { box-sizing: border-box; max-width: 100%; }
.dir-filter-group { padding: 16px 0; border-bottom: 1px solid rgba(15,23,42,.07); }
.dir-filter-group:last-child { border-bottom: 0; }
.dir-filter-group > h3 {
  margin: 0 0 12px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-2, #64748b);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dir-filter-group .clear-link {
  color: #0d9b6e;
  font-weight: 700;
  font-size: 0.74rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  background: none;
  border: none;
  padding: 0;
}

/* 44px is the accessible minimum for a finger (WCAG 2.5.8). The row was
   35.6px: 7px of padding either side of a 21.6px line box, with no min-height
   of its own. Raised on the row rather than by growing the padding, so the
   text keeps sitting where it did and only the box grows. */
.dir-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 7px 0;
  font-size: 0.9rem;
  color: var(--fg-1, #0f172a);
  cursor: pointer;
  user-select: none;
}
.dir-check input { accent-color: #0d9b6e; width: 17px; height: 17px; cursor: pointer; flex: 0 0 auto; }
.dir-check:hover { color: #146644; }
.dir-check-count { margin-inline-start: auto; font-size: .8rem; color: var(--fg-3, #64748b); font-weight: 600; }


.dir-filter-reset {
  width: 100%;
  margin-top: 16px;
  padding: 11px;
  border-radius: 11px;
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.08);
  color: var(--fg-2, #64748b);
  font: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  transition: color 150ms, border-color 150ms;
}
.dir-filter-reset:hover { color: #0d9b6e; border-color: rgba(13,155,110,.30); }


/* ── Mobile filter sheet trigger + head (hidden on desktop) ── */
.dir-filters-btn { display: none; }
.dir-sheet-head { display: none; }
.dir-filter-scrim { display: none; }


@media (max-width: 980px) {
  .dir-layout { grid-template-columns: 1fr; }

  .dir-filters-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(15,23,42,.12);
    background: white;
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--fg-1, #0f172a);
    cursor: pointer;
  }
  .dir-filters-btn .cnt {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--green-500, #0d9b6e);
    color: white;
    font-size: 0.72rem;
    font-weight: 800;
    display: grid;
    place-items: center;
  }

  /* The filter rail becomes an off-canvas end-side sheet. */
  .dir-filters {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    z-index: 1100;
    height: 100dvh;
    max-height: none;
    width: min(340px, 88vw);
    margin: 0;
    border-radius: 0;
    border-inline-end: 0;
    transform: translateX(110%);
    /* Hidden once the slide-out ends: parked off-screen only, its filters took Tab focus while closed (as the menu drawer did). */
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  [dir="rtl"] .dir-filters { transform: translateX(-110%); }
  .dir-filters.no-anim { transition: none; }
  .dir-filters.is-open { transform: none; visibility: visible; transition-delay: 0s; }

  .dir-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 0 10px;
    border-bottom: 1px solid rgba(15,23,42,.07);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
  }
  .dir-sheet-x {
    border: 0;
    background: transparent;
    /* 29x37 on its own. Nothing sits within 22px of it, so a near miss costs
       nothing -- but it is still the way out of a sheet. */
    min-width: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 6px;
    font-size: 1.05rem;
    color: var(--fg-2, #64748b);
    cursor: pointer;
  }

  .dir-filter-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(15,23,42,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .dir-filter-scrim.is-open { opacity: 1; pointer-events: auto; }
  body.dir-sheet-lock { overflow: hidden; }
}

/* Range group (min/max pair + apply) — a numeric alternative to a checkbox
   group inside the same rail. */
.dir-range { display: grid; gap: var(--space-2); }
.dir-range-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.9rem;
  color: var(--fg-1, #0f172a);
  /* Grid items default to min-width:auto, so this row refused to shrink below
     the number input's intrinsic width and pushed 23px out of the rail. */
  min-width: 0;
}
.dir-range-field > span { flex: 0 0 3.2rem; color: var(--fg-2, #64748b); font-weight: 700; font-size: 0.82rem; }
.dir-range-field input {
  /* 0 basis, not auto: a number input's intrinsic width is ~20 characters, which
     is wider than the space the rail has to give it. */
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.9rem;
  background: white;
  color: inherit;
}
.dir-range-field input:focus-visible { outline: 2px solid rgba(13,155,110,.45); outline-offset: 1px; }
/* 16px on a touch screen, or iOS zooms the page in on focus (form-kit.css, .input-wrap). */
@media (pointer: coarse) { .dir-range-field input { font-size: 1rem; } }
/* 44px is the accessible minimum for a finger (WCAG 2.5.8). */
.dir-range-go {
  min-height: 44px;
  margin-top: var(--space-1);
  padding: 9px;
  border-radius: 10px;
  border: 1px solid rgba(13,155,110,.30);
  background: rgba(13,155,110,.08);
  color: #0d9b6e;
  font: inherit;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}
.dir-range-go:hover { background: rgba(13,155,110,.14); }

/* Live filtering: the results region is refreshed in place, so it needs a
   loading state of its own — the browser's page-load spinner never appears. */
#filter-results { position: relative; transition: opacity 120ms ease; }
#filter-results.is-loading { opacity: 0.45; pointer-events: none; }
#filter-results.is-loading::after {
  content: "";
  position: absolute;
  inset-block-start: 34px;
  inset-inline-start: 50%;
  width: 26px;
  height: 26px;
  margin-inline-start: -13px;
  border-radius: 999px;
  border: 2px solid rgba(13,155,110,.25);
  border-top-color: #0d9b6e;
  animation: filter-spin 0.7s linear infinite;
}
@keyframes filter-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #filter-results { transition: none; }
  #filter-results.is-loading::after { animation: none; border-top-color: rgba(13,155,110,.25); }
}

/* Phone (<=560px): the filters trigger drops to an icon like the sort beside it,
   so search + filters + sort stay on ONE row at 375px instead of wrapping. The
   count badge stays — it is the only thing that must survive the shrink. */
/* Opt-in icon-only trigger (.is-icon). Sort now lives inside the sheet, so this
   one glyph opens both — there is no second mystery button beside it. The word
   stays in aria-label/title, never dropped outright. */
/* Square, and the height is as load-bearing as the width: `padding: 0`
   removes what was giving this button its size, so without a height it
   collapsed to the glyph's own line box -- 46 wide and 23 tall, half a
   tap target. */
.dir-filters-btn.is-icon { width: 46px; min-height: 46px; padding: 0; position: relative; }
.dir-filters-btn.is-icon .dir-filters-btn-tx { display: none; }
.dir-filters-btn.is-icon .cnt { position: absolute; top: -5px; inset-inline-end: -5px; }


/* Sort inside the rail uses the shared form-kit menu-select (data-fk-menu).
   form-kit styles the trigger transparently and leaves the surrounding pill to
   the host — same contract .br-sort uses in the top bar. */
.dir-filter-group .fk-menu {
  width: 100%;
  position: relative;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 10px;
  background: white;
  transition: border-color 160ms var(--ease-out);
}
.dir-filter-group .fk-menu:focus-within { border-color: rgba(13,155,110,.45); }
.dir-filter-group .fk-menu-trigger {
  width: 100%;
  justify-content: space-between;
  padding: 10px 11px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--fg-1, #0f172a);
}
.dir-filter-group .fk-menu-list { inset-inline: 0; }
.dir-filter-group > h3 > label { cursor: pointer; }

/* Inline validation for the range group — beside the fields it is about, not in
   a page-level banner the provider would have to hunt for. */
.dir-range-err {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: var(--space-2) 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #b3402f;
}
