<!DOCTYPE html>
<html lang="{{ t.html_lang | default(locale | default('en')) }}" class="no-js">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    {% if theme.favicon %}
    <link rel="icon" href="{{ base_path | default('') }}{{ theme.favicon }}">
    {% endif %}
    <title>{% block title %}{{ title | default(site.title) }}{% endblock %} - {{ site.title }}</title>
    <link rel="stylesheet" href="{{ base_path | default('') }}css/terradoc.css">
    <script>document.documentElement.classList.remove('no-js');document.documentElement.classList.add('js');</script>
    <style>
        :root {
            --td-color-primary: {{ theme.colors.primary | default('#3D352F') }};
            --td-color-accent: {{ theme.colors.accent | default('#B7522C') }};
            --td-color-accent-muted: {{ theme.colors.accent_muted | default('#9A4427') }};
            --td-color-bg: {{ theme.colors.bg | default('#F9F6F2') }};
            --td-color-bg-light: {{ theme.colors.bg_light | default('#F5EDE8') }};
            --td-color-bg-infobox: {{ theme.colors.bg_infobox | default('#FAF8F5') }};
            --td-color-border: {{ theme.colors.border | default('#E8E4DF') }};
            --td-color-border-dark: {{ theme.colors.border_dark | default('#C8B8A8') }};
            --td-color-text: {{ theme.colors.text | default('#333333') }};
            --td-color-text-muted: {{ theme.colors.text_muted | default('#6B6B6B') }};
            --td-color-highlight: {{ theme.colors.highlight | default('#fff59d') }};
            --td-color-warning-bg: {{ theme.colors.warning_bg | default('#fff8e1') }};
            --td-color-surface: {{ theme.colors.surface | default('#FFFFFF') }};
            --td-color-border-light: {{ theme.colors.border_light | default('#EEEEEE') }};
            --td-color-text-secondary: {{ theme.colors.text_secondary | default('#555555') }};
            --td-color-accent-light: {{ theme.colors.accent_light | default('#FDF0EB') }};
            --td-color-success: {{ theme.colors.success | default('#5B8C5A') }};
            --td-color-error: {{ theme.colors.error | default('#CC0000') }};
            --td-color-accent-ring: {{ theme.colors.accent_ring | default('rgba(183, 82, 44, 0.2)') }};
            --td-radius: {{ theme.border_radius | default('4px') }};
            --td-font-family: {{ theme.font_family | default("-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif") }};
            --td-font-headings: {{ theme.font_family_headings | default('inherit') }};
            --td-font-mono: {{ theme.font_family_mono | default("'Lucida Sans Unicode', 'DejaVu Sans', monospace") }};
        }
        {% if theme.colors_dark %}
        @media (prefers-color-scheme: dark) {
            :root {
                --td-color-primary: {{ theme.colors_dark.primary }};
                --td-color-accent: {{ theme.colors_dark.accent }};
                --td-color-accent-muted: {{ theme.colors_dark.accent_muted }};
                --td-color-bg: {{ theme.colors_dark.bg }};
                --td-color-bg-light: {{ theme.colors_dark.bg_light }};
                --td-color-bg-infobox: {{ theme.colors_dark.bg_infobox }};
                --td-color-border: {{ theme.colors_dark.border }};
                --td-color-border-dark: {{ theme.colors_dark.border_dark }};
                --td-color-text: {{ theme.colors_dark.text }};
                --td-color-text-muted: {{ theme.colors_dark.text_muted }};
                --td-color-highlight: {{ theme.colors_dark.highlight }};
                --td-color-warning-bg: {{ theme.colors_dark.warning_bg }};
                --td-color-surface: {{ theme.colors_dark.surface }};
                --td-color-border-light: {{ theme.colors_dark.border_light }};
                --td-color-text-secondary: {{ theme.colors_dark.text_secondary }};
                --td-color-accent-light: {{ theme.colors_dark.accent_light }};
                --td-color-success: {{ theme.colors_dark.success }};
                --td-color-error: {{ theme.colors_dark.error }};
                --td-color-accent-ring: {{ theme.colors_dark.accent_ring }};
            }
        }
        {% endif %}
        {% block extra_styles %}{% endblock %}
    </style>
</head>
<body>
    <a href="#main-content" class="skip-link">{{ t.skip_link | default('Pular para conteúdo') }}</a>

    {% set np = nav_prefix | default('') %}
    <nav aria-label="{{ t.nav_label | default('Navegação principal') }}">
        <div class="td-nav-inner">
            <a href="{{ np }}index.html" class="brand">
                {% if theme.logo %}
                <img src="{{ base_path | default('') }}{{ theme.logo }}" alt="" class="brand-logo">
                {% endif %}
                <span>{{ t.nav_brand | default(site.title) }}</span>
            </a>
            <button class="nav-toggle" aria-label="{{ t.nav_menu_label | default('Menu') }}" aria-expanded="false">&#9776;</button>
            <div class="nav-links">
                {% for mod in modules %}
                <a href="{{ np }}{{ mod.slug }}.html"{% if page == mod.slug %} class="active" aria-current="page"{% endif %}>{{ t['nav_' + mod.slug] | default(mod.name) }}</a>
                {% endfor %}
            </div>
            {% if locale_switches and locale_switches | length > 1 %}
            <div class="lang-switch" aria-label="{{ t.lang_switch_label | default('Language selector') }}">
                {% for switch in locale_switches %}
                    {% if switch.is_current %}
                    <span class="lang-current" aria-current="true">{{ switch.label }}</span>
                    {% else %}
                    <a href="{{ switch.href }}" class="lang-link">{{ switch.label }}</a>
                    {% endif %}
                {% endfor %}
            </div>
            {% endif %}
        </div>
    </nav>

    <main id="main-content" class="td-container">
        {% block content %}{% endblock %}
    </main>

    <footer>
        <div class="td-container">
            {% if t.footer_text %}<p class="footer-text">{{ t.footer_text }}</p>{% endif %}
            <p>{{ t.footer_generated | default('Gerado com') }} <a href="https://github.com/plataformasindigenas/aptoro">aptoro</a> {{ t.footer_and | default('e') }} <a href="https://github.com/plataformasindigenas/kodudo">kodudo</a></p>
            {% if meta and meta.version %}<p>Schema v{{ meta.version }}</p>{% endif %}
        </div>
    </footer>

    <script src="{{ base_path | default('') }}js/common.js"></script>
    {% block scripts %}{% endblock %}
</body>
</html>
