/*
 * Shop / Archive CSS
 * High-end electronics store redesign.
 *
 * @package wc-store
 */

/* ─── Shop Main Layout ──────────────────────────────────────────────────────── */

.wcstore-shop-main {
  padding: 0 0 var(--sp-xl);
}

.wcstore-shop-main .wcstore-page-title {
  padding: 0 var(--wcstore-container-pad);
  max-width: var(--wcstore-max-width);
  margin: var(--sp-lg) auto var(--sp-xs);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.woocommerce-products-header__title + .archive-description,
.term-description,
.woocommerce-product-archive-description {
  padding: 0 var(--wcstore-container-pad);
  max-width: var(--wcstore-max-width);
  margin: 0 auto var(--sp-lg);
  color: var(--wcstore-text-muted);
  font-size: var(--text-lg);
  line-height: 1.5;
  font-weight: 500;
}

/* ─── WCLSF: Shop Wrapper (sidebar + products) ──────────────────────────────── */

.wclsf-shop-wrapper {
  display: grid;
  grid-template-columns: var(--wcstore-sidebar-width) minmax(0, 1fr);
  gap: var(--sp-xl);
  max-width: var(--wcstore-max-width);
  margin: 0 auto;
  padding: 0 var(--wcstore-container-pad);
}

/* Sidebar column */
.wclsf-sidebar-wrapper {
  position: sticky;
  top: calc(var(--wcstore-header-height) + var(--sp-lg));
  max-height: calc(100vh - var(--wcstore-header-height) - calc(var(--sp-lg) * 2));
  overflow-y: auto;
  scrollbar-width: none;
}
.wclsf-sidebar-wrapper::-webkit-scrollbar {
  display: none;
}

/* Products column */
.wclsf-products-wrapper {
  min-width: 0;
}

/* ─── WCLSF: Sidebar panel ──────────────────────────────────────────────────── */

.wclsf-sidebar {
  background: transparent;
  padding: 0;
}

.wclsf-widget {
  border-bottom: 1px solid var(--wcstore-border-light);
  padding-bottom: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.wclsf-widget:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.wclsf-widget-title {
  font-family: var(--wcstore-font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--wcstore-text);
  margin: 0 0 var(--sp-sm);
}

/* ─── WCLSF: Category filter ────────────────────────────────────────────────── */

.wclsf-category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wclsf-category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--wcstore-text-muted);
  transition: color var(--wcstore-transition);
}

.wclsf-category-item:hover {
  color: var(--wcstore-text);
}

.wclsf-category-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--wcstore-border);
  appearance: none;
  background: var(--wcstore-surface);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
  position: relative;
}

.wclsf-category-checkbox:checked {
  background: var(--wcstore-text);
  border-color: var(--wcstore-text);
}

.wclsf-category-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid var(--wcstore-surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.wclsf-category-name {
  flex: 1;
}

.wclsf-category-count {
  font-size: var(--text-xs);
  color: var(--wcstore-text-muted);
}

/* ─── Shop Toolbar ──────────────────────────────────────────────────────────── */

.wcstore-shop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp-sm);
  border-bottom: 1px solid var(--wcstore-border-light);
}

.wcstore-shop-toolbar__count .woocommerce-result-count {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--wcstore-text-muted);
  font-weight: 500;
}

.wcstore-shop-toolbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.woocommerce-ordering select {
  padding: 8px 32px 8px 16px;
  font-size: var(--text-sm);
  font-family: var(--wcstore-font-body);
  font-weight: 600;
  border: none;
  background: var(--wcstore-surface);
  color: var(--wcstore-text);
  border-radius: var(--wcstore-radius-full);
  cursor: pointer;
  appearance: none;
  box-shadow: var(--wcstore-shadow-sm);
}

/* ─── Premium Product Card (content-product.php) ──────────────────────────────── */

.wcstore-products-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-lg);
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Full-bleed, edge-to-edge product card base */
.wcstore-product-card {
  position: relative;
  background: var(--wcstore-surface);
  border-radius: var(--wcstore-radius-lg);
  padding: 0;
  /* Removed overflow:hidden — it was clipping the asymmetric badge at right:-8px */
  display: flex;
  flex-direction: column;
  transition: transform var(--duration-slow) var(--ease-out-expo),
              box-shadow var(--duration-slow) var(--ease-out-expo);
  box-shadow: var(--wcstore-shadow-sm);
  /* Stacking context so ::before/::after z-index work correctly cross-browser */
  isolation: isolate;
}

.wcstore-card-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* Animated Gradient Trace Border */
.wcstore-card-border {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out-expo);
}

.wcstore-card-border rect {
  fill: none;
  stroke: url(#card-gradient); /* We create this dynamically or use a CSS conic-gradient trick */
}

/* Using CSS instead of SVG stroke for cooler gradient trace */
.wcstore-product-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--wcstore-radius-lg) + 2px);
  background: conic-gradient(from 0deg, transparent 70%, var(--wcstore-primary) 100%);
  z-index: -2;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out-expo);
  animation: rotate-border 4s linear infinite;
}

@keyframes rotate-border {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.wcstore-product-card::after {
  content: '';
  position: absolute;
  inset: 1px;
  background: var(--wcstore-surface);
  border-radius: var(--wcstore-radius-lg);
  z-index: -1;
}

.wcstore-product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--wcstore-shadow-lg);
}

.wcstore-product-card:hover::before {
  opacity: 1;
}

/* Image wrapper - full bleed */
.wcstore-card-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--wcstore-bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wcstore-product-card img {
  max-width: 80%;
  max-height: 80%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform var(--duration-slow) var(--ease-out-expo);
  mix-blend-mode: multiply; /* Looks great on white/light backgrounds */
}

/* Dark mode: disable multiply blend so images don't go invisible */
@media (prefers-color-scheme: dark) {
  .wcstore-product-card img {
    mix-blend-mode: normal;
  }
}

html[data-theme='dark'] .wcstore-product-card img {
  mix-blend-mode: normal;
}

.wcstore-product-card:hover img {
  transform: scale(1.08);
}

/* Asymmetric Badges */
.wcstore-card-badges {
  position: absolute;
  top: 16px;
  right: -8px; /* Off-grid asymmetry */
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.wcstore-badge {
  font-family: var(--wcstore-font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-radius: 4px 0 0 4px; /* Asymmetric radius */
  color: #fff;
  box-shadow: var(--wcstore-shadow-sm);
}

.wcstore-badge--featured { background: var(--wcstore-text); }
.wcstore-badge--sale { background: var(--wcstore-accent); }
.wcstore-badge--outofstock { background: var(--wcstore-error); }

/* Content Section */
.wcstore-card-content {
  padding: var(--sp-md);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.wcstore-card-title {
  font-family: var(--wcstore-font-heading);
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0 0 var(--sp-sm);
  line-height: 1.2;
}

.wcstore-card-title a {
  color: var(--wcstore-text);
}

.wcstore-card-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--sp-lg);
  margin-top: auto;
}

.wcstore-card-specs .spec-item {
  font-size: 11px;
  font-weight: 700;
  color: var(--wcstore-text-muted);
  background: var(--wcstore-bg);
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Footer / Price / Hover Reveal */
.wcstore-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  position: relative;
  min-height: 44px;
  overflow: hidden; /* Clips the sliding CTA within card footer only */
}

.wcstore-card-price {
  font-family: var(--wcstore-font-heading);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--wcstore-text);
  transition: opacity var(--duration-normal) var(--ease-out-expo),
              transform var(--duration-normal) var(--ease-out-expo);
}

.wcstore-card-price del {
  color: var(--wcstore-text-muted);
  font-size: var(--text-sm);
  margin-right: 6px;
  font-weight: 500;
}

.wcstore-card-price ins {
  text-decoration: none;
  color: var(--wcstore-primary);
}

/* CTA Add to Cart */
.wcstore-card-action {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%) translateX(20px); /* Vertically centred, shifted right */
  opacity: 0;
  pointer-events: none;
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.wcstore-product-card:hover .wcstore-card-action {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}

.wcstore-product-card:hover .wcstore-card-price {
  transform: translateX(-10px);
}

/* Override default WC button styles for this card context specifically */
.wcstore-card-action .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  font-family: var(--wcstore-font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--wcstore-radius-full);
  background: var(--wcstore-text);
  color: var(--wcstore-surface);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.wcstore-card-action .button:hover {
  background: var(--wcstore-primary);
  transform: scale(1.05);
}

/* Loading State */
.wcstore-product-card.loading .wcstore-card-action .button {
  background: var(--wcstore-text-muted);
}
.wcstore-product-card.loading::before {
  opacity: 1 !important;
  background: conic-gradient(from 0deg, transparent 70%, var(--wcstore-text-muted) 100%);
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 991px) {
  .wclsf-shop-wrapper {
    grid-template-columns: 1fr;
    gap: var(--sp-md);
  }

  .wclsf-sidebar-wrapper {
    position: fixed;
    top: 0;
    left: -100%;
    width: 300px;
    height: 100vh;
    z-index: 1500;
    background: var(--wcstore-surface);
    padding: var(--sp-xl) var(--sp-md);
    transition: left var(--duration-normal) var(--ease-out-expo);
    box-shadow: var(--wcstore-shadow-lg);
  }

  .wclsf-sidebar-wrapper.is-open {
    left: 0;
  }
}

@media (max-width: 640px) {
  .wcstore-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  
  /* On mobile, usually no hover, so we show the cart button permanently or re-layout */
  .wcstore-card-action {
    opacity: 1;
    transform: none;
    position: static;
  }
  
  .wcstore-card-price {
    transform: none !important;
  }
}
