header {
  position: fixed;
  width: 100%;
  font-family: Geologica;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid #ddd;
  padding-block: 1rem;
  z-index: 1000;
  transition: background-color 0.3s ease;

  & .momentum {
    width: 160px;
    height: 48.10457229614258px;
  }

  & .btn-flex-container {
    & .dropdown {
      & .submenu {
        top: 40px;
        left: 50%;
        transform: translateX(-50%);

        & li {
          color: black;
          transition: color 0.25s ease;

          &:hover {
            color: #999999;
          }
        }

        @media (max-width: 1800px) {
          top: 30px;
        }
      }
    }
  }
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-basis: 1296px;
  padding-inline: 1.5rem;
}
.menu {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}
.menu li {
  position: relative;

  &.active {
    position: relative;

    &::before {
      content: "";
      position: absolute;
      width: 100%;
      height: 4px;
      border-top-left-radius: 40px;
      border-top-right-radius: 40px;
      right: 50%;
      transform: translateX(50%);
      background: linear-gradient(
        180deg,
        #8039e5 0%,
        #b939e5 50%,
        #e539bd 100%
      );
      bottom: calc((88.73px - 24px)/(-2)); /* 88.73 - height of header, 24 - height of li element */
      animation: expand-bar 1s ease forwards;

      @media(max-width: 1800px) {
        bottom: calc((73px - 24px)/(-2));
      }
    }
  }
}

.menu li.portfolio-dropdown {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.menu li.portfolio-dropdown > .portfolio-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

@keyframes expand-bar {
  from {
  width: 0;
  opacity: 0;
  }
  to {
  width: 100%;
  opacity: 1;
  }
}

.menu a,
.dropdown-button {
  display: flex;
  align-items: center;
  font-family: Geologica;
  text-decoration: none;
  color: inherit;
  font-weight: 400;
  line-height: 1.5rem;
  cursor: pointer;
  transition: 0.3s;
}

.menu a:hover,
.dropdown-button:hover {
  color: #999999 !important;
}

.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0.5rem;
  background: white;
  border-radius: 0.5rem;
  padding: 1rem 1.5rem;
  list-style: none;
  z-index: 2;
  box-shadow: 0px 8px 16px 0px #0000003d;
  text-wrap: nowrap;
}

.menu .submenu a:not(.mobile-menu .menu a),
.menu .submenu .dropdown-button:not(.mobile-menu .menu .dropdown-button) {
  color: black;

  & .dropdown-arrow {
    background-color: black;
  }
}

/* Add for nested submenu positioning */
.submenu li.dropdown > .submenu {
  top: -0.75rem;
  left: calc(100%);
}

.dropdown:hover > .submenu {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.mobile-menu .dropdown:hover > .submenu {
  display: none;
}

.menu li.dropdown:hover > .submenu {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
}

.mobile-menu .menu li.dropdown:hover > .submenu {
  display: none;
}

.submenu.active {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
}

.mobile-menu .mobile-menu-body .submenu.active {
  gap: 2rem !important;
}

@media(min-width: 1100px) {
  .submenu li.dropdown .dropdown-button .dropdown-arrow {
    transform: rotate(-90deg);
  }

  *:not(.mobile-menu) .submenu li.dropdown:hover .dropdown-arrow,
  .submenu li.dropdown.open .dropdown-arrow {
    transform: rotate(90deg);
  }
}


.mobile-menu .dropdown:hover > .dropdown-button .dropdown-arrow {
  transform: none;
}

.dropdown:hover > .dropdown-button .dropdown-arrow {
  transform: rotate(180deg);
}
.menu > .dropdown.open > .dropdown-button .dropdown-arrow, 
.mobile-menu .dropdown.open > .dropdown-button .dropdown-arrow,
.dropdown.language-selector.open > .dropdown-button .dropdown-arrow {
  transform: rotate(180deg) !important;
}

.controls {
  display: flex;
  gap: 2rem;
  align-items: center;

  @media (max-width: 1100px) {
    gap: 1rem;
  }
}

/* Мобільне меню */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--black);
  color: white;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
}
.mobile-menu.active {
  display: flex;
  position: fixed;
  z-index: 1001;
  transform: translateX(0);
}

/* Add styles for mobile menu links */
.mobile-menu .menu a:hover {
  color: rgba(255, 255, 255, 0.8);
}

.cross {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-block;
  margin-left: 0.75rem;
  transition: 0.3s ease;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-image: url("../../img/cross_24px.svg");
  mask-image: url("../../img/cross_24px.svg");
  mask-repeat: no-repeat;
  mask-position: right;
}

.menu-toggle {
  display: none;
  width: 1.5rem;
  height: 1.5rem;
  transition: 0.3s ease;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-image: url("../../img/menu_24px.svg");
  mask-image: url("../../img/menu_24px.svg");
  mask-repeat: no-repeat;
  mask-position: right;
}

.dark {
  & .menu-toggle {
    background-color: white;
  }

  & .cross {
    background-color: white;
  }
}

header.dark {
  border-bottom: 1px solid #333333;
}

.light {
  & .menu-toggle {
    background-color: black;
  }

  & .cross {
    background-color: black;
  }
}

/* .cross {
  font-size: 1.25rem;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}
.menu-toggle {
  display: none;
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
} */

@media (max-width: 1800px) {
  header {
    padding-block: 0.5rem;

    & .btn-flex-container {
      & .contact-btn {
        height: 46px;
        padding-inline: 2rem;
      }

      & .contact-btn-mini {
        width: 46px !important;
        height: 46px !important;
      }
    }
  }
}

@media (max-width: 1160px) {
  header {
    & ul.menu {
      gap: 1rem;
    }
  }
} 

@media (max-width: 1100px) {
  header {
    padding-block: 1rem;
    & .momentum {
      width: 133.04348754882812px;
      height: 40px;
    }
  }

  .mobile-menu {
    display: flex;
    align-items: start;
    justify-content: space-between;
    padding-bottom: 3rem;

  }

  .controls {
    flex-direction: row-reverse;
  }

  .controls .contact-btn {
    display: none;
  }

  /* .controls .language-selector {
    display: none;
  } */

  .mobile-menu-body {
    padding-inline: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 90%;
    gap: 2rem;
    overflow: hidden;
  }

  .navbar > .menu {
    display: none;
  }

  .mobile-menu .menu {
    font-size: 1.25rem;
    padding-left: 0;
    display: flex;
    gap: 2rem;
    margin-block: 0;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;

    &::-webkit-scrollbar {
      display: none;
    }

    & a,
    .dropdown-button {
      white-space: normal;
      justify-content: space-between;
    }
  }

  .mobile-menu .menu li.portfolio-dropdown {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .mobile-menu .menu li.portfolio-dropdown > .portfolio-link {
    flex: 1;
    justify-content: space-between;
  }

  .mobile-menu .menu li.portfolio-dropdown > .submenu {
    width: 100%;
  }

  .menu-toggle {
    color: #0a0a0a;
    display: block;
  }
  .mobile-menu .contact-btn {
    border-color: white;
  }
  /* For mobile menu, set arrow colors to white */
  .mobile-menu .arrow-right.light,
  .mobile-menu .dropdown-arrow.light {
    background-color: white;
  }

  .mobile-menu .dropdown-arrow.light {
    width: 1.5rem;
    height: 1.5rem;
  }

  .contact-btn {
    color: white;
    width: fit-content;
  }

  .submenu:not(.language-selector > .submenu) {
    display: none;
    position: static;
    top: 100%;
    left: 0.5rem;
    background: none;
    border-radius: 0.5rem;
    list-style: none;
    z-index: 2;
    box-shadow: 0px 8px 16px 0px #0000003d;
    text-wrap: nowrap;
    padding-bottom: 0;
    padding-top: 2rem;
  }

  /* Add for nested submenu positioning */
  .submenu li.dropdown > .submenu {
    top: -0.75rem;
    left: calc(100% - 0.5rem);
  }

  .submenu.active:not(.language-selector > .submenu) {
    display: flex;
    box-shadow: none;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    padding-right: 0;
  }

  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1.5rem;
    border-bottom: 1px solid #333333;
  }

  .mobile-menu-title {
    font-size: 1rem;
    line-height: 24px;
    font-weight: bold;
    color: white;
  }

  .mobile-lang-selector .language-selector {
    font-size: 1rem;
    color: white;
    text-decoration: underline;
  }

  .mobile-menu-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
  }
}

.language-selector {
  position: relative;
}

.language-selector > .dropdown-button {
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: underline;
  color: #666666;
  transition: opacity 0.3s ease;
  font-weight: 500;
  font-size: 1rem;
}

.dark .language-selector > .dropdown-button {
  color: #999999;
}

.language-selector .submenu {
  gap: 0;
  color: var(--black);
  margin-block: 0;
  padding: 0;
  top: 1.5rem;
  left: 0;
  border-radius: 0.5rem;
  border: 2px solid white;
}

.language-selector .submenu li {
  text-transform: uppercase;
  padding: 1rem 1.5rem;
  cursor: pointer;
}

.language-selector .submenu li:hover {
  background-color: var(--black);
  color: white;
  border-radius: 0.5rem;
}
