/* ==========================================================================
   Product grid + product card (owner: archive)
   Used on shop/category pages, home rails, related products.
   Markup: ul.products.product-grid > li.product-card (see woocommerce/content-product.php)
   ========================================================================== */

/* ---------- Grid ---------- */
.product-grid {
  --grid-gap: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--grid-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
/* WooCommerce clearfix pseudo elements would take grid cells */
.product-grid::before,
.product-grid::after {
  content: none !important;
  display: none !important;
}
@media (min-width: 640px) {
  .product-grid { --grid-gap: 16px; }
}
@media (min-width: 768px) {
  .product-grid { --grid-gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .product-grid,
  .product-grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .product-grid--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Rail variant: horizontal scroll with snap (home best sellers, related). */
.product-grid--rail {
  display: flex;
  grid-template-columns: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.product-grid--rail::-webkit-scrollbar { display: none; }
.product-grid--rail > li {
  flex: 0 0 calc((100% - var(--grid-gap)) / 1.6);
  scroll-snap-align: start;
}
@media (min-width: 640px) {
  .product-grid--rail > li { flex-basis: calc((100% - var(--grid-gap) * 2) / 2.5); }
}
@media (min-width: 1024px) {
  .product-grid--rail > li { flex-basis: calc((100% - var(--grid-gap) * 3) / 4); }
}

/* ---------- Card shell ---------- */
.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: var(--r-md);
  box-shadow: var(--sh-clay);
  text-align: left;
  transition: box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.product-card:hover { box-shadow: var(--sh-elevated); }

/* Neutralise WooCommerce default loop styles (floats, widths, margins). */
.products.product-grid > li.product.product-card,
.woocommerce .products.product-grid > li.product.product-card {
  float: none;
  width: auto;
  margin: 0;
  padding: 0;
  clear: none;
}

/* ---------- Media ---------- */
.product-card__media {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--c-bg);
  color: inherit;
  text-decoration: none;
}
.product-card .product-card__media img,
.products.product-grid .product-card .product-card__media img,
.product-card__media .ph {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: cover;
  border-radius: 0;
  box-shadow: none;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.product-card__media .ph { aspect-ratio: auto !important; }
.product-card__media .ph__label { font-size: var(--t-xs); padding: 0 12px; text-align: center; }
/* The card title sits right below, so the placeholder label would only repeat it. */
.product-card__media .ph__label { display: none; }
.products.product-grid .product-card .product-card__img--alt,
.product-card .product-card__img--alt { opacity: 0; }

@media (hover: hover) {
  .product-card:hover .product-card__media img { transform: scale(1.05); }
  .product-card.has-alt-image:hover .product-card__img--main { opacity: 0; }
  .product-card.has-alt-image:hover .product-card__img--alt { opacity: 1; }
}
.product-card.outofstock .product-card__img--main { opacity: .72; }

/* ---------- Badges ---------- */
.product-card__badges {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
@media (min-width: 640px) {
  .product-card__badges { top: 12px; left: 12px; }
}

/* ---------- Wishlist ---------- */
.product-card__wish {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--c-glass);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--c-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
@media (min-width: 640px) {
  .product-card__wish { top: 12px; right: 12px; }
}
.product-card:hover .product-card__wish,
.product-card:focus-within .product-card__wish,
.product-card__wish.is-active,
.product-card__wish:focus-visible { opacity: 1; }
@media (hover: none) {
  .product-card__wish { opacity: 1; }
}
.product-card__wish:hover { color: var(--c-blush-dark); transform: scale(1.06); }
.product-card__wish.is-active { color: var(--c-blush-dark); }
.product-card__wish.is-active svg { fill: currentColor; }
.product-card__wish:focus-visible { outline: 2px solid var(--c-blush); outline-offset: 2px; }

/* ---------- Body ---------- */
.product-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 12px;
}
@media (min-width: 640px) {
  .product-card__body { padding: 16px; }
}

.product-card__title,
.woocommerce ul.products li.product .product-card__title {
  margin: 0;
  padding: 0; /* woocommerce.css adds .5em padding to loop h3: breaks the 2-line clamp + row alignment */
  font-family: var(--f-sans);
  font-size: var(--t-small);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--c-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}
.product-card__title a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.product-card:hover .product-card__title a,
.product-card__title a:hover { color: var(--c-blush-dark); }
.product-card__title a:focus-visible { outline: 2px solid var(--c-blush); outline-offset: 2px; border-radius: 2px; }

/* ---------- Rating ---------- */
.product-card__rating {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1;
}
.product-card__rating .stars__count {
  font-size: 11px;
  color: var(--c-muted);
}

/* ---------- Price ---------- */
.product-card__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-top: 8px;
  font-size: var(--t-small);
  font-weight: 600;
  line-height: 1.3;
  color: var(--c-text);
}
.product-card__price .price { color: inherit; font-size: inherit; }
.product-card__price ins {
  order: -1;
  text-decoration: none;
  background: none;
  color: var(--c-text);
  font-weight: 600;
}
.product-card__price del {
  order: 2;
  font-size: var(--t-xs);
  font-weight: 400;
  color: var(--c-muted);
  opacity: 1;
}
.product-card__price .woocommerce-price-suffix {
  font-size: 11px;
  font-weight: 400;
  color: var(--c-muted);
}
.product-card__price .screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Actions ---------- */
.product-card__actions {
  margin-top: auto;
  padding-top: 14px;
}
@media (min-width: 640px) {
  .product-card__actions { padding-top: 16px; }
}
.product-card__btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 40px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
@media (min-width: 640px) {
  .product-card__btn { font-size: var(--t-small); }
}
.product-card__btn .icon { flex: 0 0 auto; }
.product-card__btn:active { transform: scale(.98); }

/* WooCommerce AJAX states */
.product-card__btn.loading {
  pointer-events: none;
  color: transparent !important;
}
.product-card__btn.loading .icon { opacity: 0; }
.product-card__btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--c-on-dark);
  border-right-color: transparent;
  border-radius: 50%;
  animation: anhdo-card-spin .7s linear infinite;
}
.product-card__btn--oos.loading::after { border-color: var(--c-text); border-right-color: transparent; }
.product-card__btn.added { background: var(--c-blush-dark); }
.product-card .added_to_cart { display: none; }

@keyframes anhdo-card-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .product-card,
  .product-card__media img,
  .product-card__wish { transition: none; }
  .product-card:hover .product-card__media img { transform: none; }
}
