/* Card - Main */
.product-card {
  container-type: inline-size;
  container-name: card;
}

.bbd-product-card__content {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: var(--gap-md);
  flex-shrink: 0;
  flex-grow: 1;
  padding-block: var(--padding-lg);

  @container card (width >= 300px) {
    grid-template-columns: auto 125px;
    grid-template-rows: repeat(2, auto);
    align-items: flex-start;
    row-gap: var(--gap-xl);
  }
}

.bbd-product-card__text-link {
  place-self: flex-end flex-end;

  @container card (width < 300px) {
    display: none;
  }
}

.bbd-product-card__price {
  align-self: flex-end;
  padding-block-end: 3px;
}

/* Card - Second image hover */
.card-gallery__second-image-overlay {
  position: absolute;
  inset: 0;
  z-index: var(--layer-above);
  opacity: 0;
  visibility: hidden;
  transition: all var(--animation-speed-slow) ease-in-out;
  background: var(--color-background);

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: var(--gallery-aspect-ratio, var(--ratio));
  }

  &.is-visible {
    opacity: 1;
    visibility: visible;
  }
}

.card-gallery__thumbnail {
  position: absolute;
  z-index: var(--layer-heightened);
  right: var(--padding-xs);
  bottom: var(--padding-xs);
  display: flex;
  overflow: hidden;
  justify-content: center;
  align-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color-white);
  color: var(--color-black);
  cursor: pointer;

  @container card (width >= 300px) {
    width: 40px;
    height: 40px;
  }

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.card-gallery__thumbnail-icon {
  display: none;

  svg {
    width: var(--icon-size-lg);
    height: var(--icon-size-lg);
  }
}

.card-gallery__thumbnail.is-active {
  border-radius: 0;

  img {
    display: none;
  }

  .card-gallery__thumbnail-icon {
    display: flex;
  }
}

/* Card - Badges */
.product-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2xs);

  .product-badges__badge {
    padding: 6px;
    border: 1px solid var(--color-border);
    background-color: transparent;
    font-size: var(--font-size--3xs);
    font-variation-settings: var(--heading-regular);
    letter-spacing: var(--letter-spacing--heading-normal);

    @container card (width < 300px) {
      font-size: var(--font-size--4xs);
      padding: 4px;
    }
  }
}

/* Swatches */
.bbd-product-card__swatches {
  display: flex;
  justify-content: flex-end;
  height: 100%;

  &.bbd-product-card__swatches--large {
    @container card (width < 300px) {
      display: none;
    }
  }
}

.product-card-swatches {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  background: var(--color-background);
}

.product-card-swatches__container {
  position: relative;
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  height: 100%;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    right: 100%;
    width: 80px;
    height: 120%;
    background: linear-gradient(270deg, var(--color-background) 10%, rgba(var(--color-background-rgb) / 0%) 100%);
  }
}

.product-card-swatches__expand-button {
  position: absolute;
  z-index: var(--layer-heightened);
  padding: 0;
  border: 0;
  inset: 0;
  background: transparent;
  cursor: pointer;
}

.product-card-swatches__list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  padding-inline-end: var(--padding-xs);
}

.product-card-swatches__swatch {
  position: relative;
  width: 1.25rem;
  height: 1.25rem;
  background-color: var(--variation-color);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  border: 0;

  &.active {
    width: 1.5rem;
    height: 1.5rem;
  }

  &:nth-last-child(n + 2 of &:not(.hidden)) {
    right: -10px;
    z-index: 2;
  }

  &:nth-last-child(n + 3 of &:not(.hidden)) {
    right: -20px;
    z-index: 3;
  }
}

.product-card-swatches__remainder {
  position: relative;
  margin-block: 0;
  padding-block-start: 5px;
  font-size: var(--font-size--sm);
  line-height: 1;
  color: var(--color-caption);
}

/* Teaser version */
.product-card-swatches--teaser {
  position: absolute;
  right: 3.25em;
  bottom: 0.9rem;
  height: auto;
  background: transparent;

  @media screen and (min-width: 750px) {
    right: 0.5em;
    bottom: 0.5rem;
  }

  @container card (width >= 300px) {
    display: none;
  }

  .product-card-swatches__container {
    align-items: center;

    &::before {
      display: none;
    }
  }

  .product-card-swatches__list {
    padding-inline-end: var(--padding-2xs);
  }

  .product-card-swatches__swatch {
    width: 0.5rem;
    height: 0.5rem;

    &.active {
      width: 0.75rem;
      height: 0.75rem;
    }

    &:nth-last-child(n + 2 of &:not(.hidden)) {
      right: -4px;
      z-index: 2;
    }

    &:nth-last-child(n + 3 of &:not(.hidden)) {
      right: -8px;
      z-index: 3;
    }
  }

  .product-card-swatches__remainder {
    padding-block: 0;
    font-size: var(--font-size--xs);
  }
}

/* Expanded version */
.product-card-swatches--expanded {
  .product-card-swatches__expand-button {
    display: none;
  }

  .product-card-swatches__list {
    gap: 6px;
  }

  .product-card-swatches__swatch {
    transition: scale var(--animation-speed-slow) ease-in-out;

    &:nth-last-child(n + 2 of &:not(.hidden)),
    &:nth-last-child(n + 3 of &:not(.hidden)) {
      right: 0;
    }

    &.hidden {
      display: block !important;
    }

    &:hover,
    &:focus-visible {
      scale: 1.2;
    }
  }

  .product-card-swatches__remainder {
    display: none;
  }
}

/* Card - Gallery */
.bbd-product-card__gallery {
  position: relative;

  slideshow-arrows {
    padding-inline: var(--padding-xs);

    .slideshow-control {
      place-content: center;
      min-width: 32px;
      min-height: 32px;
      padding: 0;
    }
  }

  @media screen and (max-width: 749px) {
    slideshow-arrows {
      .slideshow-control {
        min-width: 24px;
        min-height: 24px;

        .svg-wrapper,
        .svg-wrapper svg {
          width: var(--icon-size-sm);
          height: var(--icon-size-sm);
        }
      }
    }
  }

  @media screen and (max-width: 500px) {
    slideshow-arrows {
      padding: 0;
    }
  }

  &:has(.card-gallery__thumbnail.is-active),
  &:has(.card-gallery--active),
  &:has(.card-gallery--preview) {
    .product-badges__badge {
      border-color: var(--color-background);
      background-color: var(--color-background);
    }

    .product-card-swatches--teaser {
      opacity: 0;
    }

    slideshow-arrows .slideshow-control {
      background-color: var(--color-background);
    }
  }

  &:has(.card-gallery--active) {
    @media screen and (max-width: 749px) {
      .bbd-card-second-image-container {
        display: none;
      }
    }
  }
}
