.header {
  animation: headerSlideDown 0.55s cubic-bezier(0.23, 1, 0.32, 1) both;
  background: var(--color-cream);
  border-bottom: 1px solid var(--color-brown-a30);
  box-shadow: 0 6px 18px var(--color-black-a12);
  box-sizing: border-box;
  color: var(--color-black);
  font-family: "MFB-Oldstyle", serif;
  font-style: normal;
  left: 0;
  min-height: var(--header-height);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
}

@keyframes headerSlideDown {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header__nav {
  align-items: center;
  box-sizing: border-box;
  display: flex;
  gap: 0.5rem;
  min-height: var(--header-height);
  padding: 1.25rem;
  width: 100%;
}

.header__nav-item {
  align-items: center;
  border-color: var(--color-black);
  border-style: solid;
  border-width: 2px 2px 0 2px;
  box-sizing: border-box;
  color: var(--color-black);
  display: flex;
  flex: 1;
  font-size: var(--fs-3xl);
  padding: 0.25rem 0.5rem;
  position: relative;
  text-decoration: none;
  transition: background 0.25s ease;
}

.header__nav-item.is-current {
  border-color: var(--color-brown);
  color: var(--color-brown);
}

.header__nav-item::before {
  border: 3px solid var(--color-brown);
  border-bottom: none;
  bottom: 0;
  clip-path: polygon(
    0 100%,
    0 100%,
    0 100%,
    0 100%,
    0 100%,
    0 100%,
    0 100%,
    0 100%
  );
  content: "";
  left: -2px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  right: -2px;
  top: -2px;
  transition: opacity 0.2s ease;
  z-index: 1;
}

.header__nav-item:hover::before {
  animation: traceBorder 0.55s cubic-bezier(0.23, 1, 0.32, 1) forwards;
  opacity: 1;
}

@keyframes traceBorder {
  0% {
    clip-path: polygon(
      0 100%,
      0 100%,
      0 100%,
      0 100%,
      0 100%,
      0 100%,
      0 100%,
      0 100%
    );
  }
  30% {
    clip-path: polygon(
      0 100%,
      0 0,
      3px 0,
      3px 0,
      3px 0,
      3px 0,
      3px 3px,
      3px 100%
    );
  }
  65% {
    clip-path: polygon(
      0 100%,
      0 0,
      100% 0,
      100% 0,
      calc(100% - 3px) 0,
      calc(100% - 3px) 3px,
      3px 3px,
      3px 100%
    );
  }
  100% {
    clip-path: polygon(
      0 100%,
      0 0,
      100% 0,
      100% 100%,
      calc(100% - 3px) 100%,
      calc(100% - 3px) 3px,
      3px 3px,
      3px 100%
    );
  }
}
.header__nav-item:nth-child(1) {
  animation: fadeInDown 0.4s ease 0.15s both;
}
.header__nav-item:nth-child(2) {
  animation: fadeInDown 0.4s ease 0.25s both;
}
.header__nav-item:nth-child(3) {
  animation: fadeInDown 0.4s ease 0.35s both;
}

.header__nav-item:last-child {
  border-right: none;
}
.header__nav-item:last-child::before {
  border-right: none;
  right: 0;
}

.header__nav-item:last-child:hover::before {
  animation: traceBorderNoRight 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes traceBorderNoRight {
  0% {
    clip-path: polygon(0 100%, 0 100%, 0 100%, 0 100%, 0 100%, 0 100%);
  }
  45% {
    clip-path: polygon(0 100%, 0 0, 3px 0, 3px 0, 3px 3px, 3px 100%);
  }
  100% {
    clip-path: polygon(0 100%, 0 0, 100% 0, 100% 3px, 3px 3px, 3px 100%);
  }
}

.header__logo:hover,
.header__nav-item:hover {
  background: var(--color-black-a04);
}
.header__nav-number {
  display: inline-block;
  fill: currentColor;
  height: 1.2rem;
  vertical-align: middle;
  width: 1.2rem;
}

.header__nav-number svg {
  display: block;
  height: 100%;
  width: 100%;
}

@media (max-width: 768px) {
  .header__nav {
    gap: 0.25rem;
    padding: 0.75rem;
  }

  .header__logo {
    font-size: var(--fs-3xl);
  }

  .header__nav-item {
    font-size: var(--fs-2xl);
  }

  .header__nav-number {
    height: 1rem;
    width: 1rem;
  }
}
.header__avatar {
  border: 2px solid var(--color-black-a04);
  border-radius: 50%;
  display: inline-block;
  height: 1.2rem;
  margin-right: 0.5rem;
  object-fit: cover;
  width: 1.2rem;
}
