<!DOCTYPE html>
<html lang="{{ .Lang }}" class="theme-dark">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="{{ .Site.Params.siteDescription }}">
  <meta property="og:locale" content="{{ .Site.Language.Params.locale }}">
  <meta property="og:type" content="website">
  <meta property="og:url" content="{{ .Permalink }}">
  <meta property="og:site_name" content="{{ .Site.Title }}">
  <title>{{ .Title }}{{ if ne .Title .Site.Title }} — {{ .Site.Title }}{{ end }}</title>

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="/images/fav.png">

  <!-- Fonts -->
  <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&family=Oxanium:wght@400;600;700&display=swap" rel="stylesheet">

  <!-- Feather Icons -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.css">

  <!-- Tailwind CSS -->
  {{ $css := resources.Get "css/main.min.css" }}
  <link rel="stylesheet" href="{{ $css.RelPermalink }}">

  <!-- Syntax highlighting (Chroma) -->
  {{ $chroma := resources.Get "css/chroma-custom.css" | minify }}
  <link rel="stylesheet" href="{{ $chroma.RelPermalink }}">
</head>
<body class="bg-bg text-text antialiased" data-page-kind="{{ if .IsHome }}home{{ else }}other{{ end }}">
  <!-- Reading progress bar (only on single pages/articles) -->
  {{ if eq .Kind "page" }}
  <div
    id="reading-progress"
    class="fixed top-0 left-0 h-1 transition-all duration-100"
    style="width: 0%; background: linear-gradient(to right, var(--accent), var(--accent2)); z-index: 9999;"
  ></div>
  {{ end }}
  <!-- Skip to main content link -->
  <a href="#main" class="sr-only focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50 focus:px-4 focus:py-2 focus:bg-accent focus:text-white focus:rounded">
    {{ i18n "skipToContent" }}
  </a>

  <!-- Dot grid background pattern -->
  <div class="fixed inset-0 pointer-events-none opacity-5 dot-grid" style="
    background-image: radial-gradient(circle, currentColor 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: -1;
  "></div>

  <!-- Matrix rain canvas background -->
  <canvas id="matrix-rain" aria-hidden="true"></canvas>

  <!-- Theme toggle & language toggle (before Alpine loads to prevent flash) -->
  <script>
    (function() {
      const theme = localStorage.getItem('theme') || 'dark';
      const html = document.documentElement;
      html.classList.remove('theme-light', 'theme-dark');
      html.classList.add('theme-' + theme);
    })();
  </script>

  <!-- Navigation -->
  {{ partial "header.html" . }}

  <!-- Main content (spaced for fixed header) -->
  <main id="main" class="mt-20 relative z-10">
    {{ block "main" . }}{{ end }}
  </main>

  <!-- Footer -->
  {{ partial "footer.html" . }}

  <!-- Alpine.js -->
  <script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js" defer></script>

  <!-- Feather Icons initialization -->
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
  <script>feather.replace();</script>

  <!-- Theme toggle script -->
  {{ $themeScript := resources.Get "js/theme-toggle.js" | minify }}
  <script src="{{ $themeScript.RelPermalink }}"></script>

  <!-- Menu script -->
  {{ $menuScript := resources.Get "js/menu.js" | minify }}
  <script src="{{ $menuScript.RelPermalink }}"></script>

  <!-- Contact form script -->
  {{ $contactScript := resources.Get "js/contact-form.js" | minify }}
  <script src="{{ $contactScript.RelPermalink }}"></script>

  <!-- 404 Not Found page script -->
  {{ $notFoundScript := resources.Get "js/not-found-page.js" | minify }}
  <script src="{{ $notFoundScript.RelPermalink }}"></script>

  <!-- Reading progress bar script (on single pages/articles) -->
  {{ if eq .Kind "page" }}
  {{ $progressScript := resources.Get "js/reading-progress.js" | minify }}
  <script src="{{ $progressScript.RelPermalink }}"></script>
  {{ end }}

  <!-- Matrix rain background effect -->
  {{ with resources.Get "js/matrix-rain.js" }}
  {{ $s := . | minify }}
  <script src="{{ $s.RelPermalink }}"></script>
  {{ end }}
</body>
</html>
