{% set node_classes = [
  'node',
  'node--person',
  'node--full',
] %}
{% set attributes = attributes|default(create_attribute()) %}

{% extends "@ui-node/node--full.html.twig" %}

{% import _self as person %}

{% macro info_card(headshot, name, job_title, email, socials) %}
  {% if
    headshot or
    name or
    job_title or
    socials
  %}
    <div class="node__info-card">
      {% if headshot %}
        <div class="node__headshot">
          {{ headshot }}
        </div>
      {% endif %}

      <div class="node__info-card-content">
        {% if name %}
          <div class="node__name">
            {{ name }}
          </div>
        {% endif %}

          {% if job_title %}
            <div class="node__job-title">
              {{ job_title }}
            </div>
          {% endif %}

          {% if socials %}
            <div class="node__social-links">
              {{ socials }}
            </div>
          {% endif %}

          {% if email %}
            <div class="node__email">
              {{ email }}
            </div>
          {% endif %}

          <div class="node__meet-the-team-cta">
            <a href="{{ path('entity.node.canonical', { 'node': 20 }, { 'fragment': 'team' }) }}">Meet the team</a>
          </div>
        </div>
      </div>
    </div>
  {% endif %}
{% endmacro %}

{% macro page_image(image) %}
  {% if image %}
    <div class="node__page-image">
      {{ image }}
    </div>
  {% endif %}
{% endmacro %}

{% block node_header %}
  {{ parent() }}

  {% if node_field_summary %}
    <div class="node__summary">
      {{ node_field_summary }}
    </div>
  {% endif %}
{% endblock %}

{% block node_content %}
  {% if node_field_erm_page_image %}
    {{ person.page_image(node_field_erm_page_image) }}
  {% else %}
    {{ person.info_card(
      node_field_erm_headshot,
      node_field_label,
      node_field_job_title,
      node_field_email,
      node_field_social_links
    ) }}
  {% endif %}

  {% if node_field_bio %}
    <div class="node__bio">
      {{ node_field_bio }}
    </div>
  {% endif %}

  {% if node_field_erm_page_image %}
    {{ person.info_card(
      node_field_erm_headshot,
      node_field_label,
      node_field_job_title,
      node_field_email,
      node_field_social_links
    ) }}
  {% else %}
    {{ person.page_image(node_field_erm_page_image) }}
  {% endif %}

  {% if node_view_stories_recent_by_person %}
    <div class="node__view-stories-recent-by-person">
      {{ node_view_stories_recent_by_person }}
    </div>
  {% endif %}
{% endblock %}
