{% load i18n static dsfr_tags wagtailuserbar wagtail_dsfr_tags %}

<!DOCTYPE html>
<html lang="{% get_current_language as LANGUAGE_CODE %}{{ LANGUAGE_CODE }}"
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.theme_modale_button %}data-fr-scheme="system"{% else %}data-fr-scheme="light"{% endif %}
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.mourning %}data-fr-mourning{% endif %}>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport"
          content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    {% block title %}
      <title>
        {% if title %}{{ title }} —{% endif %}
      {{ settings.sites_conformes_content_manager.CmsDsfrConfig.site_title }}</title>
    {% endblock title %}

    {% block description %}
    {% endblock description %}

    {% block canonical_url %}
      <link rel="canonical" href="{% canonical_url %}" />
    {% endblock canonical_url %}

    {% dsfr_favicon %}

    {% dsfr_css %}
    <link href="{% static 'css/style.css' %}" rel="stylesheet" type="text/css" />

    {% block extra_css %}
    {% endblock extra_css %}

    {% block cookie_banner %}
      {% include "blocks/cookie_banner.html" %}
    {% endblock cookie_banner %}

    {% block tracking %}
      {% if settings.sites_conformes_content_manager.CustomScriptsSettings.head_scripts %}
        {{ settings.sites_conformes_content_manager.CustomScriptsSettings.head_scripts|safe }}
      {% endif %}
    {% endblock tracking %}

    {% block social_media %}
    {% endblock social_media %}
  </head>

  <body>
    {% block skiplinks %}
      {% dsfr_skiplinks skiplinks %}
    {% endblock skiplinks %}

    {% wagtailuserbar %}
    {% include "blocks/header.html" %}

    {% if settings.sites_conformes_content_manager.CmsDsfrConfig.notice_title or settings.sites_conformes_content_manager.CmsDsfrConfig.notice_description %}
      {% include "blocks/notice.html" %}
    {% endif %}

    <main id="content" role="main">
      {% block content %}
      {% endblock content %}
    </main>

    {% block follow_newsletter_social_media %}
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.show_newsletter_and_social_block %}
        <aside id="cmsfr-block-follow">
          {% include "blocks/follow.html" %}
        </aside>
      {% endif %}
    {% endblock follow_newsletter_social_media %}

    {% include "blocks/footer.html" %}

    {% if settings.sites_conformes_content_manager.CmsDsfrConfig.theme_modale_button %}
      {% dsfr_theme_modale %}
    {% endif %}

    {% dsfr_js nonce=request.csp_nonce %}
    {% block extra_js %}
    {% endblock extra_js %}

    {% block body_tracking_scripts %}
      {% if settings.sites_conformes_content_manager.CustomScriptsSettings.body_scripts %}
        {{ settings.sites_conformes_content_manager.CustomScriptsSettings.body_scripts|safe }}
      {% endif %}
    {% endblock body_tracking_scripts %}
  </body>
</html>
