/* Progressive Gifts · Below-widget — centered cards with FREE badge. */

.wffn-bundles-gifts--below.wffn-bundles-gifts--below .wffn-bundles-gifts-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  /* Row gap is the space below one card's name; the next row's badge room comes on top of it. */
  gap: 8px 20px;
}

.wffn-bundles-gift-card.wffn-bundles-gift-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  /* Both badges overflow above their tile, out of flow. Each card reserves its own room for
     them, so a second row's badge clears the previous row's name however many lines it wraps
     to. (Reserving it once at the top of the list left only the row gap for later rows.)
     Scaled with the text: a theme that enlarges the badge enlarges the room, a badge line is at
     most 1.7em tall plus its 4px padding and 4px offset. */
  padding-block-start: calc(max(28px, calc(1.7em + 10px)) + var(--wffn-bundles-gift-card-pad, 0px));
  /* "Card bg color" / "Card border color". No fallback on purpose: unset, each
     declaration is invalid and the card stays bare, exactly as before. */
  background: var(--wffn-bundles-gift-card-bg);
  box-shadow: inset 0 0 0 1px var(--wffn-bundles-gift-card-border);
  /* Only set once the card has a fill or an outline. */
  border-radius: var(--wffn-bundles-gift-card-radius, 0px);
  padding-inline: var(--wffn-bundles-gift-card-pad, 0px);
  padding-block-end: var(--wffn-bundles-gift-card-pad, 0px);
  max-width: 100%;
  box-sizing: border-box;
}
.wffn-bundles-gift-card-media.wffn-bundles-gift-card-media {
  position: relative;
  /* Flex, not block: an inline-level thumb/icon sat on the text baseline and
     added a ~9px descender gap the locked tile does not have. */
  display: flex;
  /* With the card's own cap, a gift width wider than the row shrinks to it. */
  max-width: 100%;
}

.wffn-bundles-gift-thumb.wffn-bundles-gift-thumb {
  display: block;
  width: var(--wffn-bundles-gift-image-size, 80px);
  /* A width wider than the card row shrinks to it and stays square. */
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: var(--wffn-bundles-image-radius);
  overflow: hidden;
  background: var(--wffn-bundles-thumb-bg);
}
.wffn-bundles-gift-thumb.wffn-bundles-gift-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Locked card: the media becomes a clean gift-tile holding the icon + "Locked".
   Sized to the unlocked thumb, so locking does not resize the card (see below). */
.wffn-bundles-gift-card.wffn-bundles-gift-card.wffn-bundles-gift--locked .wffn-bundles-gift-card-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: var(--wffn-bundles-gift-image-size, 80px);
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  background: var(--wffn-bundles-thumb-bg);
  border-radius: calc(var(--wffn-bundles-image-radius, 8px) * 1.5);
}

/* Keep the action row in flow whenever its button is hidden, or every lock and
   unlock changes the card height and reflows the page below it. */
.wffn-bundles-gift-card.wffn-bundles-gift-card.wffn-bundles-gift--locked .wffn-bundles-gift-choose,
.wffn-bundles-gift-card.wffn-bundles-gift-card.wffn-bundles-gift--chosen .wffn-bundles-gift-choose {
  display: flex;
  visibility: hidden;
}
/* Same for a variable gift's picker, the other row a locked card drops. */
.wffn-bundles-gift-card.wffn-bundles-gift-card.wffn-bundles-gift--locked .wffn-bundles-gift-variant .wffn-bundles-variant {
  display: inline-flex;
  visibility: hidden;
}
.wffn-bundles-gift-card.wffn-bundles-gift-card.wffn-bundles-gift--locked .wffn-bundles-gift-thumb,
.wffn-bundles-gift-card.wffn-bundles-gift-card.wffn-bundles-gift--locked .wffn-bundles-gift-icon {
  display: none;
}

.wffn-bundles-gift-locked-icon.wffn-bundles-gift-locked-icon {
  display: none;
  /* Scales with the tile so a smaller one still fits the icon and its label. */
  width: min(42px, calc(var(--wffn-bundles-gift-image-size, 80px) * 0.525));
  height: min(42px, calc(var(--wffn-bundles-gift-image-size, 80px) * 0.525));
  background-image: var(--wffn-bundles-icon-gift);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.4;
}
.wffn-bundles-gift-card.wffn-bundles-gift-card.wffn-bundles-gift--locked .wffn-bundles-gift-locked-icon {
  display: block;
}

.wffn-bundles-gift-card.wffn-bundles-gift-card .wffn-bundles-gift-icon {
  width: var(--wffn-bundles-gift-image-size, 80px);
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: var(--wffn-bundles-image-radius, 8px);
  font-size: 34px;
}

.wffn-bundles-gift-badge.wffn-bundles-gift-badge {
  position: absolute;
  /* Bottom-anchored: the pill's own height then never bites into the tile,
     whatever line-height the theme gives it. */
  inset-block-end: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  gap: 4px;
  white-space: nowrap;
  background: var(--wffn-bundles-badge-bg);
  color: var(--wffn-bundles-badge-fg);
  /* The card's price: "Price font" in the Free Gifts design. */
  font-size: var(--wffn-bundles-gift-price-size, 11px);
  font-weight: 600;
  /* Declared, not inherited: a theme line-height of 28px made this a 34px pill
     that overran the space reserved for it above the tile (BeTheme). */
  line-height: 1.4;
  padding: 2px 8px;
  border-radius: 6px;
}
.wffn-bundles-gift-badge-strike.wffn-bundles-gift-badge-strike {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Free-shipping gifts: a "Free Shipping" pill above the icon, out of flow like
   `.wffn-bundles-gift-badge` or it pushes this card's tile below every other card's. */
.wffn-bundles-gift-ship-badge.wffn-bundles-gift-ship-badge {
  position: absolute;
  inset-block-end: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  white-space: nowrap;
  background: var(--wffn-bundles-badge-bg);
  color: var(--wffn-bundles-badge-fg);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  padding: 3px 12px;
  border-radius: 999px;
}

.wffn-bundles-gift-card-name.wffn-bundles-gift-card-name {
  font-size: calc(var(--wffn-bundles-title-size) - 2px);
  color: var(--wffn-bundles-title-color);
  text-align: center;
  max-width: 120px;
  word-break: break-word;
}

/* A variable gift's picker sits under its name. Left alone it is inline-flex, so the Size and
   Color dropdowns lay side by side (~280px) and stretch that one card far wider than its
   neighbours, leaving uneven gaps and pushing the last gift onto a row of its own. Give it the
   name's width instead, centered, with the dropdowns stacked. */
.wffn-bundles-gift-card.wffn-bundles-gift-card .wffn-bundles-gift-variant {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 120px;
}
.wffn-bundles.wffn-bundles .wffn-bundles-gifts--below .wffn-bundles-gift-variant .wffn-bundles-variant {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  text-align: center;
}
.wffn-bundles.wffn-bundles .wffn-bundles-gifts--below .wffn-bundles-gift-variant .wffn-bundles-variant-axis {
  width: 100%;
  max-width: 100%;
}
