---
import { Icon } from "astro-icon";
import Logo from "~/components/widgets/Logo.astro";
import { getPermalink, getBlogPermalink, getHomePermalink } from "~/utils/permalinks";

const { } = Astro.props;
---

<header
  class="sticky top-0 z-40 flex-none mx-auto w-full bg-white md:bg-white/90 dark:bg-slate-900 dark:md:bg-slate-900/90 md:backdrop-blur-sm border-b dark:border-b-0">
  <div class="py-3 px-3 mx-auto w-full md:flex md:justify-between max-w-6xl md:px-4">
    <div class="flex justify-between">
      <a class="flex items-center" href={getHomePermalink()}>
        <Logo />
      </a>
      <div class="flex items-center md:hidden">
        <button type="button"
          class="text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center"
          aria-label="Toggle between Dark and Light mode" data-aw-toggle-color-scheme>
          <Icon name="tabler:sun" class="w-6 h-6" />
        </button>
        <button
          class="ml-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center transition"
          aria-label="Toggle Menu" data-aw-toggle-menu>
          <Icon name="tabler:menu" class="w-6 h-6" optimize={false} />
        </button>
      </div>
    </div>
    <nav class="items-center w-full md:w-auto hidden md:flex text-gray-600 dark:text-slate-200 h-screen md:h-auto"
      aria-label="Main navigation" id="menu">
      <ul
        class="flex flex-col pt-8 md:pt-0 md:flex-row md:self-center collapse w-full md:w-auto collapsed text-xl md:text-base">
        <li>
          <a class="font-medium hover:text-gray-900 dark:hover:text-white px-4 py-3 flex items-center transition duration-150 ease-in-out"
            href="#">Pages
          </a>
        </li>
        <li>
          <a class="font-medium hover:text-gray-900 dark:hover:text-white px-4 py-3 flex items-center transition duration-150 ease-in-out"
            href={getPermalink("useful-resources-to-create-websites", "post")}>Resources
          </a>
        </li>
        <li>
          <a class="font-medium hover:text-gray-900 dark:hover:text-white px-4 py-3 flex items-center transition duration-150 ease-in-out"
            href={getBlogPermalink()}>Blog
          </a>
        </li>
        <li class="md:hidden">
          <a class="font-bold hover:text-gray-900 dark:hover:text-white px-4 py-3 flex items-center transition duration-150 ease-in-out"
            href="https://github.com/onwidget/astrowind">
            Github
          </a>
        </li>
      </ul>
      <div class="md:self-center flex items-center mb-4 md:mb-0 collapse collapsed">
        <div class="hidden items-center mr-3 md:flex">
          <button type="button"
            class="text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center"
            aria-label="Toggle between Dark and Light mode" data-aw-toggle-color-scheme>
            <Icon name="tabler:sun" class="w-5 h-5" />
          </button>
          <a class="text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center"
            aria-label="RSS Feed" href="/rss.xml">
            <Icon name="tabler:rss" class="w-5 h-5" />
          </a>
          <a href="https://github.com/onwidget/astrowind"
            class="inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 mr-1"
            aria-label="Astrowind Github">
            <Icon name="tabler:brand-github" class="w-5 h-5" />
          </a>
        </div>
      </div>
    </nav>
  </div>
</header>

<style is:global>
    [data-aw-toggle-menu] path {
      @apply transition;
    }
    [data-aw-toggle-menu].expanded g > path:first-child {
      @apply -rotate-45 translate-y-[15px] translate-x-[-3px];
    }

    [data-aw-toggle-menu].expanded g > path:last-child {
      @apply rotate-45 translate-y-[-8px] translate-x-[14px];
    }
</style>