{#
/**
* @file
* LocalGovDrupal theme implementation to display a single page.
*
* The doctype, html, head and body tags are not in this template. Instead they
* can be found in the html.html.twig template in this directory.
*
* Available variables:
*
* General utility variables:
* - base_path: The base URL path of the Drupal installation. Will usually be
*   "/" unless you have installed Drupal in a sub-directory.
* - is_front: A flag indicating if the current page is the front page.
* - logged_in: A flag indicating if the user is registered and signed in.
* - is_admin: A flag indicating if the user has permission to access
*   administration pages.
* - has_sidebar_first: Can we expect any content in the first sidebar?
* - has_sidebar_second: See above.
*
* Site identity:
* - front_page: The URL of the front page. Use this instead of base_path when
*   linking to the front page. This includes the language domain or prefix.
*
* Page content (in order of occurrence in the default page.html.twig):
* - messages: Status and error messages. Should be displayed prominently.
* - node: Fully loaded node, if there is an automatically-loaded node
*   associated with the page and the node ID is the second argument in the
*   page's path (e.g. node/12345 and node/12345/revisions, but not
*   comment/reply/12345).
*
* Regions:
* - page.header
* - page.search
* - page.mobile_search
* - page.primary_menu
* - page.secondary_menu
* - page.banner
* - page.breadcrumb
* - page.messages
* - page.content_top
* - page.content
* - page.content_bottom
* - page.sidebar_first
* - page.sidebar_second
* - page.footer_first
* - page.footer_second
* - page.disabled
* @see template_preprocess_page()
* @see html.html.twig
*
* @ingroup themeable
*/
#}

{#
  We'll use this `footer_regions` array later to check if there is content in
  at least one of them before we start rendering the footer element. It will
  probably always return true, but no harm in checking.
#}
{%
  set footer_regions = [
    'has_footer_first',
    'has_footer_second',
    'has_footer_third',
    'footer',
    'has_lower_footer_first',
    'has_lower_footer_second',
    'has_lower_footer_third',
  ]
%}

{#
  We create a dedicated tabs region and place it at the top of the page.
  This is to make sure tabs don't interfere with any other content, but
  especially to make sure other content doesn't interfere with tabs (which)
  can often happen if `position: absolute` further down the page, causing
  content to cover tabs and other issues.

  Taking this approach also means we can have consistent styling for the
  tabs region on all localgov_drupal websites. Yay!
#}
{% if has_tabs %}
  {{ page.tabs }}
{% endif %}

{% block header %}
  {% include '@localgov_base_france/layout/header.html.twig' with {'page': page} %}
{% endblock %}

{% if has_banner %}
  {{ page.banner }}
{% endif %}

{% if has_breadcrumb %}
  {{ page.breadcrumb }}
{% endif %}

{{ page.messages }}

<main class="main" id="main-content" tabindex="-1"> {# The "skip to content" link jumps to here. #}

  {% if has_content_top %}
    {{ page.content_top }}
  {% endif %}

  {# Begin Sidebars #}
  {% if has_sidebars %}
    <div class="lgd-container">
      <div class="lgd-row">
        {% if has_sidebar_first and not has_sidebar_second %}
          <aside class="lgd-row__one-third sidebar sidebar--first">
            {{ page.sidebar_first }}
          </aside>
          <div class="lgd-row__two-thirds">
            <div class="padding-horizontal">
              {{ page.content }}
            </div>
          </div>
        {% endif %}

        {% if has_sidebar_second and not has_sidebar_first %}
          <div class="lgd-row__two-thirds">
            <div class="padding-horizontal">
              {{ page.content }}
            </div>
          </div>
          <aside class="lgd-row__one-third sidebar sidebar--second">
            {{ page.sidebar_second }}
          </aside>
        {% endif %}

        {% if has_sidebar_first and has_sidebar_second %}
          <aside class="lgd-row__one-quarter sidebar sidebar--first">
            {{ page.sidebar_first }}
          </aside>
          <div class="lgd-row__one-half">
            <div class="padding-horizontal">
              {{ page.content }}
            </div>
          </div>
          <aside class="lgd-row__one-quarter sidebar sidebar--second">
            {{ page.sidebar_second }}
          </aside>
        {% endif %}
      </div>
    </div>

    {% else %}
    {# When we have no sidebars #}
    {#
      If there are no sidebars, the content region take up 100% of the space, but:
      1.  If we are on a node page, we do not constrain the content (this will be handled
          by the node templates, so some parts of the template (hero, etc) can be the full
          width of the screen).
      2.  If we are not on a node page, we'll contain the content, so views pages, taxonomy
          pages, login page, etc are not bleeding to the edge of the screen.
    #}
    {% if not node %}
      <div class="lgd-container padding-horizontal">
        {{ page.content }}
      </div>
      {% else %}
        {{ page.content }}
    {% endif %}
  {% endif %}
  {# End Sidebars #}

  {% if has_content_bottom %}
    {{ page.content_bottom }}
  {% endif %}
</main>

{% if back_to_top %}
  {#
    Position the link just after <main> at the end so that it's in about the
    right place, *and* to try to minimize the chances of being rendered inside
    a positioned element.
  #}
  {% include "@localgov_base/_components/back-to-top.twig" %}
{% endif %}

{# Begin Footer Regions #}
{% block footer_sections %}
  {% if footer_regions %}
    {#
      Wrap all of the "lgd-footers" in a `footer` element for semantics.
      This should ensure that all the contact/housekeeping links/etc
      are within the footer element to assist screenreaders and other
      automated tools.
    #}
    <footer class="lgd-footer">

    {# Begin Pre-footer #}
    {% block pre_footer %}
      {% if has_footer_first or has_footer_second or has_footer_third %}
        <div class="lgd-footer__pre-footer">
          <div class="lgd-container">
            <div class="lgd-row">
              {% if has_footer_first %}
                <div class="lgd-row__one-third">
                  {{ page.footer_first }}
                </div>
              {% endif %}

              {% if has_footer_second %}
                <div class="lgd-row__one-third">
                  {{ page.footer_second }}
                </div>
              {% endif %}

              {% if has_footer_third %}
                <div class="lgd-row__one-third">
                  {{ page.footer_third }}
                </div>
              {% endif %}
            </div>
          </div>
        </div>
      {% endif %}
    {% endblock %}
    {# End Pre-footer #}

    {# Begin Footer #}
    {% block footer %}
      {% if has_footer %}
        <div class="lgd-footer__footer">
          <div class="lgd-container">
            <div class="lgd-row">
              <div class="lgd-row__full">
                {{ page.footer }}
              </div>
            </div>
          </div>
        </div>
      {% endif %}
    {% endblock %}
    {# End Footer #}

    {# Begin Post-footer #}
    {% block post_footer %}
      {% if has_lower_footer_first or has_lower_footer_second or has_lower_footer_third %}
        <div class="lgd-footer__post-footer">
          <div class="lgd-container">
            <div class="lgd-row">
              {% if has_lower_footer_first %}
                <div class="lgd-row__one-third">
                  {{ page.lower_footer_first }}
                </div>
              {% endif %}

              {% if has_lower_footer_second %}
                <div class="lgd-row__one-third">
                  {{ page.lower_footer_second }}
                </div>
              {% endif %}

              {% if has_lower_footer_third %}
                <div class="lgd-row__one-third">
                  {{ page.lower_footer_third }}
                </div>
              {% endif %}
            </div>
          </div>
        </div>
      {% endif %}
    {% endblock %}
    {# End Post-footer #}

    {% if has_housekeeping %}
      <div class="lgd-footer__housekeeping">
      {{ page.housekeeping }}
      </div>
    {% endif %}

    </footer>
  {% endif %}
{% endblock %}
{# End Footer Regions #}
