<!DOCTYPE html>
<html lang="{{ request.state.language }}">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="description" content="{{ meta_description | default('') }}" />
        <meta name="keywords" content="{{ meta_keywords | default('') }}" />
        <meta name="color-scheme" content="{{ color_scheme | default('light') }}" />
        <title>
            {% block title %}
            {% endblock title %}
        </title>
        {% if canonical_url %}<link rel="canonical" href="{{ canonical_url }}" />{% endif %}
        {% for fp in font_preloads | default([]) %}
            <link rel="preload"
                  as="font"
                  href="{{ fp.href }}"
                  type="{{ fp.type }}"
                  {% if fp.crossorigin %}crossorigin="{{ fp.crossorigin }}"{% endif %} />
        {% endfor %}
        {% block extra_head_links %}
        {% endblock extra_head_links %}
        {# Reserve the vertical scrollbar gutter so centered chrome doesn't
           shift horizontally when navigating between short and long pages.
           Inline (with the CSP nonce) rather than in bundle.css so the rule
           applies to existing projects on framework upgrade without
           rebuilding their CSS bundle. -#}
        <style nonce="{{ csp_nonce }}">html { scrollbar-gutter: stable; }</style>
        {% include "base/theme_init.html.jinja" %}

        <link rel="stylesheet" href="{{ url_for('css', path='bundle.css').path }}" />
        {% include "base/theme.html.jinja" %}

        {# Pre-script head hook. Anything here is parsed before the bundle
           below, so htmx reads a `<meta name="htmx-config">` placed here at
           startup (it reads config when the script evaluates, not later).

           The default restores htmx 2 error-swap behavior: 4xx/5xx response
           bodies are not swapped into the target, so a validation 422 or a
           500 never replaces a fragment with an error page. Per-element
           `hx-status:<code>` attributes still win (exact codes are matched
           before the 4xx/5xx wildcards). Override this block to customize
           the htmx config; keep `noSwap` unless you handle error swapping
           some other way. -#}
        {% block htmx_config %}
            <meta name="htmx-config" content='{"noSwap": [204, 304, "4xx", "5xx"]}' />
        {% endblock htmx_config %}
        {% block scripts %}
            <script src="{{ url_for('js', path='bundle.js').path }}"></script>
        {% endblock scripts %}
        {% if umami_website_id and not DEBUG %}
            <script defer src="/meta.js" data-website-id="{{ umami_website_id }}"></script>
        {% endif %}
        {% block extra_scripts %}
        {% endblock extra_scripts %}
        {% include "base/favicons.html.jinja" %}
        {% include "base/opengraph.html.jinja" %}

        {% block head %}
        {% endblock head %}
    </head>
    <body preload="mousedown"
          class="{{ BODY_CLASS }}"
          {% block body_attrs %}
          {% endblock body_attrs %}>
        {% block start_of_body %}
        {% endblock start_of_body %}
        {% block header %}
            {% if not SKIP_HEADER %}
                {% include "base/header.html.jinja" %}

            {% endif %}
        {% endblock header %}
        {% block before_main %}
        {% endblock before_main %}
        {% block body %}
            {% block content %}
            {% endblock content %}
        {% endblock body %}
        {% block after_main %}
        {% endblock after_main %}
        {% block footer %}
            {% if not SKIP_FOOTER %}
                {% include "base/footer.html.jinja" %}

            {% endif %}
        {% endblock footer %}
        {% if DEBUG %}{{ hotreload.script(url_for('hot-reload') ) | safe }}{% endif %}
        {% block end_of_body %}
        {% endblock end_of_body %}
    </body>
</html>
