/*
 * Filtros, ordem e paginação das grades de coleção e busca (template-parts/snippets/rp-cl-facets.php).
 * Visual do tema publicado (botões em pílula, gaveta lateral no computador e por baixo no celular), com CSS próprio.
 */

/* Botões (a base fica em assets/css/rp-cl-base.css) */
.rp-cl-section .button .icon-md { width: 22px; height: 22px; flex: none; }
.rp-cl-section .button .icon-sm { width: 20px; height: 20px; flex: none; }
/* Ícone e texto dos botões de filtro: 12px de espaço, como no tema publicado. */
.rp-cl-facets .button .btn-text { gap: 12px; }
.rp-cl-facets .icon { stroke-width: 1.2px; }
.rp-cl-section .facet-wrapper > .button { height: clamp(56px, 3vw, 60px); min-height: 0; }
.rp-cl-section .w-full { width: 100%; }
.facet-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}
.button--secondary .facet-count { background: #000; color: #fff; }
.facet-count[hidden] { display: none; }

/* Barra acima da grade */
.collection__topbar { --topbar-pad: 20px; position: relative; z-index: 10; margin: calc(var(--topbar-pad) * -1) calc(var(--rp-cl-gutter) * -1) 0; padding: var(--topbar-pad) 0; }
.facet-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 0 var(--rp-cl-gutter); }
.facet-wrapper, .facet-sorting { display: none; }
.facet-count-text { flex-grow: 1; margin: 0; font-size: 12px; line-height: 1.6; }
@media (min-width: 1024px) { .facet-count-text { font-size: 14px; } }
@media (min-width: 1280px) {
  /* Faixa fixa no topo: espaço de clamp(20px, 1.473vw, 28px) e a grade começa clamp(16px, 2.947vw, 56px) abaixo. */
  .collection__topbar { --topbar-pad: clamp(20px, 1.473vw, 28px); position: sticky; top: 0; margin-bottom: calc(var(--topbar-pad) * -1); background: #fff; }
  .rp-cl-section .collection__content { margin-top: clamp(16px, 2.947vw, 56px); }
  .facet-wrapper { display: block; }
  .facet-sorting { display: inline-flex; align-items: center; gap: 24px; margin-left: auto; font-size: 12px; }
}
/* "Sort by:" do computador. Fechado: botão com a ordem atual e um ponto, da largura do texto (mínimo de 180px, como o
   tema publicado faz por JavaScript). Aberto: painel preto de 320px por cima do botão, com "SORT BY", fechar e a lista. */
.sort-wrapper {
  --sort-pad: clamp(26px, 1.473vw, 30px);
  position: relative;
  min-width: 180px;
  height: clamp(56px, 3.263vw, 60px);
}
.rp-cl-section .sort-by { width: 100%; height: 100%; min-height: 0; padding: 18px calc(var(--sort-pad) + 2px); letter-spacing: -.06px; }
.sort-header { display: flex; align-items: center; justify-content: center; gap: 20px; width: 100%; }
.sort-selection { white-space: nowrap; }
.sort-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sort-panel {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 3;
  width: 320px;
  padding: 18px var(--sort-pad) 26px;
  border-radius: 32px;
  background: #000;
  color: #fff;
  letter-spacing: -.06px;
}
.sort-panel[hidden] { display: none; }
.sort-panel__header { position: relative; display: flex; align-items: flex-start; justify-content: space-between; height: 40px; }
.sort-title { margin-top: 12px; font-size: 12px; font-weight: 500; line-height: 1.6; letter-spacing: .1em; text-transform: uppercase; opacity: .4; }
.sort-close { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: #fff; color: #000; cursor: pointer; }
.sort-close svg { width: 20px; height: 20px; }
.sort-listbox { display: grid; gap: 8px; width: calc(100% - 4px); margin: 24px 0 0; padding: 0; list-style: none; }
.sort-listbox li { position: relative; }
.sort-listbox label { display: inline-block; font-size: 16px; font-weight: 500; line-height: 1.6; white-space: nowrap; cursor: pointer; }
.sort-listbox input:checked + label { opacity: .4; pointer-events: none; }
.sort-listbox input:checked + label::before { content: ""; position: absolute; top: 50%; right: 0; width: 6px; height: 6px; border-radius: 50%; background: currentColor; transform: translateY(-50%); }
.sort-listbox input:focus-visible + label { outline: 2px solid #fff; outline-offset: 2px; }

/* Filtros ativos */
.active-facets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 28px; }
/* Sem filtro ativo a faixa some (no tema publicado ela fica vazia e com display: none). */
.active-facets:not(:has(> *)) { display: none; }
@media (min-width: 1280px) { .active-facets { margin-bottom: 0; margin-top: clamp(16px, 1.684vw, 32px); } }
.active-facets__button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 60px;
  background: rgba(0, 0, 0, .05);
  font-size: 12px;
  color: inherit;
  text-decoration: none;
}
.active-facets__button svg { width: 16px; height: 16px; }
.active-facets__clear { font-size: 12px; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* Botão fixo "Filter and sort" (celular e tablet) */
.facet-sticky {
  position: fixed;
  z-index: 25;
  left: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 100%;
  text-align: center;
  pointer-events: none;
}
.facet-sticky .button { pointer-events: auto; min-height: 56px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
@media (min-width: 1280px) { .facet-sticky { display: none; } }

/* Gaveta */
.facet-drawer { position: fixed; inset: 0; z-index: 30; }
.facet-drawer[hidden] { display: none; }
.facet-drawer__overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .3); opacity: 0; transition: opacity .3s ease; }
.facet-drawer .drawer__inner {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
  background: #fff;
  color: #000;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22, .61, .36, 1);
}
.facet-drawer.is-open .facet-drawer__overlay { opacity: 1; }
.facet-drawer.is-open .drawer__inner { transform: none; }
@media (min-width: 768px) {
  .facet-drawer .drawer__inner { top: 0; bottom: 0; width: min(480px, 100vw); max-height: none; border-radius: 0 20px 20px 0; transform: translateX(-100%); }
}
.drawer__header { display: flex; align-items: center; justify-content: space-between; padding: 32px 20px 24px; border-bottom: 1px solid rgba(0, 0, 0, .06); }
.drawer__title { font-size: 20px; font-weight: 500; line-height: 1; letter-spacing: -.025em; }
@media (min-width: 1024px) { .drawer__title { font-size: 30px; } .drawer__header { padding: 40px 32px 28px; } }
.rp-cl-section .button--close { width: 48px; min-height: 48px; height: 48px; padding: 0; }
.drawer__content { flex: 1 1 auto; overflow-y: auto; padding: 24px 20px 0; overscroll-behavior: contain; }
@media (min-width: 1024px) { .drawer__content { padding: 24px 32px 0; } }
.drawer__sticky { padding: 24px 20px; background: #fff; }
@media (min-width: 1024px) { .drawer__sticky { padding: 24px 32px 32px; } }
.drawer__sticky .results-count { margin-left: 4px; }
html.rp-cl-lock { overflow: hidden; }

.facet-form { display: grid; }
.facet-form .details { display: block; padding: 0; border-bottom: 1px solid rgba(0, 0, 0, .06); }
.facet-form .details__summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 24px 0; list-style: none; cursor: pointer; }
.facet-form .details__summary::-webkit-details-marker { display: none; }
.facet-form .details__summary svg { width: 12px; height: 12px; transition: transform .25s ease; }
.facet-form details[open] > .details__summary svg { transform: rotate(180deg); }
.facet-form .details__label { font-size: 16px; font-weight: 500; cursor: pointer; }
@media (min-width: 1024px) { .facet-form .details__label { font-size: 18px; } }
.facet-form .details__content { padding: 0 0 28px; }
.facet-form .select-sort-by { padding-bottom: 24px; }

/* Campos com rótulo flutuante */
.facet-form .field { position: relative; display: flex; align-items: center; flex-grow: 1; }
.facet-form .select {
  width: 100%;
  height: 62px;
  padding: 16px 46px 0 26px;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, .024);
  font: inherit;
  font-size: 12px;
  color: #000;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.facet-form .select + svg { position: absolute; right: 22px; top: 50%; width: 12px; height: 12px; margin-top: -6px; pointer-events: none; }
.facet-form .label.is-floating { position: absolute; top: 12px; left: 26px; font-size: 10px; color: rgba(0, 0, 0, .55); pointer-events: none; }
.facet-form .switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, .1);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background-color .2s ease;
}
.facet-form .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .2s ease;
}
.facet-form .switch:checked { background: #000; }
.facet-form .switch:checked::after { transform: translateX(18px); }
.facet-form .switch:focus-visible { outline: 2px solid #000; outline-offset: 2px; }

/* Faixa de preço */
.price-range { display: grid; gap: 32px; }
.range-wrapper { position: relative; height: 20px; }
.range-wrapper::before, .range-wrapper::after { content: ""; position: absolute; top: 8px; height: 4px; border-radius: 4px; }
.range-wrapper::before { left: 0; right: 0; background: rgba(0, 0, 0, .1); }
.range-wrapper::after { left: var(--range-min, 0%); right: calc(100% - var(--range-max, 100%)); background: #000; }
.price-range .range {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 20px;
  margin: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
}
.price-range .range::-webkit-slider-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #000; box-shadow: 0 0 0 4px #fff inset; appearance: none; -webkit-appearance: none; pointer-events: auto; cursor: grab; }
.price-range .range::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #000; box-shadow: 0 0 0 4px #fff inset; pointer-events: auto; cursor: grab; }
.price-range .range::-webkit-slider-runnable-track { background: none; }
.price-range .range::-moz-range-track { background: none; }
.input-wrapper { display: flex; align-items: center; gap: 24px; font-size: 12px; }
.input-wrapper .prefix { position: absolute; left: 20px; font-size: 12px; }
.input-wrapper .input {
  width: 100%;
  padding: 16px 20px 16px 32px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, .024);
  font: inherit;
  font-size: 12px;
  color: #000;
  -moz-appearance: textfield;
}
.input-wrapper .input::-webkit-outer-spin-button, .input-wrapper .input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

/* Grade carregando */
[data-rp-cl-results] { transition: opacity .2s ease; }
[data-rp-cl-results].is-loading { opacity: .45; pointer-events: none; }

/* Paginação: 40px no celular e 48px com 8px de espaço a partir de 768px, letra de 12px (medidas da loja publicada). */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0; align-self: center; font-size: 12px; line-height: 1.6; }
@media (min-width: 768px) { .pagination { gap: 8px; } }
.pagination .page {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: rgb(23, 23, 23);
  text-decoration: none;
  transition: background-color .2s ease, color .2s ease;
}
@media (min-width: 768px) { .pagination .page { width: 48px; height: 48px; } }
.pagination .page.current { background: rgb(23, 23, 23); color: #fff; pointer-events: none; }
.pagination .next, .pagination .previous { display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0; font-weight: 500; color: rgb(23, 23, 23); text-decoration: none; }
@media (min-width: 768px) { .pagination .next, .pagination .previous { height: 48px; } }
.pagination .icon-sm { width: 20px; height: 20px; stroke-width: 1px; }
