.checkbox-upsells {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkbox-upsells__heading {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.checkbox-upsells__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checkbox-upsells__item {
  position: relative;
}

.checkbox-upsells__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px 8px 12px;
  border: 1px solid rgba(var(--color-text), 0.14);
  border-radius: 8px;
  background: rgba(var(--color-text), 0.03);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.checkbox-upsells__item:has(.checkbox-upsells__input:checked) .checkbox-upsells__row {
  border-color: rgba(var(--color-button-background), 1);
  background: rgba(var(--color-button-background), 0.2);
}

.checkbox-upsells__choice {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
}

.checkbox-upsells__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.checkbox-upsells__box {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid rgba(var(--color-text), 0.55);
  border-radius: 4px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.checkbox-upsells__box svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: rgba(var(--color-button-text), 1);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.checkbox-upsells__input:checked + .checkbox-upsells__box {
  border-color: rgba(var(--color-button-background), 1);
  background: rgba(var(--color-button-background), 1);
}

.checkbox-upsells__input:checked + .checkbox-upsells__box svg {
  opacity: 1;
}

.checkbox-upsells__input:focus-visible + .checkbox-upsells__box {
  outline: 2px solid rgba(var(--color-text), 0.8);
  outline-offset: 2px;
}

.checkbox-upsells__thumb {
  flex: none;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(var(--color-text), 0.06);
}

.checkbox-upsells__thumb img,
.checkbox-upsells__card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.checkbox-upsells__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.checkbox-upsells__title {
  line-height: 1.3;
}

.checkbox-upsells__price {
  opacity: 0.75;
}

.checkbox-upsells__info {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(var(--color-text), 0.6);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.checkbox-upsells__info svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.checkbox-upsells__info .dot {
  fill: currentColor;
}

.checkbox-upsells__info:hover,
.checkbox-upsells__item.is-open .checkbox-upsells__info {
  color: rgba(var(--color-text), 1);
  background: rgba(var(--color-text), 0.08);
}

.checkbox-upsells__info:focus-visible {
  outline: 2px solid rgba(var(--color-text), 0.8);
  outline-offset: 1px;
}

.checkbox-upsells__item.is-sold-out .checkbox-upsells__choice {
  cursor: not-allowed;
  opacity: 0.5;
}

/* More-info card. Touch: expands in place under the row. */
.checkbox-upsells__card {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.25s ease, visibility 0.25s;
}

.checkbox-upsells__item.is-open .checkbox-upsells__card {
  grid-template-rows: 1fr;
  visibility: visible;
}

.checkbox-upsells__card-inner {
  display: flex;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.checkbox-upsells__card-image {
  flex: none;
  width: 96px;
  height: 96px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(var(--color-text), 0.06);
}

.checkbox-upsells__card-body {
  min-width: 0;
  padding: 12px 4px 4px 0;
}

.checkbox-upsells__card-title {
  margin: 0;
  font-weight: 600;
}

.checkbox-upsells__card-blurb {
  margin: 4px 0 0;
  opacity: 0.85;
}

.checkbox-upsells__card-link {
  display: inline-block;
  margin-top: 8px;
  color: rgba(var(--color-text), 1);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Inline, mouse: floating card above its row, so it never covers the add to cart button below
   and the layout never jumps. (In the popup the card expands in place, so it never clips.) It stops short of the info button column so every other
   info button stays reachable. Fast in, faster out. */
@media (hover: hover) and (pointer: fine) {
  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__info {
    position: relative;
  }

  /* Bridge from the open item's info button up to the card's corner. */
  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__item.is-open .checkbox-upsells__info::before {
    position: absolute;
    right: 0;
    bottom: 50%;
    width: calc(100% + 16px);
    height: 54px;
    content: '';
  }

  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__card {
    position: absolute;
    right: 48px;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: block;
    padding: 14px;
    border: 1px solid rgba(var(--color-button-background), 1);
    border-radius: 8px;
    background: rgba(var(--color-background), 1);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(3px);
    pointer-events: none;
    transition: opacity 0.08s ease, transform 0.08s ease, visibility 0s linear 0.08s;
  }

  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__item.is-open {
    z-index: 21;
  }

  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__item.is-open .checkbox-upsells__card {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition: opacity 0.1s ease, transform 0.1s ease, visibility 0s;
  }

  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__card-inner {
    overflow: visible;
  }

  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__card-image {
    width: 120px;
    height: 120px;
    margin-top: 0;
  }

  .checkbox-upsells:not(.checkbox-upsells--popup) .checkbox-upsells__card-body {
    padding: 2px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .checkbox-upsells__row,
  .checkbox-upsells__box,
  .checkbox-upsells__card {
    transition: none;
  }
}

/* Popup: the block renders only a closed dialog in the product info column, so it takes no
   room (and adds no flex gap) next to quantity and Add to Cart. */
.checkbox-upsells--popup {
  display: contents;
}

.upsell-popup {
  width: min(560px, calc(100vw - 48px));
  max-width: none;
  max-height: min(780px, calc(100dvh - 48px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(var(--color-text), 0.14);
  border-radius: 12px;
  background: rgb(var(--color-background));
  color: rgb(var(--color-text));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.upsell-popup[open] {
  display: flex;
  flex-direction: column;
  animation: upsell-popup-in 0.24s ease;
}

.upsell-popup::backdrop {
  background: rgba(0, 0, 0, 0.6);
  animation: upsell-popup-fade 0.24s ease;
}

.upsell-popup__panel {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.upsell-popup__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(var(--color-text), 0.7);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.upsell-popup__close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.upsell-popup__close:hover {
  color: rgb(var(--color-text));
  background: rgba(var(--color-text), 0.08);
}

.upsell-popup__close:focus-visible {
  outline: 2px solid rgba(var(--color-text), 0.8);
  outline-offset: 1px;
}

.upsell-popup__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 32px 28px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.upsell-popup__heading {
  margin: 0 40px 6px 0;
  color: rgb(var(--color-text));
}

.upsell-popup__footer {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 16px;
  padding: 18px 28px 26px;
  border-top: 1px solid rgba(var(--color-text), 0.12);
}

.upsell-popup__footer .checkbox-upsells__error {
  margin: 0;
}

.upsell-popup__progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upsell-popup__progress[hidden] {
  display: none;
}

.upsell-popup__progress-text {
  margin: 0;
}

.upsell-popup__progress-text strong {
  font-weight: 700;
}

.upsell-popup__progress.is-unlocked .upsell-popup__progress-text {
  font-weight: 600;
}

.upsell-popup__progress.is-unlocked .upsell-popup__progress-text::before {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: -3px;
  content: '';
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.upsell-popup__progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(var(--color-text), 0.12);
}

.upsell-popup__progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(var(--color-button-background), 1);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s ease;
}

.upsell-popup__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Buttons: 8px radius, hero-style shine sweep on hover instead of the native dim and ring. */
.upsell-popup .upsell-popup__button.button {
  overflow: hidden;
  border-radius: 8px;
}

.upsell-popup .upsell-popup__button.button::after {
  display: none;
}

.upsell-popup .upsell-popup__button.button::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  z-index: 2;
  width: 40%;
  content: '';
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  pointer-events: none;
}

.upsell-popup .upsell-popup__button.button:not([disabled]):hover {
  background-color: rgba(var(--color-button-background), var(--button-background-opacity));
}

.upsell-popup .upsell-popup__button--decline.button {
  --color-button-background: transparent;

  color: rgb(var(--color-text));
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(var(--color-text), 0.35);
}

.upsell-popup .upsell-popup__button--decline.button:not([disabled]):hover {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(var(--color-text), 0.6);
}

.upsell-popup .upsell-popup__button--decline.button::before {
  background: linear-gradient(90deg, transparent, rgba(var(--color-text), 0.14), transparent);
}

.upsell-popup .upsell-popup__button.button:focus-visible {
  outline: 2px solid rgba(var(--color-text), 0.8);
  outline-offset: -4px;
}

@media (hover: hover) {
  .upsell-popup .upsell-popup__button.button:hover::before {
    animation: upsell-popup-sweep 0.7s ease forwards;
  }
}

@keyframes upsell-popup-sweep {
  to {
    left: 130%;
  }
}

@keyframes upsell-popup-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes upsell-popup-fade {
  from {
    opacity: 0;
  }
}

/* Theme mobile breakpoint: full screen sheet. */
@media (max-width: 959px) {
  .upsell-popup {
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .upsell-popup__body {
    padding: 56px 20px 20px;
  }

  .upsell-popup__heading {
    margin-right: 0;
  }

  .upsell-popup__footer {
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  }

  .upsell-popup__actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .upsell-popup[open],
  .upsell-popup::backdrop,
  .upsell-popup .upsell-popup__button.button:hover::before {
    animation: none;
  }

  .upsell-popup__progress-fill {
    transition: none;
  }
}
