/** Shopify CDN: Minification failed

Line 16:0 Unexpected "{"
Line 16:1 Expected identifier but found "%"
Line 17:73 Expected identifier but found whitespace
Line 18:10 Expected identifier but found "%"
Line 19:0 Unexpected "{"
Line 19:1 Expected identifier but found "%"
Line 20:0 Unexpected "{"
Line 20:1 Expected identifier but found "%"
Line 21:0 Unexpected "{"
Line 21:1 Expected identifier but found "%"
... and 74 more hidden warnings

**/
{%- comment -%}
  Looping top offer bar — shared by header section and offer-bar block.
  Usage: {% render 'sefira-offer-bar', settings_obj: section.settings, bar_id: section.id %}
{%- endcomment -%}
{%- assign s = settings_obj -%}
{%- if s == blank -%}
  {%- assign s = block.settings -%}
{%- endif -%}
{%- if bar_id == blank -%}
  {%- assign bar_id = block.id | default: 'sefira' -%}
{%- endif -%}
{%- assign bar_uid = bar_id | replace: '_', '' | downcase -%}
{%- assign slide_ms = s.slide_interval | default: 4 | times: 1000 -%}

{%- capture offer_slides -%}
  {%- for i in (1..6) -%}
    {%- assign text_key = 'offer_text_' | append: i -%}
    {%- assign code_key = 'offer_code_' | append: i -%}
    {%- assign offer_text = s[text_key] -%}
    {%- assign offer_code = s[code_key] -%}
    {%- if offer_text != blank -%}
      <div class="sefira-offer-bar__slide" data-sefira-offer-slide{% if offer_code != blank %} data-coupon="{{ offer_code | escape }}"{% endif %}>
        <div class="sefira-offer-bar__pill">
          <span class="sefira-offer-bar__text">{{ offer_text | escape }}</span>
          {%- if offer_code != blank -%}
            <span class="sefira-offer-bar__sep" aria-hidden="true">|</span>
            <span class="sefira-offer-bar__code-label">USE CODE :</span>
            <span class="sefira-offer-bar__code">{{ offer_code | escape }}</span>
          {%- endif -%}
        </div>
      </div>
    {%- endif -%}
  {%- endfor -%}
{%- endcapture -%}

{%- if offer_slides != blank -%}
<div
  class="sefira-offer-bar"
  id="sefira-offer-bar-{{ bar_uid }}"
  data-sefira-offer-bar
  data-interval="{{ slide_ms }}"
  style="--sefira-offer-bg: {{ s.background_color | default: '#000000' }}; --sefira-offer-text: {{ s.text_color | default: '#ffffff' }}; --sefira-offer-highlight: {{ s.highlight_color | default: '#e31b23' }}; --sefira-offer-pad: {{ s.padding_vertical | default: 10 }}px;"
  {{ block.shopify_attributes }}
>
  <div class="sefira-offer-bar__inner">
    <div class="sefira-offer-bar__viewport">
      <div class="sefira-offer-bar__track" data-sefira-offer-track>
        {{ offer_slides }}
      </div>
    </div>
    <span class="sefira-offer-bar__toast" data-sefira-offer-toast hidden>Code copied!</span>
  </div>
</div>

<style>
  .sefira-offer-bar {
    width: 100%;
    max-width: 100vw;
    background: var(--sefira-offer-bg, #000);
    color: var(--sefira-offer-text, #fff);
    box-sizing: border-box;
    position: relative;
    z-index: 20;
  }

  .sefira-offer-bar__inner {
    width: 100%;
    margin: 0 auto;
    padding: var(--sefira-offer-pad, 10px) 12px;
    box-sizing: border-box;
    position: relative;
  }

  .sefira-offer-bar__viewport {
    position: relative;
    width: 100%;
    overflow: hidden;
    transition: min-height 0.35s ease;
  }

  .sefira-offer-bar__track {
    display: flex;
    width: 100%;
    will-change: transform;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sefira-offer-bar__slide {
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 4px;
  }

  .sefira-offer-bar__pill {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.5rem;
    max-width: 100%;
    text-align: center;
    line-height: 1.35;
    font-size: {{ s.font_size | default: 13 }}px;
    font-weight: {{ s.font_weight | default: '400' }};
    letter-spacing: 0.01em;
  }

  .sefira-offer-bar__text {
    color: var(--sefira-offer-text, #fff);
  }

  .sefira-offer-bar__sep {
    opacity: 0.55;
    font-weight: 300;
  }

  .sefira-offer-bar__code-label {
    opacity: 0.9;
    font-weight: 400;
  }

  .sefira-offer-bar__code {
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .sefira-offer-bar__slide[data-coupon] {
    cursor: pointer;
  }

  .sefira-offer-bar__toast {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%) translateY(4px);
    background: #fff;
    color: #111;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
    z-index: 5;
  }

  .sefira-offer-bar__toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  @media (min-width: 750px) {
    .sefira-offer-bar__pill {
      flex-wrap: nowrap;
      white-space: nowrap;
      background: none !important;
      box-shadow: none !important;
      padding: 0;
    }

    .sefira-offer-bar__text,
    .sefira-offer-bar__code-label,
    .sefira-offer-bar__code,
    .sefira-offer-bar__sep {
      color: var(--sefira-offer-text, #fff) !important;
    }

    .sefira-offer-bar__code {
      background: none !important;
      padding: 0;
      border-radius: 0;
      font-weight: 700;
      letter-spacing: 0.04em;
    }

    .sefira-offer-bar__sep {
      opacity: 0.45;
      margin: 0 0.15rem;
    }
  }

  @media (max-width: 749px) {
    .sefira-offer-bar__inner {
      padding: 8px 12px;
    }

    .sefira-offer-bar__pill {
      flex-wrap: nowrap;
      white-space: nowrap;
      background: none !important;
      box-shadow: none !important;
      padding: 0;
      font-size: {{ s.font_size_mobile | default: 12 }}px;
      gap: 0.3rem 0.45rem;
      max-width: calc(100vw - 24px);
    }

    .sefira-offer-bar__text,
    .sefira-offer-bar__code-label,
    .sefira-offer-bar__sep {
      color: var(--sefira-offer-text, #fff) !important;
      text-transform: uppercase;
      letter-spacing: 0.02em;
    }

    .sefira-offer-bar__sep {
      opacity: 0.55;
      font-weight: 300;
    }

    .sefira-offer-bar__code-label {
      font-weight: 400;
    }

    .sefira-offer-bar__code {
      display: inline-block;
      background: var(--sefira-offer-highlight, #e31b23) !important;
      color: #fff !important;
      padding: 4px 12px;
      border-radius: 999px;
      font-weight: 700;
      font-size: {{ s.font_size_mobile | default: 12 }}px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      line-height: 1.2;
      box-shadow: none;
    }
  }
</style>

<script>
  (function () {
    if (window.__sefiraOfferBarInit) return;
    window.__sefiraOfferBarInit = true;

    function initOfferBar(root) {
      if (!root || root.getAttribute('data-sefira-offer-init') === '1') return;
      var slides = root.querySelectorAll('[data-sefira-offer-slide]');
      if (!slides.length) return;
      root.setAttribute('data-sefira-offer-init', '1');

      var idx = 0;
      var timer = null;
      var animating = false;
      var interval = parseInt(root.getAttribute('data-interval'), 10) || 4000;
      var toast = root.querySelector('[data-sefira-offer-toast]');
      var track = root.querySelector('[data-sefira-offer-track]');
      var viewport = root.querySelector('.sefira-offer-bar__viewport');

      function syncHeight() {
        if (!viewport || !slides[idx]) return;
        var pill = slides[idx].querySelector('.sefira-offer-bar__pill');
        if (pill) viewport.style.minHeight = pill.offsetHeight + 'px';
      }

      function show(i, instant) {
        if (!track) return;
        idx = i;
        if (instant) track.style.transition = 'none';
        track.style.transform = 'translateX(-' + (idx * 100) + '%)';
        if (instant) {
          track.offsetHeight;
          track.style.transition = '';
        }
        syncHeight();
      }

      function next() {
        if (animating || slides.length < 2) return;
        animating = true;
        show((idx + 1) % slides.length);
        setTimeout(function () { animating = false; }, 560);
      }

      function start() {
        stop();
        if (slides.length > 1) {
          timer = setInterval(next, interval);
        }
      }

      function stop() {
        if (timer) {
          clearInterval(timer);
          timer = null;
        }
      }

      show(0, true);
      syncHeight();
      start();

      window.addEventListener('resize', syncHeight);

      root.addEventListener('mouseenter', stop);
      root.addEventListener('mouseleave', start);

      root.addEventListener('click', function (e) {
        var slide = e.target.closest('[data-sefira-offer-slide]');
        if (!slide) return;
        var code = slide.getAttribute('data-coupon');
        if (!code) return;

        function flashToast() {
          if (!toast) return;
          toast.hidden = false;
          toast.classList.add('is-visible');
          setTimeout(function () {
            toast.classList.remove('is-visible');
            toast.hidden = true;
          }, 1800);
        }

        if (navigator.clipboard && navigator.clipboard.writeText) {
          navigator.clipboard.writeText(code).then(flashToast);
        } else {
          var ta = document.createElement('textarea');
          ta.value = code;
          document.body.appendChild(ta);
          ta.select();
          try {
            document.execCommand('copy');
            flashToast();
          } catch (err) {}
          document.body.removeChild(ta);
        }
      });
    }

    function bootOfferBars(scope) {
      (scope || document).querySelectorAll('[data-sefira-offer-bar]').forEach(initOfferBar);
    }

    bootOfferBars();
    document.addEventListener('shopify:section:load', function (e) {
      bootOfferBars(e.target);
    });
  })();
</script>
{%- endif -%}
