<!DOCTYPE html>

{%- macro css() %}
    <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
    {%- for css in css_files %}
      {%- if css|attr("filename") %}
    {{ css_tag(css) }}
      {%- else %}
    <link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" />
      {%- endif %}
    {%- endfor %}
{%- endmacro %}

{%- macro header() %}
    <header class="md-header" data-md-component="header" data-md-state="shadow">
      <nav class="md-header-nav md-grid">
        <div class="md-flex">
          <!-- Link to home -->
          <div class="md-flex__cell md-flex__cell--shrink">
            <a href="/"
               title="{{ project }}"
               class="md-header-nav__button md-logo">
              <i class="md-icon">&#xE80C;</i>
            </a>
          </div>

          <!-- Header title -->
          <div class="md-flex__cell md-flex__cell--stretch">
            <div class="md-flex__ellipsis md-header-nav__title"
                 data-md-component="title">
            <span class="md-header-nav__topic">
              {{ project }}
            </span>
            </div>
          </div>

          <!-- Button to open search dialogue -->
          <div class="md-flex__cell md-flex__cell--shrink">
            <label class="md-icon md-icon--search md-header-nav__button"
                   for="__search"></label>

            <!-- Search interface -->
            <div class="md-search" data-md-component="search" role="dialog">
              <label class="md-search__overlay" for="__search"></label>
              <div class="md-search__inner" role="search">
                <form class="md-search__form" name="search">
                  <input type="text" class="md-search__input" aria-label="search" name="query"
                         placeholder="Search"
                         autocapitalize="off" autocorrect="off" autocomplete="off"
                         spellcheck="false" data-md-component="query"
                         data-md-state="active" />
                  <label class="md-icon md-search__icon" for="__search"></label>
                  <button type="reset" class="md-icon md-search__icon"
                          data-md-component="reset" tabindex="-1">
                    &#xE5CD;<!-- close -->
                  </button>
                </form>
                <div class="md-search__output">
                  <div class="md-search__scrollwrap" data-md-scrollfix>
                    <div class="md-search-result" data-md-component="result">
                      <div class="md-search-result__meta">Type to start searching</div>
                      <ol class="md-search-result__list"></ol>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </nav>
    </header>
    {%- endmacro %}

<!-- Main navigation -->
{%- macro navigation() %}
    <div class="md-sidebar md-sidebar--primary"
         data-md-component="navigation">
      <div class="md-sidebar__scrollwrap">
        <div class="md-sidebar__inner">
          <nav class="md-nav md-nav--primary" data-md-level="0">
            <!-- Site title -->
            <label class="md-nav__title md-nav__title--site" for="__drawer">
              {{ project }}
            </label>
            {{ toctree() }}
          </nav>
        </div>
      </div>
    </div>
{%- endmacro %}

<!-- Table of contents -->
{%- macro localtoc() %}
    <div class="md-sidebar md-sidebar--secondary"
         data-md-component="toc">
      <div class="md-sidebar__scrollwrap">
        <div class="md-sidebar__inner">
          <nav class="md-nav md-nav--secondary">
            <label class="md-nav__title md-nav__title--site" for="__drawer">
              Table of contents
            </label>
            {{ toc }}
          </nav>
        </div>
      </div>
    </div>
{%- endmacro %}

<html xmlns="http://www.w3.org/1999/xhtml"{% if language is not none %} lang="{{ language }}"{% endif %}>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- Keep for compatibility, see http://bit.ly/2tMB6ag -->
    <meta http-equiv="x-ua-compatible" content="ie=edge" />
    {%- block htmltitle %}
    <title>{{ title|striptags|e }}{{ titlesuffix }}</title>
    {%- endblock %}
    {%- block css %}
    {{- css() }}
    {%- endblock %}
  </head>
  <body dir="ltr" data-md-color-primary="orange" data-md-color-accent="orange">
    {%- block header %}{{ header() }}{% endblock %}
    <div class="md-container">
      <main class="md-main" role="main">
        <div class="md-main__inner md-grid" data-md-component="container">
          {%- block navigation %}{{ navigation() }}{% endblock %}
          {%- block localtoc %}{{ localtoc() }}{% endblock %}
          {% block body %} {% endblock %}
        </div>
      </main>
    </div>
  </body>
</html>
