/*
 * Makerique Boutique theme for OpenCart 4
 * Copyright (c) 2026 Heliopsy. All Rights Reserved.
 * https://makerique.com
 * SPDX-License-Identifier: LicenseRef-Proprietary
 * Proprietary and confidential. Unauthorized copying, distribution, or
 * modification of this file, by any means, is strictly prohibited.
 */

/* =========================================================================
   Makerique Boutique — Product card enhancements
   Second-image-on-hover swap + Sale / New promo ribbons.
   Rendered by catalog event/prodcard.php into product/thumb.twig and
   product/product.twig. Styles off the CSS custom properties in
   makerique.css — do not hard-code colours, radii or timings here.
   (Positioning for .product-thumb .image lives here, NOT in product.css.)
   ========================================================================= */

/* ---- 0. Card layout — never clip the action-button row --------------- */
/* Listing cards (incl. the Featured module) laid out as a flex column so the
   cart / wishlist / COMPARE row can be pinned to the bottom and stays fully
   visible. Only the .image wrapper clips (for the hover-swap); the card and
   its .content must NOT, or the buttons get cut off. */
.product-thumb {
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.product-thumb .content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: visible;
}
.product-thumb .content .description {
  flex: 1 1 auto;
}
/* Pin the action-button form to the bottom of the card. */
.product-thumb .content > form {
  margin-top: auto;
}

/* ---- 1. Image wrapper (hover-swap host) ------------------------------ */
.product-thumb .image {
  position: relative;
  overflow: hidden;
  border-radius: var(--mr-radius);
}
.product-thumb .image > a {
  display: block;
  position: relative;
  /* Fixed square crop box so every card image is uniform regardless of the
     source aspect ratio. Without an explicit height, object-fit:cover below is
     inert and a tall/large source image blows the card out (grid overlap). */
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

/* Both images share the same box so the hover image sits exactly over the main one. */
.product-thumb .image .mr-main-img,
.product-thumb .image .mr-hover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--mr-radius);
}

/* List view drives image height from the row instead of a square crop box —
   let the image fill the row (its own rules in listing.css set height:100%). */
.mr-listing--list .product-thumb .image > a,
#product-list.product-list .product-thumb .image > a {
  aspect-ratio: auto;
  height: 100%;
}

.product-thumb .image .mr-hover-img {
  position: absolute;
  inset: 0;
  height: 100%;
  opacity: 0;
  transition: opacity var(--mr-transition);
  pointer-events: none;
}
.product-thumb:hover .image .mr-hover-img,
.product-thumb:focus-within .image .mr-hover-img {
  opacity: 1;
}

/* ---- 2. Promo label ribbons ------------------------------------------ */
/* Top-RIGHT corner: the product-type badge stack (Physical/Digital/…) owns the
   top-left, so promo labels sit opposite it — otherwise the two absolutely-
   positioned stacks overlap and the labels mash together ("NEW" over "PHYSICAL"
   reading as "NEW …CAL"). */
.mr-label-stack {
  position: absolute;
  top: .6rem;
  right: .6rem;
  left: auto;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .35rem;
  pointer-events: none;
}

.mr-label {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: var(--mr-radius-pill);
  font-family: var(--mr-font-heading, inherit);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fff;
  box-shadow: var(--mr-shadow);
  white-space: nowrap;
}
.mr-label--sale       { background: var(--mr-sale); }
.mr-label--new        { background: var(--mr-badge-rts); }
.mr-label--soldout    { background: var(--mr-muted, #6b6b6b); }
.mr-label--lowstock   { background: var(--mr-warning, #d98324); }
.mr-label--bestseller { background: var(--mr-accent, #e91e63); }
/* Custom badge: theme primary unless an inline background colour is supplied. */
.mr-label--custom     { background: var(--mr-primary, #333); }

/* Inline variant for the product detail page (flows above the title). */
.mr-label-stack--inline {
  position: static;
  flex-direction: row;
  flex-wrap: wrap;
  margin-bottom: .6rem;
}

/* ---- 3. Reduced motion ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .product-thumb .image .mr-hover-img {
    transition: none;
  }
}
