/* ============================================================
   CraftyWorth v2 — Product Card
   Inspired by: Artifact Uprising minimal card
   Philosophy: Photo first. Name + Price only. CTA on hover.
   ============================================================ */

/* ── Grid ── */
.cw-products {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  list-style: none;
  margin: 0; padding: 0;
}

/* ── Card ── */
.cw-card, .product {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform var(--t-lg), box-shadow var(--t-lg);
  will-change: transform;
}
.cw-card:hover, .product:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-2);
}

/* ── Image wrapper (1:1 square) ── */
.cw-card__img, .product .woocommerce-LoopProduct-link {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--off);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  text-decoration: none;
}

.cw-card__photo,
.product .attachment-woocommerce_thumbnail,
.product img.wp-post-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .45s ease;
}
.cw-card:hover .cw-card__photo,
.product:hover .attachment-woocommerce_thumbnail,
.product:hover img.wp-post-image {
  transform: scale(1.05);
}

/* Placeholder when no image */
.cw-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--line);
  font-size: 40px;
  background: var(--off);
}

/* ── Badge (top-left, ONE only) ── */
.cw-card__badge {
  position: absolute;
  top: 10px; left: 10px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--pill);
  z-index: 2;
  white-space: nowrap;
}
.cw-card__badge--sale    { background: var(--a); color: #fff; }
.cw-card__badge--custom  { background: var(--p); color: #fff; }
.cw-card__badge--corp    { background: var(--ink); color: #fff; }

/* ── Wishlist (top-right) ── */
.cw-card__wish {
  position: absolute;
  top: 10px; right: 10px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(4px);
  border: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  transition: color var(--t), transform var(--t), background var(--t);
  z-index: 2;
  box-shadow: var(--sh-1);
}
.cw-card__wish:hover { color: var(--p); background: #fff; transform: scale(1.1); }
.cw-card__wish.is-on  { color: var(--p); }

/* YITH Wishlist override */
.cw-card .yith-wcwl-add-to-wishlist { position: absolute; top: 10px; right: 10px; z-index: 2; }
.cw-card .yith-wcwl-add-to-wishlist a,
.cw-card .yith-wcwl-add-to-wishlist .add_to_wishlist {
  display: flex !important;
  width: 34px !important; height: 34px !important;
  border-radius: 50% !important;
  background: rgba(255,255,255,.9) !important;
  border: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0 !important;
  color: var(--ink-3) !important;
  box-shadow: var(--sh-1) !important;
  transition: color var(--t), background var(--t) !important;
}
.cw-card .yith-wcwl-add-to-wishlist a:hover { color: var(--p) !important; background: #fff !important; }

/* ── Hover CTA overlay (Martfury-inspired slide-up) ── */
.cw-card__hover-cta {
  position: absolute;
  bottom: -100%;
  left: 0; right: 0;
  background: var(--p);
  color: #fff;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 11px;
  transition: bottom .22s ease;
  z-index: 3;
}
@media (hover: hover) {
  .cw-card:hover .cw-card__hover-cta { bottom: 0; }
}

/* ── Card Body ── */
.cw-card__body, .product .woocommerce-loop-product__link + * {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

/* Title — 2 lines max */
.cw-card__title,
.product .woocommerce-loop-product__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  font-family: var(--body);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}
.cw-card__title a { color: inherit; }
.cw-card__title a:hover { color: var(--p); }

/* Price row */
.cw-card__price,
.product .price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.cw-card__price .amount,
.product .price .woocommerce-Price-amount,
.product .price .amount {
  font-family: var(--head);
  font-size: 20px;
  font-weight: 600;
  color: var(--p);
  line-height: 1;
}
.cw-card__price del,
.product .price del {
  font-size: 12px;
  color: var(--ink-3);
  text-decoration: line-through;
  font-family: var(--body);
}
.cw-card__price ins,
.product .price ins { text-decoration: none; font-style: normal; }

/* ── Corporate card ── */
.cw-card[data-type="corporate"] .cw-card__img {
  background: linear-gradient(135deg, var(--ink) 0%, #1E2D3A 100%);
}

/* ── CTA Button — always visible ── */
.cw-card .button,
.product .add_to_cart_button,
.product .button {
  display: inline-flex !important;
  width: 100% !important;
  height: 42px !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  border-radius: 999px !important;
  font-family: var(--body) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  border: 0 !important;
  transition: background .2s, transform .2s !important;
  text-decoration: none !important;
  white-space: nowrap !important;
}
/* Add to cart = accent (saffron) */
.cw-card .add_to_cart_button,
.product .add_to_cart_button {
  background: var(--a) !important;
  color: #fff !important;
}
.cw-card .add_to_cart_button:hover { background: var(--a-d) !important; transform: translateY(-1px) !important; }
/* View product / select options = primary */
.cw-card .button:not(.add_to_cart_button),
.product .button:not(.add_to_cart_button) {
  background: var(--p) !important;
  color: #fff !important;
}
.cw-card .button:not(.add_to_cart_button):hover { background: var(--p-d) !important; transform: translateY(-1px) !important; }
/* Loading state */
.cw-card .add_to_cart_button.loading::after { content: ''; display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: cwspin .7s linear infinite; margin-left: 6px; }
@keyframes cwspin { to { transform: rotate(360deg); } }
/* Added state */
.cw-card .add_to_cart_button.added { background: #2d8a4e !important; }
/* OOS */
.cw-card .button[disabled],
.product .button[disabled] { background: var(--line) !important; color: var(--ink-3) !important; cursor: not-allowed !important; }

/* ── Responsive ── */
@media (max-width: 1200px) { .cw-products { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .cw-products { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (max-width: 640px)  {
  .cw-products { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .cw-card__body { padding: 10px 10px 12px; }
  .cw-card__title { font-size: 12.5px; min-height: 35px; }
  .cw-card__price .amount,
  .product .price .woocommerce-Price-amount { font-size: 17px; }
  .cw-card__hover-cta { display: none; }
  .cw-card__badge { font-size: 8.5px; padding: 2px 8px; }
}

/* ── Card CTA wrapper ── */
.cw-card__cta { margin-top: auto; padding-top: 10px; }

/* Customize Now button — gradient, distinct from regular cart/corp CTAs */
.cw-card__btn-custom {
  background: linear-gradient(135deg, var(--a, #E8651A) 0%, var(--p, #A0293E) 100%) !important;
  color: #fff !important;
  border: 0 !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  letter-spacing: .02em !important;
  box-shadow: 0 2px 8px rgba(160, 41, 62, 0.18) !important;
  transition: transform .15s ease, box-shadow .2s ease, background .2s !important;
}
.cw-card__btn-custom::before {
  content: '\2726';
  font-size: 12px;
  line-height: 1;
  display: inline-block;
}
.cw-card__btn-custom:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 14px rgba(160, 41, 62, 0.35) !important;
  background: linear-gradient(135deg, var(--p, #A0293E) 0%, var(--a, #E8651A) 100%) !important;
}

/* Corporate Quote button */
.cw-card__btn-corp {
  background: var(--ink) !important;
  color: #fff !important;
}
.cw-card__btn-corp:hover { background: #2C2018 !important; }

/* Secondary bulk-quote link (appears under primary CTA for priced + quote_ok items) */
.cw-card__bulk-link {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--p);
  text-align: center;
  text-decoration: none;
  letter-spacing: .02em;
}
.cw-card__bulk-link:hover { color: var(--p-d, var(--p)); text-decoration: underline; }

/* Mobile: smaller CTA */
@media (max-width: 640px) {
  .cw-card .button { height: 36px !important; font-size: 12px !important; }
  .cw-card__cta { padding-top: 8px; }
  .cw-card__bulk-link { font-size: 10.5px; }
}

/* ── Consistent Card Heights (equal rhythm) ── */
.cw-card {
  height: 100%;
}
.cw-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.cw-card__title {
  flex: 1;
}
.cw-card__cta {
  margin-top: auto;
  padding-top: 10px;
}

/* ── Product Title Display Fix (shorter display) ── */
.cw-card__title a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Placeholder — professional SVG-based, no emoji ── */
.cw-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #F8F3EE 0%, var(--off, #FEF7F0) 100%);
  color: var(--ink-3, #7A6458);
  position: relative;
  overflow: hidden;
}
.cw-card__placeholder::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  background: var(--line, #EAD9CC);
  border-radius: 50%;
  /* Center dot decoration */
}
.cw-card__placeholder::after {
  content: 'Preview Coming Soon';
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3, #7A6458);
  opacity: .7;
}

/* Overflow prevention — flex/grid containers */
.cw-card, ul.products li.product, .products .product { min-width: 0; }

/* ── Quick View button on card (Phase 4) ── */
.cw-card__qv {
    position: absolute; bottom: 8px; right: 8px; z-index: 3;
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.92); border: 1px solid var(--line,#EAD9CC);
    color: var(--ink,#1A1208); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transform: translateY(4px);
    transition: opacity .15s, transform .15s, background .15s;
    font-family: inherit;
}
.cw-card:hover .cw-card__qv,
.cw-card:focus-within .cw-card__qv { opacity: 1; transform: translateY(0); }
.cw-card__qv:hover { background: var(--p,#A0293E); color: #fff; border-color: var(--p); }
@media (max-width: 768px) { .cw-card__qv { opacity: 1; transform: none; } }

/* ── 2nd image on hover (Phase 5) ── */
.cw-card__img { position: relative; display: block; overflow: hidden; }
.cw-card__photo { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity .5s ease; }
/* Secondary image — desktop: hover swap; touch: JS auto-cycle via .cw-img-showing2 class */
.cw-card__img2 {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; opacity: 0;
    transition: opacity .5s ease;
    pointer-events: none;
}
/* Desktop hover swap */
@media (hover: hover) and (pointer: fine) {
    .cw-card:hover .cw-card__img2 { opacity: 1; }
    .cw-card:hover .cw-card__photo { opacity: 0; }
}
/* Touch auto-cycle (class toggled by JS) */
.cw-card.cw-img-showing2 .cw-card__img2 { opacity: 1; }
.cw-card.cw-img-showing2 .cw-card__photo { opacity: 0; }

/* ── Quick View Modal (Phase 4) ── */
.cwv2-qv-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(0,0,0,.55); display: flex;
    align-items: center; justify-content: center;
    padding: 16px; box-sizing: border-box;
}
.cwv2-qv-overlay[hidden] { display: none; }
.cwv2-qv-modal {
    background: #fff; border-radius: 16px;
    max-width: 720px; width: 100%; max-height: 90vh;
    overflow-y: auto; position: relative;
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
    animation: cwv2QvIn .2s ease;
}
@keyframes cwv2QvIn { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:scale(1); } }
.cwv2-qv-close {
    position: absolute; top: 12px; right: 14px; z-index: 2;
    width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid var(--line); background: #fff;
    font-size: 20px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-3); font-family: inherit;
}
.cwv2-qv-close:hover { background: var(--off); color: var(--ink); }
.cwv2-qv-body { padding: 24px; }
.cwv2-qv-inner {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start;
}
@media (max-width: 600px) { .cwv2-qv-inner { grid-template-columns: 1fr; } .cwv2-qv-modal { border-radius: 12px; } }
.cwv2-qv-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 10px; display: block; }
.cwv2-qv-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 6px; }
.cwv2-qv-title { font-family: var(--head,Georgia,serif); font-size: clamp(18px,2.5vw,24px); font-weight: 600; line-height: 1.2; margin: 0 0 10px; word-break: break-word; }
.cwv2-qv-price .price, .cwv2-qv-price .amount { font-size: 22px; font-weight: 800; color: var(--p); font-family: var(--head,Georgia,serif); }
.cwv2-qv-price del .amount { font-size: 15px; color: var(--ink-3); font-weight: 400; }
.cwv2-qv-price ins { text-decoration: none; }
.cwv2-qv-stock { font-size: 12px; font-weight: 600; margin: 8px 0; }
.cwv2-qv-stock.in { color: #166534; } .cwv2-qv-stock.out { color: #dc2626; }
.cwv2-qv-desc { font-size: 13px; line-height: 1.6; color: var(--ink-2); margin: 10px 0 16px; }
.cwv2-qv-actions { display: flex; flex-direction: column; gap: 8px; }
.cwv2-qv-btn-main {
    display: block; text-align: center; padding: 13px 20px; border-radius: 999px;
    font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
    background: var(--p,#A0293E); color: #fff; border: none; font-family: inherit;
    transition: background .15s;
}
.cwv2-qv-btn-main:hover { background: var(--p-d,#7A1E2F); }
.cwv2-qv-btn-sec {
    display: block; text-align: center; padding: 11px 20px; border-radius: 999px;
    font-weight: 600; font-size: 13px; text-decoration: none; cursor: pointer;
    background: var(--off,#FEF7F0); color: var(--p); border: 1px solid var(--p);
    font-family: inherit; transition: background .15s;
}
.cwv2-qv-btn-sec:hover { background: var(--p); color: #fff; }
.cwv2-qv-loading { display: flex; align-items: center; justify-content: center; min-height: 200px; }
.cwv2-qv-loading span {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--p);
    animation: cwv2QvSpin .7s linear infinite; display: block;
}
@keyframes cwv2QvSpin { to { transform: rotate(360deg); } }

/* ── WooCommerce ul.products grid override — ensure consistent 4-col layout ── */
.woocommerce ul.products,
.woocommerce-page ul.products,
ul.products {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 24px !important;
  float: none !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product,
ul.products li.product {
  width: 100% !important;
  float: none !important;
  clear: none !important;
  margin: 0 !important;
}
@media (max-width:1200px) {
  .woocommerce ul.products, .woocommerce-page ul.products, ul.products { grid-template-columns: repeat(3,1fr) !important; }
}
@media (max-width:640px) {
  .woocommerce ul.products, .woocommerce-page ul.products, ul.products { grid-template-columns: repeat(2,1fr) !important; gap: 12px !important; }
}

/* ── FIX: WC clearfix pseudo-elements break CSS Grid ── */
/* ul.products::before & ::after (WC clearfix) take grid cells → push 1st product to col 2 */
.woocommerce ul.products::before,
.woocommerce ul.products::after,
.woocommerce-page ul.products::before,
.woocommerce-page ul.products::after,
ul.products::before,
ul.products::after {
  display: none !important;
  content: none !important;
}
