/* ============================================================
   ASMON — PLP extras: out-of-stock state + always-on cart CTA
   (loaded on shop/category/tag pages after plp.css)
   ============================================================ */

/* ── Out-of-stock card state ─────────────────────────────── */
.product-card.is-oos { position: relative; }
.product-card.is-oos .product-card-media img {
  filter: grayscale(40%) opacity(.78);
}
.product-card.is-oos .product-card-title {
  color: var(--ink-2);
}

/* "ناموجود" badge — top-corner pill, calmer than the sale badge */
.pc-badge.pc-badge--oos {
  background: var(--midnight);
  color: var(--gold-soft);
  border: 1px solid rgba(200,164,100,.35);
  font-weight: 600;
}

/* "برای قیمت تماس بگیرید" replacement for the price */
.oos-call {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--gold-2);
  letter-spacing: -.005em;
  transition: color var(--t);
}
.oos-call:hover { color: var(--bronze); }

/* ── CTA button variants ─────────────────────────────────── */
/* Variant 1: out-of-stock → "تماس بگیرید" (gold outline, midnight on hover) */
.product-card-cart.product-card-cart--oos {
  background: var(--paper) !important;
  color: var(--gold-2) !important;
  border: 1px solid var(--gold) !important;
}
.product-card-cart.product-card-cart--oos:hover {
  background: var(--midnight) !important;
  color: var(--gold-soft) !important;
  border-color: var(--midnight) !important;
}

/* Variant 2: variable product → "انتخاب گزینه‌ها" (subtle ghost) */
.product-card-cart.product-card-cart--variable {
  background: var(--ivory-2) !important;
  color: var(--gold-2) !important;
  border: 1px solid var(--line-2) !important;
}
.product-card-cart.product-card-cart--variable:hover {
  background: var(--gold) !important;
  color: var(--midnight) !important;
  border-color: var(--gold) !important;
}

/* Variant 3: external/grouped/etc → "مشاهده محصول" (plain) */
.product-card-cart.product-card-cart--view {
  background: var(--ivory-2) !important;
  color: var(--ink-2) !important;
  border: 1px solid var(--line) !important;
}
.product-card-cart.product-card-cart--view:hover {
  background: var(--paper) !important;
  color: var(--gold-2) !important;
  border-color: var(--gold-soft) !important;
}

/* ── AJAX add-to-cart — loading / added states ───────────── */
.product-card-cart.loading {
  opacity: .65;
  pointer-events: none;
  position: relative;
}
.product-card-cart.loading > span:not(.spinner) { opacity: 0; }
.product-card-cart.loading::after {
  content: '';
  position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.18);
  border-top-color: currentColor;
  animation: ac-spin .8s linear infinite;
}
.product-card-cart.added,
.product-card-cart.added_to_cart {
  background: linear-gradient(135deg, #34a07a, var(--success, #2f855a)) !important;
  color: #fff !important;
  border-color: transparent !important;
}
.product-card-cart.added::before {
  content: '✓ ';
  font-weight: 700;
}
@keyframes ac-spin { to { transform: rotate(360deg); } }

/* The WC "view cart" link that auto-appears next to AJAX buttons —
   we don't need it; the floating header cart-count update is enough. */
.added_to_cart.wc-forward {
  display: none !important;
}

/* ── List view tweaks: keep the CTA visible at the bottom ─ */
ul.products.is-list .product-card-cart {
  position: static;
  opacity: 1;
  transform: none;
}
ul.products.is-list .product-card.is-oos .product-card-media img {
  filter: grayscale(40%) opacity(.85);
}

/* ============================================================
   v3.8 — Action row (heart + cart), OOS-to-end, list-view fix,
          pill polish, YITH wishlist normalization
   ============================================================ */

/* ── Card border + hover lift (more visible than the
   default --line which is nearly invisible on ivory) ──────── */
.product-card {
  border: 1px solid var(--line-2) !important;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(20,16,8,.04);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.product-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-2) !important;
  box-shadow: 0 12px 28px rgba(200,164,100,.20);
}

/* ── Action row that wraps heart + cart ─────────────────────
   Always visible at the bottom of the card (no hover-reveal).
*/
.product-card .product-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 16px;
  margin-top: auto;
}

/* Cart button INSIDE the actions row — neutralise the absolute
   positioning that home.css sets on bare .product-card-cart. */
.product-card .product-card-actions .product-card-cart {
  position: static !important;
  inset: auto !important;
  margin: 0 !important;
  opacity: 1 !important;
  transform: none !important;
  flex: 1 1 auto;
  min-width: 0;
  width: auto !important;
}

/* ── Wishlist heart (YITH or fallback) ───────────────────── */
.product-card-fav {
  flex: 0 0 auto;
  display: inline-flex;
}
.product-card-fav-btn,
.product-card-fav .yith-wcwl-add-button > a,
.product-card-fav .yith-wcwl-add-to-wishlist a {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px !important;
  height: 38px !important;
  background: var(--paper) !important;
  border: 1px solid var(--line) !important;
  border-radius: 50% !important;
  color: var(--ink-2) !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 14px !important;
  line-height: 1 !important;
  text-decoration: none !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t) !important;
}
.product-card-fav-btn:hover,
.product-card-fav .yith-wcwl-add-to-wishlist a:hover {
  color: var(--danger) !important;
  border-color: rgba(178,59,59,.45) !important;
  transform: translateY(-1px);
}
.product-card-fav .yith-wcwl-add-to-wishlist a.exists,
.product-card-fav .yith-wcwl-add-to-wishlist a[data-product-added],
.product-card-fav .yith-wcwl-add-to-wishlist .add_to_wishlist.added,
.product-card-fav-btn.is-active,
.product-card-fav-btn[aria-pressed="true"] {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
  background: rgba(178,59,59,.08) !important;
}
.product-card-fav-btn.is-active svg,
.product-card-fav-btn[aria-pressed="true"] svg { fill: var(--danger); }
/* YITH spits out trailing text — show only the icon. */
.product-card-fav .yith-wcwl-add-to-wishlist .yith-wcwl-icon { margin: 0 !important; }
.product-card-fav .yith-wcwl-add-button-text,
.product-card-fav .yith-wcwl-add-to-wishlist .yith-wcwl-add-button > .yith-wcwl-button-text,
.product-card-fav .feedback,
.product-card-fav .yith-wcwl-wishlistexistsbrowse,
.product-card-fav .yith-wcwl-wishlistaddedbrowse,
.product-card-fav .yith-wcwl-add-to-wishlist-button-block { display: none !important; }
.product-card-fav .ajax-loading { position: absolute; opacity: .8; }

.product-card-fav-btn { cursor: pointer; }
.product-card-fav-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* (Mobile rules unnecessary now that the action row is always
   static — kept here as a no-op marker.) */

/* ── List view: enforce 1-column rows, horizontal card layout ──
   The base rule `.plp-main ul.products { grid-template-columns:
   repeat(2, ...) !important }` (plp.css:151) keeps the grid 2-col
   in list mode unless we override with the same !important. */
.plp-main    ul.products.is-list,
.plp-section ul.products.is-list {
  grid-template-columns: 1fr !important;
  gap: 14px !important;
}
@media (min-width: 1500px) {
  .plp-main    ul.products.is-list,
  .plp-section ul.products.is-list { grid-template-columns: 1fr !important; }
}

/* Card itself becomes a 3-track horizontal row: image | body | actions.
   `display: contents` on the link removes it from the layout tree so
   media + body become direct children of the card grid. */
ul.products.is-list .product-card {
  display: grid !important;
  grid-template-columns: 180px minmax(0, 1fr) auto !important;
  align-items: stretch;
  gap: 0 !important;
  padding: 0;
}
ul.products.is-list .product-card .product-card-link {
  display: contents !important;
  color: inherit;
}

/* Cells inside list-view card */
ul.products.is-list .product-card-media {
  aspect-ratio: 1/1 !important;
  height: auto;
  width: 100%;
}
ul.products.is-list .product-card-body {
  padding: 16px 20px !important;
  align-items: flex-start !important;
  justify-content: center;
  text-align: start;
  min-height: 0;
}
ul.products.is-list .product-card-title {
  text-align: start !important;
  min-height: 0 !important;
  font-size: 1.05rem !important;
}
ul.products.is-list .product-card-pills {
  justify-content: flex-start !important;
  min-height: 0 !important;
}
ul.products.is-list .product-card-foot {
  justify-content: flex-start !important;
  margin-top: 6px !important;
}

/* Actions: vertically centred at the row end, cart not full-width */
ul.products.is-list .product-card-actions {
  padding: 0 18px !important;
  margin: 0 !important;
  align-self: center;
}
ul.products.is-list .product-card-cart {
  width: auto !important;
  flex: 0 0 auto !important;
  padding: 12px 24px !important;
}

/* Mobile list view: stack vertically when there's no room for 3 tracks */
@media (max-width: 720px) {
  ul.products.is-list .product-card {
    grid-template-columns: 130px minmax(0, 1fr) !important;
  }
  ul.products.is-list .product-card-actions {
    grid-column: 1 / -1;
    padding: 0 16px 14px !important;
  }
  ul.products.is-list .product-card-cart {
    width: 100% !important;
    flex: 1 1 auto !important;
  }
}

/* ── Pills: gold-tinted to match the brand mockup ────────── */
.pc-pill {
  background: linear-gradient(135deg, rgba(200,164,100,.12), rgba(200,164,100,.04)) !important;
  border-color: rgba(200,164,100,.28) !important;
  color: var(--bronze) !important;
  font-weight: 600 !important;
}

/* ── OOS to the END of the grid via CSS `order` ───────────
   WC's wc_product_class adds `outofstock` to the <li> wrapping
   the card, so we can target the LI directly. */
.plp-section ul.products > li.outofstock,
.plp-main    ul.products > li.outofstock { order: 99; }

/* ============================================================
   v3.9 — Card visual match to the customer-provided mockup
   ============================================================ */

/* Card frame: no harsh border, layered shadow, generous radius. */
.product-card {
  border: 1px solid transparent !important;
  background: var(--paper) !important;
  border-radius: 18px !important;
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(20,16,8,.04),
    0 4px 14px rgba(20,16,8,.06);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  align-self: stretch;
  height: 100%;
  min-height: 480px;  /* safety baseline so cards never differ */
}
.plp-section ul.products,
.plp-main    ul.products { align-items: stretch !important; }
.plp-section ul.products > .plp-cell,
.plp-main    ul.products > .plp-cell { display: flex; height: 100%; }
.plp-section ul.products > .plp-cell > .product-card,
.plp-main    ul.products > .plp-cell > .product-card { flex: 1; }

/* Image area — locked square aspect ratio + cover fit so every
   product photo renders at the exact same pixel dimensions, no
   matter what the uploaded source image's aspect ratio is. */
.product-card-media {
  aspect-ratio: 1 / 1 !important;
  width: 100% !important;
  height: auto !important;
  position: relative;
  overflow: hidden;
  background: var(--ivory-2);
  flex: none;
}
.product-card-media img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center center;
  display: block;
}
.product-card:hover {
  transform: translateY(-4px);
  border-color: rgba(200,164,100,.28) !important;
  box-shadow:
    0 14px 32px rgba(20,16,8,.10),
    0 4px 10px rgba(200,164,100,.10);
}

/* Body: tighter bottom padding so the cart button sits close. */
.product-card-body {
  padding: 16px 18px 10px !important;
  align-items: stretch;
}

/* Title: clean weight, centred, locked to a 2-line height.
   `-webkit-box` doesn't always respect min-height, so we wrap it
   with the explicit `height` shorthand — every title is exactly
   3.2em tall regardless of whether the text is 1 or 2 lines. */
.product-card-title {
  font-size: 1rem !important;
  font-weight: 600 !important;
  color: var(--ink) !important;
  text-align: center;
  line-height: 1.6 !important;
  height: 3.2em !important;
  min-height: 3.2em !important;
  max-height: 3.2em !important;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 !important;
  flex: none;
}

/* Pills: subtle gold tint, centred row.
   Pills row always renders (PHP) so every card reserves the same
   vertical space; lock both min and max so 0 or 2 pills behave the
   same height-wise. */
.product-card-pills {
  justify-content: center;
  height: 28px !important;
  min-height: 28px !important;
  flex: none;
  margin: 0 !important;
}
.plp-section .pc-pill,
.plp-main    .pc-pill {
  background: rgba(200,164,100,.10) !important;
  border-color: rgba(200,164,100,.20) !important;
  color: var(--bronze) !important;
  font-size: .76rem !important;
  font-weight: 500 !important;
  padding: 4px 12px !important;
  letter-spacing: -.005em;
}

/* Price: bronze-gold tone, centred, pinned to the bottom of the
   card-body so every card lines up at the same vertical position
   regardless of title / pill content above it. */
.product-card-foot {
  justify-content: center;
  margin-top: auto !important;
}
.product-card-foot .price {
  color: var(--gold-2) !important;
  font-weight: 700 !important;
  font-size: 1rem !important;
}

/* Hide the heart for now — the mockup uses only the cart CTA. */
.product-card-fav { display: none !important; }

/* Action row at the bottom — always visible, spans full width. */
.product-card .product-card-actions {
  padding: 0 14px 14px !important;
  margin-top: auto;
  display: flex !important;
  align-items: stretch !important;
  gap: 8px !important;
  opacity: 1 !important;
  transform: none !important;
  position: static !important;
}

/* Cart CTA — gold gradient pill, full-width, lift on hover. */
.product-card-cart {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100% !important;
  flex: 1 1 100% !important;
  padding: 12px 18px !important;
  background: linear-gradient(135deg, var(--gold), var(--gold-2)) !important;
  color: var(--midnight) !important;
  font-weight: 700 !important;
  font-size: .88rem !important;
  border-radius: 14px !important;
  border: 0 !important;
  letter-spacing: -.005em;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(200,164,100,.30) !important;
  transition: transform var(--t), box-shadow var(--t), filter var(--t) !important;
}
.product-card-cart:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(200,164,100,.45) !important;
  filter: brightness(1.06);
}
.product-card-cart svg { stroke: var(--midnight); }

/* Variant: out-of-stock — outlined, calmer */
.product-card-cart.product-card-cart--oos {
  background: var(--paper) !important;
  color: var(--gold-2) !important;
  border: 1.5px solid var(--gold) !important;
  box-shadow: 0 2px 8px rgba(200,164,100,.10) !important;
}
.product-card-cart.product-card-cart--oos:hover {
  background: var(--midnight) !important;
  color: var(--gold-soft) !important;
  border-color: var(--midnight) !important;
}
..product-card-cart.product-card-cart--oos svg { stroke: currentColor; }

/* Variant: variable product — neutral, hovers gold */
.product-card-cart.product-card-cart--variable {
  background: var(--ivory-2) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line-2) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.04) !important;
}
..product-card-cart.product-card-cart--variable:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-2)) !important;
  color: var(--midnight) !important;
  border-color: transparent !important;
}
..product-card-cart.product-card-cart--variable svg { stroke: currentColor; }

/* Badge polish: subtle shadow + bolder pill */
.pc-badge {
  border-radius: 999px !important;
  padding: 5px 13px !important;
  font-size: .74rem !important;
  font-weight: 700 !important;
  letter-spacing: -.01em;
  box-shadow: 0 4px 12px rgba(20,16,8,.18) !important;
}
