/** Shopify CDN: Minification failed

Line 16:0 Unexpected "{"
Line 16:1 Unexpected "{"
Line 16:3 Expected identifier but found "'section-main-product.css'"
Line 17:0 Unexpected "{"
Line 17:1 Unexpected "{"
Line 17:3 Expected identifier but found "'component-price.css'"
Line 18:0 Unexpected "{"
Line 18:1 Unexpected "{"
Line 18:3 Expected identifier but found "'component-rte.css'"
Line 19:0 Unexpected "{"
... and 614 more hidden warnings

**/
{{ 'section-main-product.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'component-rte.css' | asset_url | stylesheet_tag }}
{{ 'component-loading-overlay.css' | asset_url | stylesheet_tag }}

{%- liquid
  assign product = section.settings.product
  assign product_form_id = 'product-form-' | append: section.id
  assign layout = section.settings.layout
  assign first_image = product.featured_media.preview_image

  if section.settings.ratio_desktop == 'adapt'
    if first_image
      assign ratio_desktop = first_image.aspect_ratio
    else
      assign ratio_desktop = '1'
    endif
  else
    assign ratio_desktop = section.settings.ratio_desktop | replace: '-', ' / '
  endif

  if section.settings.ratio_mobile == 'adapt'
    if first_image
      assign ratio_mobile = first_image.aspect_ratio
    else
      assign ratio_mobile = '1'
    endif
  else
    assign ratio_mobile = section.settings.ratio_mobile | replace: '-', ' / '
  endif

  assign image_count = 0
  for media in product.media
    if media.media_type == 'image'
      assign image_count = image_count | plus: 1
    endif
  endfor

  if layout == 'stacked'
    if section.settings.full_bleed
      assign sizes_attr = '100vw'
    else
      assign sizes_attr = '(min-width: 750px) ' | append: section.settings.content_width | append: 'px, 100vw'
    endif
  else
    assign sizes_attr = '(min-width: 750px) ' | append: section.settings.media_width | append: 'vw, 100vw'
  endif
-%}

{%- style -%}
  #shopify-section-{{ section.id }} .christmas-product {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round }}px;
    margin: 0;
  }

  #shopify-section-{{ section.id }} .christmas-product__inner {
    max-width: {{ section.settings.content_width }}px;
    margin: 0 auto;
  }

  /* ---------- Image gallery ---------- */
  #shopify-section-{{ section.id }} .xmas-gallery {
    display: block;
    position: relative;
  }

  #shopify-section-{{ section.id }} .xmas-gallery__track {
    display: flex;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    aspect-ratio: {{ ratio_mobile }};
    background: rgba(var(--color-foreground), 0.04);
  }

  #shopify-section-{{ section.id }} .xmas-gallery__track::-webkit-scrollbar {
    display: none;
  }

  #shopify-section-{{ section.id }} .xmas-gallery__slide {
    flex: 0 0 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  #shopify-section-{{ section.id }} .xmas-gallery__slide img,
  #shopify-section-{{ section.id }} .xmas-gallery__slide svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  #shopify-section-{{ section.id }} .xmas-gallery__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 4.4rem;
    height: 4.4rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: #121212;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  }

  #shopify-section-{{ section.id }} .xmas-gallery__arrow:hover {
    background: #fff;
  }

  #shopify-section-{{ section.id }} .xmas-gallery__arrow--prev { left: 1.2rem; }
  #shopify-section-{{ section.id }} .xmas-gallery__arrow--next { right: 1.2rem; }

  #shopify-section-{{ section.id }} .xmas-gallery__dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.8rem;
    z-index: 2;
    display: flex;
    justify-content: center;
  }

  #shopify-section-{{ section.id }} .xmas-gallery__dot {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border: 0;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  #shopify-section-{{ section.id }} .xmas-gallery__dot::before {
    content: '';
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  }

  #shopify-section-{{ section.id }} .xmas-gallery__dot[aria-current="true"]::before {
    background: #fff;
  }

  /* ---------- Product info (fixes overlapping text) ---------- */
  #shopify-section-{{ section.id }} .product__info-wrapper {
    padding: 0;
    max-width: none;
    width: auto;
  }

  #shopify-section-{{ section.id }} .product__info-container {
    max-width: none;
  }

  #shopify-section-{{ section.id }} .product__info-container > * {
    margin-top: 0;
    margin-bottom: 0;
  }

  #shopify-section-{{ section.id }} .product__info-container > * + * {
    margin-top: 1.6rem;
  }

  #shopify-section-{{ section.id }} .product__info-container > .product__tax {
    margin-top: 0.4rem;
  }

  /* The (usually empty) instalments slot after the price shouldn't add extra space */
  #shopify-section-{{ section.id }} .product__info-container > .christmas-product__payment-terms {
    margin-top: 0;
  }

  #shopify-section-{{ section.id }} .product__info-container > .christmas-product__payment-terms form {
    margin: 0;
  }

  #shopify-section-{{ section.id }} .product__title {
    line-height: 1.2;
  }

  #shopify-section-{{ section.id }} .product__info-container .price {
    line-height: 1.3;
  }

  {%- if section.settings.options_inline %}
    /* Portion size and quantity on one line, each label centred above its control */
    #shopify-section-{{ section.id }} .product__info-container {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-start;
      column-gap: 3.2rem;
    }

    #shopify-section-{{ section.id }} .product__info-container > * {
      flex: 0 0 100%;
      min-width: 0;
    }

    #shopify-section-{{ section.id }} .product__info-container > variant-radios,
    #shopify-section-{{ section.id }} .product__info-container > variant-selects,
    #shopify-section-{{ section.id }} .product__info-container > .product-form__quantity {
      flex: 0 0 auto;
    }

    #shopify-section-{{ section.id }} .product__info-container > variant-radios .product-form__input,
    #shopify-section-{{ section.id }} .product__info-container > variant-selects .product-form__input {
      margin: 0;
      max-width: none;
    }

    #shopify-section-{{ section.id }} .product__info-container > .product-form__quantity {
      margin: 1.6rem 0 0;
      max-width: none;
    }

    #shopify-section-{{ section.id }} .product__info-container > variant-radios legend {
      width: 100%;
      text-align: center;
    }

    #shopify-section-{{ section.id }} .product__info-container > variant-selects .form__label,
    #shopify-section-{{ section.id }} .product__info-container > .product-form__quantity .form__label {
      display: block;
      text-align: center;
    }
  {%- endif %}

  {%- if section.settings.text_align == 'center' %}
    /* Centre all text-based elements in the text column */
    #shopify-section-{{ section.id }} .product__info-container {
      text-align: center;
      justify-content: center;
    }

    #shopify-section-{{ section.id }} .product__info-container .rte,
    #shopify-section-{{ section.id }} .product__info-container .product__description,
    #shopify-section-{{ section.id }} .product__info-container .product__title,
    #shopify-section-{{ section.id }} .product__info-container .product__text {
      text-align: center;
    }

    #shopify-section-{{ section.id }} .product__info-container .price {
      justify-content: center;
      text-align: center;
    }

    #shopify-section-{{ section.id }} .product__info-container legend,
    #shopify-section-{{ section.id }} .product__info-container .form__label {
      display: block;
      width: 100%;
      text-align: center;
    }

    #shopify-section-{{ section.id }} .product__info-container .product-form__input {
      margin-left: auto;
      margin-right: auto;
    }

    #shopify-section-{{ section.id }} .product__info-container quantity-input {
      margin-left: auto;
      margin-right: auto;
    }

    #shopify-section-{{ section.id }} .product__info-container .product__view-details {
      justify-content: center;
    }
  {%- endif %}

  /* Selected option (e.g. portion size) uses the same colour as the Add to cart button */
  #shopify-section-{{ section.id }} .product-form__input input[type='radio']:checked + label {
    {%- if section.settings.selected_color != blank %}
      background-color: {{ section.settings.selected_color }};
      border-color: {{ section.settings.selected_color }};
      color: {{ section.settings.selected_text_color | default: '#ffffff' }};
    {%- else %}
      background-color: rgb(var(--color-button, var(--color-base-accent-1)));
      border-color: rgb(var(--color-button, var(--color-base-accent-1)));
      color: rgb(var(--color-button-text, var(--color-base-solid-button-labels)));
    {%- endif %}
  }

  /* ---------- Layout ---------- */
  #shopify-section-{{ section.id }} .christmas-product__info {
    max-width: {{ section.settings.text_width }}px;
    margin: 3.2rem auto 0;
  }

  #shopify-section-{{ section.id }} .christmas-product__grid > .product__media-wrapper {
    padding: 0;
    margin: 0;
  }

  #shopify-section-{{ section.id }} .christmas-product__grid > .product__info-wrapper {
    margin-top: 2.4rem;
  }

  @media screen and (min-width: 750px) {
    #shopify-section-{{ section.id }} .christmas-product {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }

    #shopify-section-{{ section.id }} .xmas-gallery__track {
      aspect-ratio: {{ ratio_desktop }};
    }

    #shopify-section-{{ section.id }} .xmas-gallery__arrow--prev { left: 2rem; }
    #shopify-section-{{ section.id }} .xmas-gallery__arrow--next { right: 2rem; }

    #shopify-section-{{ section.id }} .christmas-product__grid {
      display: flex;
      flex-wrap: nowrap;
      align-items: flex-start;
      gap: 5rem;
      margin: 0;
    }

    /* Image on the right: swap the order of the two columns */
    #shopify-section-{{ section.id }} .christmas-product__grid.christmas-product__grid--media-right > .product__media-wrapper {
      order: 2;
    }

    #shopify-section-{{ section.id }} .christmas-product__grid.christmas-product__grid--media-right > .product__info-wrapper {
      order: 1;
    }

    #shopify-section-{{ section.id }} .christmas-product__grid > .product__media-wrapper {
      flex: 0 0 {{ section.settings.media_width }}%;
      max-width: {{ section.settings.media_width }}%;
      width: auto;
    }

    #shopify-section-{{ section.id }} .christmas-product__grid > .product__info-wrapper {
      flex: 1 1 0;
      min-width: 0;
      margin: 0;
      {%- if section.settings.text_valign == 'center' %}
        align-self: center;
      {%- endif %}
    }

    {%- if section.settings.fill_height %}
      /* Image fills the full height of the text column */
      #shopify-section-{{ section.id }} .christmas-product__grid {
        align-items: stretch;
      }

      #shopify-section-{{ section.id }} .christmas-product__grid > .product__media-wrapper .xmas-gallery {
        height: 100%;
      }

      #shopify-section-{{ section.id }} .christmas-product__grid > .product__media-wrapper .xmas-gallery__track {
        aspect-ratio: auto;
        height: 100%;
        min-height: {{ section.settings.min_image_height }}px;
      }
    {%- endif %}
  }
{%- endstyle -%}

{%- capture gallery -%}
  <xmas-gallery class="xmas-gallery" data-autoplay="{{ section.settings.autoplay_seconds }}">
    <div class="xmas-gallery__track" data-track aria-label="{{ product.title | escape }} images">
      {%- assign slide_number = 0 -%}
      {%- for media in product.media -%}
        {%- if media.media_type == 'image' -%}
          {%- assign slide_number = slide_number | plus: 1 -%}
          {%- if slide_number == 1 -%}
            {%- assign img_loading = 'eager' -%}
          {%- else -%}
            {%- assign img_loading = 'lazy' -%}
          {%- endif -%}
          {%- assign img_style = 'object-position: ' | append: media.preview_image.presentation.focal_point -%}
          {%- assign img_alt = media.alt | default: product.title -%}
          <div class="xmas-gallery__slide" data-slide data-media-ref="{{ media.id }}" role="group" aria-label="Image {{ slide_number }} of {{ image_count }}">
            {{ media.preview_image | image_url: width: 3000 | image_tag: widths: '600, 900, 1200, 1600, 2000, 2400, 3000', sizes: sizes_attr, loading: img_loading, alt: img_alt, style: img_style }}
          </div>
        {%- endif -%}
      {%- endfor -%}
      {%- if image_count == 0 -%}
        <div class="xmas-gallery__slide">
          {{ 'product-1' | placeholder_svg_tag: 'placeholder-svg' }}
        </div>
      {%- endif -%}
    </div>

    {%- if image_count > 1 -%}
      <button type="button" class="xmas-gallery__arrow xmas-gallery__arrow--prev" data-prev aria-label="Previous image">
        <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M15 5l-7 7 7 7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
      </button>
      <button type="button" class="xmas-gallery__arrow xmas-gallery__arrow--next" data-next aria-label="Next image">
        <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M9 5l7 7-7 7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
      </button>
      <div class="xmas-gallery__dots">
        {%- for i in (1..image_count) -%}
          <button type="button" class="xmas-gallery__dot" data-dot aria-label="Show image {{ i }}"{% if i == 1 %} aria-current="true"{% endif %}></button>
        {%- endfor -%}
      </div>
    {%- endif -%}
  </xmas-gallery>
{%- endcapture -%}

{%- capture info -%}
  <div class="product__info-wrapper">
    <div id="ProductInfo-{{ section.id }}" class="product__info-container">
      {%- for block in section.blocks -%}
        {%- case block.type -%}
        {%- when 'text' -%}
          <p class="product__text{% if block.settings.text_style == 'uppercase' %} caption-with-letter-spacing{% elsif block.settings.text_style == 'subtitle' %} subtitle{% endif %}" {{ block.shopify_attributes }}>
            {{- block.settings.text -}}
          </p>
        {%- when 'rich_text' -%}
          <div class="product__description rte" {{ block.shopify_attributes }}>
            {{- block.settings.text -}}
          </div>
        {%- when 'description' -%}
          {%- if product.description != blank -%}
            <div class="product__description rte" {{ block.shopify_attributes }}>
              {{ product.description }}
            </div>
          {%- endif -%}
        {%- when 'title' -%}
          <h2 class="h1 product__title" {{ block.shopify_attributes }}>
            {%- if product.title != blank -%}
              {{ product.title | escape }}
            {%- else -%}
              {{ 'onboarding.product_title' | t }}
            {%- endif -%}
          </h2>
        {%- when 'price' -%}
          <div class="no-js-hidden" id="price-{{ section.id }}" role="status" {{ block.shopify_attributes }}>
            {%- render 'price', product: product, use_variant: true, show_badges: true, price_class: 'price--large' -%}
          </div>
          {%- if shop.taxes_included or shop.shipping_policy.body != blank -%}
            <div class="product__tax caption rte">
              {%- if shop.taxes_included -%}
                {{ 'products.product.include_taxes' | t }}
              {%- endif -%}
              {%- if shop.shipping_policy.body != blank -%}
                {{ 'products.product.shipping_policy_html' | t: link: shop.shipping_policy.url }}
              {%- endif -%}
            </div>
          {%- endif -%}
          {%- if product != blank -%}
            <div class="christmas-product__payment-terms" {{ block.shopify_attributes }}>
              {%- form 'product', product -%}
                <input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
                {{ form | payment_terms }}
              {%- endform -%}
            </div>
          {%- endif -%}
        {%- when 'quantity_selector' -%}
          <div class="product-form__input product-form__quantity" {{ block.shopify_attributes }}>
            <label class="form__label" for="Quantity-{{ section.id }}">
              {{ 'products.product.quantity.label' | t }}
            </label>
            <quantity-input class="quantity">
              <button class="quantity__button no-js-hidden" name="minus" type="button">
                <span class="visually-hidden">{{ 'products.product.quantity.decrease' | t: product: product.title | escape }}</span>
                {% render 'icon-minus' %}
              </button>
              <input class="quantity__input"
                  type="number"
                  name="quantity"
                  id="Quantity-{{ section.id }}"
                  min="1"
                  value="1"
                  form="{{ product_form_id }}"
                >
              <button class="quantity__button no-js-hidden" name="plus" type="button">
                <span class="visually-hidden">{{ 'products.product.quantity.increase' | t: product: product.title | escape }}</span>
                {% render 'icon-plus' %}
              </button>
            </quantity-input>
          </div>
        {%- when 'variant_picker' -%}
          {%- unless product.has_only_default_variant -%}
            {%- if block.settings.picker_type == 'button' -%}
              <variant-radios class="no-js-hidden" data-section="{{ section.id }}" data-url="{{ product.url }}" data-update-url="false" {{ block.shopify_attributes }}>
                {%- for option in product.options_with_values -%}
                    <fieldset class="js product-form__input">
                      <legend class="form__label">{{ option.name }}</legend>
                      {%- for value in option.values -%}
                        <input type="radio" id="{{ section.id }}-{{ option.position }}-{{ forloop.index0 }}"
                              name="{{ option.name }}"
                              value="{{ value | escape }}"
                              form="{{ product_form_id }}"
                              {% if option.selected_value == value %}checked{% endif %}
                        >
                        <label for="{{ section.id }}-{{ option.position }}-{{ forloop.index0 }}">
                          {{ value }}
                        </label>
                      {%- endfor -%}
                    </fieldset>
                {%- endfor -%}
                <script type="application/json">
                  {{ product.variants | json }}
                </script>
              </variant-radios>
            {%- else -%}
              <variant-selects class="no-js-hidden" data-section="{{ section.id }}" data-url="{{ product.url }}" data-update-url="false" {{ block.shopify_attributes }}>
                {%- for option in product.options_with_values -%}
                  <div class="product-form__input product-form__input--dropdown">
                    <label class="form__label" for="Option-{{ section.id }}-{{ forloop.index0 }}">
                      {{ option.name }}
                    </label>
                    <div class="select">
                      <select id="Option-{{ section.id }}-{{ forloop.index0 }}"
                        class="select__select"
                        name="options[{{ option.name | escape }}]"
                        form="{{ product_form_id }}"
                      >
                        {%- for value in option.values -%}
                          <option value="{{ value | escape }}" {% if option.selected_value == value %}selected="selected"{% endif %}>
                            {{ value }}
                          </option>
                        {%- endfor -%}
                      </select>
                      {% render 'icon-caret' %}
                    </div>
                  </div>
                {%- endfor -%}

                <script type="application/json">
                  {{ product.variants | json }}
                </script>
              </variant-selects>
            {%- endif -%}
          {%- endunless -%}

          <noscript class="product-form__noscript-wrapper-{{ section.id }}">
            <div class="product-form__input{% if product.has_only_default_variant %} hidden{% endif %}">
              <label class="form__label" for="Variants-{{ section.id }}">{{ 'products.product.product_variants' | t }}</label>
              <div class="select">
                <select name="id" id="Variants-{{ section.id }}" class="select__select" form="{{ product_form_id }}">
                  {%- for variant in product.variants -%}
                    <option
                      {% if variant == product.selected_or_first_available_variant %}selected="selected"{% endif %}
                      {% if variant.available == false %}disabled{% endif %}
                      value="{{ variant.id }}"
                    >
                      {{ variant.title }}
                      {%- if variant.available == false %} - {{ 'products.product.sold_out' | t }}{% endif %}
                      - {{ variant.price | money | strip_html }}
                    </option>
                  {%- endfor -%}
                </select>
                {% render 'icon-caret' %}
              </div>
            </div>
          </noscript>
        {%- when 'buy_buttons' -%}
          <div {{ block.shopify_attributes }}>
            {%- if product != blank -%}
              <product-form class="product-form">
                <div class="product-form__error-message-wrapper" role="alert" hidden>
                  <svg aria-hidden="true" focusable="false" role="presentation" class="icon icon-error" viewBox="0 0 13 13">
                    <circle cx="6.5" cy="6.50049" r="5.5" stroke="white" stroke-width="2"/>
                    <circle cx="6.5" cy="6.5" r="5.5" fill="#EB001B" stroke="#EB001B" stroke-width="0.7"/>
                    <path d="M5.87413 3.52832L5.97439 7.57216H7.02713L7.12739 3.52832H5.87413ZM6.50076 9.66091C6.88091 9.66091 7.18169 9.37267 7.18169 9.00504C7.18169 8.63742 6.88091 8.34917 6.50076 8.34917C6.12061 8.34917 5.81982 8.63742 5.81982 9.00504C5.81982 9.37267 6.12061 9.66091 6.50076 9.66091Z" fill="white"/>
                    <path d="M5.87413 3.17832H5.51535L5.52424 3.537L5.6245 7.58083L5.63296 7.92216H5.97439H7.02713H7.36856L7.37702 7.58083L7.47728 3.537L7.48617 3.17832H7.12739H5.87413ZM6.50076 10.0109C7.06121 10.0109 7.5317 9.57872 7.5317 9.00504C7.5317 8.43137 7.06121 7.99918 6.50076 7.99918C5.94031 7.99918 5.46982 8.43137 5.46982 9.00504C5.46982 9.57872 5.94031 10.0109 6.50076 10.0109Z" fill="white" stroke="#EB001B" stroke-width="0.7">
                  </svg>
                  <span class="product-form__error-message"></span>
                </div>

                {%- form 'product', product, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}
                  <input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}" disabled>
                  <div class="product-form__buttons">
                    <button
                      type="submit"
                      name="add"
                      class="product-form__submit button button--full-width {% if block.settings.show_dynamic_checkout and product.selling_plan_groups == empty %}button--secondary{% else %}button--primary{% endif %}"
                    {% if product.selected_or_first_available_variant.available == false %}disabled{% endif %}
                    >
                        <span>
                          {%- if product.selected_or_first_available_variant.available -%}
                            {{ 'products.product.add_to_cart' | t }}
                          {%- else -%}
                            {{ 'products.product.sold_out' | t }}
                          {%- endif -%}
                        </span>
                        <div class="loading-overlay__spinner hidden">
                          <svg aria-hidden="true" focusable="false" role="presentation" class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
                            <circle class="path" fill="none" stroke-width="6" cx="33" cy="33" r="30"></circle>
                          </svg>
                        </div>
                    </button>
                    {%- if block.settings.show_dynamic_checkout -%}
                      {{ form | payment_button }}
                    {%- endif -%}
                  </div>
                {%- endform -%}
              </product-form>
            {%- else -%}
              <div class="product-form">
                <div class="product-form__buttons form">
                  <button
                    type="submit"
                    name="add"
                    class="product-form__submit button button--full-width button--primary"
                    disabled
                  >
                    {{ 'products.product.sold_out' | t }}
                  </button>
                </div>
              </div>
            {%- endif -%}
          </div>
        {%- when 'custom_liquid' -%}
          {{ block.settings.custom_liquid }}
        {%- when 'rating' -%}
          {%- if product.metafields.reviews.rating.value != blank -%}
            {% liquid
              assign rating_decimal = 0
              assign decimal = product.metafields.reviews.rating.value.rating | modulo: 1
              if decimal >= 0.3 and decimal <= 0.7
                assign rating_decimal = 0.5
              elsif decimal > 0.7
                assign rating_decimal = 1
              endif
            %}
            <div class="rating" role="img" aria-label="{{ 'accessibility.star_reviews_info' | t: rating_value: product.metafields.reviews.rating.value, rating_max: product.metafields.reviews.rating.value.scale_max }}">
              <span aria-hidden="true" class="rating-star" style="--rating: {{ product.metafields.reviews.rating.value.rating | floor }}; --rating-max: {{ product.metafields.reviews.rating.value.scale_max }}; --rating-decimal: {{ rating_decimal }};"></span>
            </div>
            <p class="rating-text caption">
              <span aria-hidden="true">{{ product.metafields.reviews.rating.value }} / {{ product.metafields.reviews.rating.value.scale_max }}</span>
            </p>
            <p class="rating-count caption">
              <span aria-hidden="true">({{ product.metafields.reviews.rating_count }})</span>
              <span class="visually-hidden">{{ product.metafields.reviews.rating_count }} {{ "accessibility.total_reviews" | t }}</span>
            </p>
          {%- endif -%}
        {%- endcase -%}
      {%- endfor -%}
      {%- if section.settings.show_view_details -%}
        <a href="{{ product.url }}" class="link product__view-details animate-arrow">
          {{ 'products.product.view_full_details' | t }}
          {% render 'icon-arrow' %}
        </a>
      {%- endif -%}
    </div>
  </div>
{%- endcapture -%}

<div class="christmas-product{% if section.settings.secondary_background %} background-secondary{% endif %}">
  {%- if layout == 'stacked' -%}
    {%- if section.settings.full_bleed -%}
      {{ gallery }}
    {%- else -%}
      <div class="page-width">
        <div class="christmas-product__inner">
          {{ gallery }}
        </div>
      </div>
    {%- endif -%}
    <div class="page-width">
      <div class="christmas-product__info product">
        {{ info }}
      </div>
    </div>
  {%- else -%}
    <div class="page-width">
      <div class="christmas-product__inner">
        <div class="product christmas-product__grid{% if section.settings.media_position == 'right' %} christmas-product__grid--media-right{% endif %}">
          <div class="product__media-wrapper">
            {{ gallery }}
          </div>
          {{ info }}
        </div>
      </div>
    </div>
  {%- endif -%}

  {%- comment -%}
    Hidden anchors so the theme's variant picker script finds the media it
    looks for, without reordering the visible gallery.
  {%- endcomment -%}
  <ul hidden aria-hidden="true">
    {%- for media in product.media -%}
      <li class="product__media-item" data-media-id="{{ section.id }}-{{ media.id }}"></li>
    {%- endfor -%}
  </ul>
</div>

<script>
  if (!customElements.get('xmas-gallery')) {
    customElements.define('xmas-gallery', class XmasGallery extends HTMLElement {
      connectedCallback() {
        this.track = this.querySelector('[data-track]');
        this.slides = Array.from(this.querySelectorAll('[data-slide]'));
        this.dots = Array.from(this.querySelectorAll('[data-dot]'));
        this.index = 0;
        if (!this.track || this.slides.length < 2) return;

        const prev = this.querySelector('[data-prev]');
        const next = this.querySelector('[data-next]');
        if (prev) prev.addEventListener('click', () => { this.stopAutoplay(); this.goTo(this.index - 1); });
        if (next) next.addEventListener('click', () => { this.stopAutoplay(); this.goTo(this.index + 1); });
        this.dots.forEach((dot, i) => {
          dot.addEventListener('click', () => { this.stopAutoplay(); this.goTo(i); });
        });

        this.track.addEventListener('scroll', () => {
          clearTimeout(this.scrollTimer);
          this.scrollTimer = setTimeout(() => this.syncFromScroll(), 80);
        }, { passive: true });
        this.track.addEventListener('pointerdown', () => this.stopAutoplay(), { passive: true });

        // When a variant (e.g. "Serves Two") is chosen, show that variant's image.
        this.section = this.closest('.shopify-section') || this.parentElement;
        this.onVariantChange = (event) => {
          const picker = event.target.closest('variant-radios, variant-selects');
          if (!picker) return;
          const variant = picker.currentVariant;
          if (variant && variant.featured_media) this.goToMedia(variant.featured_media.id);
        };
        this.section.addEventListener('change', this.onVariantChange);

        const seconds = parseFloat(this.dataset.autoplay || '0');
        const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
        if (seconds > 0 && !reduceMotion) {
          this.paused = false;
          this.addEventListener('mouseenter', () => { this.paused = true; });
          this.addEventListener('mouseleave', () => { this.paused = false; });
          this.timer = setInterval(() => {
            if (!this.paused) this.goTo(this.index + 1);
          }, seconds * 1000);
        }
      }

      disconnectedCallback() {
        this.stopAutoplay();
        if (this.section && this.onVariantChange) {
          this.section.removeEventListener('change', this.onVariantChange);
        }
      }

      stopAutoplay() {
        if (this.timer) {
          clearInterval(this.timer);
          this.timer = null;
        }
      }

      goTo(i) {
        const count = this.slides.length;
        this.index = ((i % count) + count) % count;
        this.track.scrollTo({ left: this.index * this.track.clientWidth, behavior: 'smooth' });
        this.updateDots();
      }

      goToMedia(mediaId) {
        const i = this.slides.findIndex((slide) => slide.dataset.mediaRef === String(mediaId));
        if (i > -1) this.goTo(i);
      }

      syncFromScroll() {
        const i = Math.round(this.track.scrollLeft / this.track.clientWidth);
        if (i !== this.index && i >= 0 && i < this.slides.length) {
          this.index = i;
          this.updateDots();
        }
      }

      updateDots() {
        this.dots.forEach((dot, n) => {
          if (n === this.index) {
            dot.setAttribute('aria-current', 'true');
          } else {
            dot.removeAttribute('aria-current');
          }
        });
      }
    });
  }
</script>
<script src="{{ 'product-form.js' | asset_url }}" defer="defer"></script>

{%- liquid
  if product.selected_or_first_available_variant.featured_media
    assign seo_media = product.selected_or_first_available_variant.featured_media
  else
    assign seo_media = product.featured_media
  endif
-%}

<script type="application/ld+json">
  {
    "@context": "http://schema.org/",
    "@type": "Product",
    "name": {{ product.title | json }},
    "url": {{ shop.url | append: product.url | json }},
    {% if seo_media -%}
      {%- assign media_size = seo_media.preview_image.width | append: 'x' -%}
      "image": [
        {{ seo_media | img_url: media_size | prepend: "https:" | json }}
      ],
    {%- endif %}
    "description": {{ product.description | strip_html | json }},
    {% if product.selected_or_first_available_variant.sku != blank -%}
      "sku": {{ product.selected_or_first_available_variant.sku | json }},
    {%- endif %}
    "brand": {
      "@type": "Thing",
      "name": {{ product.vendor | json }}
    },
    "offers": [
      {%- for variant in product.variants -%}
        {
          "@type" : "Offer",
          {%- if variant.sku != blank -%}
            "sku": {{ variant.sku | json }},
          {%- endif -%}
          "availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
          "price" : {{ variant.price | divided_by: 100.00 | json }},
          "priceCurrency" : {{ cart.currency.iso_code | json }},
          "url" : {{ shop.url | append: variant.url | json }}
        }{% unless forloop.last %},{% endunless %}
      {%- endfor -%}
    ]
  }
</script>

{% schema %}
{
  "name": "Christmas product",
  "tag": "section",
  "class": "christmas-product-section",
  "blocks": [
    {
      "type": "text",
      "name": "Text (one line)",
      "settings": [
        {
          "type": "text",
          "id": "text",
          "default": "Text block",
          "label": "Text"
        },
        {
          "type": "select",
          "id": "text_style",
          "options": [
            { "value": "body", "label": "Body" },
            { "value": "subtitle", "label": "Subtitle" },
            { "value": "uppercase", "label": "Uppercase" }
          ],
          "default": "body",
          "label": "Text style"
        }
      ]
    },
    {
      "type": "rich_text",
      "name": "Landing page copy",
      "settings": [
        {
          "type": "richtext",
          "id": "text",
          "default": "<p>Write the copy for this product here.</p>",
          "label": "Copy"
        }
      ]
    },
    {
      "type": "description",
      "name": "Product description",
      "limit": 1
    },
    {
      "type": "title",
      "name": "Title",
      "limit": 1
    },
    {
      "type": "price",
      "name": "Price",
      "limit": 1
    },
    {
      "type": "quantity_selector",
      "name": "Quantity selector",
      "limit": 1
    },
    {
      "type": "variant_picker",
      "name": "Variant picker",
      "limit": 1,
      "settings": [
        {
          "type": "select",
          "id": "picker_type",
          "options": [
            { "value": "dropdown", "label": "Dropdown" },
            { "value": "button", "label": "Buttons" }
          ],
          "default": "button",
          "label": "Type"
        }
      ]
    },
    {
      "type": "buy_buttons",
      "name": "Buy buttons",
      "limit": 1,
      "settings": [
        {
          "type": "checkbox",
          "id": "show_dynamic_checkout",
          "default": true,
          "label": "Show dynamic checkout buttons (Buy it now)"
        }
      ]
    },
    {
      "type": "custom_liquid",
      "name": "Custom liquid",
      "settings": [
        {
          "type": "liquid",
          "id": "custom_liquid",
          "label": "Custom liquid"
        }
      ]
    },
    {
      "type": "rating",
      "name": "Product rating",
      "limit": 1
    }
  ],
  "settings": [
    {
      "type": "product",
      "id": "product",
      "label": "Product"
    },
    {
      "type": "header",
      "content": "Layout"
    },
    {
      "type": "select",
      "id": "layout",
      "label": "Layout",
      "options": [
        { "value": "stacked", "label": "Image above text (banner width)" },
        { "value": "side", "label": "Image beside text" }
      ],
      "default": "side"
    },
    {
      "type": "checkbox",
      "id": "full_bleed",
      "default": true,
      "label": "Image runs edge to edge",
      "info": "Only applies when the image is above the text."
    },
    {
      "type": "range",
      "id": "content_width",
      "min": 800,
      "max": 1600,
      "step": 50,
      "unit": "px",
      "label": "Maximum width",
      "info": "With 'Image beside text', increasing this makes the text and copy column wider.",
      "default": 1200
    },
    {
      "type": "range",
      "id": "text_width",
      "min": 400,
      "max": 1000,
      "step": 20,
      "unit": "px",
      "label": "Text column width",
      "info": "Only applies when the image is above the text.",
      "default": 640
    },
    {
      "type": "range",
      "id": "media_width",
      "min": 30,
      "max": 70,
      "step": 5,
      "unit": "%",
      "label": "Image width on desktop",
      "info": "Only applies to 'Image beside text'. Lower = wider text and copy column.",
      "default": 50
    },
    {
      "type": "select",
      "id": "text_align",
      "label": "Text alignment",
      "options": [
        { "value": "left", "label": "Left" },
        { "value": "center", "label": "Centre" }
      ],
      "default": "left"
    },
    {
      "type": "select",
      "id": "text_valign",
      "label": "Text position next to image",
      "info": "Only applies to 'Image beside text' on desktop.",
      "options": [
        { "value": "top", "label": "Top" },
        { "value": "center", "label": "Middle" }
      ],
      "default": "center"
    },
    {
      "type": "checkbox",
      "id": "fill_height",
      "default": true,
      "label": "Image fills the height of the text",
      "info": "Only applies to 'Image beside text' on desktop. Overrides 'Image shape on desktop'."
    },
    {
      "type": "range",
      "id": "min_image_height",
      "min": 300,
      "max": 800,
      "step": 20,
      "unit": "px",
      "label": "Minimum image height",
      "default": 460
    },
    {
      "type": "select",
      "id": "media_position",
      "label": "Image position on desktop",
      "info": "Only applies to 'Image beside text'.",
      "options": [
        { "value": "left", "label": "Left" },
        { "value": "right", "label": "Right" }
      ],
      "default": "left"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 120,
      "step": 4,
      "unit": "px",
      "label": "Space above",
      "default": 32
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 120,
      "step": 4,
      "unit": "px",
      "label": "Space below",
      "default": 32
    },
    {
      "type": "checkbox",
      "id": "secondary_background",
      "default": false,
      "label": "Use secondary background"
    },
    {
      "type": "checkbox",
      "id": "show_view_details",
      "default": false,
      "label": "Show 'View full details' link"
    },
    {
      "type": "header",
      "content": "Portion size & quantity"
    },
    {
      "type": "checkbox",
      "id": "options_inline",
      "default": true,
      "label": "Show portion size and quantity side by side",
      "info": "Also centres each label above its buttons."
    },
    {
      "type": "header",
      "content": "Selected option colour"
    },
    {
      "type": "color",
      "id": "selected_color",
      "label": "Background",
      "info": "Leave empty to use your theme's button colour (the same as Add to cart)."
    },
    {
      "type": "color",
      "id": "selected_text_color",
      "label": "Text",
      "info": "Only used if you set a background colour above."
    },
    {
      "type": "header",
      "content": "Image gallery"
    },
    {
      "type": "select",
      "id": "ratio_desktop",
      "label": "Image shape on desktop",
      "options": [
        { "value": "21-9", "label": "Extra wide (21:9)" },
        { "value": "16-9", "label": "Wide (16:9)" },
        { "value": "3-2", "label": "Landscape (3:2)" },
        { "value": "4-3", "label": "Landscape (4:3)" },
        { "value": "1-1", "label": "Square" },
        { "value": "adapt", "label": "Match first image" }
      ],
      "default": "adapt"
    },
    {
      "type": "select",
      "id": "ratio_mobile",
      "label": "Image shape on mobile",
      "options": [
        { "value": "4-5", "label": "Portrait (4:5)" },
        { "value": "1-1", "label": "Square" },
        { "value": "4-3", "label": "Landscape (4:3)" },
        { "value": "16-9", "label": "Wide (16:9)" },
        { "value": "adapt", "label": "Match first image" }
      ],
      "default": "4-5"
    },
    {
      "type": "range",
      "id": "autoplay_seconds",
      "min": 0,
      "max": 10,
      "step": 1,
      "unit": "s",
      "label": "Auto-rotate images every",
      "info": "0 = off. Stops as soon as the customer swipes or taps an arrow.",
      "default": 0
    }
  ],
  "presets": [
    {
      "name": "Christmas product",
      "blocks": [
        { "type": "title" },
        { "type": "price" },
        { "type": "rich_text" },
        { "type": "variant_picker" },
        { "type": "quantity_selector" },
        { "type": "buy_buttons" }
      ]
    }
  ]
}
{% endschema %}
