{{ 'component-image-with-text.css' | asset_url | stylesheet_tag }}
{{ 'image-with-shop.css' | asset_url | stylesheet_tag }}

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

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

{%- liquid
  assign fetch_priority = 'auto'
  if section.index == 1
    assign fetch_priority = 'high'
  endif
  if section.settings.color_scheme == section.settings.section_color_scheme and section.settings.content_layout == 'no-overlap'
    assign remove_color_classes = true
  endif
-%}

<div class="section-{{ section.id }}-padding gradient color-{{ section.settings.section_color_scheme }}">
    {% unless section.settings.full_page_content %}<div class="page-width">{% endunless %}
    <div class="image-with-text image-with-text--{{ section.settings.content_layout }} isolate{% if settings.text_boxes_border_thickness > 0 and settings.text_boxes_border_opacity > 0 and settings.media_border_thickness > 0 and settings.media_border_opacity > 0 %} collapse-borders{% endif %}{% unless section.settings.color_scheme == section.settings.section_color_scheme and settings.media_border_thickness > 0 and settings.text_boxes_shadow_opacity == 0 and settings.text_boxes_border_thickness == 0 or settings.text_boxes_border_opacity == 0 %} collapse-corners{% endunless %}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}">
      <div class="image-with-text__grid grid grid--gapless grid--1-col grid--3-col-tablet{% if section.settings.layout == 'text_first' %} image-with-text__grid--reverse{% endif %}">
        <div class="image-with-text__media-item image-with-shop__media-item image-with-text__media-item--{{ section.settings.desktop_content_position }} grid__item">
          <div
            class="image-with-text__media image-with-text__media--{{ section.settings.height }} global-media-settings{% unless remove_color_classes %} gradient color-{{ section.settings.color_scheme }}{% else %} background-transparent{% endunless %}{% if section.settings.image != blank %} media{% else %} image-with-text__media--placeholder placeholder{% endif %}{% if section.settings.image_behavior != 'none' %} animate--{{ section.settings.image_behavior }}{% endif %}"
            {% if section.settings.height == 'adapt' and section.settings.image != blank %}
              style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"
            {% endif %}
          >
            {%- if section.settings.image != blank -%}
              {%- if section.settings.image_behavior == 'ambient' or section.settings.image_behavior == 'zoom-in' -%}
                {%- assign widths = '198, 432, 642, 900, 1284, 1800' -%}
                {%- capture sizes -%}
              (min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 1.6667 }}px,
              (min-width: 750px) calc((100vw - 130px) / 1.667), calc((100vw - 50px) / 1.667)
            {%- endcapture -%}
              {%- else -%}
                {%- assign widths = '165, 360, 535, 750, 1070, 1500' -%}
                {%- capture sizes -%}
              (min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px,
              (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)
            {%- endcapture -%}
              {%- endif -%}
              {{
                section.settings.image
                | image_url: width: 1500
                | image_tag: sizes: sizes, widths: widths, fetchpriority: fetch_priority
              }}
            {%- else -%}
              {{ 'detailed-apparel-1' | placeholder_svg_tag: 'placeholder-svg' }}
            {%- endif -%}
          </div>
          {% render "tag-badge", props: section%}
        </div>
        <div class="image-with-shop__text-item grid__item">

        {%- for block in section.blocks -%}
            {% case block.type %}
              {%- when 'image' -%}
                  {% if block.settings.shop_image != blank or block.settings.mbl_shop_image != blank  %}
                    <div class="image-with-shop__media-item">
                      <div class="media image-with-text__media--{{ section.settings.height }} global-media-settings desktop-image{% if block.settings.mbl_shop_image != blank %} small-hide{% endif %}"  
                        {% if section.settings.height == 'adapt' %}
                          style="padding-bottom: {{ 1 | divided_by: block.settings.shop_image.aspect_ratio | times: 100 }}%;"
                        {% endif %}>
                          {{ block.settings.shop_image | image_url: width: block.settings.shop_image.width | image_tag }}
                      </div>
                      {% if block.settings.mbl_shop_image != blank %}
                        <div class="media image-with-text__media--{{ section.settings.height }} global-media-settings medium-hide large-up-hide"   
                          {% if section.settings.height == 'adapt' %}
                            style="padding-bottom: {{ 1 | divided_by: block.settings.mbl_shop_image.aspect_ratio | times: 100 }}%;"
                          {% endif %}
                        >
                          {{ block.settings.mbl_shop_image | image_url: width: block.settings.mbl_shop_image.width | image_tag }}
                        </div>
                      {% endif %}

                      {% render "tag-badge", props: block%}
                    </div>

                  {% endif %}
                {% endcase %}
            {% endfor %}
          <div
            id="ImageWithText--{{ section.id }}"
            class="image-with-text__content image-with-text__content--{{ section.settings.desktop_content_position }} image-with-text__content--desktop-{{ section.settings.desktop_content_alignment }} image-with-text__content--mobile-{{ section.settings.mobile_content_alignment }} image-with-text__content--{{ section.settings.height }} content-container{% unless remove_color_classes %} gradient color-{{ section.settings.color_scheme }}{% else %} background-transparent{% endunless %}"
          >
            {%- for block in section.blocks -%}
              {% case block.type %}
                {%- when 'heading' -%}
                  <h2
                    class="image-with-text__heading inline-richtext {{ block.settings.heading_size }}"
                    {{ block.shopify_attributes }}
                  >
                    {{ block.settings.heading }}
                  </h2>
                {%- when 'caption' -%}
                  <p
                    class="image-with-text__text image-with-text__text--caption {{ block.settings.text_style }} {{ block.settings.text_style }}--{{ block.settings.text_size }} {{ block.settings.text_style }}"
                    {{ block.shopify_attributes }}
                  >
                    {{ block.settings.caption | escape }}
                  </p>
                {%- when 'text' -%}
                  <div class="image-with-text__text rte {{ block.settings.text_style }}" {{ block.shopify_attributes }} style="color: {{ block.settings.text_color }}">
                    {{ block.settings.text }}
                  </div>
                {%- when 'button' -%}
                    <div class="buttons">
                        {%- if block.settings.button_label != blank -%}
                            <a
                                {% if block.settings.button_link == blank %} 
                                role="link" aria-disabled="true"
                                {% else %} 
                                href="{{ block.settings.button_link }}"
                                {% endif %} 
                                class="button{% if block.settings.button_style_secondary %} button--secondary{% else %} button--primary{% endif %}">
                                {{ block.settings.button_label | escape }}
                            </a>
                        {%- endif -%}
                        {%- if block.settings.button_label_2 != blank -%}
                            <a
                              {% if block.settings.button_link_2 == blank %}
                                role="link" aria-disabled="true"
                              {% else %} 
                                href="{{ block.settings.button_link_2 }}"
                              {% endif %} 
                              class="button{% if block.settings.button_style_secondary_2 %} button--secondary{% else %} button--primary{% endif %}">
                                {{ block.settings.button_label_2 | escape }}
                            </a>
                        {%- endif -%}

                    </div>
              {%- endcase -%}
            {%- endfor -%}
          </div>
        </div>
      </div>
    </div>
    {% unless section.settings.full_page_content %}</div>{% endunless %}
</div>

{% schema %}
{
  "name": "Image with shop",
  "class": "section image-with-shop-section",
  "disabled_on": {
    "groups": ["header", "footer"]
  },
  "settings": [
    {
      "type": "checkbox",
      "id": "full_page_content",
      "label": "Make this content full width?",
	    "default": false
    },
    {
      "type": "image_picker",
      "id": "image",
      "label": "t:sections.image-with-text.settings.image.label"
    },
    {
      "type": "select",
      "id": "height",
      "options": [
        {
          "value": "adapt",
          "label": "t:sections.image-with-text.settings.height.options__1.label"
        },
        {
          "value": "small",
          "label": "t:sections.image-with-text.settings.height.options__2.label"
        },
        {
          "value": "medium",
          "label": "t:sections.image-with-text.settings.height.options__3.label"
        },
        {
          "value": "large",
          "label": "t:sections.image-with-text.settings.height.options__4.label"
        }
      ],
      "default": "adapt",
      "label": "t:sections.image-with-text.settings.height.label"
    },
    {
      "type": "select",
      "id": "layout",
      "options": [
        {
          "value": "image_first",
          "label": "t:sections.image-with-text.settings.layout.options__1.label"
        },
        {
          "value": "text_first",
          "label": "t:sections.image-with-text.settings.layout.options__2.label"
        }
      ],
      "default": "image_first",
      "label": "t:sections.image-with-text.settings.layout.label"
    },
    {
      "type": "select",
      "id": "image_behavior",
      "options": [
        {
          "value": "none",
          "label": "t:sections.all.animation.image_behavior.options__1.label"
        },
        {
          "value": "ambient",
          "label": "t:sections.all.animation.image_behavior.options__2.label"
        },
        {
          "value": "zoom-in",
          "label": "t:sections.all.animation.image_behavior.options__4.label"
        }
      ],
      "default": "none",
      "label": "t:sections.all.animation.image_behavior.label"
    },
    {
      "type": "header",
      "content": "t:sections.image-with-text.settings.header.content"
    },
    {
      "type": "select",
      "id": "desktop_content_alignment",
      "options": [
        {
          "value": "left",
          "label": "t:sections.image-with-text.settings.desktop_content_alignment.options__1.label"
        },
        {
          "value": "center",
          "label": "t:sections.image-with-text.settings.desktop_content_alignment.options__2.label"
        },
        {
          "value": "right",
          "label": "t:sections.image-with-text.settings.desktop_content_alignment.options__3.label"
        }
      ],
      "default": "left",
      "label": "t:sections.image-with-text.settings.desktop_content_alignment.label"
    },
    {
      "type": "select",
      "id": "mobile_content_alignment",
      "options": [
        {
          "value": "left",
          "label": "t:sections.image-with-text.settings.mobile_content_alignment.options__1.label"
        },
        {
          "value": "center",
          "label": "t:sections.image-with-text.settings.mobile_content_alignment.options__2.label"
        },
        {
          "value": "right",
          "label": "t:sections.image-with-text.settings.mobile_content_alignment.options__3.label"
        }
      ],
      "default": "left",
      "label": "t:sections.image-with-text.settings.mobile_content_alignment.label"
    },
    {
      "type": "header",
      "content": "Tag"
    },
    {
      "type": "select",
      "id": "icon_type",
      "label": "Logo type",
      "options": [
        {
        "value": "image",
        "label": "Image"
        },
        {
        "value": "code",
        "label": "Code"
        }
      ],
      "default": "image"
    },
    {
      "type": "image_picker",
      "id": "tag_icon",
      "label": "Icon",
      "visible_if": "{{ section.settings.icon_type == 'image' }}"
    },
    {
      "type": "html",
      "id": "tag_icon_code",
      "label": "Icon code",
      "visible_if": "{{ section.settings.icon_type == 'code' }}"
    },
    {
      "type": "text",
      "label": "Text",
      "id": "tag_text"
    },
    {
      "type": "url",
      "label": "Link",
      "id": "tag_link"
    },
    {
      "type": "color",
      "label": "Text color",
      "id": "tag_color",
      "default": "#0F5028"
    },
    {
      "type": "color",
      "label": "Background color",
      "id": "tag_background",
      "default": "#FFFFFF"
    },
    {
      "type": "header",
      "content": "t:sections.image-with-text.settings.header_colors.content"
    },
    {
        "type": "select",
        "id": "section_color_scheme",
        "options": [
            {
            "value": "accent-1",
            "label": "t:sections.all.colors.accent_1.label"
            },
            {
            "value": "accent-2",
            "label": "t:sections.all.colors.accent_2.label"
            },
            {
            "value": "background-1",
            "label": "t:sections.all.colors.background_1.label"
            },
            {
            "value": "background-2",
            "label": "t:sections.all.colors.background_2.label"
            },
            {
            "value": "inverse",
            "label": "t:sections.all.colors.inverse.label"
            }
        ],
        "default": "background-1",
        "label": "t:sections.all.colors.label"
    },
    {
        "type": "select",
        "id": "color_scheme",
        "options": [
            {
            "value": "accent-1",
            "label": "t:sections.all.colors.accent_1.label"
            },
            {
            "value": "accent-2",
            "label": "t:sections.all.colors.accent_2.label"
            },
            {
            "value": "background-1",
            "label": "t:sections.all.colors.background_1.label"
            },
            {
            "value": "background-2",
            "label": "t:sections.all.colors.background_2.label"
            },
            {
            "value": "inverse",
            "label": "t:sections.all.colors.inverse.label"
            }
        ],
        "default": "background-1",
        "label": "t:sections.all.colors.label"
    },
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 36
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 36
    }
  ],
  "blocks": [
    {
        "type": "image",
        "name": "Image",
        "limit": 1,
        "settings": [
          {
            "type": "image_picker",
            "label": "Image",
            "id": "shop_image"
          },
          {
            "type": "image_picker",
            "label": "Mobile Image",
            "id": "mbl_shop_image"
          },
          {
            "type": "header",
            "content": "Tag"
          },
          {
            "type": "select",
            "id": "icon_type",
            "label": "Logo type",
            "options": [
              {
              "value": "image",
              "label": "Image"
              },
              {
              "value": "code",
              "label": "Code"
              }
            ],
            "default": "image"
          },
          {
            "type": "image_picker",
            "id": "tag_icon",
            "label": "Icon",
            "visible_if": "{{ section.settings.icon_type == 'image' }}"
          },
          {
            "type": "html",
            "id": "tag_icon_code",
            "label": "Icon code",
            "visible_if": "{{ section.settings.icon_type == 'code' }}"
          },
          {
            "type": "text",
            "label": "Text",
            "id": "tag_text"
          },
          {
            "type": "url",
            "label": "Link",
            "id": "tag_link"
          },
          {
            "type": "color",
            "label": "Text color",
            "id": "tag_color"
          },
          {
            "type": "color",
            "label": "Background color",
            "id": "tag_background"
          }
        ]
    },
    {
      "type": "heading",
      "name": "t:sections.image-with-text.blocks.heading.name",
      "limit": 1,
      "settings": [
        {
          "type": "inline_richtext",
          "id": "heading",
          "default": "t:sections.image-with-text.blocks.heading.settings.heading.default",
          "label": "t:sections.image-with-text.blocks.heading.settings.heading.label"
        },
        {
          "type": "select",
          "id": "heading_size",
          "options": [
            {
              "value": "h4",
              "label": "t:sections.all.heading_size.options__1.label"
            },
            {
              "value": "h3",
              "label": "t:sections.all.heading_size.options__2.label"
            },
            {
              "value": "h2",
              "label": "t:sections.all.heading_size.options__3.label"
            },
            {
              "value": "h1",
              "label": "t:sections.all.heading_size.options__4.label"
            }
          ],
          "default": "h1",
          "label": "t:sections.all.heading_size.label"
        }
      ]
    },
    {
      "type": "caption",
      "name": "t:sections.image-with-text.blocks.caption.name",
      "limit": 1,
      "settings": [
        {
          "type": "text",
          "id": "caption",
          "default": "t:sections.image-with-text.blocks.caption.settings.text.default",
          "label": "t:sections.image-with-text.blocks.caption.settings.text.label"
        },
        {
          "type": "select",
          "id": "text_style",
          "options": [
            {
              "value": "subtitle",
              "label": "t:sections.image-with-text.blocks.caption.settings.text_style.options__1.label"
            },
            {
              "value": "caption-with-letter-spacing",
              "label": "t:sections.image-with-text.blocks.caption.settings.text_style.options__2.label"
            }
          ],
          "default": "caption-with-letter-spacing",
          "label": "t:sections.image-with-text.blocks.caption.settings.text_style.label"
        },
        {
          "type": "select",
          "id": "text_size",
          "options": [
            {
              "value": "small",
              "label": "t:sections.image-with-text.blocks.caption.settings.caption_size.options__1.label"
            },
            {
              "value": "medium",
              "label": "t:sections.image-with-text.blocks.caption.settings.caption_size.options__2.label"
            },
            {
              "value": "large",
              "label": "t:sections.image-with-text.blocks.caption.settings.caption_size.options__3.label"
            }
          ],
          "default": "medium",
          "label": "t:sections.image-with-text.blocks.caption.settings.caption_size.label"
        }
      ]
    },
    {
      "type": "text",
      "name": "t:sections.image-with-text.blocks.text.name",
      "limit": 1,
      "settings": [
        {
          "type": "richtext",
          "id": "text",
          "default": "t:sections.image-with-text.blocks.text.settings.text.default",
          "label": "t:sections.image-with-text.blocks.text.settings.text.label"
        },
        {
          "type": "select",
          "id": "text_style",
          "options": [
            {
              "value": "body",
              "label": "t:sections.image-with-text.blocks.text.settings.text_style.options__1.label"
            },
            {
              "value": "subtitle",
              "label": "t:sections.image-with-text.blocks.text.settings.text_style.options__2.label"
            }
          ],
          "default": "body",
          "label": "t:sections.image-with-text.blocks.text.settings.text_style.label"
        },
        {
          "type": "color",
          "id": "text_color",
          "label": "Color"
        }
      ]
    },
    {
      "type": "button",
      "name": "t:sections.image-with-text.blocks.button.name",
      "limit": 1,
      "settings": [
        {
          "type": "text",
          "id": "button_label",
          "default": "Button label",
          "label": "t:sections.rich-text.blocks.buttons.settings.button_label_1.label",
          "info": "t:sections.rich-text.blocks.buttons.settings.button_label_1.info"
        },
        {
          "type": "url",
          "id": "button_link",
          "label": "t:sections.rich-text.blocks.buttons.settings.button_link_1.label"
        },
        {
          "type": "checkbox",
          "id": "button_style_secondary",
          "default": false,
          "label": "t:sections.rich-text.blocks.buttons.settings.button_style_secondary_1.label"
        },
        {
          "type": "text",
          "id": "button_label_2",
          "label": "t:sections.rich-text.blocks.buttons.settings.button_label_2.label",
          "info": "t:sections.rich-text.blocks.buttons.settings.button_label_2.info"
        },
        {
          "type": "url",
          "id": "button_link_2",
          "label": "t:sections.rich-text.blocks.buttons.settings.button_link_2.label"
        },
        {
          "type": "checkbox",
          "id": "button_style_secondary_2",
          "default": false,
          "label": "t:sections.rich-text.blocks.buttons.settings.button_style_secondary_2.label"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Image with shop",
      "blocks": [
        {
          "type": "heading"
        },
        {
          "type": "text"
        },
        {
          "type": "button"
        }
      ]
    }
  ]
}
{% endschema %}
