/*
 * Product Card — Borderless Uniform Grid.
 *
 * No border, no shadow, no radius. Image 1:1. CTA always visible.
 * Reused across: shop archive (5-col), category (4-col), related (4-col),
 * upsell/cross-sell (3-col) — only grid column count changes per context.
 *
 * Ordering: card base → image → nth-child placeholder colours → title →
 *   price → CTA → hover → grid (5-col default) → responsive → reduced motion.
 * No > * reset: card uses flex-vertical (no WP flow margins on children).
 *
 * Tokens read:
 *   color.terracotta.*           — CTA hover, nth-child placeholders
 *   color.green.*                — nth-child placeholders
 *   color.neutral.*              — nth-child placeholders
 *   semantic.color.text.primary  — title
 *   semantic.color.text.muted    — price, CTA default
 *   semantic.typography.display  — title (Cormorant Garamond)
 *   semantic.typography.body     — price, CTA (Inter)
 *   space.1 / space.2 / space.4 / space.5 / space.6
 *   duration.base / easing.default
 */

/* --- Card container ------------------------------------------------- */

.wpdl-product-card.wp-block-group {
  position: relative; /* badge overlay anchor */
  margin-block: 0;
  gap: 0;
  cursor: pointer;
}

/* --- Product image -------------------------------------------------- */

.wpdl-product-card__img.wp-block-image {
  /* WP sets .wp-block-image figure to width:fit-content; the 1×1 placeholder
     SVG collapses it to 1px. Force full card width so the 1:1 image zone renders. */
  position: relative;
  inline-size: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--wp--custom--radius--sm);
  margin-block: 0 var(--wp--custom--space--4);
}

/* Overlay — transparent by default, fades to dark on hover */
.wpdl-product-card__img.wp-block-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgb(0 0 0 / 0%);
  transition: background-color var(--wp--custom--duration--base) var(--wp--custom--easing--default);
  pointer-events: none;
}

.wpdl-product-card__img.wp-block-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--wp--custom--duration--base) var(--wp--custom--easing--default);
}

/* --- Placeholder colours (P4 demo — replaced by real photos at P9) -- */

.wpdl-product-card:nth-child(1)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--accent--primary); }
.wpdl-product-card:nth-child(2)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--brand--primary); }
.wpdl-product-card:nth-child(3)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--brand--primary); }
.wpdl-product-card:nth-child(4)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--text--muted); }
.wpdl-product-card:nth-child(5)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--accent--primary); }
.wpdl-product-card:nth-child(6)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--border--subtle); }
.wpdl-product-card:nth-child(7)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--brand--soft); }
.wpdl-product-card:nth-child(8)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--accent--primary); }
.wpdl-product-card:nth-child(9)  .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--focus--ring); }
.wpdl-product-card:nth-child(10) .wpdl-product-card__img.wp-block-image { background-color: var(--wp--custom--semantic--color--text--secondary); }

/* --- Title ---------------------------------------------------------- */

.wpdl-product-card__title {
  font-family: var(--wp--custom--semantic--typography--display--font-family);
  font-size: 1.0625rem;   /* 17px */
  font-weight: 500;
  line-height: 1.25;
  color: var(--wp--custom--semantic--color--text--primary);
  margin-block: 0 var(--wp--custom--space--2);
}

/* --- Price ---------------------------------------------------------- */

.wpdl-product-card__price {
  font-family: var(--wp--custom--semantic--typography--body--font-family);
  font-size: 0.8125rem;   /* 13px */
  font-weight: 400;
  color: var(--wp--custom--semantic--color--text--muted);
  margin-block: 0 var(--wp--custom--space--1);
}

/* --- Badge — absolute overlay, top-left of image ------------------- */

.wpdl-product-card__badge.wp-block-group {
  position: absolute;
  top: var(--wp--custom--space--3);
  inset-inline-start: var(--wp--custom--space--3);
  z-index: 1;
  margin-block: 0;
  padding-block: var(--wp--custom--space--1);
  padding-inline: var(--wp--custom--space--2);
  background-color: var(--wp--custom--semantic--color--accent--primary);
  border-radius: var(--wp--custom--radius--sm);
  gap: var(--wp--custom--space--1);
  align-items: center;
  pointer-events: none;
}

.wpdl-product-card__badge .wpdl-icon {
  width: 0.75rem;
  height: 0.75rem;
  color: rgb(255 255 255);
  flex-shrink: 0;
}

.wpdl-product-card__badge-label {
  font-family: var(--wp--custom--semantic--typography--body--font-family);
  font-size: 0.5625rem;   /* 9px */
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgb(255 255 255);
  margin-block: 0;
}

/* --- CTA — always visible ------------------------------------------ */

.wpdl-product-card__cta {
  font-family: var(--wp--custom--semantic--typography--body--font-family);
  font-size: 0.6875rem;   /* 11px */
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wp--custom--semantic--color--text--muted);
  margin-block: 0;
  min-block-size: 2.75rem; /* 44px touch target */
  display: flex;
  align-items: center;
  transition:
    color     var(--wp--custom--duration--base) var(--wp--custom--easing--default),
    translate var(--wp--custom--duration--base) var(--wp--custom--easing--default);
}

/* --- Hover (desktop only) ------------------------------------------ */

.wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__img.wp-block-image img {
  transform: scale(1.03);
}

.wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__img.wp-block-image::after {
  background-color: rgb(0 0 0 / 8%);
}

.wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__cta {
  color: var(--wp--custom--semantic--color--accent--primary);
  translate: var(--wp--custom--space--1) 0;
}

/* --- Section outer wrapper (constrained, handles padding + max-width) --- */

.wpdl-product-card-grid.wp-block-group {
  padding-inline: var(--wp--custom--space--7); /* 32px section inset */
}

/* Reset WP constrained-layout top margin on inner items group */
.wpdl-product-card-grid > .wpdl-product-card-grid__items {
  margin-block: 0;
  margin-inline: 0;
  max-width: 100%;
}

/* --- Inner grid (direct display:grid, children not constrained) --------- */

.wpdl-product-card-grid__items.wp-block-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--wp--custom--space--5);   /* 20px */
}

/* Cards are children of flow inner group — no constrained margin treatment */
.wpdl-product-card-grid__items > .wpdl-product-card {
  margin-block: 0;
}

/* --- 4-col homepage featured (--4col modifier on outer wrapper) --------- */

.wpdl-product-card-grid--4col .wpdl-product-card-grid__items.wp-block-group {
  grid-template-columns: repeat(4, 1fr);
  gap: var(--wp--custom--space--6);   /* 24px */
  max-width: 90rem;    /* 1440px — stops growing on ultra-wide screens */
  margin-inline: auto; /* center when viewport > 1440px */
}

/* Portrait image for 4-col homepage: taller, more impactful for flowers.
   stylelint: selector order intentional — sets aspect-ratio only; nth-child
   rules above set background-color. No cascade conflict on same property. */
/* stylelint-disable-next-line no-descending-specificity */
.wpdl-product-card-grid--4col .wpdl-product-card__img.wp-block-image {
  aspect-ratio: 4 / 5;
}

/* --- Tablet (< 64em / 1024px) -------------------------------------- */

@media (width < 64em) {
  .wpdl-product-card-grid__items.wp-block-group {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--wp--custom--space--5);
  }

  .wpdl-product-card-grid--4col .wpdl-product-card-grid__items.wp-block-group {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--wp--custom--space--4);
  }

  .wpdl-product-card__title {
    font-size: 0.875rem;  /* 14px */
  }

  .wpdl-product-card__price {
    font-size: 0.6875rem; /* 11px */
  }

  .wpdl-product-card__cta {
    font-size: 0.5625rem; /* 9px */
  }
}

/* --- Mobile (< 40em / 640px) --------------------------------------- */

@media (width < 40em) {
  .wpdl-product-card-grid__items.wp-block-group {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--wp--custom--space--4);
  }

  .wpdl-product-card-grid--4col .wpdl-product-card-grid__items.wp-block-group {
    gap: var(--wp--custom--space--3);  /* 12px tighter gap on phone */
  }
}

/* --- Reduced motion ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .wpdl-product-card__img.wp-block-image img,
  .wpdl-product-card__cta {
    transition: none;
  }

  .wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__cta {
    color: var(--wp--custom--semantic--color--accent--primary);
  }
}

/* =============================================================================
   WC P8 — woocommerce/product-collection integration
   Selectors mirror the static card rules above, targeting WC block class names.
   Requires WC 8.0+ (product-collection block). Verify in wp-env at P8.
   ============================================================================= */

/* Override WC's flex grid with our CSS grid.
   WC loads after theme at equal specificity, so we add .is-flex-container to the
   ul selector: (0,4,0) beats WC's (0,2,0) on the ul, (0,4,1) beats WC's (0,3,1)
   on > li — ensuring our grid layout wins regardless of stylesheet order. */
.wpdl-product-card-grid--4col .wpdl-product-collection .wc-block-product-template.is-flex-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--wp--custom--space--6);
  max-width: 90rem;
  margin-inline: auto;
  list-style: none;
  padding: 0;
  margin-block: 0;
}

/* Reset WC's per-item width (calc(25% - gap)) — in grid context this calculates
   against the track width not the container, collapsing each li to ~65px. */
.wpdl-product-card-grid--4col .wpdl-product-collection .wc-block-product-template.is-flex-container > li {
  width: auto;
  margin: 0;
}

/* WC product image (woocommerce/product-image) — mirrors .wp-block-image rules */
.wpdl-product-card__img.wp-block-woocommerce-product-image {
  position: relative;
  inline-size: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: var(--wp--custom--radius--sm);
  margin-block: 0 var(--wp--custom--space--4);
}

.wpdl-product-card__img.wp-block-woocommerce-product-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgb(0 0 0 / 0%);
  transition: background-color var(--wp--custom--duration--base) var(--wp--custom--easing--default);
  pointer-events: none;
}

/* stylelint-disable-next-line no-descending-specificity -- WC section intentionally after static rules */
.wpdl-product-card__img.wp-block-woocommerce-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--wp--custom--duration--base) var(--wp--custom--easing--default);
}

/* WC product title link — reset browser underline */
.wpdl-product-card .wpdl-product-card__title a {
  color: inherit;
  text-decoration: none;
}

/* WC price — sale price <ins> loses underline and reads in badge-sale gold
   (matches the SALE badge) so a discount is scannable at a glance; original
   <del> is muted. */
.wpdl-product-card .wpdl-product-card__price ins {
  text-decoration: none;
  color: var(--wp--custom--semantic--color--badge--sale);
  font-weight: 500;
}

.wpdl-product-card .wpdl-product-card__price del {
  opacity: 0.55;
}

/* WC add-to-cart button rendered inside .wpdl-product-card__cta div */
.wpdl-product-card .wpdl-product-card__cta .wc-block-components-product-button__button {
  font-family: var(--wp--custom--semantic--typography--body--font-family);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wp--custom--semantic--color--text--muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  min-block-size: 2.75rem;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition:
    color     var(--wp--custom--duration--base) var(--wp--custom--easing--default),
    translate var(--wp--custom--duration--base) var(--wp--custom--easing--default);
}

/* Hover — WC image */
.wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__img.wp-block-woocommerce-product-image img {
  transform: scale(1.03);
}

.wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__img.wp-block-woocommerce-product-image::after {
  background-color: rgb(0 0 0 / 8%);
}

/* Hover — WC add-to-cart button */
.wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__cta .wc-block-components-product-button__button {
  color: var(--wp--custom--semantic--color--accent--primary);
  translate: var(--wp--custom--space--1) 0;
}

/* --- Showcase: hover-reveal Add-to-Cart button (media overlay) ------
   Only applies where the .wpdl-product-card__media wrapper exists
   (product-showcase). Other card consumers keep the in-flow text CTA. */
.wpdl-product-card__media {
  position: relative;
  z-index: 1; /* keep image link + hover cart button above the card-wide stretched link */
  overflow: hidden;
  border-radius: var(--wp--custom--radius--sm);
  margin-block: 0 var(--wp--custom--space--4);
}

/* Whole card → product detail: stretch the title link over the entire card.
   Only for showcase media cards (:has __media). The image and the hover
   Add-to-Cart button sit inside __media (z-index:1) above this link, so
   clicking the button adds to cart while clicking anywhere else opens detail. */
.wpdl-product-card:has(.wpdl-product-card__media) .wpdl-product-card__title a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Media wrapper owns the radius + clip; inner image drops its own. */
/* stylelint-disable no-descending-specificity -- sets margin/radius only; nth-child rules above set background-color, no cascade conflict */
.wpdl-product-card__media .wpdl-product-card__img.wp-block-woocommerce-product-image,
.wpdl-product-card__media .wpdl-product-card__img.wp-block-image {
  margin-block: 0;
  border-radius: 0;
}
/* stylelint-enable no-descending-specificity */

/* Actions are a solid bar overlaying the image bottom. Mobile-first: the bar
   is always visible (touch has no hover, so it must never be hidden). No
   in-flow white gap, no reordering before the title. */
.wpdl-product-card__media .wpdl-product-card__cta--cart {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  margin: 0;
  min-block-size: 0;
}

/* Desktop (>= 64em): hide the bar until the card is hovered or keyboard-
   focused. Width-based only — no hover / pointer / device detection, no JS. */
@media (width >= 64em) {
  .wpdl-product-card__media .wpdl-product-card__cta--cart {
    opacity: 0;
    translate: 0 100%;
    transition:
      opacity   var(--wp--custom--duration--base) var(--wp--custom--easing--default),
      translate var(--wp--custom--duration--base) var(--wp--custom--easing--default);
  }

  .wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__media .wpdl-product-card__cta--cart {
    opacity: 1;
    translate: 0 0;
  }
}

/* Solid brand button — overrides the text-link styling above (higher specificity). */
.wpdl-product-card .wpdl-product-card__media .wpdl-product-card__cta--cart .wc-block-components-product-button__button {
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: 100%;
  min-block-size: 2.25rem; /* 36px — compact */
  padding-block: var(--wp--custom--space--1);
  padding-inline: var(--wp--custom--space--2);
  font-size: 0.625rem; /* 10px */
  letter-spacing: 0.06em;
  background-color: var(--wp--custom--semantic--color--brand--primary);
  color: var(--wp--custom--semantic--color--text--on-brand);
  translate: 0;
}

.wpdl-product-card:is(:hover, :focus-within) .wpdl-product-card__media .wpdl-product-card__cta--cart .wc-block-components-product-button__button {
  color: var(--wp--custom--semantic--color--text--on-brand);
  translate: 0;
}

.wpdl-product-card .wpdl-product-card__media .wpdl-product-card__cta--cart .wc-block-components-product-button__button:hover {
  background-color: var(--wp--custom--semantic--color--brand--strong);
}

@media (prefers-reduced-motion: reduce) {
  .wpdl-product-card__media .wpdl-product-card__cta--cart {
    transition: none;
  }
}

/* Tablet */
@media (width < 64em) {
  .wpdl-product-card-grid--4col .wpdl-product-collection .wc-block-product-template.is-flex-container {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--wp--custom--space--4);
  }
}

/* Mobile */
@media (width < 40em) {
  .wpdl-product-card-grid--4col .wpdl-product-collection .wc-block-product-template.is-flex-container {
    gap: var(--wp--custom--space--3);
  }
}

/* Reduced motion — WC image + button */
@media (prefers-reduced-motion: reduce) {
  .wpdl-product-card__img.wp-block-woocommerce-product-image img,
  .wpdl-product-card .wpdl-product-card__cta .wc-block-components-product-button__button {
    transition: none;
  }
}
