/* ==========================================================================
   PRODUCT CARD
   Layout 1/3 per listing a 3 colonne
   ========================================================================== */

.s4w-product-card {
  flex: 0 0 calc(33.333% - 14px);
  max-width: calc(33.333% - 14px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--stroke-soft-200);
  border-right: none;
}

.s4w-product-card:last-child {
  border-right: 1px solid var(--stroke-soft-200);
}

.s4w-product-card__link {
  border: 1px solid var(--stroke-soft-200);
  border-right: none; /* evita doppio bordo */
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

/* Ultima card recupera il bordo destro */
.s4w-product-card:last-child .s4w-product-card__link {
  border-right: 1px solid var(--stroke-soft-200);
}

.s4w-product-card__link:hover .s4w-product-card__image {
  transform: scale(1.025);
  transition: transform 0.5s ease-out;
}

/* Media */
.s4w-product-card__media {
  width: 100%;
  overflow: hidden;
  margin-bottom: 0;
  background-color: var(--bg-weak-100, #f8f7f6);
  position: relative;
  aspect-ratio: 3 / 4;
}

.s4w-product-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  transition: opacity 0.6s ease;
}

/* Meta: formati + annate */
.s4w-product-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.s4w-product-card__formati {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.s4w-product-card__formato-btn {
  border: 1px solid var(--stroke-soft-200);
  border-radius: 0;
  background: var(--bg-white-0);
  padding: 4px 10px;
  margin-left: -1px;
  font-family: var(--font-primary);
  font-size: var(--paragraph-small);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
  line-height: 1.4;
}

.s4w-product-card__formato-btn:first-child {
  margin-left: 0;
}

.s4w-product-card__formato-btn:hover {
  border-color: var(--text-main-900);
  position: relative;
  z-index: 1;
}

.s4w-product-card__formato-btn.is-active {
  border-color: var(--text-main-900);
  background: var(--bg-weak-100);
  position: relative;
  z-index: 1;
}

.s4w-product-card__annate {
  font-family: var(--font-secondary);
  font-size: var(--paragraph-small)
  color: var(--text-sub-500);
  white-space: nowrap;
  margin-left: auto;
}

/* Contenuto */
.s4w-product-card__content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.s4w-product-card__name {
  font-family: var(--font-secondary);
  font-size: 22px;
  font-weight: var(--weight-regular);
  text-transform: none;
  margin: 0 0 10px 0;
  color: var(--text-main-900);
}

.s4w-product-card__denominazione {
  font-family: var(--font-secondary);
  font-size: var(--paragraph-medium);
  color: var(--text-main-900);
  margin: 0 0 8px 0;
}

.s4w-product-card__desc {
  font-family: var(--font-secondary);
  font-size: var(--paragraph-medium);
  color: var(--text-sub-500);
  margin: 0 0 16px 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.6;
}

.s4w-product-card__price {
  margin-top: auto;
  font-family: var(--font-primary);
  font-size: var(--paragraph-medium);
  color: var(--text-main-900);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.s4w-product-card__price-prefix {
  font-size: var(--paragraph-medium);
  font-weight: var(--weight-medium);
  letter-spacing: 0.05em;
}

.s4w-product-card__price-value {
  font-size: var(--paragraph-medium);
  font-weight: var(--weight-medium);
  font-family: var(--font-primary);
}
/* Body card (tutto tranne l'immagine) */
.s4w-product-card__body {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Link immagine */
.s4w-product-card__media-link {
  display: block;
  overflow: hidden;
  padding: 20px;
}

.s4w-product-card__media-link:hover .s4w-product-card__image {
  transform: scale(1.025);
  transition: transform 0.5s ease-out;
}

/* Link nome */
.s4w-product-card__name-link {
  text-decoration: none;
  color: inherit;
}

.s4w-product-card__name-link:hover .s4w-product-card__name {
  text-decoration: none;
}

/* Rimuovi il padding dal link precedente (ora è sul body) */
.s4w-product-card__link {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}
/* ==========================================================================
   LISTING WRAPPER (usato in upsell e altri listing)
   ========================================================================== */
.s4w-product-correlati {
  padding:  96px  0 0;
  background-color: var(--bg-white-0);
}
.s4w-product-correlati.s4w-product-contains {
  padding: 0 0 96px 0;
}
.s4w-product-correlati__header {
  margin-bottom: 40px;
}

.s4w-product-correlati__wrapper {
  display: flex;
  gap: 0;
}

/* Card dentro il wrapper confezione: azzera flex e occupa tutta la cella griglia */
/* Tutti e 4 i bordi espliciti su ogni card — border-collapse.js li gestirà per evitare doppioni */
.s4w-product-contains__wrapper .s4w-product-card {
  flex: none;
  max-width: none;
  width: 100%;
  border: 1px solid var(--bg-soft-200, #e2e4e9);
}

.s4w-product-contains__wrapper .s4w-product-card__media-link:hover .s4w-product-card__image {
  transform: none;
  transition: none;
}

/* ==========================================================================
   PRODUCT GRID (listing negozio, archivi, tassonomie)
   ========================================================================== */
.s4w-product-grid {
  display: flex;
  flex-wrap: wrap;
}

/* Nelle griglie la card occupa 1/3 con bordi condivisi */
.s4w-product-grid .s4w-product-card {
  flex: 0 0 33.333%;
  max-width: 33.333%;
}

/* Rimuovi bordo destro ogni 3a card */
.s4w-product-grid .s4w-product-card:nth-child(3n) {
  border-right: 1px solid var(--stroke-soft-200);
}

/* Aggiungi bordo top dalla seconda riga in poi */
.s4w-product-grid .s4w-product-card:nth-child(n + 4) {
  border-top: none;
}

@media (max-width: 1024px) {
  .s4w-product-grid .s4w-product-card {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .s4w-product-grid .s4w-product-card:nth-child(3n) {
    border-right: none;
  }

  .s4w-product-grid .s4w-product-card:nth-child(2n) {
    border-right: 1px solid var(--stroke-soft-200);
  }
}

@media (max-width: 768px) {
  .s4w-product-grid .s4w-product-card {
    flex: 0 0 100%;
    max-width: 100%;
    border-right: 1px solid var(--stroke-soft-200);
  }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1024px) {
  .s4w-product-contains .s4w-product-correlati__wrapper {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .s4w-product-contains .s4w-product-card {
    border-right: none;
  }

  .s4w-product-contains .s4w-product-card:nth-child(2n) {
    border-right: 1px solid var(--stroke-soft-200);
  }

  .s4w-product-card {
    flex: 0 0 calc(50% - 10px);
    max-width: calc(50% - 10px);
  }
}

@media (max-width: 768px) {
  .s4w-product-contains .s4w-product-correlati__wrapper {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .s4w-product-contains .s4w-product-card {
    border-right: 1px solid var(--stroke-soft-200);
  }

  .s4w-product-card {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .s4w-product-card__desc {
    -webkit-line-clamp: 2;
  }

  .s4w-product-correlati__wrapper {
    flex-direction: column;
    gap: 16px;
  }
}
