/**
 * SvichkaVisk v2 — shop & category archive (WooCommerce catalog).
 * Scoped to product listings; tokens from design.md / sv2-custom.css.
 */

/* ==========================================================================
   Archive header & breadcrumbs
   ========================================================================== */

.woocommerce.archive .woocommerce-products-header {
  margin-bottom: var(--sv2-space-lg);
  padding-bottom: var(--sv2-space-md);
  border-bottom: 1px solid var(--sv2-border);
}

.woocommerce.archive .woocommerce-products-header__title,
.woocommerce.archive .page-title {
  margin: 0;
  color: var(--sv2-brown);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.woocommerce.archive .term-description,
.woocommerce.archive .woocommerce-products-header .archive-description {
  margin-top: var(--sv2-space-sm);
  color: var(--sv2-text-muted);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 720px;
}

.woocommerce.archive .woocommerce-breadcrumb {
  margin-bottom: var(--sv2-space-md);
  color: var(--sv2-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.woocommerce.archive .woocommerce-breadcrumb a {
  color: var(--sv2-brown);
}

.woocommerce.archive .woocommerce-breadcrumb a:hover {
  color: var(--sv2-primary-hover);
}

/* Toolbar: result count + sorting */
.woocommerce.archive .woocommerce-result-count,
.woocommerce.archive .woocommerce-ordering {
  color: var(--sv2-text-muted);
  font-size: 0.9375rem;
  margin-bottom: var(--sv2-space-md);
}

.woocommerce.archive .woocommerce-ordering select {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--sv2-radius-input);
  border-color: var(--sv2-input-border);
  background: var(--sv2-card);
  color: var(--sv2-text);
}

/* ==========================================================================
   Product grid (mobile-first)
   ========================================================================== */

.woocommerce.archive ul.products {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: 100%;
  margin: 0 0 var(--sv2-space-xl);
  padding: 0;
  list-style: none;
}

/* Space between last catalog card and footer */
.woocommerce.archive #Content .content_wrapper {
  padding-bottom: var(--sv2-space-section);
}

.woocommerce.archive ul.products::before,
.woocommerce.archive ul.products::after {
  display: none;
}

.woocommerce.archive ul.products li.product {
  width: 100% !important;
  margin: 0 !important;
  float: none !important;
  clear: none !important;
}

@media (min-width: 576px) {
  .woocommerce.archive ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }
}

@media (min-width: 992px) {
  .woocommerce.archive ul.products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
  }
}

/* ==========================================================================
   Category cards (shop root — product-category)
   ========================================================================== */

.woocommerce.archive ul.products li.product-category {
  position: relative;
  overflow: hidden;
  min-height: 240px;
  border: 1px solid var(--sv2-border);
  border-radius: var(--sv2-radius-card-lg);
  background: var(--sv2-card);
  box-shadow: var(--sv2-shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.woocommerce.archive ul.products li.product-category > a {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--sv2-text);
  text-decoration: none;
}

.woocommerce.archive ul.products li.product-category img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.woocommerce.archive ul.products li.product-category .woocommerce-loop-category__title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 18px 16px;
  color: #fff;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(
    180deg,
    rgba(21, 15, 10, 0) 0%,
    rgba(21, 15, 10, 0.82) 100%
  );
}

.woocommerce.archive ul.products li.product-category .woocommerce-loop-category__title mark.count {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: var(--sv2-radius-pill);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
}

@media (hover: hover) and (pointer: fine) {
  .woocommerce.archive ul.products li.product-category:hover {
    transform: translateY(-4px);
    box-shadow: var(--sv2-shadow-md);
  }

  .woocommerce.archive ul.products li.product-category:hover img {
    transform: scale(1.04);
  }
}

/* ==========================================================================
   Product cards (category archives)
   ========================================================================== */

.woocommerce.archive ul.products li.product:not(.product-category) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--sv2-border);
  border-radius: var(--sv2-radius-card-lg);
  background: var(--sv2-card);
  box-shadow: var(--sv2-shadow-sm);
  text-align: center;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.woocommerce.archive ul.products li.product:not(.product-category) .product-loop-thumb {
  position: relative;
  overflow: hidden;
  background: var(--sv2-bg-soft);
}

.woocommerce.archive ul.products li.product:not(.product-category) .product-loop-thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.woocommerce.archive ul.products li.product:not(.product-category) .desc {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
  padding: 16px 16px 18px;
}

.woocommerce.archive ul.products li.product:not(.product-category) .mfn-woo-product-title,
.woocommerce.archive ul.products li.product:not(.product-category) h2,
.woocommerce.archive ul.products li.product:not(.product-category) h3,
.woocommerce.archive ul.products li.product:not(.product-category) h4 {
  margin: 0;
  padding: 0;
  font-size: clamp(0.9375rem, 2vw, 1.0625rem);
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.woocommerce.archive ul.products li.product:not(.product-category) .mfn-woo-product-title a,
.woocommerce.archive ul.products li.product:not(.product-category) .title a {
  color: var(--sv2-brown);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.woocommerce.archive ul.products li.product:not(.product-category) .mfn-woo-product-title a:hover,
.woocommerce.archive ul.products li.product:not(.product-category) .title a:hover {
  color: var(--sv2-primary-hover);
}

.woocommerce.archive ul.products li.product:not(.product-category) .price {
  margin: 0;
  color: var(--sv2-text);
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1.2;
}

.woocommerce.archive ul.products li.product:not(.product-category) .price ins {
  text-decoration: none;
  color: var(--sv2-primary-hover);
}

.woocommerce.archive ul.products li.product:not(.product-category) .price del {
  color: var(--sv2-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.woocommerce.archive ul.products li.product:not(.product-category) .star-rating {
  margin: 0 auto;
}

.woocommerce.archive ul.products li.product:not(.product-category) .mfn-li-product-row-button {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: auto;
  padding-top: 8px;
}

.woocommerce.archive ul.products li.product:not(.product-category) .mfn-li-product-row-button .button,
.woocommerce.archive ul.products li.product:not(.product-category) .mfn-li-product-row-button .add_to_cart_button {
  width: 100%;
  min-height: 48px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  overflow: visible;
}

/* Added-to-cart checkmark — flex-aligned (WooCommerce :after glyph sits too low) */
.woocommerce.archive ul.products li.product:not(.product-category) .add_to_cart_button.added::after,
.woocommerce.archive ul.products li.product:not(.product-category) .button.added::after {
  font-family: inherit;
  content: "✓";
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
  transform: none;
}

.woocommerce.archive ul.products li.product:not(.product-category) .add_to_cart_button.loading::after,
.woocommerce.archive ul.products li.product:not(.product-category) .button.loading::after {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -8px 0 0 -8px;
}

.woocommerce.archive ul.products li.product:not(.product-category) .button,
.woocommerce.archive ul.products li.product:not(.product-category) .add_to_cart_button {
  width: 100%;
}

.woocommerce.archive ul.products li.product:not(.product-category) span.onsale {
  top: 12px;
  left: 12px;
  right: auto;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: var(--sv2-radius-pill);
  background: var(--sv2-primary);
  color: var(--sv2-on-primary);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.3;
}

@media (hover: hover) and (pointer: fine) {
  .woocommerce.archive ul.products li.product:not(.product-category):hover {
    transform: translateY(-4px);
    box-shadow: var(--sv2-shadow-md);
  }

  .woocommerce.archive ul.products li.product:not(.product-category):hover .product-loop-thumb img {
    transform: scale(1.04);
  }
}

/* Out of stock */
.woocommerce.archive ul.products li.product.outofstock .product-loop-thumb .soldout {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.72);
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.woocommerce.archive nav.woocommerce-pagination {
  margin-top: var(--sv2-space-lg);
}

.woocommerce.archive nav.woocommerce-pagination ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  border: none;
}

.woocommerce.archive nav.woocommerce-pagination ul li {
  border: none;
}

.woocommerce.archive nav.woocommerce-pagination ul li a,
.woocommerce.archive nav.woocommerce-pagination ul li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--sv2-border);
  border-radius: var(--sv2-radius-pill);
  background: var(--sv2-card);
  color: var(--sv2-brown);
  font-weight: 700;
}

.woocommerce.archive nav.woocommerce-pagination ul li span.current {
  background: var(--sv2-primary);
  border-color: var(--sv2-primary);
  color: var(--sv2-on-primary);
}

.woocommerce.archive nav.woocommerce-pagination ul li a:hover {
  border-color: var(--sv2-primary);
  color: var(--sv2-primary-hover);
}

/* ==========================================================================
   Betheme shop sidebar / filters (if active)
   ========================================================================== */

.woocommerce.archive .shop-filters,
.woocommerce.archive #Filters .filters_wrapper {
  border-radius: var(--sv2-radius-card);
  border: 1px solid var(--sv2-border);
  background: var(--sv2-card);
}

.woocommerce.archive #Filters .filters_wrapper ul li a {
  color: var(--sv2-brown);
}

.woocommerce.archive #Filters .filters_wrapper ul li.current-cat a,
.woocommerce.archive #Filters .filters_wrapper ul li a:hover {
  color: var(--sv2-primary-hover);
}

/* ==========================================================================
   Sidebar — product categories card (WooCommerce block widget)
   ========================================================================== */

/* Admin spacer block pushes the card down — hide on shop archives */
.woocommerce .mcb-sidebar .widget.widget_block:has(.wp-block-spacer) {
  display: none;
  margin: 0;
  padding: 0;
}

.woocommerce .mcb-sidebar .widget.widget_block:has(.wc-block-product-categories) {
  margin-bottom: var(--sv2-space-lg);
  padding: 0;
  border: none;
  background: transparent;
}

/* Align card top with product grid (.with_aside .sections_group padding-top) */
@media (min-width: 768px) {
  .woocommerce.with_aside .mcb-sidebar .widget.widget_block:has(.sv2-shop-categories-card) {
    margin-top: 30px;
  }
}

.woocommerce .sv2-shop-categories-card {
  overflow: hidden;
  border: 1px solid var(--sv2-border);
  border-radius: var(--sv2-radius-card-lg);
  background: var(--sv2-card);
  box-shadow: var(--sv2-shadow-sm);
}

.woocommerce .sv2-shop-categories-card__header {
  padding: 0;
  border-bottom: 1px solid var(--sv2-border);
  background: linear-gradient(180deg, var(--sv2-bg-soft) 0%, var(--sv2-card) 100%);
}

.woocommerce .sv2-shop-categories-card__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 14px 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
  appearance: none;
  -webkit-appearance: none;
}

.woocommerce .sv2-shop-categories-card__toggle:focus-visible {
  outline: 2px solid var(--sv2-primary);
  outline-offset: -2px;
}

.woocommerce .sv2-shop-categories-card__title {
  margin: 0;
  color: var(--sv2-brown);
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.woocommerce .sv2-shop-categories-card__chevron {
  display: none;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin-inline-end: -10px;
  color: var(--sv2-text-subtle);
}

.woocommerce .sv2-shop-categories-card__chevron::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin: 16px auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.22s ease;
}

.woocommerce .sv2-shop-categories-card.is-open .sv2-shop-categories-card__chevron::before {
  margin-top: 20px;
  transform: rotate(-135deg);
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories.is-list {
  padding: 10px 12px 14px;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item {
  position: relative;
  margin: 0;
  padding: 0 40px 0 0;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item > a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--sv2-radius-input);
  color: var(--sv2-text);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list--depth-0 > .wc-block-product-categories-list-item > a::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sv2-primary-soft);
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item > ul {
  display: none;
  margin: 2px 0 8px 18px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--sv2-border);
  list-style: none;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item.li-expanded > ul {
  display: block;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list--depth-1 .wc-block-product-categories-list-item {
  padding-right: 0;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list--depth-1 .wc-block-product-categories-list-item > a {
  min-height: 40px;
  padding: 8px 12px;
  color: var(--sv2-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list--depth-1 .wc-block-product-categories-list-item > a::before {
  display: none;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories.is-list ul li .cat-expander {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--sv2-text-subtle);
  cursor: pointer;
  border-radius: var(--sv2-radius-input);
  transition: color 0.18s ease, background-color 0.18s ease;
}

/* Override Betheme mfn-icons chevron — single clean arrow only */
.woocommerce .sv2-shop-categories-card .wc-block-product-categories.is-list ul li .cat-expander::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border: 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  font-family: inherit;
  transform: rotate(45deg);
  transition: transform 0.22s ease;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories.is-list ul li.li-expanded > .cat-expander {
  transform: none;
  color: var(--sv2-primary-hover);
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories.is-list ul li.li-expanded > .cat-expander::before {
  transform: rotate(-135deg);
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item.is-current > a {
  background: var(--sv2-soft-honey);
  color: var(--sv2-brown);
  font-weight: 700;
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item.is-current > a::before {
  background: var(--sv2-primary);
}

.woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item.is-ancestor > a {
  color: var(--sv2-primary-hover);
  font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .woocommerce .sv2-shop-categories-card .wc-block-product-categories-list-item > a:hover {
    background: var(--sv2-bg-soft);
    color: var(--sv2-primary-hover);
  }

  .woocommerce .sv2-shop-categories-card .wc-block-product-categories-list--depth-0 > .wc-block-product-categories-list-item > a:hover::before {
    background: var(--sv2-primary);
    transform: scale(1.15);
  }

  .woocommerce .sv2-shop-categories-card .wc-block-product-categories.is-list ul li .cat-expander:hover {
    background: var(--sv2-bg-soft);
    color: var(--sv2-primary-hover);
  }
}

@media (min-width: 768px) {
  .woocommerce .sv2-shop-categories-card .wc-block-product-categories.is-list {
    padding: 12px 14px 16px;
  }

  .woocommerce .sv2-shop-categories-card__toggle {
    pointer-events: none;
  }
}

/* Mobile: categories above products + collapsed accordion */
@media (max-width: 767px) {
  .woocommerce.archive.with_aside .content_wrapper {
    display: flex;
    flex-direction: column;
  }

  .woocommerce.archive.with_aside .mcb-sidebar {
    order: 1;
  }

  .woocommerce.archive.with_aside .sections_group {
    order: 2;
  }

  .woocommerce .mcb-sidebar .widget.widget_block:has(.wc-block-product-categories) {
    margin-top: 0;
    margin-bottom: var(--sv2-space-md);
  }

  .woocommerce .sv2-shop-categories-card {
    border-radius: var(--sv2-radius-card);
  }

  .woocommerce .sv2-shop-categories-card__toggle {
    cursor: pointer;
    min-height: 48px;
    padding: 12px 14px 12px 18px;
  }

  .woocommerce .sv2-shop-categories-card__chevron {
    display: block;
  }

  .woocommerce .sv2-shop-categories-card:not(.is-open) .sv2-shop-categories-card__header {
    border-bottom: 0;
  }

  .woocommerce .sv2-shop-categories-card:not(.is-open) .sv2-shop-categories-card__panel {
    display: none;
  }

  .woocommerce .sv2-shop-categories-card.is-open .sv2-shop-categories-card__chevron {
    color: var(--sv2-primary-hover);
  }
}

@media (prefers-reduced-motion: reduce) {
  .woocommerce .sv2-shop-categories-card__chevron::before {
    transition: none;
  }
}
