/*
 * Frontend styles for the Product Badge module. Color, radius, font size and
 * padding are supplied as CSS custom properties via an inline <style> block
 * (see ESFW_Product_Badge::enqueue_styles()) so they can reflect the admin
 * settings without editing this file.
 */

/* .woocommerce div.product,
.woocommerce-page div.product,
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product,
li.wc-block-product,
.wc-block-components-product-image,
.wp-block-woocommerce-product-image-gallery,
.woocommerce-product-gallery {
  position: relative;
} */
.woocommerce div.product,
.woocommerce-page div.product,
li.wc-block-product,
.wc-block-components-product-image,
.wp-block-woocommerce-product-image-gallery,
.woocommerce-product-gallery {
    position: relative;
}
.esfw-badge-position-wrap {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100% - 24px);
}

.esfw-badge-position-wrap.esfw-badge-has-multiple {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.esfw-badge-pos-top-left {
  top: 12px;
  left: 12px;
  align-items: flex-start;
}

.esfw-badge-pos-top-right {
  top: 12px;
  right: 12px;
  align-items: flex-end;
}

.esfw-badge-pos-bottom-left {
  bottom: 12px;
  left: 12px;
  align-items: flex-start;
}

.esfw-badge-pos-bottom-right {
  bottom: 12px;
  right: 12px;
  align-items: flex-end;
}

.esfw-product-badge {
  position: relative;
  box-sizing: border-box;
  flex-shrink: 0;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: normal;
  overflow: visible;
  max-width: 240px;
  min-width: 40px;
  min-height: var(--esfw-badge-min-height, 42px);

  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;

  font-weight: 700;

  font-size: var(--esfw-badge-font-size, 15px);

  padding:
    var(--esfw-badge-pad-v, 12px) var(--esfw-badge-pad-h, 22px);

  color: var(--esfw-badge-color, #ffffff);

  /* background-color: var(--esfw-badge-bg, #7c3aed); */

  background-image: linear-gradient(135deg,
      var(--esfw-badge-bg, #7c3aed),
      var(--esfw-badge-bg-end, #5b21b6));

  border-radius: var(--esfw-badge-radius, 12px);

}

/*
 * Badge Designs:
 * The SVG is the shape/background only. Dynamic badge text is a separate
 * HTML layer above it so text styling and visibility do not depend on SVG
 * <text> nodes.
 */
.esfw-product-badge-design {
  position: relative;
  display: inline-block;
  vertical-align: top;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  min-width: 0;
  line-height: 0;
  overflow: visible;
  pointer-events: auto;
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.esfw-product-badge-design-shape {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0;
  object-fit: contain;
}

.esfw-product-badge-design-text {
  position: absolute;
  left: var(--esfw-badge-text-x, 50%);
  top: var(--esfw-badge-text-y, 50%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--esfw-badge-text-max-width, 80%);
  max-width: var(--esfw-badge-text-max-width, 80%);
  min-width: 0;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  color: var(--esfw-badge-color, #ffffff);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: var(--esfw-badge-font-size, 15px);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  pointer-events: none;
}

.esfw-product-badge-design.esfw-badge-design-01 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 50.00%;
  --esfw-badge-text-max-width: 79.17%;
}

.esfw-product-badge-design.esfw-badge-design-02 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 50.00%;
  --esfw-badge-text-max-width: 79.17%;
}

.esfw-product-badge-design.esfw-badge-design-03 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 48.00%;
  --esfw-badge-text-max-width: 69.39%;
}

.esfw-product-badge-design.esfw-badge-design-04 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 53.27%;
  --esfw-badge-text-max-width: 71.70%;
}

.esfw-product-badge-design.esfw-badge-design-05 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 51.46%;
  --esfw-badge-text-max-width: 75.00%;
}

.esfw-product-badge-design.esfw-badge-design-06 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 42.83%;
  --esfw-badge-text-max-width: 73.33%;
}

.esfw-product-badge-design.esfw-badge-design-07 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 46.17%;
  --esfw-badge-text-max-width: 72.13%;
}

.esfw-product-badge-design.esfw-badge-design-11 {
  --esfw-badge-text-x: 46.77%;
  --esfw-badge-text-y: 40.65%;
  --esfw-badge-text-max-width: 70.97%;
}

.esfw-product-badge-design.esfw-badge-design-12 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 44.75%;
  --esfw-badge-text-max-width: 71.67%;
}

.esfw-product-badge-design.esfw-badge-design-13 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 44.41%;
  --esfw-badge-text-max-width: 71.93%;
}

.esfw-product-badge-design.esfw-badge-design-14 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 41.73%;
  --esfw-badge-text-max-width: 69.23%;
}

.esfw-product-badge-design.esfw-badge-design-15 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 50.17%;
  --esfw-badge-text-max-width: 62.07%;
}

.esfw-product-badge-design.esfw-badge-design-16 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 46.03%;
  --esfw-badge-text-max-width: 68.97%;
}

.esfw-product-badge-design.esfw-badge-design-17 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 46.72%;
  --esfw-badge-text-max-width: 68.97%;
}

.esfw-product-badge-design.esfw-badge-design-18 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 50.17%;
  --esfw-badge-text-max-width: 68.97%;
}

.esfw-product-badge-design.esfw-badge-design-19 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 48.91%;
  --esfw-badge-text-max-width: 67.80%;
}

.esfw-product-badge-design.esfw-badge-design-20 {
  --esfw-badge-text-x: 50.00%;
  --esfw-badge-text-y: 41.17%;
  --esfw-badge-text-max-width: 68.97%;
}

.esfw-product-badge-design:hover {
  transform: translateY(-2px);
}

/* SVG shapes have transparent corners, so follow the shape with a drop shadow. */
.esfw-product-badge-design.esfw-badge-shadow {
  box-shadow: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.2));
}

.esfw-product-badge-design.esfw-badge-shadow:hover {
  filter: drop-shadow(0 9px 14px rgba(0, 0, 0, 0.24));
}

.esfw-product-badge-image {
  display: block;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.esfw-product-badge-image:hover {
  transform: translateY(-2px);
}

.esfw-product-badge-image.esfw-badge-shadow {
  box-shadow: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.2));
}

.esfw-product-badge-image.esfw-badge-shadow:hover {
  filter: drop-shadow(0 9px 14px rgba(0, 0, 0, 0.24));
}


.esfw-badge-image-small {
  width: 45px !important;
  max-width: 45px !important;
  height: auto !important;
}

.esfw-badge-image-medium {
  width: 50px !important;
  max-width: 50px !important;
  height: auto !important;
}

.esfw-badge-image-large {

  width: 58px !important;
  max-width: 58px !important;
  height: auto !important;
}

.esfw-badge-image-auto {
  width: auto !important;
  min-width: 0;
  max-width: 100px !important;
  max-height: 60px;
  height: auto !important;
}


@media (max-width: 768px) {
  .esfw-product-badge-design-text {
    font-size: calc(var(--esfw-badge-font-size, 15px) * 0.9);
  }

  .esfw-badge-image-small {
    width: 40px !important;
    max-width: 40px !important;
  }

  .esfw-badge-image-medium {
    width: 50px !important;
    max-width: 50px !important;
  }

  .esfw-badge-image-large {
    /* Same subtle Large step as the desktop rule above, scaled for mobile. */
    width: 60px !important;
    max-width: 60px !important;
  }

  .esfw-badge-image-auto {
    max-width: 110px !important;
    max-height: 56px;
  }
}

.esfw-badge-shadow {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.esfw-badge-shadow:hover {
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}


@keyframes esfw-badge-fade {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

@keyframes esfw-badge-bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@keyframes esfw-badge-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

.esfw-badge-anim-fade {
  animation: esfw-badge-fade 1.6s ease-in-out infinite;
}

.esfw-badge-anim-bounce {
  animation: esfw-badge-bounce 1.2s ease-in-out infinite;
}

.esfw-badge-anim-pulse {
  animation: esfw-badge-pulse 1.2s ease-in-out infinite;
}
/*
 * Theme-independent shop-loop image anchor.
 * The badge is moved into this wrapper by product-badge.js so all four
 * position settings are calculated from the product image, not the full card.
 */
.esfw-product-image-badge-anchor {
  position: relative !important;
  display: block;
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.esfw-product-image-badge-anchor > img {
  display: block;
  width: 100%;
  height: auto;
}

.esfw-product-image-badge-anchor > .esfw-badge-position-wrap {
  position: absolute !important;
  z-index: 999 !important;
}
