/* ==========================================================================
   Biblioteca en tablet y móvil (< 1200 px): menú flotante de la home
   --------------------------------------------------------------------------
   El menú (css/nav.css + convivencia con WoodMart) lo trae ThemeCanvas\SharedNav.
   Aquí va lo propio de la biblioteca (body.rw-shop-nav, ver ShopNav.php):
     1. Reparto: header de WoodMart en escritorio, este menú por debajo
     2. Logo RW Library y buscador del menú móvil
     3. Botón de filtros (en el sitio de «Precios»)
     4. Popup de filtros (mismo panel y animación que el menú móvil)
   ========================================================================== */

/* WoodMart imprime el CSS de sus botones dentro del body, después del menú, y a
   igual especificidad gana: su radio sale de esta variable (todos los botones del
   menú y de sus popups son redondos). */
:is(.rw-nav, .mm-panel, .rm-panel, .mnav-panel) { --btn-brd-radius: 999px; }

/* 1. Reparto ---------------------------------------------------------------- */
@media (min-width: 1200px) {
  body.rw-shop-nav :is(.rw-nav, .mm-panel, .rm-panel, #mnav-backdrop, #mnav-panel, .rws-filters, .rws-filters-backdrop) { display: none !important; }
}

@media (max-width: 1199.98px) {
  html body.rw-shop-nav .whb-header { display: none !important; }
  /* El contenido baja lo que ocupa la barra flotante y deja 16 px hasta el primer recurso. */
  html body.rw-shop-nav .main-page-wrapper { padding-top: calc(var(--nav-top, 16px) + var(--nav-h, 62px) + 16px) !important; }
  html body.rw-shop-nav #main-content { padding-top: 0 !important; }
  /* La descripción vacía de la tienda deja 25 px de margen (como en escritorio, fuera). */
  html body.rw-shop-nav .page-description:not(:has(*:not(:empty))) { margin-bottom: 0; }
  html body.rw-shop-nav .page-description > p { margin-block: 0; }
  /* Cabecera del listado: solo la barra de vista, color y orden (ShopNav::mobileTools);
     el menú, los filtros y el recuento están en el menú y en el popup. */
  html body.rw-shop-nav .shop-loop-head { margin: 0 0 14px; }
  html body.rw-shop-nav .shop-loop-head > :not(:has(.rws-mtools)),
  html body.rw-shop-nav .shop-loop-head .wd-shop-tools > :not(.rws-mtools) { display: none !important; }
  html body.rw-shop-nav .shop-loop-head .wd-shop-tools:has(.rws-mtools) { flex: 1 1 100%; width: 100%; }
  html body.rw-shop-nav .shop-loop-head:not(:has(.rws-mtools)) { display: none !important; }
  /* Barra de administración (solo con sesión): el menú baja con ella; el contenido ya
     empieza debajo de la barra (margen del html), así que el hueco sigue siendo de 16 px. */
  body.rw-shop-nav.admin-bar .rw-nav { top: calc(var(--nav-top, 16px) + 32px); }
}
@media (max-width: 782px) {
  body.rw-shop-nav.admin-bar .rw-nav { top: calc(var(--nav-top, 12px) + 46px); }
}

/* Barra de vista, color y orden bajo el menú (tablet y móvil). */
.rws-mtools { display: none; }
@media (max-width: 1199.98px) {
  html body.rw-shop-nav .rws-mtools { display: block; width: 100%; }
  html body.rw-shop-nav .rws-mtools .rw-shop-toolbar { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0; }
  html body.rw-shop-nav .rws-mtools .rw-shop-toolbar__views { flex: 0 0 auto; }
  html body.rw-shop-nav .rws-mtools .rw-shop-toolbar .wd-products-shop-view { display: flex; padding: 0; }
  html body.rw-shop-nav .rws-mtools .rw-shop-color { margin-left: auto; }
  html body.rw-shop-nav .rws-mtools .rw-shop-toolbar__order { flex: 0 0 auto; }
  /* Por debajo de 769 px WoodMart convierte el orden en un icono redondo de 30 px: aquí va la píldora. */
  html body.rw-shop-nav .rws-mtools .woocommerce-ordering.wd-ordering-mb-icon { display: block; width: auto; height: auto; }
  html body.rw-shop-nav .rws-mtools .woocommerce-ordering.wd-ordering-mb-icon::after { content: none; display: none; }
}

/* Móvil: dos vistas, lista y la del móvil (una tarjeta por fila) con su propio icono. Queda la
   cuadrícula elegida (o la de 4, la de por defecto) y se esconde la otra. En tablet, las tres. */
@media (max-width: 768.98px) {
  html body.rw-shop-nav .rws-mtools .shop-view.per-row-2,
  html body.rw-shop-nav .rws-mtools .shop-view.per-row-3:not(.current-variation),
  html body.rw-shop-nav .rws-mtools .wd-products-shop-view:has(.per-row-3.current-variation) .shop-view.per-row-4 { display: none; }
  html body.rw-shop-nav .rws-mtools .shop-view:not(.per-row-list) {
    --rws-view-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='2' y='2.5' width='20' height='8.5' rx='2.2'/%3E%3Crect x='2' y='13' width='20' height='8.5' rx='2.2'/%3E%3C/svg%3E");
  }
}

/* 2. Logo y buscador ------------------------------------------------------------ */
/* RW Library: 232×55, el símbolo ocupa ≈ 31 px de ancho a 55 px de alto */
.rw-nav-logo:has(img[src*="rw-library-logo"]) { --logo-h: 30px; --logo-w: 127px; --logo-mark-w: 17px; --logo-mark-h: 30px; }
@media (max-width: 560px) { .rw-nav-logo:has(img[src*="rw-library-logo"]) { --logo-h: 26px; --logo-w: 110px; } }

.rws-ico { display: block; flex: none; width: 20px; height: 20px; }

.mnav-panel .rws-search { position: relative; display: flex; align-items: center; width: 100%; height: 48px; border-radius: 999px; background: var(--nav-soft); color: var(--nav-ink); }
.mnav-panel .rws-search .rws-ico { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--nav-muted); pointer-events: none; }
.mnav-panel .rws-search input[type="search"] {
  box-sizing: border-box; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0 16px 0 44px;
  border: 0; border-radius: inherit; background: transparent; box-shadow: none;
  color: var(--nav-ink); font: 450 15px/1 "Geist", "Inter", ui-sans-serif, system-ui, sans-serif; letter-spacing: -0.01em;
  -webkit-appearance: none; appearance: none;
}
.mnav-panel .rws-search input[type="search"]::placeholder { color: var(--nav-muted); opacity: 1; }
.mnav-panel .rws-search input[type="search"]:focus { outline: none; }
.mnav-panel .rws-search:focus-within { box-shadow: inset 0 0 0 1px var(--nav-line-2); }

/* 3. Botón de filtros --------------------------------------------------------------- */
/* Círculo del mismo color que el botón de menú; un punto avisa de filtros activos. */
.rw-nav .burger-only .rws-filter-pill { position: relative; width: 44px; padding: 0; justify-content: center; }
.rw-nav .rws-filter-pill .rws-ico { width: 20px; height: 20px; }
.rws-filter-dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--nav-accent); box-shadow: 0 0 0 2px var(--nav-ink); }
.rws-filter-dot[hidden] { display: none; }
/* nav.css esconde «Precios» por debajo de 400 px: los filtros se quedan. */
@media (max-width: 399.98px) { .rw-nav .burger-only .rws-filter-pill { display: inline-flex; } }

/* 4. Popup de filtros ---------------------------------------------------------------- */
.rws-filters { padding: 8px 16px 0; scrollbar-width: none; }
.rws-filters::-webkit-scrollbar { display: none; }
.rws-filters[hidden], .rws-filters-backdrop[hidden] { display: none; }

.rws-f-head { position: sticky; top: -8px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -16px; padding: 14px 16px 10px 24px; background: var(--nav-panel); }
.rws-f-title { font-size: 18px; font-weight: 600; line-height: 1.2; letter-spacing: -0.03em; color: var(--nav-ink); }
.rws-filters .rws-f-close { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; background: var(--nav-soft); color: var(--nav-ink); transition: background-color 0.18s ease-out; }
.rws-filters .rws-f-close:hover { background: var(--nav-soft-2); color: var(--nav-ink); }
.rws-f-close .rws-ico { width: 18px; height: 18px; }

.rws-f-sec { padding: 16px 8px; border-top: 1px solid var(--nav-line); }
.rws-f-head + .rws-f-sec { border-top: 0; padding-top: 6px; }
.rws-filters .rws-f-label { margin: 0 0 12px; font-size: 13px; font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; color: var(--nav-muted); }
.rws-f-sec--row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.rws-filters .rws-f-sec--row .rws-f-label { margin: 0; }

.rws-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rws-filters .rws-chip {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 15px; border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--nav-line-2); color: var(--nav-ink); text-decoration: none;
  font-size: 14px; font-weight: 500; letter-spacing: -0.02em; line-height: 1; white-space: nowrap;
  transition: background-color 0.18s ease-out, color 0.18s ease-out;
}
.rws-filters .rws-chip:hover { background: var(--nav-soft); color: var(--nav-ink); }
.rws-filters .rws-chip.is-active { background: var(--nav-ink); color: var(--nav-on-ink); box-shadow: none; }

.rws-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rws-swatch { position: relative; display: block; width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(20, 20, 20, 0.12); transition: transform 0.18s ease-out; cursor: pointer; }
.rws-swatch:hover { transform: scale(1.08); }
.rws-swatch.is-active { box-shadow: inset 0 0 0 1px rgba(20, 20, 20, 0.12), 0 0 0 2px var(--nav-panel), 0 0 0 4px var(--nav-ink); }
.rws-swatch--custom { overflow: hidden; background: conic-gradient(#ff3b30, #ffcc00, #34c759, #00c7be, #007aff, #af52de, #ff2d55, #ff3b30); }
.rws-swatch--custom input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.rws-filters .rws-swatch-clear { margin-left: 4px; font-size: 13px; font-weight: 500; color: var(--nav-muted); text-decoration: underline; text-underline-offset: 3px; }

.rws-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--nav-soft); }
.rws-filters .rws-seg__btn { display: grid; place-items: center; width: 40px; height: 34px; border-radius: 999px; color: var(--nav-muted); transition: background-color 0.18s ease-out, color 0.18s ease-out; }
.rws-seg__btn .rws-ico { width: 18px; height: 18px; }
.rws-filters .rws-seg__btn:hover { color: var(--nav-ink); }
.rws-filters .rws-seg__btn.is-active { background: var(--nav-panel); color: var(--nav-ink); box-shadow: 0 0 0 1px var(--nav-line); }

/* Pie fijo con las dos acciones, como los botones del menú móvil */
.rws-f-foot { position: sticky; bottom: 0; z-index: 2; margin: 0 -16px; padding: 12px 16px 16px; background: var(--nav-panel); border-top: 1px solid var(--nav-line); }
.rws-filters .rws-f-foot :is(a, button) { flex: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 0; padding: 16px 12px; border-radius: 48px; font-size: 14px; font-weight: 500; line-height: 1.2; text-align: center; text-decoration: none; white-space: nowrap; }
.rws-filters .rws-f-foot .is-ink { background: var(--nav-soft); color: var(--nav-ink); }
.rws-filters .rws-f-foot .is-ink:hover { background: var(--nav-soft-2); color: var(--nav-ink); }
.rws-filters .rws-f-foot .is-accent { background: var(--nav-accent); color: #fff; }
.rws-filters .rws-f-foot .is-accent:hover { background: var(--nav-accent-hover); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .rws-filters .rws-chip, .rws-swatch, .rws-filters .rws-seg__btn { transition: none !important; }
}
