.main-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: $header-height;
  z-index: $z-header;
  transition: transform 250ms ease-out;

  .projects-list &, .projects-detail & {
    background: transparent;
    border-bottom: 1px solid transparent;
  }

  @include md {
    height: $header-height-mobile;
  }

  &__bottom-bar {
    height: 70px;
    background: #fff;
    border-bottom: 1px solid rgba(235,241,244,0.5);
    transition: all .2s ease-in-out;
    display: flex;
    justify-content: center;
    transition: background-color 300ms ease-out 500ms;

    @include sm {
      height: 100%;
    }

    .header-over.js-is-top & {
      background: rgba(255, 255, 255, 0.6);

      @include tablet {
        background: #fff;
      }
    }
  }

  &:hover {
    .main-header__bottom-bar {
      .header-over.js-is-top & {
        background: #fff;
        transition-delay: 0ms;
      }
    }
    .main-header__top-bar {
      .header-over.js-is-top & {
        background: $gray-bluish-light;
        transition-delay: 0ms;
      }
    }
  }

  &__container {
    width: 100%;
    max-width: $max-width;
    padding: 0 $gutter;
    display: flex;
    justify-content: space-between;
    align-items: center;

    @include sm {
      padding: 0 $gutter-mobile;
    }
  }

  &__logo-mask {
    flex-shrink: 0;
    display: inline-flex;

    // @include sm {
    //   width: 48px;
    //   overflow: hidden;
    // }

    @include md {
      width: auto;
    }
  }

  &__logo {
    width: 223px;
    height: 45px;

    @include sm {
      width: 134px;
      height: 28px;
    }

    svg {
      height: 45px;
      max-width: 100%;
      display: block;

      @include sm {
        width: 134px;
        height: 28px;
      }
    }
  }

  &__logo-desktop {
    display: inline-block;
    width: 100%;

    @include sm {
      display: none;
    }
  }

  &__logo-mobile {
    display: none;

    @include sm {
      display: inline-block;
    }
  }

  &.js-search-open {
    .header-search__box {
      transform: translateY(0);
      transition: transform .2s ease-out;
    }

    .header-search__shadow {
      opacity: .1;
    }
  }

  &__top-bar {
    height: 30px;
    background: $gray-bluish-light;
    padding-top: 3px;
    transition: background-color 300ms ease-out 500ms;

    .header-over.js-is-top & {
      background: rgba(235, 241, 244, 0.6);
    }

    @include sm {
      display: none;
    }
  }

  .js-scroll-down & {
    transform: translateY(-30px);

    @include sm {
      transform: translateY(0);
    }
  }

  &__top-bar-content {
    width: 100%;
    max-width: $max-width;
    padding: 0 $gutter;
    display: flex;
    justify-content: flex-end;
    margin: auto;
  }

  &__top-bar-item {
    position: relative;
    margin-left: 30px;

    > a {
      position: relative;
    }

    > a:after {
      content: "";
      position: absolute;
      display: block;
      height: 3px;
      background-color: $medium-color;
      width: 100%;
      top: 23px;
      pointer-events: none;
      opacity: 0;
      transform: translateY(0);
      transition: all 0.2s ease-out;
    }

    &:hover > a:after,
    &.js-open > a:after {
      opacity: 1;
      transform: translateY(-100%);
    }
  }

  &__top-bar-link,
  &__lang-switch-toggle {
    font-size: 1.2rem;
    color: $primary-color;
  }

  &__lang-switch {
    position: relative;
  }

  &__lang-switch-toggle {
    svg {
      margin-left: 2px;
      width: 8px;
      height: 8px;
      transition: transform 0.2s linear;

      path {
        fill: $primary-color;
      }
    }
  }

  &__lang-switch-drop {
    position: absolute;
    left: -16px;
    top: 27px;
    font-size: 1.2rem;
    color: $primary-color;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;

    > ul {
      flex-direction: column;
      background-color: $gray-bluish-light;
      min-width: 160px;
      pointer-events: all;
      transform: translateY(-100%);
      opacity: 0;
      transition: all 0.2s ease-out;
    }

    a {
      display: block;
      color: $primary-color;
      line-height: 36px;
      padding: 0 16px;
      transition: all 0.2s ease-out;

      &:hover {
        background-color: rgba(30,53,92,0.04);
        color: $medium-color;
      }
    }
  }

  &__lang-switch.js-open {
    svg {
      transform: rotate(-180deg);
    }

    ul {
      transform: translateY(0);
      opacity: 1;
    }
  }

  &__top-bar-nav {
    ul {
      display: flex;
    }

    a[target="_blank"] {
      padding-left: 20px;
      position: relative;
      display: inline;

      &:before {
        position: absolute;
        top: 2px;
        left: 1px;
        content: '';
        display: block;
        width: 12px;
        height: 12px;
        background: url(../assets/img/svg/external.svg) no-repeat center;
      }
    }
  }

  &__scroll-indicator {
    position: absolute;
    bottom: -4px;
    height: 4px;
    width: 100%;
    background-color: $gray-10;
    opacity: 1;
    left: 0;
    pointer-events: none;
    z-index: -1;
    transition: opacity 300ms ease-out 500ms;
    display: none;

    .projects-detail &,
    .blog-detail &,
    .article-detail &,
    .event-detail & {
      display: block;
    }

    span {
      content: '';
      display: block;
      position: absolute;
      left: 0;
      top: 0;
      width: 0;
      height: 100%;
      background-color: $medium-color;
      transition: width 200ms ease-out;
    }

    .js-is-top & {
      opacity: 0.6;
      transition-delay: 0;
    }
  }
}

.main-nav {
  margin-left: auto;
  margin-right: 25px;

  @include tablet {
    display: none;
  }

  &__search-btn {
    display: inline-flex;
    width: 20px;
    height: 20px;

    svg {
      width: 100%;
    }
  }

  &__menu {
    display: flex;
    justify-content: flex-end;
  }

  .header-menu {
    position: relative;
    margin: 0 15px;

    &:first-child {
      margin: 0 15px 0 5px;
    }

    &:last-child {
      margin: 0 5px 0 15px;
    }

    a {
      font-family: var(--font-heading);
      color: $primary-color;


      &:hover {
        color: $medium-color;
      }
    }

    > a {
      font-family: var(--font-heading);
      font-weight: 600;
      font-size: 1.9rem;
      display: flex;
      align-items: center;

      @include mdx {
        font-size: 1.7rem;
      }

      span {
        pointer-events: none;
      }

      &:after {
        content: "";
        position: absolute;
        display: block;
        height: 3px;
        background-color: $medium-color;
        width: 100%;
        top: 44px;
        pointer-events: none;
        opacity: 0;
        transform: translateY(0);
        transition: all .2s ease-out;
      }
    }

    &__sub-menu {
      width: max-content;
      max-width: 350px;
      z-index: -9999;
      position: absolute;
      pointer-events: none;
      left: -90px;
      top: 70px;
      padding: 0 40px 60px;
      overflow: hidden;

      a {
        font-size: 1.8rem;
      }

      li {
        padding: 10px 0;
      }
    }

    &__sub-menu-content {
      opacity: 0;
      background-color: #fff;
      width: 100%;
      height: 100%;
      position: relative;
      padding: 25px 50px;
      margin: 0;
      pointer-events: none;
      box-shadow: 0 20px 34px 0 rgba(0,0,0,.1);
      transform: translateY(-100%);
      transition: all .18s ease-out;
    }

    & > a.js-active {
      color: $medium-color;

      &:after {
        opacity: 1;
        transform: translateY(-100%);
      }
    }

    &__contact {
      display: flex;
      align-items: center;
      margin-left: 20px;
    }
  }

  &__contact-btn {
    height: 36px;
    padding: 0 22px;
    font-size: 1.2rem;
    border-radius: 18px;
    white-space: nowrap;

    @include mdx {
      padding: 0 12px;
    }

    @include tablet {
      display: none;
    }
  }
}

.header-search {
  display: flex;
  align-items: center;
  margin: 0 5px 0 15px;

  &__wrapper {
    position: fixed;
    z-index: 1;
    top: $header-height;
    width: 100%;
    left: 0;
    overflow: hidden;
    pointer-events: none;
    padding-bottom: 100px;
  }

  &__box {
    background: #fff;
    padding-bottom: 20px;
    padding-top: 20px;
    pointer-events: all;
    transform: translateY(-100%);
    transition: transform .3s ease, height .2s;
  }

  &__content {
    max-width: $max-width;
    padding: 0 $gutter;
    margin: auto;
  }

  &__input {
    display: flex;
    justify-content: space-between;

    input {
      border: none;
      font-size: 2.1rem;
      line-height: 2.9rem;
      color: $primary-color;
      font-weight: 300;
      height: 40px;
      padding: 0;
      width: 100%;
      font-style: italic;

      &::placeholder {
        color: $primary-color;
      }
    }

    .box-close-btn {
      margin-top: 12px;
    }
  }

  &__shadow {
    height: 25px;
    position: absolute;
    bottom: -25px;
    width: 100%;
    pointer-events: none;
    background: linear-gradient(180deg,#000 0,transparent);
    opacity: 0;
    transition: opacity .2s ease-in;
  }

  &__col {
    width: 20%;
    padding: 0 10px;

    &--extra {
      padding-top: 39px;
    }
  }

  &__results {
    display: flex;
    padding-top: 25px;
  }

  &__box-scroll {
    overflow-y: auto;
    height: 0;
    margin: 0 -10px;
    transition: height .25s ease-out;
  }

  &__result {
    a {
      font-weight: 600;
      font-family: var(--font-heading);;
    }

    p {
      color: $primary-color;
      font-size: 1.4rem;
      line-height: 2rem;
      margin: 5px 0 24px;
    }

    &-thumb {
      width: 50px;
      float: left;
      margin-right: 15px;
    }
  }

  &__group-title {
    color: $medium-color;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
  }

  &__search-more-links {
    display: flex;

    a {
      color: $medium-color;
      font-size: 1.4rem;
      font-weight: 700;
    }
  }

  .loading {
    text-align: center;
  }
}

.main-nav-mobile {
  display: none;

  @include sm {
    display: block;
  }

  &__contact {
    position: fixed;
    bottom: 18px;
    left: 18px;
    display: block;
    width: 48px;
    height: 48px;
    padding: 12px;
    background-color: $medium-color;
    border: 2px solid hsla(0,0%,93.3%,.25);
    border-radius: 22px;

    .projects-detail & {
      right: 15px;
      bottom: 170px;
    }

    path {
      fill: #fff;
    }

    .js-menu-open & {
      display: none;
    }
  }

  &__lang-menu {
    position: fixed;
    right: 0;
    top: $header-height-mobile;
    width: 100%;
    height: calc(100vh - #{$header-height-mobile});
    text-align: left;
    pointer-events: none;
    overflow: hidden;
    z-index: 9;

    ul {
      background-color: #fff;
      height: 100%;
      padding: 15px 22px 0;
      margin: 0;
      opacity: 0;
      transform: translateY(-100%);
      transition: all 0.3s linear;

      a {
        padding: 20px 0;
        display: block;
        font-size: 1.8rem;
        line-height: 2rem;
        box-shadow: inset 0 -1px 0 0 $gray-bluish;
      }
    }

    &.js-open {
      pointer-events: all;

      ul {
        opacity: 1;
        transform: translateY(0);
      }
    }
  }

  &__menu-holder {
    position: fixed;
    top: $header-height-mobile;
    left: 0;
    width: 100%;
    height: calc(100vh - #{$header-height-mobile});
    pointer-events: none;
    overflow: hidden;
  }

  &__menu-wrapper {
    background-color: $white;
    width: 300%;
    height: 100%;
    opacity: 0;
    overflow: hidden;
    transform: translate3d(0, -100%, 0);
    pointer-events: all;
    transition: all 350ms ease-out;

    .js-menu-open & {
      pointer-events: all;
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }

    .js-mobile-sub-open & {
      transform: translate3d(-33.33%, 0, 0);
    }

    .js-mobile-subsub-open & {
      transform: translate3d(-66.66%, 0, 0);
    }
  }

  &__menu {
    position: absolute;
    height: 100%;
    width: 33.33%;
    margin: 0 auto;
    padding: 15px 22px;
    overflow-y: auto;
  }

  &__sub-menus {
    position: absolute;
    top: 0;
    left: 33.33%;
    width: 33.33%;
    height: 100%;
    pointer-events: none;
    // overflow-y: auto;
    // overflow-x: hidden;
    display: flex;
    flex-direction: column;

    .js-mobile-sub-open & {
      pointer-events: all;
    }
  }

  .header-menu {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;

    .js-menu-open & {
      opacity: 1;
      transform: translateY(0);

      @for $i from 1 through 20 {
        &:nth-child(#{$i}) {
          transition-delay: $i * 0.1s;
        }
      }
    }
  }

  .header-menu__sub-menu {
    display: none;
    padding: 15px 32px 0;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
    height: 100%;

    &.js-active {
      display: flex;
    }
  }

  .header-menu > a,
  .header-menu__sub-menu-back {
    font-family: var(--font-heading);
    position: relative;
    font-size: 2.1rem;
    line-height: 120%;
    font-weight: 600;
    padding: 20px 0;
    display: block;
    box-shadow: inset 0 -1px 0 0 $gray-bluish;
    color: $medium-color;
  }

  .header-menu__sub-menu-back {
    padding-left: 40px;
    font-size: 2.6rem;
    box-shadow: unset;

    &::after {
      content: "";
      display: block;
      position: absolute;
      pointer-events: none;
      left: 5px;
      top: calc(50% - 8px);
      width: 24px;
      height: 25px;
      transform: rotate(-180deg);
      background: url(../assets/img/svg/icon-arrow-right.svg) no-repeat center 4px;
      transition: all 0.2s linear;
    }
  }

  .header-menu.header-menu--secondary a {
    font-family: $font-heading;
    font-size: 1.8rem;
    font-weight: 400;
    line-height: 120%;
    padding-left: 26px;
    color: $primary-color;

    &:before {
      position: absolute;
      top: 23px;
      left: 1px;
      content: "";
      display: block;
      width: 18px;
      height: 18px;
      background: url(../assets/img/svg/external.svg) no-repeat center;
      background-size: contain;
    }
  }

  &__submenu-back {
    font-family: $font-heading;
    padding-left: 40px;
    font-size: 2.1rem;
    line-height: 120%;
    font-weight: 600;
    padding: 20px 0;
    display: block;
    color: $medium-color;
    position: relative;

    &::after {
      content: "";
      display: block;
      position: absolute;
      left: 5px;
      top: calc(50% - 8px);
      width: 24px;
      height: 25px;
      transform: rotate(-180deg);
      background: url(../assets/img/svg/icon-arrow-right.svg) no-repeat center 4px;
    }
  }

  [data-role="submenuMobile"] {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    position: absolute;
    width: 100%;
    left: 100%;
    top: 0;
    background: #fff;
    padding: 15px 22px 0;
    opacity: 0;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    transition: opacity 0.3s ease;

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

    .tm-level1-menu-item,
    .tm-level2-menu-item {
      transition: all 0.3s linear;

      &:focus {
        background-color: $gray-bluish-light;
        border-radius: 4px;
        padding: 16px !important;
      }
    }
  }

  .mobile-sub-bt {
    transition: all 0.2s linear;

    span {
      pointer-events: none;
    }
    &::after {
      content: "";
      display: block;
      position: absolute;
      pointer-events: none;
      right: 5px;
      top: calc(50% - 8px);
      margin-top: -7px;
      width: 24px;
      height: 25px;
      background: url(../assets/img/svg/icon-arrow-right.svg) no-repeat center 4px;
      transition: all 0.2s linear;
    }

    &:focus {
      background-color: $gray-bluish-light;
      border-radius: 4px;
      padding: 20px 16px;

      &::after {
        right: calc(5px + 16px);
      }
    }
  }

  &__btn {
    font-family: $font-heading;
    position: relative;
    width: 40px;
    height: 40px;
    padding: 10px;
    margin-left: 2px;
    font-size: 1.8rem;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 100%;
  }

  &__lang::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    display: block;
    width: 100%;
    height: 3px;
    background-color: $medium-color;
    pointer-events: none;
    opacity: 0;
    transform: translateY(3px);
    transition: all 200ms ease-out;

    .js-lang-open & {
      opacity: 1;
      transform: translateY(0);
    }
  }

  &__menu-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    .menu-icon {
      position: relative;
      width: 20px;
      height: 14px;

      &__line {
        position: absolute;
        width: 100%;
        height: 1px;
        background-color: $primary-color;
        transition: all 0.3s ease;

        &:nth-child(1) {
          top: 0;
        }

        &:nth-child(2) {
          top: 6px;
        }

        &:nth-child(3) {
          top: 12px;
          width: 70%;
        }
      }
    }

    .js-menu-open & {
      .menu-icon {
        &__line {
          &:nth-child(1) {
            transform: translateY(6px) rotate(45deg);
          }

          &:nth-child(2) {
            opacity: 0;
          }

          &:nth-child(3) {
            transform: translateY(-6px) rotate(-45deg);
            width: 100%;
          }
        }
      }
    }
  }

  &__col {
    box-shadow: inset 0 -1px 0 0 $gray-bluish;
  }

  &__col-heading {
    color: $medium-color;
    font-size: 1.8rem;
    font-weight: 500;
    letter-spacing: 0.1px;
    font-family: $font-default;
    line-height: 150%;
    letter-spacing: -0.18px;
    padding: 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    transition: all 0.2s linear;

    &:focus, &:active {
      background-color: $gray-bluish-light;
      border-radius: 4px;
      padding: 16px;
    }

    a {
      width: 100%;
      color: $medium-color;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
  }

  &__col-heading-icon {
    display: inline-block;
    margin-left: 12px;
    width: 24px;
    height: 24px;

    svg {
      width: 100%;
      height: 100%;
    }
  }

  &__menu-item {
    font-family: $font-default;
    font-size: 1.8rem;
    font-style: normal;
    font-weight: 500;
    line-height: 150%;
    letter-spacing: -0.18px;
    color: $medium-color;
    padding: 16px 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    box-shadow: inset 0 -1px 0 0 $gray-bluish;

    &.tm-level2-menu-item {
      color: $primary-color;
      font-size: 1.6rem;
    }

    &.tm-main-menu-item {
      color: $primary-color;
      font-family: $font-default;
      font-size: 1.6rem;
      font-weight: 500;
      line-height: 150%;
      letter-spacing: -0.14px;
      text-decoration-line: underline;
      text-decoration-style: solid;
      text-decoration-skip-ink: auto;
      text-decoration-thickness: auto;
      text-underline-offset: auto;
      text-underline-position: from-font;
      box-shadow: unset;
    }
  }

  &__menu-item-icon {
    display: inline-block;
    margin-left: 12px;
    width: 24px;
    height: 24px;

    svg {
      width: 100%;
      height: 100%;
    }

    .tm-main-menu-item & {
      display: none;
    }
  }

  &__menu-item,
  &__col-footer a {
    display: block;
    font-size: 1.8rem;
    line-height: 2rem;
    padding: 12px 0;
    width: 100%;

    &--top {
      margin-top: 10px;
      padding: 12px 0 0;
    }
  }

  &__cta {
    margin: 32px -22px 0;
    padding: 0 22px 0;
    flex: 1;
  }

  &__banner-item {
    margin: 0 -32px;
    background-color: $medium-color;
    padding: 16px 32px;
    display: flex;

    img {
      width: 40px;
      height: auto;
      margin-right: 16px;
      flex-shrink: 0;
      object-fit: contain;
      object-position: top;
    }
  }

  &__banner-label {
    color: $white;
    font-family: $font-heading;
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 120%;
    padding: 10px 0;
  }

  &__banner-cta {
    color: $white;
    font-family: $font-heading;
    font-size: 1.8rem;
    line-height: 120%;
    margin-top: 15px;
    font-weight: 400;
    display: inline-block;
    margin-right: 20px;
    position: relative;

    &:after {
      top: 6px;
      background-color: $white;
      width: 24px;
      height: 23px;
    }

    &:hover .link-underline {
      width: calc(100% - 26px);
    }
  }

  &__actions {
    display: flex;
  }
}

.mobile-search {
  position: fixed;
  left: 0;
  top: $header-height-mobile;
  width: 100%;
  background: #fff;
  box-shadow: 0 10px 10px rgba(0,0,0,.1);
  overflow: hidden;
  opacity: 0;
  height: 0;
  transition: height .2s ease-in, opacity .2s ease-in .2s;

  &__wrapper {
    padding: 20px 0;
  }

  &__title {
    font-weight: 700;
    font-size: 14px;
    color: $primary-color;
    margin-top: 35px;
    display: none;
  }

  &.js-open {
    opacity: 1;
    height: 73px;
    transition: height .2s ease-out, opacity .2s ease-out;
  }

  input[type="text"] {
    border: none;
    font-size: 21px;
    line-height: 29px;
    color: $primary-color;
    font-style: italic;
    height: 30px;
    padding: 0 60px 0 20px;
    width: 100%;

    &::placeholder {
      color: $primary-color;
    }
  }

  input[type="submit"] {
    height: 40px;
    width: 40px;
    position: absolute;
    right: 20px;
    top: 15px;
    background: url(../assets/img/svg/Go.svg) no-repeat 50%;
    margin: 0;
    padding: 0;
    border: none;
    display: none;
  }

  .box-close-btn {
    position: absolute;
    top: 25px;
    right: 20px;
  }

  &.js-can-submit {
    input[type="submit"] {
      display: block;
    }

    .box-close-btn {
      display: none;
    }
  }
}
