/* Cut&Bind filters – scoped to the inserted controls only. */
.cb-filter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.cb-filter-heading > :is(h1, h2, h3) { margin-top: 0; margin-bottom: 0; }
.cb-filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 8px;
  padding: 0px 24px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #414143;
  font: inherit;
  font-size: 20px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
}
.cb-filter-toggle:hover, .cb-filter-toggle:focus-visible { background: #262628;  text-decoration: underline; }
.cb-filter-toggle:focus-visible, .cb-filter-pill:focus-visible {
  outline: 2px solid #e44628;
  outline-offset: 3px;
}
.cb-filter-options {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.cb-filter-options[hidden] { display: none !important; }
.cb-filter-row { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.cb-filter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  box-sizing: border-box;
  padding: 0px 12px;
  border-radius: 999px;
  background: #b7b7b7;
  color: #fff !important;
  font: inherit;
  font-size: 20px;
  line-height: 1.3;
  text-decoration: none !important;
  white-space: nowrap;
}
.cb-filter-pill:hover { background: #999; }
.cb-filter-pill.is-active { background: #414143; }
.cb-filter-pill.is-active:hover { background: #262628; }
@media (max-width: 700px) {
  .cb-filter-heading { gap: 12px; }
  .cb-filter-toggle { min-height: 40px; font-size: 16px; padding: 8px 16px; }
  .cb-filter-options { align-items: flex-start; }
  .cb-filter-row { justify-content: flex-start; gap: 8px; }
  .cb-filter-pill { min-height: 40px; font-size: 16px; padding: 8px 16px; }
}

/* The JavaScript measures the real product grid and aligns this row to it. */
.cb-filter-heading,
.cb-filter-options {
  box-sizing: border-box;
  max-width: none !important;
  position: relative;
  left: auto;
  margin-left: 0;
  margin-right: 0;
}
.cb-filter-heading { flex-wrap: nowrap; }
.cb-filter-heading > :is(h1, h2, h3) {
  text-align: left !important;
  margin-inline: 0 !important;
}
@media (max-width: 700px) {
  .cb-filter-heading { flex-wrap: nowrap; }
}

/* Shared grid-aligned container: both rows use exactly the same right edge. */
.cb-filter-wrapper {
  box-sizing: border-box;
  position: relative;
  max-width: none !important;
  min-width: 0;
}
.cb-filter-wrapper .cb-filter-heading,
.cb-filter-wrapper .cb-filter-options {
  box-sizing: border-box;
  width: 100% !important;
  max-width: 100% !important;
  margin-inline: 0 !important;
  transform: none !important;
  left: auto !important;
}
.cb-filter-wrapper .cb-filter-options {
  align-items: flex-end;
}
.cb-filter-wrapper .cb-filter-row {
  max-width: 100%;
  justify-content: flex-end;
  align-items: center;
}
.cb-filter-wrapper .cb-filter-row-label {
  align-self: center;
}
/* Use the site's typeface rather than the plugin's fixed 20px typography. */
.cb-filter-wrapper .cb-filter-toggle,
.cb-filter-wrapper .cb-filter-pill {
  font-family: inherit;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.3;
}
@media (max-width: 700px) {
  .cb-filter-wrapper .cb-filter-toggle,
  .cb-filter-wrapper .cb-filter-pill { font-size: 16px; }
}

/* v1.6: prevent inherited theme centring/max-width from shifting wrapper. */
.cb-filter-wrapper { transform: none !important; box-sizing: border-box; }
.cb-filter-wrapper .cb-filter-heading > :is(h1, h2, h3) { flex: 0 1 auto; }
@media (max-width: 700px) {
  .cb-filter-wrapper .cb-filter-row { flex-wrap: wrap; }
}

/* v1.7 – Cut&Bind supplied SVG icons, 24px source displayed at 18px. */
.cb-filter-wrapper .cb-filter-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.cb-filter-wrapper .cb-filter-icon-filter { background-image: url('./filter.svg'); }
.cb-filter-wrapper .cb-filter-icon-close { background-image: url('./close.svg'); }
.cb-filter-wrapper .cb-filter-icon-tick { background-image: url('./tick.svg'); }
.cb-filter-wrapper .cb-filter-pill { gap: 5px; }
.cb-filter-wrapper .cb-filter-toggle { gap: 6px; }

/* v1.8: plain-text Filter / Close triggers, per latest Cut&Bind mockups. */
.cb-filter-wrapper .cb-filter-toggle,
.cb-filter-wrapper .cb-filter-toggle:hover,
.cb-filter-wrapper .cb-filter-toggle:focus-visible {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: #414143;
}
.cb-filter-wrapper .cb-filter-toggle {
  padding: 6px 0;
  min-height: 40px;
  text-decoration: none;
}
.cb-filter-wrapper .cb-filter-toggle:hover { color: #222224; }
/* Source SVGs are white; render those same shapes using the text colour. */
.cb-filter-wrapper .cb-filter-toggle .cb-filter-icon {
  background-image: none;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.cb-filter-wrapper .cb-filter-toggle .cb-filter-icon-filter {
  -webkit-mask-image: url('./filter.svg');
  mask-image: url('./filter.svg');
}
.cb-filter-wrapper .cb-filter-toggle .cb-filter-icon-close {
  -webkit-mask-image: url('./close.svg');
  mask-image: url('./close.svg');
}

/* v1.9 – Clear All action below the filter rows. */
.cb-filter-wrapper .cb-filter-clear-all {
  display: inline-block;
  align-self: flex-end;
  padding: 2px 0;
  background: transparent;
  color: #414143;
  font-family: inherit;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
.cb-filter-wrapper .cb-filter-clear-all:hover { text-decoration: underline; }
.cb-filter-wrapper .cb-filter-clear-all:focus-visible {
  outline: 2px solid #e44628;
  outline-offset: 3px;
}
@media (max-width: 700px) {
  .cb-filter-wrapper .cb-filter-clear-all { font-size: 16px; align-self: flex-start; }
}
/* Underline Filter and Close on hover */

.cb-filter-wrapper .cb-filter-toggle:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* v1.15: smoothly expand/collapse filters without changing grid alignment. */
.cb-filter-wrapper .cb-filter-options {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  margin-top: 0;
  transform: translateY(-6px) !important;
}
.cb-filter-wrapper .cb-filter-options.is-open {
  max-height: 900px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  margin-top: 12px;
  transform: translateY(0) !important;
}
.cb-filter-wrapper.cb-filter-ready .cb-filter-options {
  transition: max-height 280ms ease, opacity 190ms ease,
              margin-top 280ms ease, transform 280ms ease,
              visibility 280ms;
}
@media (prefers-reduced-motion: reduce) {
  .cb-filter-wrapper.cb-filter-ready .cb-filter-options { transition: none !important; }
}

/* v1.16: no full-page reload while updating WooCommerce product results. */
main.cb-filter-loading .wp-block-query,
main.cb-filter-loading .wc-block-product-template,
main.cb-filter-loading ul.products,
main.cb-filter-loading .woocommerce-no-products-found {
  opacity: 0.48;
  transition: opacity 160ms ease;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  main.cb-filter-loading .wp-block-query,
  main.cb-filter-loading .wc-block-product-template,
  main.cb-filter-loading ul.products { transition: none; }
}
