{#
/**
 * @file
 * Dark+'s theme override for the block entity refernece field for the tabs powered custom block
 *
 * @see darkplus_preprocess_field__block_content__mt_fancy_tabs_block()
 */
#}
{{ attach_library('darkplus/media-tabs') }}
{%
  set classes = [
    'field',
    'field--name-' ~ field_name|clean_class,
    'field--type-' ~ field_type|clean_class,
    'field--label-' ~ label_display,
    'field--entity-reference-target-type-' ~ entity_reference_target_type|clean_class,
    'field--mt-media-tabs',
    'clearfix',
  ]
%}
{%
  set title_classes = [
    'field__label',
    label_display == 'inline' ? 'inline',
  ]
%}
<div{{ attributes.addClass(classes) }}>
  {% if not label_hidden %}
    <h3{{ title_attributes.addClass(title_classes) }}>{{ label }}</h3>
  {% endif %}
  <ul class="nav nav-tabs nav-tabs--enriched justify-content-center">
    {% for item in items %}
      <li class="nav-item">
        <a class="nav-link {{ loop.first ? ' active' : '' }} align-items-center d-flex" href="#tab-pane-id-{{item.tab_item_data.id}}" data-toggle="tab">
          <span>{{ "%02d"|format(loop.index) }}</span>
          {{ item.content['#paragraph'].get('field_mt_media_tab_title').value }}
        </a>
      </li>
    {% endfor %}
  </ul>
  <div class="tab-content">
    {% for item in items %}
      <div class="tab-pane fade {{ loop.first ? ' active show' : '' }}" id="tab-pane-id-{{item.tab_item_data.id}}">
        <div class="row">
          {% if item.content['#paragraph'].field_mt_media_image.value or item.content['#paragraph'].field_mt_media_video.value %}
            <div class="col-lg-7 {{ item.content['#paragraph'].field_mt_media_hor_alignment.value }}">
              {% if item.content['#paragraph'].field_mt_media_video.value %}
                {{ item.video_field }}
              {% elseif item.content['#paragraph'].field_mt_media_image.value %}
                <div class="overlay-container">
                  {% if item.content['#paragraph'].field_mt_media_button.title %}
                    <span class="overlay overlay--colored">
                      <a class="overlay-target-link" href="{{ item.content['#paragraph'].field_mt_media_button['0'].url }}"></a>
                    </span>
                  {% endif %}
                  <img src="{{ item.media_image_styled_url }}" alt="{{ item.content['#paragraph'].field_mt_media_image.alt }}" title="{{ item.content['#paragraph'].field_mt_media_image.title }}">
                </div>
              {% endif %}
            </div>
          {% endif %}
          <div class="{{ (item.content['#paragraph'].field_mt_media_image.value or item.content['#paragraph'].field_mt_media_video.value) ? 'col-lg-5' : 'col-lg-12' }}">
            {% if item.content['#paragraph'].field_mt_media_title.value %}
              <div class="mt-media-title">
                <h3 class="mt-3 mt-lg-0">{{ item.content['#paragraph'].field_mt_media_title.value }}</h3>
              </div>
            {% endif %}
            {% if item.content['#paragraph'].field_mt_media_body.value %}
              <div class="mt-media-body">
                {{ item.content }}
              </div>
            {% endif %}
            {% if item.content['#paragraph'].field_mt_media_button.title %}
              <div class="mt-media-button">
                <a class="mt-button" href="{{ item.content['#paragraph'].field_mt_media_button['0'].url }}">
                  {{ item.content['#paragraph'].field_mt_media_button.title }}
                </a>
              </div>
            {% endif %}
          </div>
        </div>
      </div>
    {% endfor %}
  </div>
</div>
