/*
 * .filter-bar — tabs with counts + search + dropdowns of a listing
 * (template-parts/global/filter-bar.php).
 * Figma: /customer-success 337:14198, hub 337:11819, Articles 337:11432;
 * M 337:13942, 337:11604, 337:12907.
 *
 * Phones: tabs scroll sideways, controls take the full width below.
 * Desktop: tabs on the left, controls (271 px each) on the right.
 */

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;

  /* @media (width >= 64.0625em) .filter-bar — 20 px between tabs and controls (Webinars 18:28183;
     Articles 18:29762 fades the tabs out 26 px before the search) */
  @media (width >= 64.0625em) {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
  }
}

/* .filter-bar__tabs — takes all the room the controls leave (they keep their width) and
   scrolls sideways when the tabs do not fit */
.filter-bar__tabs {
  display: flex;
  flex: 0 1 100%;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-color: var(--nv-blue) transparent;
  scrollbar-width: thin;
}

/* .filter-bar__tabs--draggable — the row overflows, a mouse can drag it (set by filter-bar.js) */
.filter-bar__tabs--draggable {
  cursor: grab;
}

/* .filter-bar__tabs--dragging — while dragging: no text selection, the grab cursor over the tabs too */
.filter-bar__tabs--dragging {
  cursor: grabbing;
  user-select: none;

  /* .filter-bar__tabs--dragging .filter-bar__tab */
  & .filter-bar__tab {
    cursor: grabbing;
  }
}

/* .filter-bar__tabs--more — more tabs behind the right edge (set by listing.js) */
.filter-bar__tabs--more {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 3.75rem), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 3.75rem), transparent);
}

/* .filter-bar__tab */
/* .filter-bar__tab[hidden] — tabs with no posts get `hidden` from PHP/JS; index.css
   sets display on `a`, which would otherwise override the browser's [hidden] rule. */
.filter-bar__tab[hidden] {
  display: none;
}

.filter-bar__tab {
  flex-shrink: 0;
  border-radius: 6.25rem;
  padding: calc(1.25rem - 0.14em) 1.25rem;
  background-color: rgba(204, 219, 232, 0.15);
  color: var(--nv-blue);
  font-weight: 500;
  font-size: clamp(1rem, 0.9111rem + 0.3792vw, 1.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.3s ease, color 0.3s ease;

  /* .filter-bar__tab:focus-visible */
  &:focus-visible {
    outline: 0.125rem solid var(--nv-green);
    outline-offset: -0.125rem;
  }

  /* @media (width >= 48em) .filter-bar__tab — 20 → 15 px sides */
  @media (width >= 48em) {
    padding-inline: 0.9375rem;
  }
}

/* .listing--cloud .filter-bar__tab — white pills on the grey-blue band (/customer-success, Figma 18:34468) */
.listing--cloud .filter-bar__tab {
  background-color: var(--nv-white);
}

/* .filter-bar__tab--active — large navy pill: 30 px around the cap height (72 → 77 px) */
.filter-bar__tab--active {
  padding: calc(1.875rem - 0.14em) 1.875rem;
  background: linear-gradient(90deg, var(--nv-navy) 0%, var(--nv-blue) 100%);
  color: var(--nv-white);
  font-size: clamp(1rem, 0.8223rem + 0.7583vw, 1.5rem);

  /* @media (width >= 48em) .filter-bar__tab--active — 30 → 20 px sides */
  @media (width >= 48em) {
    padding-inline: 1.25rem;
  }
}

/* .page-id-423 .filter-bar__tab — Webinars only: the phone sides (20 / 30 px) on desktop too (Figma 1574:11327) */
.page-id-423 .filter-bar__tab {
  /* @media (width >= 48em) .page-id-423 .filter-bar__tab */
  @media (width >= 48em) {
    padding-inline: 1.25rem;

    /* .page-id-423 .filter-bar__tab--active */
    &.filter-bar__tab--active {
      padding-inline: 1.875rem;
    }
  }
}

/* .filter-bar__count — the number stays readable as part of the link text */
.filter-bar__count {
  white-space: nowrap;
}

/* .filter-bar__controls — search and dropdowns */
.filter-bar__controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;

  /* @media (width >= 48em) .filter-bar__controls */
  @media (width >= 48em) {
    flex-direction: row;
    flex-shrink: 0;
  }
}

/* .filter-bar__label — visible to screen readers only */
.filter-bar__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* .filter-bar__search, .filter-bar__select — 271 × 77 boxes (M: full width × 64) */
.filter-bar__search,
.filter-bar__select {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--nv-blue);

  /* @media (width >= 48em) .filter-bar__search, .filter-bar__select */
  @media (width >= 48em) {
    width: 16.9375rem;
  }
}

/* .filter-bar__search--narrow — search next to two dropdowns: 210 px (Webinars 18:28183) */
.filter-bar__search--narrow {
  /* @media (width >= 48em) .filter-bar__search--narrow */
  @media (width >= 48em) {
    width: 13.125rem;
  }
}

/* .filter-bar__controls > .filter-bar__search:only-of-type — a lone search is one card column wide
   (Figma 397:38745) */
.filter-bar__controls > .filter-bar__search:only-of-type {
  @media (width >= 48em) {
    width: 28.375rem;
  }
}

/* .filter-bar__controls > .filter-bar__select:only-of-type — a lone dropdown (Customer Stories,
   Case Studies): 270 px (Figma 397:38796 has 271; Pavlo, 2026-10-19) */
.filter-bar__controls > .filter-bar__select:only-of-type {
  @media (width >= 48em) {
    width: 16.875rem;
  }
}

/* .filter-bar__input, .filter-bar__field */
.filter-bar__input,
.filter-bar__field {
  width: 100%;
  height: 4rem;
  border: 0.125rem solid #f6f7f9;
  border-radius: 0.625rem;
  padding: 0 1.25rem;
  background-color: var(--nv-white);
  color: var(--nv-blue);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: -0.02em;
  transition: border-color 0.3s ease;

  /* .filter-bar__input:focus-visible — blue border for the keyboard only: a click marks the
     field with data-pointer-focus (listing.js) and leaves the Figma click state */
  &:focus-visible:not([data-pointer-focus]) {
    border-color: var(--nv-blue);
  }

  /* .filter-bar__input:focus */
  &:focus {
    outline: none;
  }

  /* @media (width >= 48em) .filter-bar__input, .filter-bar__field */
  @media (width >= 48em) {
    height: 4.8125rem;
    padding: 0 1.875rem;
  }
}

/* .filter-bar__input — room for the icon on the left: 20 + 24 + 20 px on phones, 30 + 24 + 10 px from 768 px;
   the same on the right for the clear button. Click / typing: mist fill, faint placeholder (397:37098, 397:37087) */
.filter-bar__input {
  padding-inline: 4rem;
  transition: border-color 0.3s ease, background-color 0.3s ease;

  &::placeholder {
    color: var(--nv-blue);
    opacity: 1;
  }

  &::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
  }

  /* .filter-bar__input:focus */
  &:focus {
    background-color: var(--nv-mist);

    &::placeholder {
      opacity: 0.3;
    }
  }
}

/* .filter-bar__clear — 44 px tap target around the 24 px icon, 20 / 30 px from the right edge;
   shown while the field is focused (50 % when empty) or filled */
.filter-bar__clear {
  position: absolute;
  right: 0.625rem;
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  color: inherit;

  /* @media (width >= 48em) .filter-bar__clear */
  @media (width >= 48em) {
    right: 1.25rem;
  }

  /* .filter-bar__clear:focus-visible */
  &:focus-visible {
    border-radius: var(--nv-radius-s);
    outline: 0.125rem solid var(--nv-blue);
  }
}

/* .filter-bar__search:focus-within .filter-bar__clear, .filter-bar__input:not(:placeholder-shown) ~ .filter-bar__clear */
.filter-bar__search:focus-within .filter-bar__clear,
.filter-bar__input:not(:placeholder-shown) ~ .filter-bar__clear {
  display: flex;
}

/* .filter-bar__input:placeholder-shown ~ .filter-bar__clear — empty field: faded */
.filter-bar__input:placeholder-shown ~ .filter-bar__clear {
  opacity: 0.5;
}

/* .filter-bar__search-icon */
.filter-bar__search-icon {
  position: absolute;
  left: 1.25rem;
  width: 1.5rem;
  height: 1.5rem;
  pointer-events: none;

  /* @media (width >= 48em) .filter-bar__search-icon */
  @media (width >= 48em) {
    left: 1.875rem;
  }
}

/* .filter-bar__field — native select without the system arrow */
.filter-bar__field {
  padding-right: 3.75rem;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

/* .filter-bar__chevron */
.filter-bar__chevron {
  position: absolute;
  right: 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  pointer-events: none;
  transition: transform 0.3s ease;

  /* @media (width >= 48em) .filter-bar__chevron */
  @media (width >= 48em) {
    right: 1.875rem;
  }
}

/* .filter-bar__combo — styled dropdown that listing.js puts over the hidden <select>
   (Figma 397:37065 default, 397:37057 hover, 397:38816 / 397:38830 open) */
.filter-bar__combo {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

/* .filter-bar__value — a long term ends with "…" instead of being cut mid-word */
.filter-bar__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

/* .filter-bar__select--open — mist box, value at 50 %, arrow up */
.filter-bar__select--open {
  /* .filter-bar__select--open .filter-bar__combo */
  & .filter-bar__combo {
    background-color: var(--nv-mist);
  }

  /* .filter-bar__select--open .filter-bar__value */
  & .filter-bar__value {
    opacity: 0.5;
  }

  /* .filter-bar__select--open .filter-bar__chevron */
  & .filter-bar__chevron {
    transform: rotate(180deg);
  }
}

/* .filter-bar__options — list right under the box: 20 px to the first cap, 15 px around each 1 px line */
.filter-bar__options {
  position: absolute;
  z-index: 10;
  top: 100%;
  right: 0;
  left: 0;
  max-height: 25rem;
  margin: 0;
  border: 1px solid #f6f7f9;
  border-radius: 0.625rem;
  padding: 0.1875rem 1.25rem 1.1875rem;
  overflow-y: auto;
  background-color: var(--nv-mist);
  list-style: none;

  /* @media (width >= 48em) .filter-bar__options — 30 px sides, as the box */
  @media (width >= 48em) {
    padding-inline: 1.875rem;
  }
}

/* .filter-bar__option — 20 px at 70 %, line at 10 %; cap top / baseline 15 px from the lines */
.filter-bar__option {
  border-bottom: 1px solid rgba(33, 91, 135, 0.1);
  padding: calc(0.9375rem - 0.14em) 0;
  color: rgba(33, 91, 135, 0.7);
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;

  /* .filter-bar__option[hidden] — the current value is not listed */
  &[hidden] {
    display: none;
  }
}

/* .filter-bar__option--active — hovered or keyboard-active option at full colour */
.filter-bar__option--active {
  border-bottom-color: var(--nv-blue);
  color: var(--nv-blue);
}

/* .filter-bar__apply — only without JS (<noscript>) */
.filter-bar__apply {
  height: 4rem;
  border-radius: 0.625rem;
  padding: 0 1.875rem;
  background-color: var(--nv-green);
  color: var(--nv-navy);
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
  cursor: pointer;

  /* @media (width >= 48em) .filter-bar__apply */
  @media (width >= 48em) {
    height: 4.8125rem;
  }
}

/* @media (hover: hover) .filter-bar__tab:hover */
@media (hover: hover) and (pointer: fine) {
  .filter-bar__tab:not(.filter-bar__tab--active):hover {
    background-color: rgba(204, 219, 232, 0.45);
  }

  /* .filter-bar__input:hover — mist fill, the border stays (Figma 397:37084) */
  .filter-bar__input:hover {
    background-color: var(--nv-mist);
  }

  .filter-bar__field:hover {
    border-color: var(--nv-steel);
  }

  /* .filter-bar__combo:hover — mist fill, the border stays (Figma 397:37057) */
  .filter-bar__combo:hover {
    border-color: #f6f7f9;
    background-color: var(--nv-mist);
  }
}

/* @media (prefers-reduced-motion: reduce) .filter-bar */
@media (prefers-reduced-motion: reduce) {
  .filter-bar__tab,
  .filter-bar__input,
  .filter-bar__field,
  .filter-bar__chevron,
  .filter-bar__value,
  .filter-bar__option {
    transition: none;
  }
}
