{{ 'section-mega-menu-v3.css' | asset_url | stylesheet_tag }}
{% assign index_number = section.settings.index | append: '' %}

<template xo-mega-menu-name='header-mega-menu-v1' xo-mega-menu-index='{{ index_number }}'>
  <div data-id='{{ section.id }}' {% render 'section-attr' %}>
    {% render 'section-bg-image' %}
    <xo-container>
      <div class='container-header-v3 xo-scrollbar'>
        <xo-grid style='--col-width: 17rem; --col-width-mobile: 32rem'>
          {%- if section.settings.menu_style1 != blank -%}
            <div class='menu-header-v3'>
              {%- if section.settings.heading_1 != blank -%}
                <h2 class='menu-header-v3__heading'>{{- section.settings.heading_1 -}}</h2>
              {%- endif -%}
              <ul class='menu-header-v3__list-item'>
                {%- for link in section.settings.menu_style1.links -%}
                  <li class='menu-header-v3__item'>
                    {% if link.title contains '[' %}
                      <a
                        href='{{ link.url }}'
                        title='{{link.title | split: '[' | first }}'
                        class='header-v3-links'
                      >
                        {{- link.title | split: '[' | first }}
                        <span
                          class='header-v3-links__label header-v3-links__label--{{link.title | handleize}}-{{forloop.index}}'
                          {% if link.title contains '(' %}
                            style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                          {% endif %}
                        >
                          <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                        </span>

                        <style>
                          .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                            border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                          }
                        </style>
                      </a>
                    {% else %}
                      <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                    {% endif %}
                  </li>
                {%- endfor -%}
              </ul>
            </div>
          {%- endif -%}
          {%- if section.settings.menu_style2 != blank -%}
            <div class='menu-header-v3'>
              {%- if section.settings.heading_2 != blank -%}
                <h2 class='menu-header-v3__heading'>{{- section.settings.heading_2 -}}</h2>
              {%- endif -%}
              <ul class='menu-header-v3__list-item'>
                {%- for link in section.settings.menu_style2.links -%}
                  <li class='menu-header-v3__item'>
                    {% if link.title contains '[' %}
                      <a
                        href='{{ link.url }}'
                        title='{{link.title | split: '[' | first }}'
                        class='header-v3-links'
                      >
                        {{- link.title | split: '[' | first }}
                        <span
                          class='header-v3-links__label header-v3-links__label--{{link.title | handleize}}-{{forloop.index}}'
                          {% if link.title contains '(' %}
                            style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                          {% endif %}
                        >
                          <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                        </span>

                        <style>
                          .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                            border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                          }
                        </style>
                      </a>
                    {% else %}
                      <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                    {% endif %}
                  </li>
                {%- endfor -%}
              </ul>
            </div>
          {%- endif -%}
          {%- if section.settings.menu_style3 != blank -%}
            <div class='menu-header-v3'>
              {%- if section.settings.heading_3 != blank -%}
                <h2 class='menu-header-v3__heading'>{{- section.settings.heading_3 -}}</h2>
              {%- endif -%}
              <ul class='menu-header-v3__list-item'>
                {%- for link in section.settings.menu_style3.links -%}
                  <li class='menu-header-v3__item'>
                    {% if link.title contains '[' %}
                      <a
                        href='{{ link.url }}'
                        title='{{link.title | split: '[' | first }}'
                        class='header-v3-links'
                      >
                        {{- link.title | split: '[' | first }}
                        <span
                          class='header-v3-links__label header-v3-links__label--{{link.title | handleize}}-{{forloop.index}}'
                          {% if link.title contains '(' %}
                            style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                          {% endif %}
                        >
                          <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                        </span>

                        <style>
                          .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                            border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                          }
                        </style>
                      </a>
                    {% else %}
                      <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                    {% endif %}
                  </li>
                {%- endfor -%}
              </ul>
            </div>
          {%- endif -%}
          {%- if section.settings.menu_style4 != blank -%}
            <div class='menu-header-v3'>
              {%- if section.settings.heading_4 != blank -%}
                <h2 class='menu-header-v3__heading'>{{- section.settings.heading_4 -}}</h2>
              {%- endif -%}
              <ul class='menu-header-v3__list-item'>
                {%- for link in section.settings.menu_style4.links -%}
                  <li class='menu-header-v3__item'>
                    {% if link.title contains '[' %}
                      <a
                        href='{{ link.url }}'
                        title='{{link.title | split: '[' | first }}'
                        class='header-v3-links'
                      >
                        {{- link.title | split: '[' | first }}
                        <span
                          class='header-v3-links__label header-v3-links__label--{{link.title | handleize}}-{{forloop.index}}'
                          {% if link.title contains '(' %}
                            style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                          {% endif %}
                        >
                          <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                        </span>

                        <style>
                          .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                            border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                          }
                        </style>
                      </a>
                    {% else %}
                      <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                    {% endif %}
                  </li>
                {%- endfor -%}
              </ul>
            </div>
          {%- endif -%}
          {%- if section.settings.menu_style5 != blank -%}
            <div class='menu-header-v3'>
              {%- if section.settings.heading_5 != blank -%}
                <h2 class='menu-header-v3__heading'>{{- section.settings.heading_5 -}}</h2>
              {%- endif -%}
              <ul class='menu-header-v3__list-item'>
                {%- for link in section.settings.menu_style5.links -%}
                  <li class='menu-header-v3__item'>
                    {% if link.title contains '[' %}
                      <a
                        href='{{ link.url }}'
                        title='{{link.title | split: '[' | first }}'
                        class='header-v3-links'
                      >
                        {{- link.title | split: '[' | first }}
                        <span
                          class='header-v3-links__label header-v3-links__label--{{link.title | handleize}}-{{forloop.index}}'
                          {% if link.title contains '(' %}
                            style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                          {% endif %}
                        >
                          <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                        </span>

                        <style>
                          .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                            border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                          }
                        </style>
                      </a>
                    {% else %}
                      <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                    {% endif %}
                  </li>
                {%- endfor -%}
              </ul>
            </div>
          {%- endif -%}
          {%- if section.settings.menu_style6 != blank -%}
            <div class='menu-header-v3'>
              {%- if section.settings.heading_6 != blank -%}
                <h2 class='menu-header-v3__heading'>{{- section.settings.heading_6 -}}</h2>
              {%- endif -%}
              <ul class='menu-header-v3__list-item'>
                {%- for link in section.settings.menu_style6.links -%}
                  <li class='menu-header-v3__item'>
                    {% if link.title contains '[' %}
                      <a
                        href='{{ link.url }}'
                        title='{{link.title | split: '[' | first }}'
                        class='header-v3-links'
                      >
                        {{- link.title | split: '[' | first }}
                        <span
                          class='header-v3-links__label header-v3-links__label--{{link.title | handleize}}-{{forloop.index}}'
                          {% if link.title contains '(' %}
                            style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                          {% endif %}
                        >
                          <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                        </span>

                        <style>
                          .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                            border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                          }
                        </style>
                      </a>
                    {% else %}
                      <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                    {% endif %}
                  </li>
                {%- endfor -%}
              </ul>
            </div>
          {%- endif -%}
        </xo-grid>
      </div>
    </xo-container>
  </div>
</template>

{% schema %}
{
  "name": "t:sections.mega_menu_v3.name",
  "class": "section-mega-menu",
  "settings": [
    {
      "type": "select",
      "id": "index",
      "label": "t:sections.mega_menu_v3.settings.index_number.label",
      "default": "2",
      "options": [
        {
          "value": "0",
          "label": "t:sections.mega_menu_v3.settings.index_number.option_1.label"
        },
        {
          "value": "1",
          "label": "t:sections.mega_menu_v3.settings.index_number.option_2.label"
        },
        {
          "value": "2",
          "label": "t:sections.mega_menu_v3.settings.index_number.option_3.label"
        },
        {
          "value": "3",
          "label": "t:sections.mega_menu_v3.settings.index_number.option_4.label"
        },
        {
          "value": "4",
          "label": "t:sections.mega_menu_v3.settings.index_number.option_5.label"
        },
        {
          "value": "5",
          "label": "t:sections.mega_menu_v3.settings.index_number.option_6.label"
        }
      ]
    },
    {
      "type": "text",
      "id": "heading_1",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v3.settings.heading_1.label"
    },
    {
      "type": "link_list",
      "id": "menu_style1",
      "label": "t:sections.mega_menu_v3.settings.menu_style1.label",
      "info": "t:sections.mega_menu_v3.settings.menu_style1.info"
    },
    {
      "type": "text",
      "id": "heading_2",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v3.settings.heading_2.label"
    },
    {
      "type": "link_list",
      "id": "menu_style2",
      "label": "t:sections.mega_menu_v3.settings.menu_style2.label",
      "info": "t:sections.mega_menu_v3.settings.menu_style2.info"
    },
    {
      "type": "text",
      "id": "heading_3",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v3.settings.heading_3.label"
    },
    {
      "type": "link_list",
      "id": "menu_style3",
      "label": "t:sections.mega_menu_v3.settings.menu_style3.label",
      "info": "t:sections.mega_menu_v3.settings.menu_style3.info"
    },
    {
      "type": "text",
      "id": "heading_4",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v3.settings.heading_4.label"
    },
    {
      "type": "link_list",
      "id": "menu_style4",
      "label": "t:sections.mega_menu_v3.settings.menu_style4.label",
      "info": "t:sections.mega_menu_v3.settings.menu_style4.info"
    },
    {
      "type": "text",
      "id": "heading_5",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v3.settings.heading_5.label"
    },
    {
      "type": "link_list",
      "id": "menu_style5",
      "label": "t:sections.mega_menu_v3.settings.menu_style5.label",
      "info": "t:sections.mega_menu_v3.settings.menu_style5.info"
    },
    {
      "type": "text",
      "id": "heading_6",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v3.settings.heading_6.label"
    },
    {
      "type": "link_list",
      "id": "menu_style6",
      "label": "t:sections.mega_menu_v3.settings.menu_style6.label",
      "info": "t:sections.mega_menu_v3.settings.menu_style6.info"
    },
    {
      "type": "header",
      "content": "t:sections.all.heading.content"
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:sections.all.color_scheme.label"
    },
    {
      "type": "color",
      "id": "background_color",
      "label": "t:sections.all.bg_color.label"
    },
    {
      "type": "color_background",
      "id": "background_gradient",
      "label": "t:sections.all.bg_gradient.label"
    },
    {
      "type": "image_picker",
      "id": "background_image_desktop",
      "label": "t:sections.all.background_image_desktop.label"
    },
    {
      "type": "image_picker",
      "id": "background_image_mobile",
      "label": "t:sections.all.background_image_mobile.label"
    },
    {
      "type": "checkbox",
      "id": "use_parallax",
      "label": "t:sections.all.use_parallax.label",
      "default": true
    },
    {
      "type": "number",
      "id": "padding_top",
      "label": "t:sections.all.padding_top.label",
      "default": 50
    },
    {
      "type": "number",
      "id": "padding_bottom",
      "label": "t:sections.all.padding_bottom.label",
      "default": 50
    }
  ],
  "presets": [
    {
      "name": "t:sections.mega_menu_v3.presets.name"
    }
  ]
}
{% endschema %}
