/* Sits right above the iqitelementor "Oggi in regalo per te!" box. */
.nmc-buy-together {
  --nmc-bt-bg: #fcf7f2;
  --nmc-bt-border: #efd6c2;
  --nmc-bt-divider: #e9ded4;
  --nmc-bt-title: #3f7a72;
  --nmc-bt-text: #333;
  --nmc-bt-price: #3f7a72;
  --nmc-bt-check-border: #d8ccc1;
  --nmc-bt-check-on: #6a9a94;
  /* Same as the theme's .btn-primary. */
  --nmc-bt-button: #e8c09f;
  --nmc-bt-button-hover: #cda686;
  --nmc-bt-error: #ca5058;
  --nmc-bt-pad-x: 1.25rem;
  /* The box's width depends on the product column (col-md-5 on desktop,
     full width on phones), so the grid responds to the box, not the viewport. */
  container: nmc-bt / inline-size;
  margin: 1.25rem 0;
  padding: 1rem var(--nmc-bt-pad-x) 1.25rem;
  background: var(--nmc-bt-bg);
  border: 1px solid var(--nmc-bt-border);
  border-radius: 20px;
}

.nmc-buy-together__title {
  margin: 0 0 1rem;
  color: var(--nmc-bt-title);
  font-size: clamp(1.2rem, 6cqi, 1.5rem);
  font-weight: 600;
  line-height: 1.2;
}

/* Always a single row: three tiles fit (two in a narrow box), any extra
   ones scroll horizontally with snap, driven by the arrows or a swipe. */
.nmc-buy-together__viewport {
  position: relative;
}

/* The scroller bleeds into the box's side padding so tiles slide right up
   to the border instead of being cut off inside it; the matching padding
   and scroll-padding keep the resting positions where they were. */
.nmc-buy-together__list {
  display: flex;
  margin: 0 calc(-1 * var(--nmc-bt-pad-x));
  padding: 0 var(--nmc-bt-pad-x);
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-padding-inline: var(--nmc-bt-pad-x);
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  --nmc-bt-per-view: 3;
  --nmc-bt-peek: 0px;
}

/* When the row scrolls, tiles shrink so part of the next one shows at the
   edge, hinting there is more. */
.nmc-buy-together__list:has(> :nth-child(4)) {
  --nmc-bt-peek: 3.5rem;
}

.nmc-buy-together__list::-webkit-scrollbar {
  display: none;
}

.nmc-buy-together__item {
  display: flex;
  flex: 0 0 calc((100% - var(--nmc-bt-peek)) / var(--nmc-bt-per-view));
  flex-direction: column;
  min-width: 0;
  padding: 0 .75rem;
  scroll-snap-align: start;
}

.nmc-buy-together__item + .nmc-buy-together__item {
  border-left: 1px solid var(--nmc-bt-divider);
}

.nmc-buy-together__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  margin-bottom: .75rem;
}

.nmc-buy-together__thumb img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.nmc-buy-together__check {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin: 0;
  color: var(--nmc-bt-text);
  font-size: .85rem;
  font-weight: 400;
  line-height: 1.3;
  cursor: pointer;
}

.nmc-buy-together__checkbox {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 20px;
  height: 20px;
  margin: -.05rem 0 0;
  background: #fff;
  border: 1px solid var(--nmc-bt-check-border);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.nmc-buy-together__checkbox:checked {
  background: var(--nmc-bt-check-on);
  border-color: var(--nmc-bt-check-on);
}

.nmc-buy-together__checkbox:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.nmc-buy-together__checkbox:focus-visible {
  outline: 2px solid var(--nmc-bt-check-on);
  outline-offset: 2px;
}

.nmc-buy-together__text {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  min-width: 0;
}

.nmc-buy-together__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nmc-buy-together__price {
  color: var(--nmc-bt-price);
  font-weight: 700;
}

.nmc-buy-together__regular-price {
  margin-left: .3rem;
  color: #999;
  font-size: .8em;
  text-decoration: line-through;
}

.nmc-buy-together__actions {
  margin-top: 1.25rem;
  text-align: center;
}

.nmc-buy-together .nmc-buy-together__button {
  padding: .6rem 2rem;
  color: #fff;
  font-size: .95rem;
  font-weight: 500;
  text-transform: none;
  background-color: var(--nmc-bt-button);
  border-color: var(--nmc-bt-button);
  border-radius: 50px;
}

.nmc-buy-together .nmc-buy-together__button:hover,
.nmc-buy-together .nmc-buy-together__button:focus {
  color: #fff;
  background-color: var(--nmc-bt-button-hover);
  border-color: var(--nmc-bt-button-hover);
}

.nmc-buy-together .nmc-buy-together__button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.nmc-buy-together__button.processing-add {
  cursor: progress;
}

.nmc-buy-together__messages {
  margin-top: .75rem;
  color: var(--nmc-bt-error);
  font-size: .8rem;
}

.nmc-buy-together__messages p {
  margin: 0 0 .25rem;
}

.nmc-buy-together__arrow {
  position: absolute;
  z-index: 1;
  /* Centred on the 120px thumbnails. */
  top: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--nmc-bt-title);
  background: #fff;
  border: 1px solid var(--nmc-bt-border);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  transform: translateY(-50%);
  cursor: pointer;
  transition: opacity .15s, background-color .15s;
}

.nmc-buy-together__arrow--prev {
  left: -.9rem;
}

.nmc-buy-together__arrow--next {
  right: -.9rem;
}

.nmc-buy-together__arrow:hover {
  background: var(--nmc-bt-bg);
}

.nmc-buy-together__arrow:focus-visible {
  outline: 2px solid var(--nmc-bt-check-on);
  outline-offset: 2px;
}

.nmc-buy-together__arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

/* Below ~150px per tile, three tiles squeeze the names: show two. */
@container nmc-bt (max-width: 479.98px) {
  .nmc-buy-together__list {
    --nmc-bt-per-view: 2;
  }

  .nmc-buy-together__list:has(> :nth-child(3)) {
    --nmc-bt-peek: 3.5rem;
  }
}
