nav {
  position: sticky;
  top: 16px;
  z-index: 12;

  height: 72px;
  padding: 0 40px;
  border-radius: 100px;

  display: flex;
  align-items: center;
  gap: 24px;

  transition: border-radius 300ms ease;

  background: #00000077;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media screen and (min-width: 1200px) {
  nav {
    --width: min(1296px, 100vw);
    width: var(--width);
    transform: translateX(calc((1200px - var(--width)) / 2));

    &:not(.secondary):not(:has(+ .secondary)) {
      background: transparent;
      backdrop-filter: unset;
      -webkit-backdrop-filter: unset;
    }

    &:has(.multi):not(:has(+ .secondary)):before {
      position: absolute;
      z-index: -1;
      height: 72px;
      width: 100%;
      border-radius: 100px;
      content: '';
      background: #00000077;
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      margin-left: -40px;
    }
  }
}

nav a,
nav .multi {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;

  position: relative;
}

nav a {
  cursor: pointer;
}

nav .multi icon {
  transition: transform 180ms ease;
}

nav:not(.mobile) .multi:hover,
nav.mobile .multi.active {
  & > icon,
  & > .title > icon {
    transform: rotate(180deg);
  }
}

nav .multi .menu {
  position: absolute;
  top: 80px;

  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.15);

  transform: translate(min(-40%, 300px), 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms linear;
  width: 700px;

  background: #00000077;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px) opacity(1);
  isolation: isolate;
  z-index: 20;

  padding: 24px;
  border-radius: 24px;

  /* hover handler */
  &::after {
    position: absolute;
    top: -36px;
    content: '';
    width: 100%;
    height: calc(100% + 12px);
    z-index: -1;
  }

  .side a icon {
    color: #c65bff;
  }
}

nav:has(+ .secondary) .multi .menu {
  background: #190233;
}

nav .multi:hover .menu {
  opacity: 1;
  pointer-events: all;
}

nav .multi .menu .sides {
  display: flex;
  gap: 40px;

  > .side {
    flex: 1 0 200px;
  }
}

nav .multi .menu .sides .side h2 {
  font-size: 18px;
  height: 40px;
}

nav .multi .menu .sides .side a {
  height: 40px;
  font-size: 14px;

  transition: color 120ms ease;
}

nav .multi .menu .sides .side a:hover {
  color: #c65bffff;
}

nav .multi .menu .sides .side a:active {
  color: #c65bffaa;
}

nav .multi .menu .actions {
  margin-top: 34px;
  display: flex;
  align-items: center;
  gap: 24px;
}

nav.secondary {
  top: 96px;
  margin-top: 8px;
  height: 90px;
  background: #00000033;
  gap: 4px;
  overflow-x: auto;
  z-index: 11;
}

@media screen and (max-width: 1200px) {
  nav.secondary {
    height: 100px;
  }
}

nav.secondary a {
  height: 100%;
  padding: 4px;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  white-space: normal;

  font-size: 14px;

  flex: 1 1 auto;
  min-width: 100px;

  position: relative;
  overflow: hidden;

  transition: transform 120ms ease;
}

/* nav.secondary a:hover {
  transform: scale(0.95);
}

nav.secondary a:active {
  transform: scale(1);
} */

nav.secondary a:before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  background: linear-gradient(
    #5f30e222 10%,
    #5f30e277,
    #5f30e2aa 80%,
    #5f30e222
  );
  z-index: -1;
  opacity: 0;

  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

nav.secondary a.active:before,
nav.secondary a:hover:before {
  opacity: 1;
}

nav.secondary a:active:before {
  transform: scale(1.2) rotate(5deg);
}

nav.secondary a icon {
  flex: 0 0 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(1.2);
}

nav.secondary .divider {
  height: 60%;
  width: 2px;
  background-color: #5f30e277;
  border-radius: 3px;
}

nav.secondary {
  transition:
    height 300ms ease,
    border-radius 300ms ease,
    background-color 300ms ease;
}

nav.secondary.inactive:not(:hover) {
  height: 48px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  background-color: #00000077;
}

@media screen and (min-width: 1200px) {
  nav:not(.mobile):not(.secondary):not(:has(+ .secondary)) {
    animation: fadeInNav 1s ease;
  }

  nav.secondary.inactive:not(:hover) {
    top: 88px;
  }

  nav:has(~ .secondary.inactive:not(:hover)) {
    border-radius: 50px 50px 0 0;
  }
}

@media screen and (max-width: 1200px) {
  nav {
    border-radius: 0;
    top: 0;
    margin: -16px -16px 0 -16px;
    padding: 0 16px;

    &:before {
      border-radius: 0;
      margin-left: -20px;
    }
  }

  nav.secondary {
    top: 72px;
    margin-top: 0;
    border-top: 1px solid #5f30e233;
  }
}

nav .btn {
  height: 34px;
  font-size: 12px;
  white-space: nowrap;
}

.nav-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  background: #000000aa;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease;

  &.active {
    pointer-events: all;
    opacity: 1;
  }
}

nav.mobile {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;

  max-width: 90vw;
  height: 100vh;
  height: -webkit-fill-available;

  padding: 0; /* vertical padding kills fill-available in safari */

  margin: 0;
  background-color: #000000aa;

  display: flex;
  flex-direction: column;
  align-items: flex-end;

  transform: translateX(100%);
  transition: 300ms transform ease;

  &.active {
    transform: translateX(0);
  }

  > .top {
    width: 100%;
    margin-top: 18px;
    padding: 0 24px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;

    > img {
      height: 36px;
    }
  }

  > .actions {
    padding: 0 24px;
  }

  > .content {
    width: 100%;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    overflow: auto;

    > * {
      width: 100%;
      padding: 0 24px;
      flex: 0 0 44px;

      display: flex;
      align-items: center;
    }

    > :not(:last-child) {
      border-bottom: 1px solid #5f30e233;
    }
  }

  > .actions {
    margin-bottom: 24px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  a:not(.btn),
  .multi {
    height: unset;
  }

  .multi {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-end;
    max-height: 44px; /* title row */
    overflow: hidden;
    padding: 0;

    transition: max-height 180ms ease;

    > .title {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 0 24px;
      flex: 0 0 44px;
      width: 100%;
    }

    > a {
      padding: 0 24px;
      padding-left: 36px;
      flex: 0 0 44px;
      width: 100%;

      &:not(.href-active) {
        color: color-mix(in srgb, #8dcefe 60%, white);
      }
    }

    > :not(:last-child) {
      border-bottom: 1px solid #5f30e233;
    }

    &.active {
      max-height: 600px;
    }
  }
}

@keyframes fadeInNav {
  0% {
    transform: translate(calc((1200px - var(--width)) / 2), -100px) scale(0.9);
    opacity: 0;
  }
  100% {
    transform: translate(calc((1200px - var(--width)) / 2), 0) scale(1);
    opacity: 1;
  }
}
