/*
 * Karty produktow (P32, zgloszenie #533, image-21.png): sklep Blocksy, siatka
 * Elementora na /sklep-2/, kategorie i blok "Nowe w sklepie" w pustym koszyku.
 * Obrazek na gorze karty od krawedzi do krawedzi, tresc z odstepem jak karty
 * oferty na stronie glownej (24-26 px), przycisk zawsze na dole karty.
 * Siatka 3/2/1 kolumny na cala szerokosc kontenera strony.
 *
 * Pierwszy selektor w :is() podnosi wage do poziomu reguly z strony.css
 * (.elementor ul.products.elementor-grid z !important), inaczej ona wygrywa.
 */
html body {
  --ss-karta-odstep: clamp(20px, 2vw, 26px);
}

html body :is(.elementor ul.products.elementor-grid, ul.products, .wc-block-grid__products) {
  display: grid !important;
  grid-template-columns: repeat(var(--ss-karty-kolumny, 3), minmax(0, 1fr)) !important;
  gap: clamp(20px, 2.4vw, 32px) !important;
  align-items: stretch !important;
  justify-content: center;
  width: 100%;
  margin: 0 auto !important;
  padding: 0 !important;
  list-style: none;
}
/* Blok "Nowe w sklepie" (pusty koszyk) ma stale 4 produkty: przy 3 kolumnach czwarty zostawal sam w wierszu. */
html body .wc-block-grid.has-4-columns .wc-block-grid__products { --ss-karty-kolumny: 4; }
@media (max-width: 999px) {
  html body :is(.elementor ul.products.elementor-grid, ul.products, .wc-block-grid__products) { --ss-karty-kolumny: 2; }
}
@media (max-width: 599px) {
  html body :is(.elementor ul.products.elementor-grid, ul.products, .wc-block-grid__products) { --ss-karty-kolumny: 1; }
}

html body :is(.elementor ul.products.elementor-grid, ul.products, .wc-block-grid__products) > :is(li.product, .wc-block-grid__product) {
  display: flex !important;
  flex-direction: column;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 0 var(--ss-karta-odstep) !important;
  background: var(--ss-karta);
  border: 1px solid var(--ss-linia);
  border-radius: var(--ss-promien);
  box-shadow: var(--ss-cien);
  overflow: hidden;
  text-align: left;
}

/* Obrazek: gora karty, zaokraglone tylko gorne rogi (dolne zakrywa tresc). */
html body :is(ul.products, .wc-block-grid__products) :is(li.product > figure, .wc-block-grid__product-image) {
  margin: 0 0 20px !important;
  border-radius: calc(var(--ss-promien) - 1px) calc(var(--ss-promien) - 1px) 0 0 !important;
  overflow: hidden;
}
html body ul.products li.product .ct-media-container { border-radius: inherit !important; }
html body :is(ul.products li.product .ct-media-container, .wc-block-grid__product-image) { display: block; line-height: 0; }
html body :is(ul.products li.product .ct-media-container, .wc-block-grid__product-image) img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover;
  border-radius: 0 !important;
}

/* Tresc karty: odstep od bokow. Margines, nie padding, zeby nie ruszac tla elementow. */
html body ul.products li.product > :not(figure),
html body .wc-block-grid__product > :not(.wc-block-grid__product-link),
html body .wc-block-grid__product-link > :not(.wc-block-grid__product-image) {
  margin-inline: var(--ss-karta-odstep) !important;
}
html body .wc-block-grid__product-link { display: flex; flex-direction: column; text-decoration: none; }
html body ul.products li.product .woocommerce-loop-product__title,
html body .wc-block-grid__product-title { margin-top: 0 !important; margin-bottom: 10px !important; }
html body .wc-block-grid__product-title { font-family: var(--ss-serif); font-size: 20px !important; line-height: 1.25; color: var(--ss-espresso); }
html body .wc-block-grid__product-price { margin-bottom: 8px !important; color: var(--ss-espresso); font-weight: 700; }

/* Przycisk zawsze na dole karty, w jednej linii w calym wierszu. */
html body ul.products li.product .ct-woo-card-actions,
html body .wc-block-grid__product .wc-block-grid__product-add-to-cart {
  margin-top: auto !important;
  padding-top: 18px;
  margin-bottom: 0 !important;
}
html body ul.products li.product .ct-woo-card-actions .button,
html body .wc-block-grid__product .wp-block-button__link { margin: 0 !important; }
