/* ═══════════════════════════════════════════════════════════════════════════
   EXPLORE / SEARCH — Search bar, filters, bottom sheets, archive grid
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Archive search area ── */
.kx-archive-search {
  padding: 0 var(--kx-page-padding);
  margin-bottom: 16px;
}

/* ── Search Bar (functional, in archive) ── */
.kx-search-bar--archive {
  display: flex;
  align-items: center;
  height: 48px;
  border-radius: var(--kx-radius-input);
  background-color: var(--kx-input-bg);
  padding: 0 16px;
  gap: 10px;
  position: relative;
  border: 1px solid transparent;
  transition: border-color 200ms ease, background-color 200ms ease;
}

.kx-search-bar--archive:focus-within {
  border-color: #D4CABB;
  background-color: var(--kx-surface);
}

.kx-search-bar__input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--kx-font-body);
  font-size: var(--kx-fs-body);
  color: var(--kx-text-primary);
  outline: none;
  min-width: 0;
}

.kx-search-bar__input::placeholder {
  color: var(--kx-text-hint);
}

.kx-search-bar__clear {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--kx-text-hint);
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Search Suggestions Dropdown ── */
.kx-search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background-color: var(--kx-surface);
  border-radius: var(--kx-radius-input);
  box-shadow: var(--kx-shadow-2);
  z-index: 100;
  max-height: 360px;
  overflow-y: auto;
}

.kx-search-suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--kx-text-primary);
  border-bottom: 1px solid var(--kx-border);
  transition: background-color 100ms ease;
}

.kx-search-suggestion:last-child {
  border-bottom: none;
}

.kx-search-suggestion:hover,
.kx-search-suggestion:active {
  background-color: var(--kx-bg);
  text-decoration: none;
  color: var(--kx-text-primary);
}

.kx-search-suggestion__img {
  width: 40px;
  height: 53px;
  border-radius: 4px;
  object-fit: cover;
  background-color: var(--kx-image-placeholder);
  flex-shrink: 0;
}

.kx-search-suggestion__info {
  flex: 1;
  min-width: 0;
}

.kx-search-suggestion__title {
  font-size: var(--kx-fs-body);
  font-weight: 600;
  color: var(--kx-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kx-search-suggestion__author {
  font-size: var(--kx-fs-caption);
  color: var(--kx-text-secondary);
}

.kx-search-suggestion__price {
  font-size: var(--kx-fs-label);
  font-weight: 700;
  color: var(--kx-accent);
  white-space: nowrap;
}

/* ── Filter Chips ── */
.kx-filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px var(--kx-page-padding) 0;
  scrollbar-width: none;
}

.kx-filter-chips::-webkit-scrollbar {
  display: none;
}

.kx-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--kx-radius-pill);
  border: 1px solid var(--kx-border);
  background-color: transparent;
  font-family: var(--kx-font-body);
  font-size: var(--kx-fs-label);
  color: var(--kx-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.kx-filter-chip:hover {
  border-color: var(--kx-accent);
  color: var(--kx-accent);
}

.kx-filter-chip--active {
  background-color: var(--kx-accent);
  border-color: var(--kx-accent);
  color: #FFFFFF;
}

/* ── Bottom Sheet (mobile filters) ── */
.kx-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background-color: var(--kx-surface);
  border-radius: var(--kx-radius-sheet) var(--kx-radius-sheet) 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 1001;
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
}

.kx-bottom-sheet--open {
  transform: translateY(0);
}

.kx-bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  opacity: 0;
  transition: opacity 250ms ease;
  pointer-events: none;
}

.kx-bottom-sheet-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

.kx-bottom-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.kx-bottom-sheet__header h3 {
  font-family: var(--kx-font-display);
  font-size: var(--kx-fs-heading);
  font-weight: 600;
  margin: 0;
}

.kx-bottom-sheet__close {
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--kx-text-hint);
  cursor: pointer;
}

.kx-filter-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--kx-border);
  font-family: var(--kx-font-body);
  font-size: var(--kx-fs-title);
  color: var(--kx-text-primary);
  cursor: pointer;
}

.kx-filter-option:last-of-type {
  border-bottom: none;
}

.kx-filter-option input[type="radio"] {
  accent-color: var(--kx-accent);
  width: 18px;
  height: 18px;
}

.kx-bottom-sheet__apply {
  width: 100%;
  margin-top: 16px;
}

/* ── Override WC product grid on archive ── */
.woocommerce ul.products,
.woocommerce-page ul.products {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: var(--kx-card-gap) !important;
  padding: 0 var(--kx-page-padding) !important;
  list-style: none !important;
  margin: 0 !important;
}

.woocommerce ul.products li.product {
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
}

/* Hide default WC loop elements — our custom card replaces them */
.woocommerce ul.products li.product > a:not(.kx-book-card__link),
.woocommerce ul.products li.product > .price,
.woocommerce ul.products li.product > .star-rating,
.woocommerce ul.products li.product > .button,
.woocommerce ul.products li.product > h2,
.woocommerce ul.products li.product > img {
  display: none !important;
}

@media (min-width: 768px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (min-width: 1024px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* Desktop: filters as sidebar */
  .kx-bottom-sheet {
    display: none !important;
  }

  .kx-bottom-sheet-overlay {
    display: none !important;
  }
}

@media (min-width: 1200px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products {
    grid-template-columns: repeat(5, 1fr) !important;
    max-width: var(--kx-content-max-width);
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* ── WC result count + ordering ── */
.woocommerce-result-count {
  font-family: var(--kx-font-body);
  font-size: var(--kx-fs-label);
  color: var(--kx-text-secondary);
}

.woocommerce-ordering select {
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-radius-input);
  padding: 8px 12px;
  font-family: var(--kx-font-body);
  font-size: var(--kx-fs-label);
  background-color: var(--kx-surface);
}
