/* Botefumeiro Shop Nav — archive & shop landing (v1.3.4 responsive) */

:root {
  --btfm-accent: #508c25;
  --btfm-tile-bg: #508c25;
  --btfm-tile-icon: clamp(72px, 22vw, 84px);
  --btfm-tile-min: clamp(72px, 22vw, 84px);
  --btfm-tile-img-pad: clamp(5px, 1.5vw, 8px);
  --btfm-tile-gap: 10px;
  --btfm-grid-max: 1200px;
  --btfm-grid-pad-x: max(12px, env(safe-area-inset-left, 0px));
  --btfm-grid-pad-y: 16px;
  --btfm-nav-products-gap: 1.25rem;
}

/* ── Prevent horizontal page scroll ── */

body.woocommerce-shop:has(.btfm-archive-subcats),
body.tax-product_cat:has(.btfm-archive-subcats),
body.btfm-sibling-nav {
  overflow-x: clip;
}

body.woocommerce-shop,
body.tax-product_cat {
  background: #fff;
}

.btfm-shop-breadcrumbs {
  max-width: min(var(--btfm-grid-max), calc(100vw - 2.5rem));
  margin: 0 auto 1.25rem;
  padding: 1.25rem max(20px, env(safe-area-inset-right, 0px)) 0
    max(20px, env(safe-area-inset-left, 0px));
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #888;
}

.btfm-shop-breadcrumbs a {
  color: var(--btfm-accent);
  text-decoration: none;
}

.btfm-shop-breadcrumbs a:hover {
  text-decoration: underline;
}

.btfm-breadcrumb-sep {
  margin: 0 0.45rem;
  color: #ccc;
}

/* ── Category tile grid ── */

.btfm-archive-subcats,
.btfm-shop-nav {
  max-width: min(var(--btfm-grid-max), calc(100vw - 2.5rem));
  margin: 0 auto 2rem;
  padding: var(--btfm-grid-pad-y) var(--btfm-grid-pad-x) 48px;
  padding-left: max(var(--btfm-grid-pad-x), env(safe-area-inset-left, 0px));
  padding-right: max(var(--btfm-grid-pad-x), env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  width: 100%;
}

.btfm-archive-subcats__label {
  display: none !important;
}

.btfm-archive-subcats__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: var(--btfm-tile-gap);
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.btfm-archive-subcats__card {
  flex: 0 0 var(--btfm-tile-icon);
  width: var(--btfm-tile-icon);
  max-width: var(--btfm-tile-icon);
  min-height: var(--btfm-tile-icon);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid #e6ece1;
  border-radius: 10px;
  padding: clamp(4px, 1vw, 6px);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btfm-archive-subcats__card:hover {
  box-shadow: 0 4px 14px rgba(80, 140, 37, 0.13);
  border-color: #c8dbb8;
  transform: translateY(-1px);
}

.btfm-archive-subcats__card.is-current {
  border-color: var(--btfm-accent);
  box-shadow: 0 0 0 2px rgba(80, 140, 37, 0.28);
  transform: none;
  cursor: default;
}

.btfm-archive-subcats__card.is-current:hover {
  transform: none;
  box-shadow: 0 0 0 2px rgba(80, 140, 37, 0.28);
}

.btfm-archive-subcats__tile {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--btfm-tile-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  box-sizing: border-box;
  padding: var(--btfm-tile-img-pad);
}

.btfm-archive-subcats__tile img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  opacity: 1;
  visibility: visible;
  -webkit-backface-visibility: visible;
  backface-visibility: visible;
  transform: none;
}

.btfm-archive-subcats__card .btfm-archive-subcats__tile,
.btfm-archive-subcats__card .btfm-archive-subcats__tile img,
.btfm-archive-subcats__card:hover .btfm-archive-subcats__tile img,
.btfm-archive-subcats__card:focus .btfm-archive-subcats__tile img,
.btfm-archive-subcats__card:focus-visible .btfm-archive-subcats__tile img,
.btfm-archive-subcats__card.is-current .btfm-archive-subcats__tile img {
  opacity: 1 !important;
  visibility: visible !important;
  object-fit: contain !important;
}

.btfm-archive-subcats__tile--ph {
  font-family: "Roboto Slab", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1rem, 4vw, 1.4rem);
  color: #fff;
}

/* ── Hide ALL tile labels (plugin + theme + legacy) ── */

.btfm-archive-subcats__label,
.btfm-archive-subcats__name,
.btfm-subcategory-nav__label,
.btfm-sub-card--tile .btfm-sub-card__title,
.shop_categories_wrapper,
.shop_categories_wrapper *,
.shop_categories_list,
.shop_categories_list *,
.shop_categories_list_overlay,
.shop-page-category-description .shop_categories_wrapper,
.shop_categories_wrapper .category_name,
.shop_categories_list .category_name,
.shop_categories_wrapper h3,
.shop_categories_list h3,
.shop_categories_wrapper a span:not(:empty),
body.tax-product_cat .shop_categories_wrapper .woocommerce-loop-category__title,
body.tax-product_cat ul.products li.product-category .woocommerce-loop-category__title,
body.tax-product_cat ul.products li.product-category h2,
body.tax-product_cat ul.products li.product-category h3 {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  font-size: 0 !important;
  line-height: 0 !important;
}

body.btfm-hide-tile-labels .btfm-archive-subcats__card,
.btfm-archive-subcats__card {
  min-height: var(--btfm-tile-icon);
}

body.btfm-show-tile-labels .btfm-archive-subcats__name {
  display: block;
}

/* ── Hide theme defaults when plugin shows subcategory hub ── */

body.btfm-has-subcats .woocommerce-result-count,
body.btfm-has-subcats .woocommerce-ordering,
body.btfm-has-subcats ul.products li.product-category,
body.btfm-has-subcats nav.woocommerce-pagination,
body.btfm-has-subcats .shop-tools,
body.btfm-has-subcats .woocommerce-products-header__title,
body.btfm-has-subcats .page-title,
body.btfm-has-subcats .term-description > ul.products,
body.btfm-has-subcats .term-description .product-categories,
body.btfm-has-subcats .woocommerce-product-categories,
body.tax-product_cat:has(.btfm-archive-subcats) .woocommerce-result-count,
body.tax-product_cat:has(.btfm-archive-subcats) .woocommerce-ordering,
body.tax-product_cat:has(.btfm-archive-subcats) ul.products li.product-category,
body.tax-product_cat:has(.btfm-archive-subcats) nav.woocommerce-pagination,
body.tax-product_cat:has(.btfm-archive-subcats) .shop-tools,
body.woocommerce-shop:has(.btfm-archive-subcats) .woocommerce-result-count,
body.woocommerce-shop:has(.btfm-archive-subcats) .woocommerce-ordering,
body.woocommerce-shop:has(.btfm-archive-subcats) ul.products li.product-category {
  display: none !important;
}

body.btfm-hide-hub-products ul.products,
body.btfm-hide-hub-products .getbowtied_ajax_load_more_loader,
body.btfm-hide-hub-products nav.woocommerce-pagination,
body.btfm-hide-hub-products .shop-tools,
body.btfm-has-subcategories ul.products,
body.btfm-has-subcategories .getbowtied_ajax_load_more_loader {
  display: none !important;
}

body.btfm-hub-with-products ul.products,
body.btfm-hub-with-products .getbowtied_ajax_load_more_loader,
body.tax-product_cat.btfm-hub-with-products ul.products,
body.tax-product_cat.btfm-hub-with-products .getbowtied_ajax_load_more_loader,
body.tax-product_cat:has(.btfm-archive-subcats).btfm-hub-with-products ul.products,
body.tax-product_cat:has(.btfm-archive-subcats).btfm-hub-with-products .getbowtied_ajax_load_more_loader {
  display: block !important;
  visibility: visible !important;
}

body.tax-product_cat .shop-page-category-description:has(.btfm-archive-subcats) {
  margin-bottom: 0;
}

/* ── Gap between nav tiles and products grid ── */

body.btfm-sibling-nav ul.products,
body.btfm-hub-with-products ul.products,
body.tax-product_cat:has(.btfm-archive-subcats) ul.products,
body.woocommerce-shop:has(.btfm-archive-subcats) ul.products {
  margin-top: var(--btfm-nav-products-gap) !important;
  padding-top: 0.25rem;
  clear: both;
}

/* ── Sibling nav on leaf category pages ── */

body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: #fff;
  margin-bottom: 0.75rem;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) 14px
    max(12px, env(safe-area-inset-left, 0px));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav .btfm-archive-subcats__grid {
  flex-wrap: nowrap;
  justify-content: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 12px;
  scrollbar-width: thin;
  padding-bottom: 6px;
  margin: 0 auto;
  max-width: 100%;
}

body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav .btfm-archive-subcats__grid::before,
body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav .btfm-archive-subcats__grid::after {
  content: "";
  margin: auto;
  flex-shrink: 0;
}

body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav::before,
body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(16px, 4vw, 28px);
  pointer-events: none;
  z-index: 1;
}

body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav::before {
  left: 0;
  background: linear-gradient(to right, #fff 30%, transparent);
}

body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav::after {
  right: 0;
  background: linear-gradient(to left, #fff 30%, transparent);
}

body.btfm-sibling-nav .btfm-archive-subcats__card {
  scroll-snap-align: center;
  flex-shrink: 0;
}

body.btfm-sibling-nav ul.products,
body.btfm-sibling-nav .getbowtied_ajax_load_more_loader,
body.btfm-sibling-nav .woocommerce-result-count,
body.btfm-sibling-nav .woocommerce-ordering {
  display: block !important;
  visibility: visible !important;
}

/* ── Hide legacy shop categories wrapper ── */

.shop_categories_wrapper,
.shop_categories_list,
.shop_categories_list_overlay,
.shop-page-category-description .shop_categories_wrapper {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none !important;
}

body.btfm-all-catalog .btfm-shop-nav,
body.btfm-all-catalog .btfm-archive-subcats,
body.btfm-all-catalog .btfm-subcategory-nav,
body.btfm-all-catalog .term-description ul.products,
body.tax-product_cat.term-botefumeiro .term-description ul.products {
  display: none !important;
}

/* ══════════════════════════════════════════════════════════
   BREAKPOINTS
   Mobile:  320–480px  → 2–3 tiles/row, touch scroll sibling nav
   Tablet:  481–1024px → 4–5 tiles/row, centered grid
   Desktop: 1025px+    → auto-fill centered, max-width container
   ══════════════════════════════════════════════════════════ */

/* Mobile (320–480px) */
@media (max-width: 480px) {
  :root {
    --btfm-tile-icon: clamp(72px, 21vw, 84px);
    --btfm-tile-gap: 10px;
    --btfm-grid-pad-x: max(10px, env(safe-area-inset-left, 0px));
    --btfm-grid-pad-y: 12px;
    --btfm-nav-products-gap: 1rem;
  }

  .btfm-archive-subcats,
  .btfm-shop-nav {
    padding-bottom: 28px;
    margin-bottom: 1.25rem;
  }

  .btfm-archive-subcats__grid {
    gap: 10px;
    justify-content: center;
  }

  body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav {
    padding-top: 8px;
    padding-bottom: 12px;
  }

  body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav .btfm-archive-subcats__grid {
    gap: 8px;
    scroll-snap-type: x mandatory;
  }

  .btfm-archive-subcats__card.is-current {
    box-shadow: 0 0 0 3px rgba(80, 140, 37, 0.32);
  }
}

/* Extra-small phones (320–380px) */
@media (max-width: 380px) {
  :root {
    --btfm-tile-icon: clamp(68px, 20vw, 76px);
    --btfm-tile-gap: 8px;
  }
}

/* Tablet (481–1024px) */
@media (min-width: 481px) and (max-width: 1024px) {
  :root {
    --btfm-tile-icon: clamp(80px, 11vw, 88px);
    --btfm-tile-gap: 12px;
    --btfm-grid-pad-x: max(16px, env(safe-area-inset-left, 0px));
    --btfm-grid-pad-y: 20px;
    --btfm-nav-products-gap: 1.5rem;
  }

  .btfm-archive-subcats,
  .btfm-shop-nav {
    padding-bottom: 36px;
  }

  .btfm-archive-subcats__grid {
    gap: 12px;
    justify-content: center;
  }
}

/* Desktop (1025px+) */
@media (min-width: 1025px) {
  :root {
    --btfm-tile-icon: clamp(84px, 6.5vw, 96px);
    --btfm-tile-gap: 14px;
    --btfm-grid-pad-x: 1.25rem;
    --btfm-grid-pad-y: 24px;
    --btfm-nav-products-gap: 1.75rem;
  }

  .btfm-archive-subcats,
  .btfm-shop-nav {
    padding-bottom: 48px;
  }

  .btfm-archive-subcats__grid {
    gap: 14px;
    justify-content: center;
  }

  body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav::before,
  body.btfm-sibling-nav .btfm-archive-subcats.btfm-sibling-nav::after {
    width: 20px;
  }
}

/* ── Merchandiser infinite scroll — Spanish labels ── */

.getbowtied_ajax_load_more_loader {
  clear: both;
  display: block;
  padding: 2.5rem 1rem 3rem !important;
  text-align: center;
}

.getbowtied_ajax_load_more_loader > div {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-height: 46px;
  padding: 0.7rem 1.35rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(80, 140, 37, 0.1), rgba(80, 140, 37, 0.04));
  border: 1px solid rgba(80, 140, 37, 0.18);
  box-shadow: 0 8px 24px rgba(80, 140, 37, 0.08);
  color: #508c25;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.getbowtied_ajax_load_more_loader .shop_ajax_load_more,
.getbowtied_ajax_load_more_loader .blog_ajax_load_more {
  display: inline-block;
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 0;
  vertical-align: middle;
}

.getbowtied_ajax_load_more_loader .shop_ajax_load_more:before,
.getbowtied_ajax_load_more_loader .blog_ajax_load_more:before {
  background-color: #508c25 !important;
  -webkit-animation: spinLoader 0.9s linear infinite;
  animation: spinLoader 0.9s linear infinite;
}

.getbowtied_ajax_load_more_loader > div > span:last-child {
  font-size: 0 !important;
  line-height: 1 !important;
  color: transparent !important;
}

.getbowtied_ajax_load_more_loader > div > span:last-child::after {
  content: "Más productos" !important;
  font-size: 0.9rem;
  color: #508c25;
  letter-spacing: 0.02em;
}

.getbowtied_ajax_load_more_loader .shop_ajax_load_more.disabled + span::after,
.getbowtied_ajax_load_more_loader .blog_ajax_load_more.disabled + span::after,
.getbowtied_ajax_load_more_loader .shop_ajax_load_more.disabled ~ span::after {
  content: "No hay más productos" !important;
  color: #666;
}

.getbowtied_ajax_load_button.finished {
  display: none !important;
}

.getbowtied_ajax_load_button .shop_ajax_load_more.disabled,
.getbowtied_ajax_load_button .blog_ajax_load_more.disabled {
  display: none !important;
}

.getbowtied_ajax_load_more_loader:has(.shop_ajax_load_more.disabled),
.getbowtied_ajax_load_more_loader:has(.blog_ajax_load_more.disabled) {
  display: none !important;
}
