/* Advanced shop filter: {child-theme}/assets/css/shop-filter.css */

/* Layout: sidebar + results */
.crk-shop {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  width: 100%;
}
.crk-main { min-width: 0; }
.crk-filter-toggle, .crk-overlay, .crk-sidebar__close { display: none; }

/* Three cards per row next to the sidebar */
.crk-shop .crk-shop-results ul.products { grid-template-columns: repeat(3, 1fr); }

/* Sidebar */
.crk-sidebar {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 18px;
  background: #fff8ec;
  border: 1px solid #f1e3cf;
  border-radius: 14px;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: #f5c9a0 #fff3e0;
}

/* Chrome, Edge, Safari */
.crk-sidebar::-webkit-scrollbar {
  width: 8px;
}

.crk-sidebar::-webkit-scrollbar-track {
  background: #fff3e0;
  border-radius: 10px;
  margin: 10px 0;
}

.crk-sidebar::-webkit-scrollbar-thumb {
  background: #f5c9a0;
  border-radius: 10px;
  border: 2px solid #fff3e0;
}

.crk-sidebar::-webkit-scrollbar-thumb:hover {
  background: #f0a96b;
}

.crk-sidebar__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 18px; }
.crk-clear {
  padding: 0;
  border: 0;
  background: none;
  color: #d62828;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.crk-clear:hover { text-decoration: underline; }

.crk-block { padding: 14px 0; border-top: 1px solid #f1e3cf; }
.crk-block:first-child { border-top: 0; }
.crk-block__title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6b6b6b;
}

.crk-search, .crk-block select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #f1e3cf;
  border-radius: 8px;
  background: #fff;
}

/* Category tree */
.crk-cats { margin: 0; padding: 0; list-style: none; }
.crk-cats__children { display: none; margin: 2px 0 4px 22px; padding-left: 10px; border-left: 2px solid #f1e3cf; }
.crk-cat.is-open > .crk-cats__children { display: block; }
.crk-cat__row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.crk-check {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 5px 0;
  font-weight: 500;
  cursor: pointer;
}
.crk-check input { width: 16px; height: 16px; margin: 0; accent-color: #d62828; flex: none; }
.crk-cat__name { flex: 1; color: #2b2b2b; }
.crk-cat__count {
  padding: 1px 8px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid #f1e3cf;
  font-style: normal;
  font-size: 12px;
  color: #6b6b6b;
}
.crk-cat__toggle {
  position: relative;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.crk-cat__toggle::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 9px;
  width: 7px;
  height: 7px;
  border-right: 2px solid #d62828;
  border-bottom: 2px solid #d62828;
  transform: rotate(45deg);
  transition: transform .2s ease;
}
.crk-cat.is-open > .crk-cat__row .crk-cat__toggle::before { transform: rotate(-135deg); top: 11px; }
.crk-cat__toggle:hover { background: #ffe9c7; }

/* Price slider */
.crk-range { --lo: 0%; --hi: 100%; }
.crk-range__track {
  position: relative;
  height: 22px;
  margin-bottom: 10px;
}
.crk-range__track::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, #f1e3cf var(--lo), #d62828 var(--lo), #d62828 var(--hi), #f1e3cf var(--hi));
}
.crk-range__track input[type=range] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 22px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.crk-range__track input[type=range]::-webkit-slider-runnable-track { background: transparent; }
.crk-range__track input[type=range]::-moz-range-track { background: transparent; }
.crk-range__track input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #d62828;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  cursor: pointer;
  pointer-events: auto;
}
.crk-range__track input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid #d62828;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  pointer-events: auto;
}
.crk-price-row { display: flex; align-items: center; gap: 8px; }
.crk-price-row label { display: flex; flex: 1; align-items: center; gap: 4px; margin: 0; }
.crk-price-row input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  border: 1px solid #f1e3cf;
  border-radius: 8px;
  background: #fff;
}

/* "Show results" is only needed without JavaScript (and as "Done" on mobile) */
.crk-filter__actions { padding-top: 6px; }
.crk-filter__apply {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: #d62828;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.crk-filter__apply:hover { background: #f77f00; }
.crk-shop.crk-js .crk-filter__actions { display: none; }

/* Toolbar: count + chips */
.crk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; min-height: 34px; }
.crk-count { margin-right: 6px; color: #6b6b6b; font-size: 14px; }
.crk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #d62828;
  border-radius: 30px;
  background: #fff;
  color: #d62828;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.crk-chip b { font-size: 16px; line-height: 1; }
.crk-chip:hover { background: #d62828; color: #fff; }

/* Results loading + load more */
.crk-shop-results { transition: opacity .2s ease; }
.crk-shop-results.is-loading { opacity: .35; pointer-events: none; }
.crk-loadmore {
  display: block;
  margin: 26px auto 0;
  padding: 12px 34px;
  border: 2px solid #d62828;
  border-radius: 30px;
  background: #fff;
  color: #d62828;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
}
.crk-loadmore:hover:not(:disabled) { background: #d62828; color: #fff; }
.crk-loadmore:disabled { opacity: .6; cursor: wait; }

/* Tablet and mobile: sidebar becomes a slide-in drawer */
@media (max-width: 991px) {
  .crk-shop { display: block; }
  .crk-shop .crk-shop-results ul.products { grid-template-columns: repeat(3, 1fr); }

  .crk-filter-toggle {
    display: block;
    width: 100%;
    margin: 0 0 14px;
    padding: 11px 16px;
    border: 1px solid #f1e3cf;
    border-radius: 10px;
    background: #fff8ec;
    color: #d62828;
    font-weight: 700;
    cursor: pointer;
  }
  .crk-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease;
  }
  .crk-overlay.is-open { opacity: 1; visibility: visible; }

  .crk-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    width: min(340px, 88vw);
    height: 100%;
    max-height: none;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform .28s ease;
  }
  .crk-sidebar.is-open { transform: translateX(0); }
  .crk-sidebar__close {
    display: block;
    padding: 0 6px;
    border: 0;
    background: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }
  .crk-sidebar__head { gap: 10px; }
  .crk-sidebar__head strong { flex: 1; }
  .crk-shop.crk-js .crk-filter__actions { display: block; }
  body.crk-drawer-open { overflow: hidden; }
}

@media (max-width: 767px) {
  .crk-shop .crk-shop-results ul.products { grid-template-columns: repeat(2, 1fr); }
}