/* ==========================================================================
   WooGrub — cards.css
   Product card: horizontal layout, with-photo and no-photo variants.
   ========================================================================== */

/* ── Card base ───────────────────────────────────────────────────────────── */
.wg-product-card {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background-color: var(--wg-surface);
  border: 1px solid var(--wg-border);
  border-radius: var(--wg-radius);
  overflow: hidden;
  cursor: pointer;
  transition:
    box-shadow var(--wg-transition),
    border-color var(--wg-transition),
    transform var(--wg-transition);
  min-height: 100px;
  text-align: left;
  width: 100%;

  /* Ensure the + button can anchor to bottom-right of the card */
  padding-bottom: var(--wg-space-8);
}

@media (hover: hover) {
  .wg-product-card:hover {
    box-shadow: var(--wg-shadow);
    border-color: var(--wg-border-strong);
    transform: translateY(-1px);
  }
}

.wg-product-card:active {
  transform: translateY(0);
  box-shadow: var(--wg-shadow-sm);
}

/* Keyboard focus */
.wg-product-card:focus-visible {
  outline: 2px solid var(--wg-primary);
  outline-offset: 2px;
}

/* ── Thumbnail — with-photo variant ─────────────────────────────────────── */
/* Fixed square sized to roughly match the text column's height
   (title + price + 2-line description), so the image never exceeds
   the card's "natural" content height. */
.wg-product-card--has-image .wg-product-card__image {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  align-self: center;
  overflow: hidden;
  border-radius: var(--wg-radius-sm);
  margin: var(--wg-space-3);
  margin-right: 0;
}

/* Extra clearance below the image so it doesn't crowd the tags row */
.wg-product-card--has-image:has(.wg-product-card__tags .wg-tag-pill) .wg-product-card__image {
  margin-bottom: var(--wg-space-6);
}

.wg-product-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform var(--wg-transition-slow);
}

@media (hover: hover) {
  .wg-product-card:hover .wg-product-card__img {
    transform: scale(1.04);
  }
}

/* ── Body — text content ─────────────────────────────────────────────────── */
.wg-product-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--wg-space-1);
  padding: var(--wg-space-4);
  min-width: 0; /* prevent flex blowout on long titles */
}

/* ── Title ───────────────────────────────────────────────────────────────── */
.wg-product-card__title {
  font-family: var(--wg-font-heading);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--wg-text);
  line-height: 1.3;
  margin: 0;

  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Short description ───────────────────────────────────────────────────── */
.wg-product-card__description {
  font-size: 0.8125rem;
  color: var(--wg-text-muted);
  line-height: 1.45;
  margin: 0;

  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Price — sits below title, above description ─────────────────────────── */
.wg-product-card__price {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--wg-text);
}

.wg-product-card__description {
  margin-top: var(--wg-space-1);
}

/* WooCommerce price elements */
.wg-product-card__price .woocommerce-Price-amount {
  color: var(--wg-text);
}

.wg-product-card__price del {
  color: var(--wg-text-muted);
  font-weight: 400;
  font-size: 0.8125rem;
  margin-right: var(--wg-space-1);
}

.wg-product-card__price ins {
  text-decoration: none;
  color: var(--wg-primary);
}

/* ── Dietary tag pills — aligned with + button, no height impact ─────────── */
.wg-product-card__tags {
  position: absolute;
  left: var(--wg-space-3);
  right: calc(var(--wg-space-3) + 28px + var(--wg-space-2));
  bottom: var(--wg-space-3);
  height: 28px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.wg-product-card__tags .wg-tag-pills {
  flex-wrap: nowrap;
  overflow: hidden;
  width: 100%;
}

.wg-product-card__tags .wg-tag-pill {
  flex-shrink: 0;
  white-space: nowrap;
}

/* "+X" overflow indicator — sizing copied at runtime from a real
   .wg-tag-pill (see shop.js), since pill padding/radius/font come
   from the plugin's wg-front-styles.css and can't be targeted here. */
.wg-product-card__tags .wg-tag-pill--more {
  flex-shrink: 0;
  white-space: nowrap;
  box-sizing: border-box;
  border-color: var(--wg-border);
  background-color: transparent;
  color: var(--wg-text-muted);
}

/* Hidden by JS once overflow is calculated */
.wg-product-card__tags .wg-tag-pill[hidden] {
  display: none;
}

/* ── Circled + button — anchored bottom-right ────────────────────────────── */
.wg-product-card__add {
  position: absolute;
  bottom: var(--wg-space-3);
  right: var(--wg-space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--wg-radius-full);
  background-color: var(--wg-primary);
  color: var(--wg-text-on-primary);
  border: none;
  cursor: pointer;
  transition:
    background-color var(--wg-transition),
    transform var(--wg-transition);
  flex-shrink: 0;

  /* Decorative — card handles the interaction */
  pointer-events: none;
}

@media (hover: hover) {
  .wg-product-card:hover .wg-product-card__add {
    background-color: var(--wg-accent);
    transform: scale(1.1);
  }
}

.wg-product-card__add svg {
  pointer-events: none;
}

/* ── No-photo variant ────────────────────────────────────────────────────── */
.wg-product-card--no-image {
  /* Same horizontal layout, just no image column */
}

.wg-product-card--no-image .wg-product-card__body {
  /* Slightly more padding since there's no image to balance */
  padding: var(--wg-space-4) var(--wg-space-5);
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */
[data-theme="dark"] .wg-product-card {
  background-color: var(--wg-surface);
  border-color: var(--wg-border);
}

[data-theme="dark"] .wg-product-card:hover {
  border-color: var(--wg-border-strong);
  box-shadow: var(--wg-shadow);
}

[data-theme="dark"] .wg-product-card__price .woocommerce-Price-amount {
  color: var(--wg-text);
}
