/* ============================================================================
   Lash Market — catalogue facet filters.
   Design tokens come from the theme (assets/css/main.css :root); nothing here
   hard-codes a colour. Breakpoints reuse the theme's ladder (900 / 720 / 520 /
   420) and are max-width, like the rest of the project.
   ========================================================================== */

/* ---- Layout -------------------------------------------------------------- */
.lm-catalog-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  column-gap: clamp(1.5rem, 3vw, 2.5rem);
  row-gap: 1.25rem;
  align-items: start;
  grid-template-areas:
    "bar     bar"
    "filters main";
}
.lm-catalog-bar { grid-area: bar; }
.lm-filters { grid-area: filters; }
.lm-catalog-main { grid-area: main; min-width: 0; }

/* The theme asserts a 4-column grid at `.woocommerce ul.products` with
   !important; with a sidebar in the way we need three, at higher specificity. */
body.woocommerce .lm-catalog-main ul.products,
body.woocommerce-page .lm-catalog-main ul.products {
  grid-template-columns: repeat(3, 1fr) !important;
}
@media (max-width: 1100px) {
  body.woocommerce .lm-catalog-main ul.products,
  body.woocommerce-page .lm-catalog-main ul.products {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 420px) {
  body.woocommerce .lm-catalog-main ul.products,
  body.woocommerce-page .lm-catalog-main ul.products {
    grid-template-columns: 1fr 1fr !important;
    gap: .75rem !important;
  }
}

.lm-catalog-main .shop__title { font-size: clamp(2rem, 1.4rem + 2.2vw, 3.2rem); }
.lm-catalog-results { position: relative; min-height: 120px; transition: opacity .2s var(--ease); }
.lm-catalog-results[aria-busy="true"] { opacity: .45; pointer-events: none; }
.lm-catalog-results[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset-inline-start: 50%;
  inset-block-start: 2.5rem;
  width: 34px; height: 34px;
  margin-inline-start: -17px;
  border: 3px solid var(--line);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: lm-spin .8s linear infinite;
}
@keyframes lm-spin { to { transform: rotate(360deg); } }

/* ---- Toolbar (mobile trigger + sorting) ---------------------------------- */
.lm-catalog-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  margin-bottom: .5rem;
}
.lm-filters-toggle {
  display: none;
  align-items: center;
  gap: .55rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .6rem 1.1rem;
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.lm-filters-toggle:hover { border-color: var(--red); color: var(--red-deep); }
.lm-filters-toggle__icon {
  width: 16px; height: 12px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 16px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 5px / 11px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 10px / 6px 2px no-repeat;
}
.lm-filters-toggle__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  font-size: .74rem;
  font-weight: 800;
}

.lm-sort { display: flex; align-items: center; gap: .55rem; margin: 0; }
.lm-sort__label { font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lm-sort__select,
.lm-sort__apply {
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .5rem .8rem;
  cursor: pointer;
}
.lm-sort__select:hover { border-color: var(--red); }

/* ---- Sidebar ------------------------------------------------------------- */
.lm-filters__backdrop { display: none; }
.lm-filters__panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--shadow);
}
.lm-filters__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .35rem; }
.lm-filters__title { font-family: var(--font-display); font-size: 1.35rem; margin: 0; }
.lm-filters__close {
  display: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink);
  background: none;
  border: 0;
  padding: .25rem .4rem;
  cursor: pointer;
}
.lm-filters__form { margin: 0; }

.lm-facet { padding-block: 1.1rem; border-top: 1px solid var(--line); }
.lm-facet:first-child { border-top: 0; padding-top: .6rem; }
.lm-facet__title {
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .7rem;
}
.lm-facet__unit { text-transform: none; letter-spacing: 0; }
.lm-facet__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .12rem; }
.lm-facet__list--depth-1,
.lm-facet__list--depth-2 { margin-inline-start: .95rem; padding-inline-start: .55rem; border-inline-start: 1px solid var(--line); }
.lm-facet__list--extra { margin-top: .12rem; }
.lm-facet__more { margin-top: .4rem; }
.lm-facet__more-toggle {
  cursor: pointer;
  font-size: .86rem;
  font-weight: 700;
  color: var(--red-deep);
  padding: .35rem 0;
  list-style: none;
}
.lm-facet__more-toggle::-webkit-details-marker { display: none; }
.lm-facet__more-toggle::before { content: "+ "; font-weight: 800; }
.lm-facet__more[open] > .lm-facet__more-toggle::before { content: "– "; }
.lm-facet__more-toggle:hover { color: var(--red); }

/* ---- Checkbox rows ------------------------------------------------------- */
.lm-check {
  position: relative; /* anchors the visually hidden input; without it the 1px
                         input escapes to a distant positioned ancestor. */
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .34rem .4rem;
  margin-inline: -.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color .18s var(--ease);
}
.lm-check:hover { background: var(--cream); }
.lm-check__input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.lm-check__box {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: var(--white);
  position: relative;
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.lm-check__box::after {
  content: "";
  position: absolute;
  inset-inline-start: 5px;
  inset-block-start: 1px;
  width: 5px; height: 10px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(.4);
  opacity: 0;
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
.lm-check__input:checked + .lm-check__box { background: var(--red); border-color: var(--red); }
.lm-check__input:checked + .lm-check__box::after { opacity: 1; transform: rotate(45deg) scale(1); }
.lm-check__input:focus-visible + .lm-check__box { outline: 3px solid var(--red); outline-offset: 3px; }
.lm-check__label { flex: 1 1 auto; font-size: .95rem; line-height: 1.35; }
.lm-check__input:checked ~ .lm-check__label { font-weight: 700; }
.lm-check__count { flex: 0 0 auto; font-size: .8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lm-check--empty { opacity: .42; cursor: not-allowed; }
.lm-check--empty:hover { background: transparent; }

/* ---- Price --------------------------------------------------------------- */
.lm-price__slider { position: relative; height: 30px; margin: .2rem .3rem .5rem; }
.lm-price__track {
  position: absolute;
  inset-block-start: 13px;
  inset-inline: 0;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  display: block;
}
.lm-price__fill { position: absolute; inset-block: 0; left: 0; width: 100%; background: var(--red); border-radius: 999px; display: block; }
.lm-price__range {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  width: 100%;
  height: 30px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.lm-price__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--red);
  box-shadow: 0 2px 6px rgba(26, 25, 23, .25);
  cursor: pointer;
}
.lm-price__range::-moz-range-thumb {
  pointer-events: auto;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--red);
  cursor: pointer;
}
.lm-price__range::-moz-range-track { background: none; border: 0; }
.lm-price__fields { display: flex; align-items: center; gap: .5rem; }
.lm-price__field { flex: 1 1 0; display: block; min-width: 0; }
.lm-price__dash { color: var(--muted); }
.lm-price__input {
  width: 100%;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.lm-price__input:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-color: var(--red); }

/* ---- Actions ------------------------------------------------------------- */
.lm-filters__actions { display: flex; align-items: center; gap: .9rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
/* The catalogue tiles the theme prints above the loop are a browse entry point;
   once a facet narrows the list they only push the results below the fold. */
body.lm-catalog-filtered .lm-catalog-main .cat-tiles { display: none; }
.lm-filters__apply {
  flex: 1 1 auto;
  font: inherit;
  font-weight: 700;
  color: var(--white);
  background: var(--red);
  border: 0;
  border-radius: 999px;
  padding: .7rem 1.2rem;
  cursor: pointer;
  transition: background-color .2s var(--ease);
}
.lm-filters__apply:hover { background: var(--red-deep); }
.lm-filters__reset { flex: 0 0 auto; white-space: nowrap; font-size: .9rem; font-weight: 700; color: var(--muted); }
.lm-filters__reset:hover { color: var(--red); }

/* ---- Result bar and chips ------------------------------------------------ */
.lm-resultbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem 1rem;
  margin-bottom: 1.1rem;
}
.lm-resultbar__count { margin: 0; font-size: .9rem; font-weight: 700; color: var(--muted); }
.lm-chips { list-style: none; display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; }
.lm-chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .84rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .32rem .7rem .32rem .8rem;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.lm-chip:hover { border-color: var(--red); color: var(--red-deep); }
.lm-chip__x { font-size: 1.05rem; line-height: 1; color: var(--muted); }
.lm-chip:hover .lm-chip__x { color: var(--red); }
.lm-chip--reset { background: var(--ink); border-color: var(--ink); color: var(--white); }
.lm-chip--reset:hover { background: var(--red); border-color: var(--red); color: var(--white); }

.lm-catalog-empty { margin-block: 1rem 2rem; }
.lm-catalog-error {
  margin-block: 1rem;
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  border-inline-start: 4px solid var(--red);
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
}

/* ---- Mobile: the sidebar becomes a drawer -------------------------------- */
@media (max-width: 900px) {
  .lm-catalog-layout { display: block; }
  .lm-catalog-bar { justify-content: space-between; }
  .lm-filters-toggle { display: inline-flex; }

  .lm-filters {
    position: fixed;
    inset: 0;
    z-index: 1000;
    visibility: hidden;
  }
  .lm-filters.is-open { visibility: visible; }
  .lm-filters__backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(26, 25, 23, .55);
    opacity: 0;
    transition: opacity .25s var(--ease);
  }
  /* An author `display: block` beats the UA sheet's `[hidden] { display: none }`,
     which would leave the script's `backdrop.hidden` toggle doing nothing. */
  .lm-filters__backdrop[hidden] { display: none; }
  .lm-filters.is-open .lm-filters__backdrop { opacity: 1; }
  .lm-filters__panel {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(360px, 88vw);
    max-height: 100%;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    padding: 1.25rem 1.15rem 2rem;
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
    -webkit-overflow-scrolling: touch;
  }
  .lm-filters.is-open .lm-filters__panel { transform: translateX(0); }
  /* Keep the title and the close button reachable however far the facet list
     has been scrolled — the drawer is taller than the viewport by design. */
  .lm-filters__head {
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
    background: var(--white);
    margin-inline: -1.15rem;
    padding: .9rem 1.15rem .6rem;
    border-bottom: 1px solid var(--line);
  }
  .lm-filters__close { display: block; }
  .lm-filters__actions {
    position: sticky;
    inset-block-end: -2rem;
    background: var(--white);
    padding-block: 1rem;
    margin-block-end: -2rem;
  }
  body.lm-filters-open { overflow: hidden; }
}

@media (max-width: 520px) {
  .lm-sort__label { display: none; }
  .lm-resultbar { gap: .5rem .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lm-filters__panel,
  .lm-filters__backdrop,
  .lm-catalog-results { transition: none; }
  .lm-catalog-results[aria-busy="true"]::after { animation: none; }
}
