<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>
      {% block title %}Hassette{% endblock %}
    </title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap">
    <link rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link rel="icon" type="image/png" href="/ui/static/img/hassette-logo.png">
    <link rel="stylesheet" href="/ui/static/css/tokens.css">
    <link rel="stylesheet" href="/ui/static/css/style.css">
    <script>
      if (localStorage.getItem('ht-sidebar') === 'closed') {
        document.documentElement.classList.add('ht-sidebar-closed');
      }
    </script>
    <script src="https://unpkg.com/htmx.org@2.0.4"></script>
    <script src="https://unpkg.com/idiomorph@0.3.0/dist/idiomorph-ext.min.js"></script>
    <script defer src="/ui/static/js/ws-handler.js"></script>
    <script defer src="/ui/static/js/live-updates.js"></script>
    <script defer src="/ui/static/js/log-table.js"></script>
    <script defer
            src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.8/dist/cdn.min.js"></script>
  </head>
  <body x-data x-init="$store.ws.connect()">
    <div class="ht-layout"
         hx-boost="true"
         hx-target="#page-content"
         hx-select="#page-content"
         hx-swap="outerHTML show:window:top"
         x-data="{ sidebarOpen: (() => { const saved = localStorage.getItem('ht-sidebar'); return saved !== null ? saved === 'open' : window.innerWidth >= 769; })() }"
         x-effect="localStorage.setItem('ht-sidebar', sidebarOpen ? 'open' : 'closed')"
         @keydown.escape.window="sidebarOpen = false"
         @resize.window="if (window.innerWidth < 769) sidebarOpen = false">
      {% include "components/nav.html" %}
      <div class="ht-sidebar-backdrop"
           x-show="sidebarOpen"
           x-transition.opacity
           @click="sidebarOpen = false"></div>
      <main class="ht-main">
        {% include "components/status_bar.html" %}
        {% include "components/alert_banner.html" %}
        <section id="page-content" class="ht-section">
          {% block content %}{% endblock %}
        </section>
      </main>
    </div>
  </body>
</html>
