/* =====================================================
   Janet Rady - Art Filters V2
   Matches site palette: #111 dark, #f6f2eb warm bg
===================================================== */

.jaf {
  margin: 24px 0 18px;
}

/* Topbar */
.jaf__topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.jaf__count {
  white-space: nowrap;
  font-size: 14px;
  color: #555;
}

/* Shared button/input base */
.jaf__mobile-toggle,
.jaf__apply,
.jaf__clear,
.jaf-chip,
.jaf__group-title,
.jaf__sort select,
.jaf__search input,
.jaf__term-search {
  font-family: inherit;
  font-size: 14px;
  color: #111;
  border: 1px solid rgba(0,0,0,.18);
  background: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
  -webkit-appearance: none;
  appearance: none;
}

.jaf__mobile-toggle:hover,
.jaf__group-title:hover {
  border-color: rgba(0,0,0,.35);
  background: #faf8f4;
}

.jaf__search input,
.jaf__term-search {
  border-radius: 12px;
  width: 100%;
}

.jaf__sort select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23111' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

/* Panel */
.jaf__panel {
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 18px;
  padding: 16px;
  background: #fff;
}

.jaf__panel-head { display: none; }

/* Groups grid */
.jaf__groups {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  position: relative;
}

.jaf__group {
  min-width: 0;
  position: relative;
}

.jaf__group-title {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  padding: 10px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dropdown body - overlaps content below, does NOT push layout */
.jaf__group-body {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  z-index: 9000; /* above product badges (z-index 3) and WC elements */
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.10);
  max-height: 320px;
  overflow-y: auto;
  display: none;
}

.jaf__group-body.is-open {
  display: block;
}

/* Last groups open to the right to avoid viewport overflow */
.jaf__group:nth-last-child(-n+3) .jaf__group-body {
  left: auto;
  right: 0;
}

/* Checklist */
.jaf__checklist {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.jaf__checklist li + li {
  margin-top: 8px;
}

.jaf__checklist label,
.jaf__toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #111;
}

.jaf__checklist label:hover,
.jaf__toggles label:hover { color: #555; }

.jaf__checklist em {
  font-style: normal;
  opacity: .55;
  margin-left: auto;
  font-size: 12px;
}

/* Checkboxes */
.jaf__checklist input[type="checkbox"],
.jaf__toggles input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: #111;
  cursor: pointer;
}

/* Toggles */
.jaf__toggles {
  display: grid;
  gap: 10px;
}

.jaf__toggles--inline {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Range sliders */
.jaf__range-slider {
  margin: 16px 8px 12px;
}

.jaf__range-values {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #555;
  margin-top: 4px;
}

.jaf__dim-label {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #888;
  margin: 14px 0 4px;
}
.jaf__dim-label:first-child { margin-top: 0; }

/* jQuery UI slider overrides - larger touch targets */
.ui-slider {
  position: relative;
  height: 4px;
  background: rgba(0,0,0,.12);
  border-radius: 999px;
  border: none;
}

.ui-slider .ui-slider-range {
  position: absolute;
  height: 100%;
  background: #111;
  border-radius: 999px;
}

.ui-slider .ui-slider-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  cursor: grab;
  outline: none;
  /* Larger touch area without changing visual size */
  -webkit-tap-highlight-color: transparent;
}

.ui-slider .ui-slider-handle:active { cursor: grabbing; }

/* Panel actions */
.jaf__panel-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.jaf__apply {
  background: #111;
  color: #fff;
  border-color: #111;
}
.jaf__apply:hover { background: #333; border-color: #333; }

.jaf__clear {
  background: #fff;
  color: #111;
}
.jaf__clear:hover { background: #f5f5f5; }

/* Chips */
.jaf__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.jaf-chip {
  font-size: 13px;
  padding: 6px 12px;
}
.jaf-chip span { margin-left: 4px; opacity: .65; }
.jaf-chip--clear { border-style: dashed; }

/* Pagination */
.jaf-page {
  border: 1px solid rgba(0,0,0,.18);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #111;
  line-height: 1;
  font-family: inherit;
  transition: background .15s ease, border-color .15s ease;
}
.jaf-page:hover { background: #f5f5f5; border-color: rgba(0,0,0,.3); }
.jaf-page.is-active { background: #111; color: #fff; border-color: #111; }
.jaf-page--dots { cursor: default; border-color: transparent; background: transparent; }

.jaf-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  justify-content: center;
  align-items: center;
}

.jaf-pagination__range {
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
}

/* Results */
#art-results-grid { min-height: 200px; }

#art-results-grid.is-loading,
#art-results-pagination.is-loading { opacity: .55; pointer-events: none; }

.jaf__empty { padding: 40px 0; text-align: center; color: #888; font-size: 15px; }

/* Hide native WC pagination */
#art-results-pagination .woocommerce-pagination { display: none; }

#art-results-pagination {
  display: block !important;
  visibility: visible !important;
  min-height: 0;
  overflow: visible !important;
  margin: 10px 0 60px;
  width: 100%;
  clear: both;
}

/* Backdrop (desktop: hidden) */
.jaf__drawer-backdrop { display: none; }

/* =====================================================
   Responsive - tablet
===================================================== */
@media (max-width: 1200px) {
  .jaf__groups { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .jaf__groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* =====================================================
   Responsive - mobile
===================================================== */
@media (max-width: 767px) {

  .jaf__topbar {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .jaf__search { grid-column: 1 / -1; }
  .jaf__count  { text-align: right; font-size: 13px; }

  /* Slide-in drawer */
  .jaf__panel {
    position: fixed;
    top: 0; left: 0;
    width: min(92vw, 380px);
    height: 100vh;
    z-index: 9999;
    border-radius: 0 18px 18px 0;
    transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.19,1,.22,1);
    overflow: hidden; /* panel itself doesn't scroll */
    display: flex;
    flex-direction: column;
    padding: 0;
  }

  body.jaf-drawer-open .jaf__panel {
    transform: translateX(0);
  }

  .jaf__panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(0,0,0,.08);
    flex-shrink: 0;
  }

  .jaf__panel-head h3 { margin: 0; font-size: 16px; }

  .jaf__close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    color: #111;
  }

  /* Scrollable filter groups area */
  .jaf__groups {
    grid-template-columns: 1fr;
    gap: 0;
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    /* Extra bottom padding so last item clears the sticky actions bar */
    padding-bottom: 80px;
  }

  /* On mobile, groups stack - body is NOT absolute, flows normally */
  .jaf__group { position: static; }

  .jaf__group-body {
    position: static;
    display: none;
    box-shadow: none;
    border-radius: 12px;
    margin-top: 6px;
    min-width: 0;
  }

  .jaf__group-body.is-open { display: block; }

  .jaf__group-title {
    border-radius: 12px;
    width: 100%;
    text-align: left;
  }

  /* Sticky actions bar - always visible, clears browser chrome */
  .jaf__panel-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,.08);
    padding: 12px 16px;
    /* Extra padding for phones with bottom browser bars / home indicator */
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 16px));
    margin: 0;
    flex-shrink: 0;
    z-index: 2;
  }

  /* Backdrop */
  .jaf__drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: .24s ease;
    display: block;
  }

  body.jaf-drawer-open .jaf__drawer-backdrop {
    opacity: 1;
    visibility: visible;
  }

  /* Larger slider handles for touch */
  .ui-slider .ui-slider-handle {
    width: 28px;
    height: 28px;
    top: 50%;
  }
}