/**
 * Plik: assets/css/components/product-card.css
 *
 * Odpowiada za:
 * - wygląd karty produktu Cercasa (jak w sekcjach Polecane / brand panel)
 * - siatkę listy produktów na stronie kategorii
 *
 * Nie umieszczać tutaj:
 * - stylów karuzeli home
 * - @import
 *
 * Powiązane pliki:
 * - templates/catalog/_partials/miniatures/product.tpl
 * - assets/js/components/cercasa-product-card.js
 */

.cercasa-product-card {
  --cercasa-pc-text: #1a1a1a;
  --cercasa-pc-muted: #3f4540;
  --cercasa-pc-line: #d5dbd4;
  --cercasa-pc-btn: 2.15rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
  padding: 0 0 0.85rem;
  overflow: hidden;
  color: var(--cercasa-pc-text);
  background: #fff;
  border: 0;
  box-shadow: none;
  font-family: var(--cercasa-font-sans, "Poppins", sans-serif);
}

.cercasa-product-card__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: #fafafa;
  border: 1px solid rgba(26, 26, 26, 0.08);
}

/* Flag / badge — stała szerokość, wycentrowany tekst, CAPS */
.cercasa-product-card .product-flags {
  --cercasa-pc-flag-width: 3.5rem;
  --cercasa-pc-flag-height: 1.45rem;
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 3;
  max-width: calc(100% - 1.1rem);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

.cercasa-product-card .product-flags .badge,
.cercasa-product-card .product-flags li.badge {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box;
  width: var(--cercasa-pc-flag-width) !important;
  min-width: var(--cercasa-pc-flag-width) !important;
  max-width: var(--cercasa-pc-flag-width) !important;
  height: var(--cercasa-pc-flag-height) !important;
  min-height: var(--cercasa-pc-flag-height) !important;
  margin: 0;
  /* lekko więcej paddingu u góry — CAPS optycznie „wiszą” za wysoko */
  padding: 0.12em 0 0 !important;
  overflow: hidden;
  font-family: var(--cercasa-font-sans, "Poppins", sans-serif) !important;
  font-size: 0.62rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em;
  text-indent: 0.06em;
  line-height: 1 !important;
  color: #fff !important;
  text-align: center !important;
  text-overflow: ellipsis;
  text-transform: uppercase !important;
  white-space: nowrap;
  vertical-align: middle;
  background: #111 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12) !important;
}

.cercasa-product-card .product-flags .badge::before,
.cercasa-product-card .product-flags .badge::after {
  content: none !important;
  display: none !important;
}

/* -20% / promocja */
.cercasa-product-card .product-flags .badge.discount,
.cercasa-product-card .product-flags .badge.on-sale {
  color: #fff !important;
  background: #111 !important;
}

/* Nowy — nadpisz niebieski Bootstrap / HB */
.cercasa-product-card .product-flags .badge.new,
.cercasa-product-card .product-flags .badge.bg-primary,
.cercasa-product-card .product-flags .new {
  color: #111 !important;
  background: #fff !important;
  background-color: #fff !important;
  border: 1px solid rgba(17, 17, 17, 0.12) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) !important;
}

/* Pack / inne */
.cercasa-product-card .product-flags .badge.pack {
  color: #111 !important;
  background: #f3f4f6 !important;
  border: 1px solid rgba(17, 17, 17, 0.08) !important;
  box-shadow: none !important;
}

/* Brak na stanie — cały napis, bez obcięcia do szerokości -10% */
.cercasa-product-card .product-flags .badge.out_of_stock,
.cercasa-product-card .product-flags .badge.out-of-stock {
  width: auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: var(--cercasa-pc-flag-height) !important;
  padding: 0.28rem 0.45rem !important;
  overflow: visible;
  letter-spacing: 0.04em;
  text-indent: 0;
  line-height: 1.15 !important;
  white-space: normal;
  text-overflow: clip;
  color: #5a605b !important;
  background: rgba(255, 255, 255, 0.92) !important;
  border: 1px solid rgba(90, 96, 91, 0.22) !important;
  box-shadow: none !important;
}

/* Logo marki — mały kwadrat w prawym górnym rogu zdjęcia */
.cercasa-product-card__brand {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  background: #fff;
  border: 0;
}

.cercasa-product-card__brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.cercasa-product-card__media:has(.cercasa-product-card__brand) .wishlist-button,
.cercasa-product-card__media:has(.cercasa-product-card__brand) .wishlist-button-add {
  top: 2.9rem;
}

/* Wishlist (blockwishlist dokłada .wishlist-button do .thumbnail-container) */
.cercasa-product-card .wishlist-button,
.cercasa-featured__media .wishlist-button,
.cercasa-brandpanel__media .wishlist-button,
.cercasa-brandright__media .wishlist-button {
  position: absolute !important;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 5;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
}

.cercasa-product-card .wishlist-button-add,
.cercasa-featured__media .wishlist-button-add,
.cercasa-brandpanel__media .wishlist-button-add,
.cercasa-brandright__media .wishlist-button-add {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  width: 2.15rem !important;
  height: 2.15rem !important;
  min-width: 2.15rem !important;
  padding: 0.4rem !important;
  overflow: visible !important;
  box-shadow: none !important;
  border: 1px solid rgba(26, 26, 26, 0.1) !important;
  border-radius: 0 !important;
  background: rgba(255, 255, 255, 0.95) !important;
  color: #1a1a1a !important;
  cursor: pointer;
}

.cercasa-product-card .wishlist-button-add:hover {
  opacity: 1 !important;
  background: #fff !important;
}

.cercasa-product-card .wishlist-button-add:active,
.cercasa-featured__media .wishlist-button-add:active,
.cercasa-brandpanel__media .wishlist-button-add:active,
.cercasa-brandright__media .wishlist-button-add:active {
  transform: none !important;
}

.cercasa-product-card .wishlist-button-add .material-icons,
.cercasa-featured__media .wishlist-button-add .material-icons,
.cercasa-brandpanel__media .wishlist-button-add .material-icons,
.cercasa-brandright__media .wishlist-button-add .material-icons {
  display: block !important;
  flex: 0 0 auto;
  width: 1.05rem !important;
  height: 1.05rem !important;
  margin: 0 !important;
  overflow: visible !important;
  font-size: 0 !important;
  line-height: 0 !important;
  color: transparent !important;
  background-color: #1a1a1a;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -1 24 26'%3E%3Cpath fill='black' d='M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -1 24 26'%3E%3Cpath fill='black' d='M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.cercasa-product-card .wishlist-button-add .material-icons.is-filled,
.cercasa-featured__media .wishlist-button-add .material-icons.is-filled,
.cercasa-brandpanel__media .wishlist-button-add .material-icons.is-filled,
.cercasa-brandright__media .wishlist-button-add .material-icons.is-filled {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -1 24 26'%3E%3Cpath fill='black' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -1 24 26'%3E%3Cpath fill='black' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E");
}

.cercasa-product-card__image-link {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  text-decoration: none;
}

.cercasa-product-card__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  padding: 0;
  border: 0;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
  box-sizing: border-box;
  image-rendering: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.cercasa-product-card__image.is-active {
  opacity: 1;
  pointer-events: auto;
}

.cercasa-product-card__segments {
  display: flex;
  gap: 0.25rem;
  margin: 0.45rem 0.65rem 0;
}

.cercasa-product-card__segment {
  flex: 1 1 0;
  height: 2px;
  padding: 0;
  cursor: pointer;
  appearance: none;
  background: #cfd5cc;
  border: 0;
}

.cercasa-product-card__segment.is-active {
  background: var(--cercasa-pc-text);
}

.cercasa-product-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
  padding: 0.7rem 0.65rem 0;
}

.cercasa-product-card__name {
  display: -webkit-box;
  flex: 0 0 auto;
  margin: 0;
  overflow: hidden;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--cercasa-pc-text);
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  /* Stała wysokość 2 linii → kolory zawsze w tej samej linii */
  height: calc(1.35em * 2);
  min-height: calc(1.35em * 2);
  max-height: calc(1.35em * 2);
}

/* Warianty kolorów — mała kropka, pole kliknięcia 44×44 */
.cercasa-product-card__variants {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 0;
  align-items: center;
  height: 2.75rem;
  min-height: 2.75rem;
}

.cercasa-product-card__variants a,
.cercasa-variant-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: none;
  text-decoration: none;
}

.cercasa-variant-swatch__dot {
  display: block;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid rgba(26, 26, 26, 0.15);
  border-radius: 50% !important;
  background-position: center;
  background-size: cover;
}

.cercasa-product-card__variants a.color:not(:has(.cercasa-variant-swatch__dot)) {
  padding: 0.675rem;
  background-clip: content-box;
  background-origin: content-box;
}

.cercasa-product-card__variants a:hover .cercasa-variant-swatch__dot,
.cercasa-product-card__variants a:focus-visible .cercasa-variant-swatch__dot,
.cercasa-product-card__variants a.color:not(:has(.cercasa-variant-swatch__dot)):hover,
.cercasa-product-card__variants a.color:not(:has(.cercasa-variant-swatch__dot)):focus-visible {
  outline: 1px solid #111;
  outline-offset: 1px;
}

.cercasa-product-card .product-list-reviews,
.cercasa-product-card [class*="product-list-reviews"] {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.2;
}

.cercasa-product-card__prices {
  min-width: 0;
}

.cercasa-product-card__name:hover,
.cercasa-product-card__name:focus-visible {
  color: #000;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.cercasa-product-card__meta {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
  align-items: flex-end;
  justify-content: space-between;
  /* Cena + koszyk zawsze na dole karty */
  margin-top: auto;
  padding-top: 0.35rem;
}

.cercasa-product-card__price {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--cercasa-pc-text);
}

.cercasa-product-card__regular {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--cercasa-text-muted, #5a605b);
  text-decoration: line-through;
}

.cercasa-product-card__actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.35rem;
  align-items: center;
}

.cercasa-product-card__cart-form {
  display: inline-flex;
  margin: 0;
}

.cercasa-product-card__cart-btn {
  display: inline-flex !important;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: var(--cercasa-pc-btn) !important;
  height: var(--cercasa-pc-btn) !important;
  min-width: var(--cercasa-pc-btn);
  min-height: var(--cercasa-pc-btn);
  max-width: var(--cercasa-pc-btn);
  max-height: var(--cercasa-pc-btn);
  padding: 0 !important;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid var(--cercasa-pc-text);
  border-radius: 0;
  cursor: pointer;
  color: #fff;
  background: var(--cercasa-pc-text);
  text-decoration: none;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.cercasa-product-card__cart-btn:hover,
.cercasa-product-card__cart-btn:focus-visible {
  background: #000;
  border-color: #000;
  color: #fff;
}

.cercasa-product-card__cart-btn:focus-visible {
  outline: 2px solid #1a1a1a;
  outline-offset: 2px;
}

.cercasa-product-card__cart-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  color: #fff;
  line-height: 0;
}

.cercasa-product-card__cart-icon .cercasa-icon__svg {
  display: block;
  width: 1.1rem;
  height: 1.2rem;
}

/* Lista produktów — pełna szerokość, 6 w rzędzie na desktopie */
#js-product-list .products.cercasa-products,
.products.cercasa-products {
  --cercasa-products-gap: 0.85rem;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--cercasa-products-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  width: 100%;
}

#js-product-list .products.cercasa-products > .cercasa-product-card,
.products.cercasa-products > .cercasa-product-card {
  width: 100%;
  min-width: 0;
  height: 100%;
  align-self: stretch;
}

/* Wyłącz domyślne efekty Hummingbird na karcie Cercasa */
.cercasa-product-card.product-miniature,
.cercasa-product-card .product-miniature__inner {
  box-shadow: none !important;
  transform: none !important;
}

@media (max-width: 1199.98px) {
  #js-product-list .products.cercasa-products,
  .products.cercasa-products {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  #js-product-list .products.cercasa-products,
  .products.cercasa-products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  #js-product-list .products.cercasa-products,
  .products.cercasa-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/*
  PDP rails — tło pasa; karuzela (flex/scroll) jest w pages/product.css
*/
body#product .cercasa-product__footer-hooks {
  --cercasa-rail-gutter: var(--cercasa-pdp-gutter, var(--cercasa-hero-gutter, clamp(1.25rem, 3vw, 3rem)));
  position: relative;
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding-block: 1.85rem 2.15rem;
  padding-inline: 0;
  background-color: #fcfbf9;
  box-shadow: none;
  box-sizing: border-box;
}

body#product .cercasa-product-rail,
body#product .ps-viewedproduct,
body#product .ps-categoryproducts {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 1.5rem;
  background: transparent;
  box-sizing: border-box;
}

body#product .cercasa-product-rail:last-child,
body#product .ps-viewedproduct:last-child,
body#product .ps-categoryproducts:last-child {
  padding-bottom: 0;
}

body#product .cercasa-product-rail .module-products,
body#product .cercasa-product-rail .module-products.container,
body#product .ps-viewedproduct .module-products,
body#product .ps-categoryproducts .module-products {
  width: 100% !important;
  max-width: none !important;
  margin-inline: 0 !important;
  padding-inline: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
  .cercasa-product-card__image,
  .cercasa-product-card__cart-btn {
    transition: none;
  }
}
