/** Shopify CDN: Minification failed

Line 25:0 Unexpected "("

**/
#testimonial-desc{
  /* font-size: 12px;
  margin: 1rem auto;
  font-style: italic;
  max-width: min(70vw, 920px); */

  /* 1 line, smallest font */
    font-size: 9px;
    margin: 1rem auto;
    font-style: italic;
    max-width: min(90vw, 1050px);

    /* 1 line, same font, longer text */
    /* font-size: 12px;
    margin: 1rem auto;
    font-style: italic;
    max-width: min(90vw, 1352px); */
}

(() => {
  var STAR_COUNT = 5;
  var REVIEW_COUNT = "59,900+";
  var BLOCK_CLASS = "custom-rating-block-v1";
  var EXPID = "WUN-11";

  var starSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M7.99991 13.2155L4.48466 15.0635C3.72716 15.4617 2.84216 14.819 2.98616 13.9752L3.65741 10.0602L0.813414 7.28675C0.199914 6.68975 0.538164 5.64875 1.38491 5.52425L5.31641 4.95425L7.07366 1.39175C7.45241 0.622998 8.54666 0.622998 8.92616 1.39175L10.6834 4.95425L14.6149 5.52425C15.4617 5.648 15.7999 6.68825 15.1872 7.28675L12.3424 10.0602L13.0137 13.9752C13.1577 14.819 12.2727 15.4625 11.5152 15.0635L7.99991 13.2155Z" fill="url(#paint0_linear)"/><defs><linearGradient id="paint0_linear" x1="8" y1="0.815" x2="8" y2="15.185" gradientUnits="userSpaceOnUse"><stop stop-color="#FFE61C"/><stop offset="1" stop-color="#FFA929"/></linearGradient></defs></svg>`;

  var halfStarSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
    <defs>
      <linearGradient id="paint0_linear_half" x1="8" y1="0.815" x2="8" y2="15.185" gradientUnits="userSpaceOnUse">
        <stop stop-color="#FFE61C"/>
        <stop offset="1" stop-color="#FFA929"/>
      </linearGradient>
      <clipPath id="clip-half-star"><rect x="0" y="0" width="8" height="16"/></clipPath>
    </defs>
    <g clip-path="url(#clip-half-star)">
      <path d="M7.99991 13.2155L4.48466 15.0635C3.72716 15.4617 2.84216 14.819 2.98616 13.9752L3.65741 10.0602L0.813414 7.28675C0.199914 6.68975 0.538164 5.64875 1.38491 5.52425L5.31641 4.95425L7.07366 1.39175C7.45241 0.622998 8.54666 0.622998 8.92616 1.39175L10.6834 4.95425L14.6149 5.52425C15.4617 5.648 15.7999 6.68825 15.1872 7.28675L12.3424 10.0602L13.0137 13.9752C13.1577 14.819 12.2727 15.4625 11.5152 15.0635L7.99991 13.2155Z" fill="url(#paint0_linear_half)"/>
    </g>
    <path d="M7.99991 13.2155L4.48466 15.0635C3.72716 15.4617 2.84216 14.819 2.98616 13.9752L3.65741 10.0602L0.813414 7.28675C0.199914 6.68975 0.538164 5.64875 1.38491 5.52425L5.31641 4.95425L7.07366 1.39175C7.45241 0.622998 8.54666 0.622998 8.92616 1.39175L10.6834 4.95425L14.6149 5.52425C15.4617 5.648 15.7999 6.68825 15.1872 7.28675L12.3424 10.0602L13.0137 13.9752C13.1577 14.819 12.2727 15.4625 11.5152 15.0635L7.99991 13.2155Z" stroke="url(#paint0_linear_half)" stroke-width="1"/>
  </svg>`;

  var asset = [
    {
      stars: `${starSVG}${starSVG}${starSVG}${starSVG}${starSVG}`,
      title: "Bester Gutschein überhaupt",
      description: "Damit macht man nichts verkehrt...",
      author: "Mary S."
    },
    {
      stars: `${starSVG}${starSVG}${starSVG}${starSVG}${starSVG}`,
      title: "Einfach praktisch mit großer Auswahl",
      description: "Einfach praktisch...",
      author: "Mich Ael"
    },
    {
      stars: `${starSVG}${starSVG}${starSVG}${starSVG}${starSVG}`,
      title: "Toll und unkompliziert!",
      description: "Gute Geschenkidee...",
      author: "Diana Lange"
    }
  ];

  function waitFor(sel, cb, limit = 30) {
    let intv = setInterval(() => {
      var el = document.querySelector(sel);
      if (el) { clearInterval(intv); cb(el); }
      else if (--limit < 0) clearInterval(intv);
    }, 200);
  }

  function createRatingSummaryBlock() {
    let starsHTML = '';
    for (let i = 0; i < 4; i++) starsHTML += starSVG;
    starsHTML += halfStarSVG;
    return `
      <div class="${BLOCK_CLASS}" style="display:flex;align-items:center;gap:6px;line-height:1;font-size:15px;margin-left:16px;">
        <span style="display:flex;gap:2px;height:16px;">${starsHTML}</span>
        <span style="color:#333;">(${REVIEW_COUNT})</span>
      </div>`;
  }

  function injectStarsBlock() {
    const price = document.querySelector('.price.price--large');
    if (!price) return;
    if (price.closest('.price-and-stars-flex-wrapper')) return;

    const motivText = price.nextElementSibling?.classList.contains('product__text') ? price.nextElementSibling : null;
    const wrapper = document.createElement('div');
    wrapper.className = 'price-and-stars-flex-wrapper';
    wrapper.style.display = 'flex';
    wrapper.style.alignItems = 'center';
    wrapper.style.flexWrap = 'wrap';

    price.parentNode.insertBefore(wrapper, price);
    wrapper.appendChild(price);
    if (motivText) wrapper.appendChild(motivText);
    wrapper.insertAdjacentHTML('beforeend', createRatingSummaryBlock());
  }

  function createReviewSection() {
    return `<div id="testimonial-section" style="margin:32px auto;"><div class="${EXPID}-review-section" style="display:flex;justify-content:center;flex-wrap:wrap;gap:14px;">
      ${asset.map(r => `<div class="${EXPID}-review-card" style="display:flex;flex-direction:column;justify-content:space-between;height:100%;margin-bottom:24px;padding:20px 24px;background:#fff;border-radius:10px;box-shadow:0 1px 8px rgba(0,0,0,0.04);">
        <div><div class="${EXPID}-stars" style="margin-bottom:6px;">${r.stars}</div>
        <div class="${EXPID}-review-title" style="font-weight:700;">${r.title}</div>
        <div class="${EXPID}-review-content" style="margin:10px 0 0 0;">${r.description}</div></div>
        <div class="${EXPID}-review-author" style="margin-top:16px;font-weight:600;">${r.author}</div>
      </div>`).join('')}
    </div></div>`;
  }

  waitFor('.price.price--large', injectStarsBlock);

  waitFor('#MainContent', (main) => {
    if (!document.querySelector('.' + EXPID + '-review-section')) {
      const foot = document.querySelector('footer, .footer-group, #shopify-section-footer-group');
      const container = document.createElement('div');
      container.innerHTML = createReviewSection();
      const node = container.firstElementChild;
      if (foot) foot.parentNode.insertBefore(node, foot);
      else main.appendChild(node);

      setTimeout(() => {
        const cards = document.querySelectorAll('.' + EXPID + '-review-card');
        let max = 0;
        cards.forEach(card => {
          card.style.height = 'auto';
          max = Math.max(max, card.offsetHeight);
        });
        cards.forEach(card => card.style.height = max + 'px');
      }, 200);
    }
  });

  const observer = new MutationObserver(() => injectStarsBlock());
  observer.observe(document.body, { childList: true, subtree: true });
})();
