---
import "../assets/fonts/fonts.css";

import "@fortawesome/fontawesome-free/css/all.min.css";
import "nprogress/nprogress.css";

import Navbar from "../components/Navbar.astro";
import { ViewTransitions } from "astro:transitions";

const { title } = Astro.props;
---

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <meta name="viewport" content="width=device-width" />
    <meta name="generator" content={Astro.generator} />
    {title && <title>山羊寒舍 | {title}</title>}
    {!title && <title>山羊寒舍</title>}

    <script is:inline>
      if (localStorage.getItem("theme") === null) {
        document.documentElement.setAttribute("data-theme", "light");
      } else {
        document.documentElement.setAttribute("data-theme", localStorage.getItem("theme"));
      }
    </script>

    <script>
      import NProgress from "nprogress";
      NProgress.configure({ showSpinner: false, trickleRate: 0.02, trickleSpeed: 800 });
      document.addEventListener("astro:before-preparation", function () {
        NProgress.start();
      });
      document.addEventListener("astro:after-preparation", function () {
        NProgress.done();
      });
    </script>

    <ViewTransitions />
  </head>
  <body>
    <!-- Header -->
    <Navbar />

    <!-- Content -->
    <main transition:animate="slide">
      <slot />
    </main>

    <!-- Styles -->
    <style>
      html {
        overflow-x: hidden !important;
        overflow-y: auto !important;
      }
    </style>

    <style is:global>
      .h-fullpage {
        height: calc(100vh - 64px);
      }

      .max-h-fullpage {
        max-height: calc(100vh - 64px);
      }

      .mt-header {
        margin-top: 64px;
      }

      .top-header {
        top: 64px;
      }

      #nprogress .bar {
        background: #49509e !important;
      }
    </style>

    <script>
      import { themeChange } from "theme-change";
      themeChange();
    </script>

    <script
      async
      src="https://analytics.smartsheep.studio/script.js"
      data-website-id="9d676a27-b473-44a3-b444-5a7d851e31e8"></script>
  </body>
</html>