:host {
  /**
  * @prop --klevu-product-width: Width of the product
  * @prop --klevu-product-small-width: Width of the product when small variant is used
  * @prop --klevu-product-image-aspect-ratio 1: On what aspect the background image will be
  * @prop --klevu-product-image-fill cover: How to fill image to it's space.
  * @prop --klevu-product-border none: Border style of the product
  * @prop --klevu-product-border-radius --klevu-border-radius-s: Border radius style of the product
  * @prop --klevu-product-details-spacing: gap of the flex grid for product details
  */
  display: inline-block;
  --loading-animation-time: 5s;
  --width: var(--klevu-product-width, inherit);
  --small-width: var(--klevu-product-small-width, 150px);
  --image-aspect-ratio: var(--klevu-product-image-aspect-ratio, 1);
  --image-fill: var(--klevu-product-image-fill, cover);
  --border: var(--klevu-product-border, none);
  --border-radius: var(--klevu-product-border-radius, var(--klevu-border-radius-s, 4px));
  --gap-for-flex: var(--klevu-product-details-spacing, var(--klevu-spacing-06, 24px));
  --line-clamp: var(--klevu-product-name-lines, 2);
  --product-container-cursor: var(--klevu-product-container-cursor, "auto");
}

:host(.line) {
  display: block;
}

:host a {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
  width: 100%;
}

.container {
  display: block;
  padding: var(--klevu-spacing-04);
  border: var(--border);
  border-radius: var(--border-radius);
  box-sizing: border-box;
  height: 100%;
  cursor: var(--product-container-cursor);
}

.container.default {
  display: flex;
  flex-direction: column;
  max-width: var(--width);
  gap: var(--gap-for-flex);
}
.container.default a,
.container.small a {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  max-width: var(--width);
  gap: var(--gap-for-flex);
}

.container.default.fixedWidth {
  max-width: auto;
  width: var(--width);
}

.container.small {
  display: flex;
  flex-direction: column;
  max-width: var(--small-width);
  gap: var(--klevu-spacing-06);
}

.container.small.fixedWidth {
  max-width: auto;
  width: var(--small-width);
}

.default .image {
  width: 100%;
  aspect-ratio: var(--image-aspect-ratio);
  background-size: var(--image-fill);
  background-position: center center;
  background-repeat: no-repeat;
}

.small .image {
  width: 100%;
  aspect-ratio: var(--image-aspect-ratio);
  background-size: var(--image-fill);
  background-position: center center;
  background-repeat: no-repeat;
}

.container.line a {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: var(--klevu-spacing-06);
}

.line .info {
  display: flex;
  flex-direction: column;
  margin-left: var(--klevu-spacing-04);
  flex: 1;
}

.line .info p {
  display: block;
  margin: 0;
  text-align: right;
}

.line .info .price {
  margin-top: var(--klevu-spacing-04);
}

.container.line .image {
  width: 100px;
  height: 100%;
  aspect-ratio: 1;
  background-size: var(--image-fill);
  background-position: center center;
  flex-shrink: 0;
}

@media (max-width: 400px) {
  .container.line .image {
    width: 80px;
  }
}

.brandname {
  margin-bottom: 0;
}

.productname span {
  display: block;
  display: -webkit-box;
  text-overflow: ellipsis;
  -webkit-line-clamp: var(--line-clamp);
  -webkit-box-orient: vertical;
  height: calc(var(--klevu-body-s-height) * var(--klevu-body-s-line-height) * 2);
  text-align: left;
  margin-top: var(--klevu-spacing-04);
  overflow: hidden;
}

.brandname + .productname {
  margin-top: 0;
}

.small .productname {
  font-size: inherit;
}

.description {
  text-overflow: ellipsis;
  overflow: hidden;
  max-height: 3.5em;
}

.container.small .description {
  display: none;
}

.price {
  margin-top: var(--klevu-spacing-04);
  text-align: left;
  font-size: var(--klevu-h2-size);
  font-weight: var(--klevu-h2-weight);
}

.small .price {
  font-size: inherit;
  font-weight: inherit;
}

.container.line .loading {
  display: flex;
  flex-direction: row;
}

.loading.image {
  background: linear-gradient(-75deg, #a1a1a1 0%, #eaeaea 50%, #f8f8f8 100%);
  background-size: 400% 400%;
  animation: loadinggradient 5s linear infinite;
}

.loading.content div {
  width: 100%;
  height: 32px;
  margin-bottom: 6px;
  background: linear-gradient(-75deg, #a1a1a1 0%, #eaeaea 50%, #f8f8f8 100%);
  background-size: 400% 400%;
  animation: loadinggradient var(--loading-animation-time) linear infinite;
}

:host(.line.loading) .container {
  display: flex;
}

:host(.line.loading) .content {
  width: 100%;
  display: flex;
  flex-direction: column;
  margin: 0 var(--klevu-spacing-04);
}

.loading.content div:nth-child(1) {
  animation-delay: calc(var(--loading-animation-time) / 5);
}

.loading.content div:nth-child(2) {
  animation-delay: calc(var(--loading-animation-time) / 4);
}

.loading.content div:nth-child(3) {
  animation-delay: calc(var(--loading-animation-time) / 3);
}

.swatches {
  display: none;
  margin: var(--klevu-spacing-02) 0;
}

.swatches > div {
  height: 32px;
  width: 32px;
  background-size: cover;
}

.container.default .swatches {
  display: flex;
  gap: var(--klevu-spacing-02);
}

.image.no-image {
  color: var(--klevu-color-neutral-5);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 4em;
}

.addToCart {
  margin-top: var(--klevu-spacing-04);
  white-space: nowrap;
}

.vatcaption {
  display: block;
  --klevu-typography-color: var(--klevu-color-neutral-6);
}
.outOfStockCaption {
  display: block;
  --klevu-typography-color: var(--klevu-color-oos-caption, #ff0000);
}

/* Hover image */
.image .hover {
  opacity: 0;
  height: 100%;
  width: 100%;
  aspect-ratio: var(--image-aspect-ratio);
  background-size: var(--image-fill);
  background-position: center center;
  background-repeat: no-repeat;
  transition: opacity 0.3s ease-in-out;
}

.image:hover .hover {
  opacity: 1;
}

@keyframes loadinggradient {
  0% {
    background-position: 0% 50%;
  }
  80% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.ratings {
  display: flex;
  gap: var(--klevu-spacing-small, 4px);
  margin: var(--klevu-spacing-small, 4px) 0;
}
