<!doctype html>
<html
  lang="{{ page.lang | default: site.lang | default: 'en' }}"
  data-theme="dark"
  class="no-js"
>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="color-scheme" content="dark light" />

    <title>
      {% if page.title %}{{ page.title }} | {% endif %}{{ site.title }}
    </title>
    {% assign page_excerpt_fallback = page.excerpt | default: content |
    strip_html | strip_newlines | replace: " ", " " | truncate: 160 %}
    <meta
      name="description"
      content="{{ page.description | default: page_excerpt_fallback | default: site.description | strip_html | truncate: 160 }}"
    />

    <!-- Favicon -->
    <link
      rel="icon"
      href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none'%3E%3Ccircle cx='14' cy='14' r='10' stroke='%234db8a8' stroke-width='2.5'/%3E%3Cpath d='M21.5 21.5L28 28' stroke='%234db8a8' stroke-width='2.5' stroke-linecap='round'/%3E%3Ccircle cx='14' cy='14' r='5' stroke='%234db8a8' stroke-width='1.5' opacity='0.6'/%3E%3Cpath d='M11 14h6M14 11v6' stroke='%234db8a8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"
    />

    <!-- DNS Prefetch for external resources -->
    <link rel="dns-prefetch" href="https://fonts.googleapis.com" />
    <link rel="dns-prefetch" href="https://fonts.gstatic.com" />
    <link rel="dns-prefetch" href="https://github.com" />

    <!-- Preconnect to fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&family=Newsreader:ital,wght@0,400;0,600;0,700;1,400;1,600&display=swap"
      rel="stylesheet"
    />

    <!-- Open Graph -->
    <meta
      property="og:title"
      content="{% if page.headline %}{{ page.title }} - {{ page.headline }}{% else %}{{ page.title | default: site.title }}{% endif %}"
    />
    <meta
      property="og:description"
      content="{{ page.description | default: page_excerpt_fallback | default: site.description | strip_html | truncate: 200 }}"
    />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="{{ page.url | absolute_url }}" />
    <meta property="og:site_name" content="{{ site.title }}" />
    <meta
      property="og:image"
      content="{{ page.og_image | default: site.og_image | absolute_url }}"
    />
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="630" />

    <!-- Twitter -->
    <meta
      name="twitter:card"
      content="{{ site.twitter.card | default: 'summary' }}"
    />
    <meta name="twitter:site" content="@{{ site.twitter.username }}" />
    <meta name="twitter:creator" content="@{{ site.twitter.username }}" />
    <meta
      name="twitter:title"
      content="{{ page.title | default: site.title }}"
    />
    <meta
      name="twitter:description"
      content="{{ page.description | default: page_excerpt_fallback | default: site.description | strip_html | truncate: 200 }}"
    />
    <meta
      name="twitter:image"
      content="{{ page.og_image | default: site.og_image | absolute_url }}"
    />

    <!-- Additional Meta -->
    <meta name="author" content="{{ site.author.name }}" />
    <meta name="robots" content="index, follow" />
    <meta
      name="googlebot"
      content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"
    />
    <meta
      name="keywords"
      content="{{ page.keywords | default: 'local search, semantic search, hybrid search, MCP server, Claude Code, Codex, OpenCode, Obsidian search, privacy-first, AI agent memory, knowledge engine, local RAG' }}"
    />

    <!-- Canonical -->
    <link rel="canonical" href="{{ page.url | absolute_url }}" />

    <!-- Stylesheet -->
    <link
      rel="stylesheet"
      href="{{ '/assets/css/style.css' | relative_url }}"
    />

    <!-- Preload critical resources -->
    <link
      rel="preload"
      href="{{ '/assets/css/style.css' | relative_url }}"
      as="style"
    />
    <link
      rel="preload"
      href="{{ '/assets/js/main.js' | relative_url }}"
      as="script"
    />

    <!-- Theme script (prevent flash) + JS detection -->
    <script>
      (function () {
        // Enable JS-dependent CSS
        document.documentElement.classList.remove("no-js");
        document.documentElement.classList.add("js");
        // Theme
        var theme = localStorage.getItem("gno-theme");
        if (!theme) {
          theme = window.matchMedia("(prefers-color-scheme: light)").matches
            ? "light"
            : "dark";
        }
        document.documentElement.setAttribute("data-theme", theme);
      })();
    </script>

    <!-- JSON-LD Structured Data -->
    {% include schema.html %}
  </head>
  <body class="layout-{{ page.layout }}">
    <a href="#main-content" class="skip-link">Skip to main content</a>

    {% include header.html %}
    <div class="sidebar-overlay" id="sidebar-overlay"></div>

    <main id="main-content" class="site-main">{{ content }}</main>

    {% include footer.html %}

    <script src="{{ '/assets/js/main.js' | relative_url }}" defer></script>
  </body>
</html>
