/* ==========================================================================
   Component: product-card  →  snippets/card-product.liquid + assets/component-card.css
   Figma: Product Card component 1164-2378 (hover state). 327×440 image box at 1440,
   12px gap to the info block; hover/focus swaps title → sizes, "n Colors" → swatches,
   reveals the compare-at price and the "ADD TO CART" bar. Hovering or focusing the eye
   opens the "Quick View" pill.
   Per-card image settings on .product-card__media:
     --card-bg                       image box background (default: Figma's white → #f3f3f3 radial)
     --focal-x / --focal-y / --zoom  cover images (same model as the hero)
     --img-x / --img-y / --img-w / --img-h  cut-out images placed inside the box
   ========================================================================== */
.product-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Image box */
.product-card__media {
  position: relative;
  aspect-ratio: 327 / 440;
  overflow: hidden;
  background: var(--card-bg, radial-gradient(53.31% 53.31% at 50% 46.69%, #ffffff 0%, #f3f3f3 100%));
}

.product-card__image-link {
  position: absolute;
  inset: 0;
  display: block;
}

.product-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focal-x, 50%) var(--focal-y, 50%);
  transform: scale(var(--zoom, 1));
  transform-origin: var(--focal-x, 50%) var(--focal-y, 50%);
}

.product-card__image--cutout {
  inset: auto;
  top: var(--img-y, 0);
  left: var(--img-x, 0);
  width: var(--img-w, 100%);
  max-width: none; /* cut-outs may be wider than the box (Figma card 3: 424px in a 327px box) */
  height: var(--img-h, auto);
  transform: none;
  filter: var(--img-shadow, none);
}

/* Badges — 12px inset, 4px apart, sharing a 20px row with the quick-view pill (so the 18px
   badges sit at 13px); Label/S (Inter 500 10px / 1) on a 2px radius */
.product-card__badges {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  pointer-events: none;
}

/* The white badge has a 0.5px #e2e2e2 stroke drawn inside the box, as Figma does: no added size */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--width-whole-px);
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-white);
  box-shadow: inset 0 0 0 0.5px var(--color-border-tertiary);
  color: var(--color-text-secondary);
  font-size: var(--text-label-s-size);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.badge--sale {
  background: var(--color-success);
  box-shadow: none;
  color: var(--color-white);
}

.badge--sold-out {
  background: var(--color-sold-out);
  box-shadow: none;
  color: var(--color-white);
}

/* Quick view — 18px eye, top right, #6f6f6f → #080808 while the card is hovered */
.product-card__quick-view {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: block;
  color: var(--color-icon-secondary);
  transition: color var(--duration-fast) ease;
}

.product-card:hover .product-card__quick-view,
.product-card:focus-within .product-card__quick-view {
  color: var(--color-icon-primary);
}

/* Hovering or focusing the eye opens the pill over it: "Quick View" + 12px eye on #080808,
   4px padding, 2px radius, revealed right to left. It is part of the button, so pointing
   at the pill keeps it open; while closed it ignores the pointer. */
.product-card__quick-view-label {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-primary);
  color: var(--color-text-inverse);
  font-size: var(--text-label-s-size);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  clip-path: inset(0 0 0 100% round var(--radius-sm));
  pointer-events: none;
  transition: clip-path var(--duration-fast) var(--ease-out), opacity var(--duration-fast) ease;
}

.product-card__quick-view-label > span {
  width: var(--width-whole-px);
}

.product-card__quick-view-label .icon-eye-small {
  color: var(--color-icon-inverse);
}

/* Open, the clip reaches 4px past the pill so the keyboard focus ring (2px + 2px offset) shows */
.product-card__quick-view:hover .product-card__quick-view-label,
.product-card__quick-view:focus-visible .product-card__quick-view-label {
  opacity: 1;
  clip-path: inset(-4px round calc(var(--radius-sm) + 4px));
  pointer-events: auto;
}

/* Add to cart — 32px bar inset 8px, Button/M (4% tracking), hidden until hover / keyboard focus */
.product-card__atc {
  position: absolute;
  z-index: 2;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--color-black);
  color: var(--color-white);
  font-size: var(--text-body-s-size);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.product-card:hover .product-card__atc,
.product-card:focus-within .product-card__atc {
  opacity: 1;
  transform: translateY(0);
}

.product-card__atc:disabled {
  background: var(--color-sold-out);
  cursor: default;
}

/* Info block — title/sizes 14px row, price 17px row, meta 14px row */
.product-card__info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px;
}

.product-card__main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-card__title {
  font-size: var(--text-body-s-size);
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card__sizes {
  display: none;
  align-items: center;
  gap: 16px;
  font-size: var(--text-body-s-size);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.product-card__sizes-label {
  color: var(--color-text-disabled);
  text-transform: uppercase;
}

/* Whole-pixel text boxes, as Figma lays out the size row and the price pair */
.product-card__sizes-label,
.product-card__size,
.product-card__price > * {
  width: var(--width-whole-px);
}

.product-card__size-list {
  display: flex;
  align-items: center;
  gap: 24px;
}

.product-card__size {
  color: var(--color-text-primary);
  transition: color var(--duration-fast) ease;
}

.product-card__size:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.product-card__size:disabled {
  color: var(--color-text-disabled);
  cursor: default;
  text-decoration: none;
}

.product-card__price {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-body-m-size);
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.product-card__price-compare {
  display: none;
  font-size: var(--text-body-s-size);
  color: var(--color-text-disabled);
  text-decoration: line-through;
}

.product-card__meta {
  display: flex;
  align-items: center;
  min-height: 14.4px;
  font-size: var(--text-body-s-size);
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-text-tertiary);
}

/* Top-aligned: Figma's hover row is just the 12px swatches, while the row keeps the 14.4px
   height of "n Colors" so the card does not change height on hover */
.product-card__swatches {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 8px;
}

/* 0.5px stroke as an inset shadow: a 0.5px border is drawn as a full device pixel at 1x,
   while Figma (and the shadow) render it at half strength */
.product-card__swatch {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  background: var(--swatch, #ffffff);
  box-shadow: inset 0 0 0 0.5px var(--color-border-secondary);
}

/* Hover / keyboard state — Figma card 3 */
.product-card:hover .product-card__title,
.product-card:focus-within .product-card__title,
.product-card:hover .product-card__colors,
.product-card:focus-within .product-card__colors {
  display: none;
}

.product-card:hover .product-card__sizes,
.product-card:focus-within .product-card__sizes,
.product-card:hover .product-card__swatches,
.product-card:focus-within .product-card__swatches {
  display: flex;
}

.product-card:hover .product-card__price-compare,
.product-card:focus-within .product-card__price-compare {
  display: inline;
}

/* The open pill covers the eye, so it carries the focus ring instead */
.product-card__quick-view:focus-visible {
  outline: none;
}

.product-card__quick-view:focus-visible .product-card__quick-view-label,
.product-card__atc:focus-visible,
.product-card__size:focus-visible,
.product-card__swatch:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .product-card__atc {
    transition: none;
    transform: none;
  }

  .product-card__quick-view-label {
    transition: none;
  }
}

/* Touch devices have no hover: keep the default rows, but still show the cart bar on tap/focus */
@media (hover: none) {
  .product-card:hover .product-card__title,
  .product-card:hover .product-card__colors {
    display: block;
  }

  .product-card:hover .product-card__sizes,
  .product-card:hover .product-card__swatches {
    display: none;
  }

  .product-card:hover .product-card__price-compare {
    display: none;
  }
}
