{% set player_bar = [
    ('/npc/spells', 'spells', 'Spells', false),
    ('/worldmap', 'worldmap', 'Maps', false),
    ('/player_tokens', 'tokens', 'Tokens', false),
    ('/shares_calculator', 'shares_calc', 'Spoil Shares', false),
    ('https://reddit.com/r/PalismaACKS/wiki', 'redditwiki', 'Wiki', true),
] %}
{% set judge_bar = [
    ('/npc/party', 'npcparty', 'Generate Party', false),
    ('/npc/single', 'npcsingle', 'Generate NPC', false),
    ('/wandering_monster', 'wandering', 'Wandering Monster', false),
    ('/lairs', 'lairs', 'Lairs', false),
    ('http://autarch.co/treasure', 'treasure', 'Treasure', true),
    ('/quest/list', 'questlist', 'Quests', false),
    ('/wiki', 'wiki', 'Wiki', false),
]%}

{% set navigation_bar = [
    ('/', 'index', 'Home', false),
    ('/handbook#detailed-table-of-contents', 'handbook', 'Handbook', false),
    (player_bar, 'section', 'Player Resources', false),
    (judge_bar, 'section', 'Judge Resources', false),
    ('https://reddit.com/r/PalismaACKS', 'subreddit', '/r/PalismaACKS', true),
] %}

{% set active_page = active_page|default('index') %}

<!doctype html>
<html>
    <head>
        <title>{% block title %}{% endblock %} - Legends of Palisma</title>

        <meta charset="utf-8">
        <meta name="viewport" contents="width=device-width, initial-scale=1">

        <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">

        <!-- UIkit CSS -->
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.6.8/dist/css/uikit.min.css" />

        <!-- UIkit JS -->
        <script src="https://cdn.jsdelivr.net/npm/uikit@3.6.8/dist/js/uikit.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/uikit@3.6.8/dist/js/uikit-icons.min.js"></script>

        <style>
            h1 strong {
                display: block;
                font-size: 50%;
                opacity: 0.65;
            }

            .uk-navbar-nav > li > a {
                font-size: 1em;
                text-transform: none;
            }
        </style>
        {% block head %} 
        {% endblock %}
    </head>
    <body>
        <nav class="uk-navbar-container" uk-navbar>
            <div class="uk-navbar-left">
                <a href="" class="uk-hidden@m uk-button-default uk-margin-small-left uk-margin-small-right" uk-toggle="target: #offcanvas-nav" uk-icon="menu"></a>
                <a href="{{ url_for('default_views.index') }}" class="uk-navbar-item uk-logo">Palisma ACKS</a>
            </div>
            <div class="uk-navbar-center uk-visible@m">
                <ul class="uk-navbar-nav">
                    {% for href, id, label, blank in navigation_bar %}
                        {% if id == 'section' %}
                        <li>
                            <a href="" {% if blank is sameas true %} target="_blank" {% endif %}>{{ label|e }}</a>
                            <div class="uk-navbar-dropdown">
                                <ul class="uk-nav uk-navbar-dropdown-nav">
                                    {% for phref, pid, plabel, pblank in href %}
                                    <li>
                                        <a href="{{ phref|e }}" {% if pblank is sameas true %} target="_blank" {% endif %}>{{ plabel|e }}</a>
                                    </li>
                                    {% endfor %}
                                </ul>
                            </div>
                        </li>
                        {% else %}
                        <li {% if id == active_page %} class="uk-active" {% endif %}>
                            <a href="{{ href|e }}" {% if blank is sameas true %} target="_blank" {% endif %}>{{ label|e }}</a>
                        </li>
                        {% endif %}
                    {% endfor %}
                </ul>
            </div>
        </nav>
        <div id="offcanvas-nav" uk-offcanvas="overlay: true">
            <div class="uk-offcanvas-bar uk-flex uk-flex-column">
                <ul class="uk-nav uk-nav-primary uk-nav-center uk-margin-auto-vertical">
                    {% for href, id, label, blank in navigation_bar %}
                        {% if id == 'section' %}
                            <li class="uk-nav-header uk-margin-large-top">{{ label|e }}</li>
                            {% for phref, pid, plabel, pblank in href %}
                            <li {% if pid == active_page %} class="uk-active" {% endif %}>
                                <a href="{{ phref|e }}" {% if pblank is sameas true %} target="_blank" {% endif %}>{{ plabel|e }}</a>
                            </li>
                            {% endfor %}
                            <li class="uk-margin-large-bottom"/>
                        {% else %}
                        <li {% if id == active_page %} class="uk-active" {% endif %}>
                            <a href="{{ href|e }}" {% if blank is sameas true %} target="_blank" {% endif %}>{{ label|e }}</a>
                        </li>
                        {% endif %}
                    {% endfor %}
                </ul>
            </div>
        </div>
        <div id="base_page_content" class="uk-container uk-margin-medium-top">
            {% block content %}{% endblock %}
        </div>
        <footer class="uk-flex uk-flex-top uk-flex-center uk-margin-small uk-margin-medium-top">
            <div class="uk-text-center uk-text-small">
                Made by <a href="https://binaryatrocity.name">binaryatrocity</a>. 
                ACKS &amp; related &copy; <a href="http://www.autarch.co/">Autarch</a>.
            </div>
        </footer>

        {% block scripts %}
        {% endblock %}
    </body>
</html>
