{% load static %}
<!doctype html>
<html lang="de">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta charset="utf-8" />
        <title>Suff - Gähsnitz Open Air</title>
        <link rel="icon" type="image/svg+xml" href="{% static 'suff/favicon.svg' %}" />
        <link rel="stylesheet" href="{% static 'suff/style.css' %}" />
    </head>
    <body>
        <main>
            <p class="site-name">Gähsnitz Open Air</p>
            <h1>Suff</h1>
            {% block content %}{% endblock %}
        </main>
        <script>
        // Track last clicked submit button so its value survives being disabled on submit.
        document.addEventListener('click', function(e) {
            var btn = e.target.closest('button[type="submit"], button:not([type])');
            if (!btn || !btn.form) return;
            var form = btn.form;
            var existing = form.querySelector('input[data-submitter]');
            if (existing) existing.remove();
            if (btn.name) {
                var hidden = document.createElement('input');
                hidden.type = 'hidden';
                hidden.name = btn.name;
                hidden.value = btn.value;
                hidden.setAttribute('data-submitter', '1');
                form.appendChild(hidden);
            }
        });
        document.addEventListener('submit', function(e) {
            var form = e.target;
            form.querySelectorAll('button[type="submit"], button:not([type])').forEach(function(btn) {
                btn.disabled = true;
                btn.style.opacity = '0.5';
            });
        });
        </script>
    </body>
</html>
