/* Card list sort buttons and the Filter pop-up (app/tfilter.php), like tradelinesupply.com, in our style.
   Computers: a row of 8 buttons and a centred pop-up with every group shown. Phones: 3 buttons per row and a
   full-screen sheet whose groups open and close, with "Clear all filters / Show results" fixed at the bottom. */

.tf-bar { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; padding: 6px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.tf-btn { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; height: 40px; padding: 0 8px; border: 1px solid transparent; border-radius: 9px;
  background: var(--surface-2); color: var(--text-2); font: 600 13px/1.1 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.tf-btn:hover { border-color: var(--gold-line); color: var(--text); }
.tf-btn.on { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.tf-arrow { font-size: 10px; opacity: .75; }
.tf-btn.on .tf-arrow { opacity: 1; }
.tf-filter { background: var(--grad); color: var(--on-gold); border-color: transparent; }
.tf-filter:hover, .tf-filter.on { color: var(--on-gold); border-color: transparent; background: var(--grad); filter: brightness(1.05); }
.tf-n { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; font: 700 11px/1 var(--sans); background: var(--text); color: var(--bg); font-variant-numeric: tabular-nums; }

.tf-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; font-size: 13px; color: var(--text-3); }
.tf-status b { color: var(--text); font-weight: 700; }
.tf-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tf-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.tf-chip span { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); font-size: 13px; line-height: 1; }
.tf-chip:hover { border-color: var(--gold-line); color: var(--text); }
.tf-chip:hover span { background: var(--err-soft); color: var(--err); }
.tf-clear { font-size: 12.5px; font-weight: 600; }

/* ---------- the pop-up ---------- */
.tf-pop { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.tf-pop[hidden] { display: none; }
.tf-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity .2s ease; }
:root[data-theme="light"] .tf-backdrop { background: rgba(30, 36, 12, .32); }
.tf-panel { position: relative; width: min(780px, 100%); max-height: min(88vh, 860px); display: flex; flex-direction: column; overflow: hidden; margin: 0;
  background: var(--surface); border: 1px solid var(--gold-line); border-radius: 18px; box-shadow: 0 40px 90px rgba(0, 0, 0, .55);
  opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .22s ease, transform .28s cubic-bezier(.2, .85, .25, 1); }
:root[data-theme="light"] .tf-panel { background: #fff; box-shadow: 0 40px 90px rgba(30, 40, 8, .22); }
.tf-pop.is-open .tf-backdrop { opacity: 1; }
.tf-pop.is-open .tf-panel { opacity: 1; transform: none; }
.tf-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 22px; background: var(--brand-bg); border-bottom: 1px solid var(--brand-line); }
.tf-head h2 { font: 800 15px/1.2 var(--head); letter-spacing: .12em; text-transform: uppercase; color: var(--brand-text); }
.tf-x { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--brand-line); color: var(--brand-text); }
.tf-x:hover { background: var(--gold-soft); color: var(--gold); }
.tf-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-content: start; }
.tf-sec { border: 1px solid var(--border); border-radius: 12px; padding: 0; min-width: 0; }
.tf-sec summary { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; list-style: none; }
.tf-sec summary::-webkit-details-marker { display: none; }
.tf-sec summary b { font: 700 11.5px/1.3 var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--text); }
.tf-sec-ico { color: var(--text-3); display: grid; }
.tf-caret { margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg) translateY(-2px); transition: transform .2s ease; }
.tf-sec[open] .tf-caret { transform: rotate(-135deg) translateY(-2px); }
.tf-sec[open] summary { border-bottom: 1px solid var(--border); }
.tf-opts { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px 14px; }
.tf-opt { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; color: var(--text-2); cursor: pointer; background: var(--surface); }
.tf-opt:hover { border-color: var(--gold-line); }
.tf-opt input { width: 15px; height: 15px; margin: 0; accent-color: #9AC312; }
.tf-opt:has(input:checked) { border-color: var(--gold-line); background: var(--gold-soft); color: var(--text); }
.tf-text, .tf-range { display: grid; gap: 6px; width: 100%; font-size: 12.5px; color: var(--text-3); }
.tf-text input, .tf-range input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: 500 14px var(--sans); }
.tf-text input:focus, .tf-range input:focus { outline: none; border-color: var(--gold); box-shadow: var(--focus); }
.tf-range > div { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.tf-range i { font-style: normal; }
.tf-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---------- tablets and phones ---------- */
@media (max-width: 980px) {
  .tf-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .tf-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 5px; }
  .tf-btn { height: 36px; font-size: 12px; padding: 0 4px; gap: 4px; }
  .tf-filter { grid-column: span 2; }
  .tf-pop { padding: 0; align-items: stretch; }
  .tf-panel { width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0; transform: translateY(24px); }
  .tf-body { grid-template-columns: 1fr; gap: 0; padding: 0 16px; }
  .tf-sec { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
  .tf-sec summary { padding: 15px 2px; }
  .tf-sec[open] summary { border-bottom: 0; }
  .tf-opts { flex-direction: column; flex-wrap: nowrap; padding: 0 2px 14px; gap: 4px; }
  .tf-opt { border: 0; border-radius: 8px; padding: 8px 4px; background: transparent; font-size: 14.5px; }
  .tf-opt:has(input:checked) { background: var(--gold-soft); }
  .tf-opt input { width: 18px; height: 18px; }
  .tf-foot { justify-content: space-between; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .tf-foot > * { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tf-panel, .tf-backdrop, .tf-caret { transition: none; }
}
