@use "settings";

// Site header
body > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-6);
  margin: 0;
  padding: 0 0 var(--space-3);
  border-bottom: var(--rule-width) solid var(--border);
  border-image: var(--starlight-rule);

  > a[rel="home"] {
    color: var(--primary);
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: 0.015em;
    text-decoration: none;
    transition: color var(--duration-normal) var(--ease-linear), transform var(--duration-normal) var(--ease-out);

    &:hover,
    &:focus-visible {
      transform: translateY(calc(-1 * var(--rule-width)));
    }

    &:active {
      transform: translateY(0) scale(0.98);
    }

    > span {
      display: inline-block;
      font-size: 0.65em;
      text-shadow: var(--glow-soft);
      transition: text-shadow var(--duration-normal) var(--ease-linear), transform var(--duration-normal) var(--ease-out);
      vertical-align: 0.12em;
    }

    &:hover > span,
    &:focus-visible > span {
      text-shadow: var(--glow-strong);
      transform: scale(1.2);
    }
  }

  @include settings.mobile {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.8rem;
  }
}

body > header nav {
  margin: 0;

  @include settings.mobile {
    width: 100%;
    overflow-x: auto;
  }

  ul {
    display: flex;
    gap: clamp(1.25rem, 2.5vw, 2.2rem);
    margin: 0;
    padding: 0;
    list-style: none;

    @include settings.mobile {
      justify-content: flex-start;
      gap: clamp(var(--space-4), 4vw, var(--space-6));
    }
  }

  li {
    margin: 0;
  }

  a {
    position: relative;
    display: inline-block;
    padding: var(--space-1) 0.1rem;
    color: var(--primary);
    background-image: linear-gradient(var(--primary), var(--primary));
    background-position: left calc(100% - 0.1rem);
    background-repeat: no-repeat;
    background-size: 0 var(--rule-width);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.5;
    text-decoration: none;
    transition: color var(--duration-normal) var(--ease-linear), background-size var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out);

    &::after {
      position: absolute;
      right: -0.1rem;
      bottom: 0;
      width: 0.2rem;
      height: 0.2rem;
      background: currentColor;
      content: "";
      opacity: 0;
      pointer-events: none;
      transform: rotate(45deg) scale(0);
      transition: opacity var(--duration-fast) var(--ease-linear), transform var(--duration-normal) var(--ease-out);
    }

    &:hover,
    &:focus-visible {
      background-size: 100% var(--rule-width);
      transform: translateY(calc(-1 * var(--rule-width)));

      &::after {
        opacity: 1;
        transform: rotate(45deg) scale(1);
      }
    }

    &:active {
      transform: translateY(0) scale(0.96);
    }

    &[aria-current="page"] {
      color: var(--text-main);
      background-size: 100% var(--rule-width);
    }
  }
}
