{{ 'section-header-v2.css' | asset_url | stylesheet_tag }}

{% liquid
  assign background_color = '--bg-color: ' | append: section.settings.background_color | append: ';'
  assign background_gradient = '--bg-gradient: ' | append: section.settings.background_gradient | append: ';'
%}

<header
  class='header-v9 {% if section.settings.transparent and template contains 'index' or template contains 'home' %} header-v9--transparent {% endif %}'
>
  {% if section.settings.enable_topbar %}
    {% assign topbar_background_color = '--topbar-bg-color: ' | append: section.settings.topbar_background_color | append: ';' %}
    {% assign topbar_background_gradient = '--topbar-bg-gradient: ' | append: section.settings.topbar_background_gradient | append: ';' %}
    <div
      class='header-v9__topbar color-{{ section.settings.topbar_color_scheme }}'
      style='{{ topbar_background_color }} {{ topbar_background_gradient }}'
    >
      <xo-container {% render 'section-layout' %}>
        <h4 class='header-v9__topbar-text'>{{ section.settings.topbar_text }}</h4>
      </xo-container>
    </div>
  {% endif %}
  <xo-sticky
    xo-direction='{{ section.settings.sticky_type }}'
    {% if section.settings.sticky_type == 'none' %}
      xo-disabled
    {% endif %}
    style='z-index: 10000; height: unset'
  >
    <xo-animate
      xo-type='fade-up'
      class='header-v9__sticky {% if section.settings.color_scheme %} color-{{ section.settings.color_scheme }}{% endif %}'
      style='{{- background_color -}} {{- background_gradient -}}'
    >
      <xo-container {% render 'section-layout' %}>
        {% if section.settings.menu_type == 'hamburger' %}
          <xo-grid style='--xs: 3'>
            <nav class='header-v9__navigation'>
              {% render 'menu-hamburger',
                menu: section.settings.menu,
                event_type: section.settings.event_type,
                hamburger_type: section.settings.hamburger_type,
                top: '5rem',
                submenu_color_scheme: section.settings.submenu_color_scheme,
                hamburger_drawer_color_scheme: section.settings.hamburger_drawer_color_scheme
              %}
            </nav>
            <div class='header-v9__logo'>
              <a href='/' class='header-v9__logo-desktop'>
                {%- if section.settings.logo_desktop != blank -%}
                  {%- assign logo_alt = section.settings.logo_desktop.alt | default: shop.name | escape -%}
                  {%- assign width = section.settings.logo_desktop_width %}
                  {%- assign height = section.settings.logo_desktop_width | divided_by: section.settings.logo_desktop.aspect_ratio %}
                  <img
                    src='{{ section.settings.logo_desktop | img_url: 'master'}}'
                    alt='{{ logo_alt }}'
                    style='width: {{ width }}px; height: {{ height }}px'
                    loading='lazy'
                    height='auto'
                    width='auto'
                  >
                {%- else -%}
                  <span class='h4 header-v9__logo-placeholder'>{{ shop.name }}</span>
                {%- endif -%}
              </a>
              <a href='/' class='header-v9__logo-mobile'>
                {%- if section.settings.logo_mobile != blank -%}
                  {%- assign logo_alt = section.settings.logo_mobile.alt | default: shop.name | escape -%}
                  {%- assign width = section.settings.logo_mobile_width %}
                  {%- assign height = section.settings.logo_mobile_width | divided_by: section.settings.logo_mobile.aspect_ratio %}
                  <img
                    src='{{ section.settings.logo_mobile | img_url: 'master'}}'
                    alt='{{ logo_alt }}'
                    style='width: {{ width }}px; height: {{ height }}px'
                    loading='lazy'
                    height='auto'
                    width='auto'
                  >
                {%- else -%}
                  <span class='h4 header-v9__logo-placeholder'>{{ shop.name }}</span>
                {%- endif -%}
              </a>
            </div>
            <div class='header-v9__utilities'>
              <xo-tooltip xo-title='{{ 'general.search.search' | t }}' xo-placement='bottom-center' class='header-v9__icon-wrap'>
                <xo-modal-trigger xo-name='search' class='header-v9__icon header-v9__icon--search'>
                  {% render 'icon', name: 'search', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                </xo-modal-trigger>
              </xo-tooltip>
              <xo-tooltip
                xo-title='{%- if customer -%}{{ 'customer.account.title' | t }}{%- else -%}{{ 'customer.login_page.title' | t }}{%- endif -%}'
                xo-placement='bottom-center'
                class='header-v9__icon-wrap header-v9__icon-wrap--desktop'
              >
                <a
                  href='{%- if customer -%}{{ routes.account_url }}{%- else -%}{{ routes.account_login_url }}{%- endif -%}'
                  class='header-v9__icon'
                >
                  {% render 'icon', name: 'account1', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                </a>
              </xo-tooltip>
              <xb-wishlist-header class='xb-wishlist__header header-v9__icon-wrap--desktop'>
                <xo-tooltip xo-title='{{ 'general.wishlist.wishlist' | t }}' xo-placement='bottom-center' class='header-v9__icon-wrap'>
                  <a href='#' class='header-v9__icon'>
                    {% render 'icon', name: 'heart', icon_size: '24', color: 'rgb(var(--color-foreground))' %}
                    <span class='xb-product-quantity header-v9__wishlist-count'></span>
                  </a>
                </xo-tooltip>
              </xb-wishlist-header>
              <xo-tooltip xo-title='{{ 'general.cart.cart' | t }}' xo-placement='bottom-center' class='header-v9__icon-wrap'>
                {% if settings.cart_type == 'page' %}
                  <a href='{{ routes.cart_url }}' class='header-v9__icon'>
                    {% render 'icon', name: 'cart', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                    <span class='header-v9__cart-count'>
                      <xo-cart-size>{{ cart.item_count }}</xo-cart-size>
                    </span>
                  </a>
                {% else %}
                  <xo-modal-trigger xo-name='cart' class='header-v9__icon'>
                    {% render 'icon', name: 'cart', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                    <span class='header-v9__cart-count'>
                      <xo-cart-size>{{ cart.item_count }}</xo-cart-size>
                    </span>
                  </xo-modal-trigger>
                {% endif %}
              </xo-tooltip>
            </div>
          </xo-grid>
        {% else %}
          <xo-grid>
            <div style='--xs: 4; --xl: 2'>
              <div class='header-v9__search-desktop'>
                <xo-tooltip xo-title='{{ 'general.search.search' | t }}' xo-placement='bottom-center' class='header-v9__icon-wrap'>
                  <xo-modal-trigger xo-name='search' class='header-v9__icon'>
                    {% render 'icon', name: 'search', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                  </xo-modal-trigger>
                </xo-tooltip>
                <xb-wishlist-header class='xb-wishlist__header'>
                  <xo-tooltip xo-title='{{ 'general.wishlist.wishlist' | t }}' xo-placement='bottom-center' class='header-v9__icon-wrap'>
                    <a href='#' class='header-v9__icon'>
                      {% render 'icon', name: 'heart', icon_size: '24', color: 'rgb(var(--color-foreground))' %}
                      <span class='xb-product-quantity header-v9__wishlist-count'></span>
                    </a>
                  </xo-tooltip>
                </xb-wishlist-header>
              </div>
              <div class='header-v9__logo'>
                <a href='/' class='header-v9__logo-mobile'>
                  {%- if section.settings.logo_mobile != blank -%}
                    {%- assign logo_alt = section.settings.logo_mobile.alt | default: shop.name | escape -%}
                    {%- assign width = section.settings.logo_mobile_width %}
                    {%- assign height = section.settings.logo_mobile_width | divided_by: section.settings.logo_mobile.aspect_ratio %}
                    <img
                      src='{{ section.settings.logo_mobile | img_url: 'master'}}'
                      alt='{{ logo_alt }}'
                      style='width: {{ width }}px; height: {{ height }}px'
                      loading='lazy'
                      height='auto'
                      width='auto'
                    >
                  {%- else -%}
                    <span class='h4 header-v9__logo-placeholder'>{{ shop.name }}</span>
                  {%- endif -%}
                </a>
              </div>
            </div>
            <div style='--xs: 4; --order-xs: -1; --xl: 8; --order-xl: 0' class='header-v9__navigation'>
              <div class='header-v9__navigation-desktop'>
                {% render 'menu-horizontal',
                  menu: section.settings.menu,
                  event_type: section.settings.event_type,
                  navigation_padding_item: '3.5rem',
                  submenu_color_scheme: section.settings.submenu_color_scheme
                %}
              </div>
              <div class='header-v9__navigation-mobile'>
                {% render 'menu-hamburger',
                  menu: section.settings.menu,
                  event_type: section.settings.event_type,
                  hamburger_type: section.settings.hamburger_type,
                  top: '5rem',
                  submenu_color_scheme: section.settings.submenu_color_scheme,
                  hamburger_drawer_color_scheme: section.settings.hamburger_drawer_color_scheme
                %}
              </div>
            </div>
            <div style='--xs: 4; --xl: 2' class='header-v9__utilities'>
              <xo-tooltip xo-title='{{ 'general.search.search' | t }}' xo-placement='bottom-center' class='header-v9__icon-wrap header-v9__icon-wrap--mobile'>
                <xo-modal-trigger xo-name='search' class='header-v9__icon header-v9__icon--search'>
                  {% render 'icon', name: 'search', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                </xo-modal-trigger>
              </xo-tooltip>
              <xo-tooltip
                xo-title='{%- if customer -%}{{ 'customer.account.title' | t }}{%- else -%}{{ 'customer.login_page.title' | t }}{%- endif -%}'
                xo-placement='bottom-center'
                class='header-v9__icon-wrap header-v9__icon-wrap--desktop'
              >
                <a
                  href='{%- if customer -%}{{ routes.account_url }}{%- else -%}{{ routes.account_login_url }}{%- endif -%}'
                  class='header-v9__icon'
                >
                  {% render 'icon', name: 'account1', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                </a>
              </xo-tooltip>
              <xo-tooltip xo-title='{{ 'general.cart.cart' | t }}' xo-placement='bottom-center' class='header-v9__icon-wrap'>
                {% if settings.cart_type == 'page' %}
                  <a href='{{ routes.cart_url }}' class='header-v9__icon'>
                    {% render 'icon', name: 'cart', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                    <span class='header-v9__cart-count'>
                      <xo-cart-size>{{ cart.item_count }}</xo-cart-size>
                    </span>
                  </a>
                {% else %}
                  <xo-modal-trigger xo-name='cart' class='header-v9__icon'>
                    {% render 'icon', name: 'cart', icon_size: '24', color: 'rgba(var(--color-foreground))' %}
                    <span class='header-v9__cart-count'>
                      <xo-cart-size>{{ cart.item_count }}</xo-cart-size>
                    </span>
                  </xo-modal-trigger>
                {% endif %}
              </xo-tooltip>
            </div>
          </xo-grid>
        {% endif %}
      </xo-container>
    </xo-animate>
  </xo-sticky>
</header>

{% render 'header-ld-json' %}

{% schema %}
{
  "name": "t:sections.header_v2.name",
  "class": "section-header",
  "settings": [
    {
      "type": "select",
      "id": "width",
      "label": "t:sections.all.width.label",
      "default": "box",
      "options": [
        {
          "value": "box",
          "label": "t:sections.all.width.options__1.label"
        },
        {
          "value": "wide",
          "label": "t:sections.all.width.options__2.label"
        },
        {
          "value": "fullwidth",
          "label": "t:sections.all.width.options__3.label"
        }
      ]
    },
    {
      "type": "select",
      "id": "sticky_type",
      "options": [
        {
          "value": "down",
          "label": "t:sections.header_v2.settings.sticky_type.options_1.label"
        },
        {
          "value": "up",
          "label": "t:sections.header_v2.settings.sticky_type.options_2.label"
        },
        {
          "value": "none",
          "label": "t:sections.header_v2.settings.sticky_type.options_3.label"
        }
      ],
      "default": "down",
      "label": "t:sections.header_v2.settings.sticky_type.label"
    },
    {
      "type": "checkbox",
      "id": "transparent",
      "default": false,
      "label": "t:sections.header_v2.settings.transparent.label",
      "info": "t:sections.header_v2.settings.transparent.info"
    },
    {
      "type": "header",
      "content": "t:sections.header_v2.settings.topbar_header.content"
    },
    {
      "type": "checkbox",
      "id": "enable_topbar",
      "label": "t:sections.header_v2.settings.enable_topbar.label",
      "default": true
    },
    {
      "type": "text",
      "id": "topbar_text",
      "label": "t:sections.header_v2.settings.topbar_text.label",
      "default": "Free ship for any orders above $100"
    },
    {
      "type": "color_scheme",
      "id": "topbar_color_scheme",
      "label": "t:sections.header_v2.settings.topbar_color_scheme.label"
    },
    {
      "type": "color",
      "id": "topbar_background_color",
      "label": "t:sections.header_v2.settings.topbar_background_color.label",
      "default": "#ffffff"
    },
    {
      "type": "color_background",
      "id": "topbar_background_gradient",
      "label": "t:sections.header_v2.settings.topbar_background_gradient.label"
    },
    {
      "type": "header",
      "content": "t:sections.header_v2.settings.logo_header.content"
    },
    {
      "type": "image_picker",
      "id": "logo_desktop",
      "label": "t:sections.header_v2.settings.logo_desktop.label",
      "info": "t:sections.header_v2.settings.logo_desktop.info"
    },
    {
      "type": "range",
      "id": "logo_desktop_width",
      "min": 50,
      "max": 250,
      "step": 10,
      "default": 150,
      "unit": "px",
      "label": "t:sections.header_v2.settings.logo_desktop_width.label"
    },
    {
      "type": "image_picker",
      "id": "logo_mobile",
      "label": "t:sections.header_v2.settings.logo_mobile.label",
      "info": "t:sections.header_v2.settings.logo_mobile.info"
    },
    {
      "type": "range",
      "id": "logo_mobile_width",
      "min": 50,
      "max": 250,
      "step": 10,
      "default": 100,
      "unit": "px",
      "label": "t:sections.header_v2.settings.logo_mobile_width.label"
    },
    {
      "type": "header",
      "content": "t:sections.header_v2.settings.menu_header.content"
    },
    {
      "type": "link_list",
      "id": "menu",
      "default": "main-menu",
      "label": "t:sections.header_v2.settings.menu.label"
    },
    {
      "type": "select",
      "id": "menu_type",
      "options": [
        {
          "value": "default",
          "label": "t:sections.header_v2.settings.menu_type.options__1.label"
        },
        {
          "value": "hamburger",
          "label": "t:sections.header_v2.settings.menu_type.options__2.label"
        }
      ],
      "default": "default",
      "label": "t:sections.header_v2.settings.menu_type.label"
    },
    {
      "type": "select",
      "id": "event_type",
      "options": [
        {
          "value": "hover",
          "label": "t:sections.header_v2.settings.event_type.options_1.label"
        },
        {
          "value": "click",
          "label": "t:sections.header_v2.settings.event_type.options_2.label"
        }
      ],
      "default": "hover",
      "label": "t:sections.header_v2.settings.event_type.label"
    },
    {
      "type": "select",
      "id": "hamburger_type",
      "options": [
        {
          "value": "drawer",
          "label": "t:sections.header_v2.settings.hamburger_type.options__1.label"
        },
        {
          "value": "horizontal",
          "label": "t:sections.header_v2.settings.hamburger_type.options__2.label"
        },
        {
          "value": "vertical",
          "label": "t:sections.header_v2.settings.hamburger_type.options__3.label"
        }
      ],
      "default": "drawer",
      "label": "t:sections.header_v2.settings.hamburger_type.label"
    },
    {
      "type": "header",
      "content": "t:sections.header_v2.settings.hamburger_drawer_header.content"
    },
    {
      "type": "color_scheme",
      "id": "hamburger_drawer_color_scheme",
      "label": "t:sections.header_v2.settings.hamburger_drawer_color_scheme.label"
    },
    {
      "type": "color",
      "id": "hamburger_drawer_background_color",
      "label": "t:sections.header_v2.settings.hamburger_drawer_background_color.label",
      "default": "#ffffff"
    },
    {
      "type": "color_background",
      "id": "hamburger_drawer_background_gradient",
      "label": "t:sections.header_v2.settings.hamburger_drawer_background_gradient.label"
    },
    {
      "type": "header",
      "content": "t:sections.header_v2.settings.submenu_header.content"
    },
    {
      "type": "color_scheme",
      "id": "submenu_color_scheme",
      "label": "t:sections.header_v2.settings.submenu_color_scheme.label"
    },
    {
      "type": "color",
      "id": "submenu_background_color",
      "label": "t:sections.header_v2.settings.submenu_background_color.label",
      "default": "#ffffff"
    },
    {
      "type": "color_background",
      "id": "submenu_background_gradient",
      "label": "t:sections.header_v2.settings.submenu_background_gradient.label"
    },
    {
      "type": "header",
      "content": "t:sections.header_v2.settings.general_header.content"
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:sections.header_v2.settings.color_scheme.label"
    },
    {
      "type": "color",
      "id": "background_color",
      "label": "t:sections.header_v2.settings.background_color.label",
      "default": "#ffffff"
    },
    {
      "type": "color_background",
      "id": "background_gradient",
      "label": "t:sections.header_v2.settings.background_gradient.label"
    }
  ]
}
{% endschema %}
