/**
* @file
* Header
*
* Contains styles for header.
*/

@use '_helper' as *;

$break-large-2: 1200px;

.header {
  top: -59px;
  z-index: 6;
  width: 100%;
  height: 0;
  transition: top .3s;
  z-index: 1000;

  @media screen and (min-width: $break-medium) {
    top: -80px;
  }

  @media screen and (min-width: $break-large-2) {
    top: -188px;
  }

  a {
    color: $color-white;

    &.skip-link {
      color: $color-black;
    }
  }

  a,
  button {
    @include focus-light();
  }

  .sticky-header & {
    position: sticky;
    top: 0;
    box-shadow: 0 0 3rem 0 rgba(0, 0, 0, 0.12);
  }

  .open-menu & {
    position: fixed;
    top: 0;
    transition: none;
  }

  .container {
    padding-left: rem(18px);
    padding-right: rem(18px);

    @media screen and (min-width: $break-large-2) {
      max-width: none;
      margin: 0 auto;
      padding-left: rem(50px);
      padding-right: rem(50px);
    }
  }

  ul li {
    &:before {
      content: none;
    }
  }

  &__wrapper {
    position: relative;
    background-color: $color-blue-dark;
    transition: background-color 0.1s ease;
    z-index: 1000;

    @media screen and (min-width: $break-large) {}
  }

  &__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: rem(22px) 0;

    @media screen and (min-width: $break-medium) {
      padding: 1.5rem 0;
    }

    @media screen and (min-width: $break-large-2) {
      justify-content: flex-end;
      padding: rem(20px) 0 rem(20px);
      margin-left: rem(calc(297px + 30px));
    }
  }

  &__logo {
    transition: all .3s ease;

    @media screen and (min-width: $break-large-2) {
      position: absolute;
      top: 50%;
      left: rem(33px);
      transform: translateY(-50%);
    }

    @media (forced-colors: active) {
      @media (prefers-color-scheme: dark) {
        background-color: white;
        filter: invert(1);
      }
    }

    &-img {
      height: rem(32px);

      @media screen and (min-width: $break-medium) {
        height: rem(39px);
      }

      @media screen and (min-width: $break-large-2) {
        height: rem(55.167px);
      }
    }

    .open-search & {
      @media screen and (max-width: $break-medium - 1) {
        opacity: 0;
        visibility: hidden;
      }
    }
    
    .open-menu & {
      img {
        @media (forced-colors: active) {
          @media (prefers-color-scheme: light) {
            filter: invert(1);
          }
        }
      }
    }
  }

  &__buttons {
    @media screen and (min-width: $break-medium) {
      margin-top: rem(19px);
    }

    @media screen and (min-width: $break-large-2) {
      display: none;
    }

    a {
      font-size: rem(12px);
      font-weight: 500;
      text-decoration: none;
      text-transform: uppercase;
      line-height: 1.5;

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

    &--top {
      display: none;

      @media screen and (min-width: $break-large-2) {
        display: flex;
        align-items: center;
        gap: 1.4rem;
        margin-top: 0;
      }
    }

    .dropdown__content {
      @media screen and (max-width: $break-large-2 - 1) {
        position: relative;
      }
    }
  }

  &__toggle-wrapper {
    @media screen and (min-width: $break-large-2) {
      display: none;
    }
  }

  &__toggle-nav {
    &-btn {
      position: relative;
      width: rem(35px);
      height: rem(35px);
      padding: rem(8px);
      background-color: $color-blue;
      border: none;
      border-radius: 100%;
      transition: opacity .15s, color .3s, background-color .3s;

      @media screen and (min-width: $break-medium) {
        width: rem(43px);
        height: rem(43px);
      }

      &:hover {
        background-color: $color-black;
      }

      &::before,
      &::after {
        content: '';
        opacity: 0;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(45deg);
        width: rem(16px);
        height: 0;
        border: 1px solid currentColor;
        background-color: currentColor;
      }

      &::after {
        transform: translate(-50%, -50%) rotate(-45deg);
      }

      .open-search & {
        opacity: 0;
        visibility: hidden;
      }

      .open-menu & {
        color: $color-blue-dark;
        background-color: $color-blue-light;

        .header__toggle-nav-lines {
          display: none;
        }

        &::before,
        &::after {
          opacity: 1;
        }
      }
    }

    &-lines {
      display: block;
      padding: rem(4px) 0;
      border: rem(2px) solid $color-white;
      border-width: rem(2px) 0;
    }

    &-mid-line {
      display: block;
      border: rem(2px) solid $color-white;
      border-width: rem(2px) 0 0;
    }
  }

  &__top-nav {
    display: flex;
    align-items: center;
    column-gap: .5rem;

    @media screen and (min-width: $break-medium) {
      column-gap: rem(10px);
    }

    @media screen and (min-width: $break-large-2) {
      margin-right: 0;
    }
  }

  &__bottom {
    display: none;
    position: fixed;
    width: 100%;
    height: calc(100% - rem(79px));
    overflow: auto;
    padding: rem(16px) rem(20px) rem(10px);
    background-color: $color-blue-dark;

    @media screen and (min-width: $break-medium) {
      padding: 3px 30px;
    }

    @media screen and (min-width: $break-large-2) {
      // need !important here to override display:none inline style on element if it's there
      display: block !important;
      position: static;
      visibility: visible;
      opacity: 1;
      height: initial;
      width: auto;
      overflow: initial;
      max-width: none;
      margin: 0 rem(44px) 0 rem(calc(297px + 50px));
      padding: 0 rem(50px);
      background: none;
      transition: opacity 0.1s ease;
    }

    .open-search & {
      opacity: 0;
      visibility: hidden;
    }

    &-container {
      @media screen and (min-width: $break-large-2) {
        display: block;
        padding: 0;
        border: none;
      }
    }
  }

  &__link {
    display: block;
    margin-bottom: rem(10px);

    .last-word {
      padding-right: 2.4rem;

      &::after {
        background-image: url(../assets/icons/arrow-top-right.svg);
      }
    }

    @media screen and (min-width: $break-large-2) {
      margin-bottom: 0;
    }
  }

  .dropdown {
    display: block;
    text-align: left;
    margin-top: -3px;

    @media screen and (min-width: $break-large-2) {
      position: relative;
      margin-bottom: 0;
    }

    &:focus-within {
      .dropdown__content {
        @media (min-width: $break-large-2) {
          // need !important here to override display:none inline style on element
          display: grid !important;
        }
      }
    }

    &__btn {
      position: relative;
      font-size: rem(12px);
      margin-bottom: rem(10px);
      border: none;
      background: transparent;
      color: $color-white;
      padding: 0;
      font-style: normal;
      font-weight: 500;
      line-height: normal;
      text-transform: uppercase;
      transition: color 0.3s ease;

      @media screen and (min-width: $break-large-2) {
        margin: 0;
      }

      &[aria-expanded="true"] {
        color: $color-gold;

        .dropdown__icon {
          border-color: $color-gold;
          transform: translateY(-2px) rotate(315deg);
        }
      }
    }

    &__icon {
      position: absolute;
      top: 50%;
      right: -13px;
      width: rem(6px);
      height: rem(6px);
      border-top: 1px solid currentColor;
      border-right: 1px solid currentColor;
      transform: translateY(-5px) rotate(135deg);
      pointer-events: none;
      transition: border-color 0.3s ease;
    }

    &__content {
      display: flex;
      flex-direction: column;
      gap: rem(10px);
      margin-bottom: rem(10px);

      @media (min-width: $break-large-2) {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        padding: rem(25px) rem(20px);
        transition: all .3s;
        position: absolute;
        width: rem(256px);
        top: calc(100% + 8px);
        right: rem(-20px);
        z-index: 1001;
        margin-top: -7px;
        background: $color-blue-light;
        border-radius: .5rem;
        overflow: hidden;
        box-shadow: 0 4px 24px 0 rgba(85, 62, 0, 0.15);
      }

      a {
        @include focus-light;
        text-transform: none;
        font-size: rem(14px);

        @media (min-width: $break-large-2) {
          @include focus-dark;
          color: $color-blue-dark;
          font-weight: 700;
          text-decoration: underline;
          font-size: rem(18px);
        }
      }
    }

    &:hover {
      .dropdown__content {
        @media (min-width: $break-large-2) {}
      }

      >.dropdown__btn {
        @media (min-width: $break-large-2) {
          color: $color-gold;
          text-decoration: underline;
          text-underline-offset: 6px;
        }

        >.dropdown__icon {
          @media (min-width: $break-large-2) {
            transform: translateY(-2px) rotate(315deg);
          }
        }
      }
    }
  }

  &__back-panel {
    display: none;
    padding: .8rem 0 1.1rem;
    background-color: $color-blue-dark;

    @media screen and (min-width: $break-large-2) {
      display: block;
    }

    .container {
      @media screen and (min-width: $break-large-2) {
        padding-left: 4rem;
        padding-right: 4rem;
      }
    }

    a {
      font-weight: 600;
      color: $color-black;
      text-decoration: none;
    }
  }
}

.main-nav {
  margin-bottom: rem(20px);

  @media (min-width: $break-medium) {
    margin-bottom: 0;
  }

  &__list {
    list-style: none;
    margin: 0;
    padding: 0;

    @media (min-width: $break-large-2) {
      position: relative;
      display: flex;
      justify-content: flex-end;
      gap: rem(34px);
    }

    &.hover {
      .main-nav__item {
        &:hover {
          .main-nav__subnav-wrap {
            @media (min-width: $break-medium) {
              opacity: 1;
              visibility: visible;
              transition: opacity 0.1s ease, visibility 0s;
            }
          }

          >a {
            color: $color-gold;
            text-decoration: underline;
            text-underline-offset: 6px;
          }
        }
      }
    }
  }

  &__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0;
    padding: rem(19px) 0;
    border-bottom: rem(1px) solid $color-blue-light;

    @media (min-width: $break-medium) {
      padding: rem(14px) 0;
    }

    @media (min-width: $break-large-2) {
      padding: 0 0 rem(31px);
      border-bottom: none;
    }

    &:nth-child(1) {
      @media (max-width: $break-large-2 - 1) {
        padding-top: 0;
      }
    }

    &:last-of-type {
      @media (max-width: $break-large-2 - 1) {
        padding-bottom: 0;
        border-bottom: none;
      }

      @media screen and (min-width: $break-large-2) {
        .main-nav__subnav-wrap {
          left: auto;
          right: rem(-20px);
        }
      }
    }

    &:last-child {
      @media (min-width: $break-medium) {
        border-bottom: none;
      }
    }

    &:focus-within {
      .main-nav__subnav-wrap {
        @media (min-width: $break-medium) {
          opacity: 1;
          grid-template-rows: 1fr;
          visibility: visible;
        }
      }
    }

    a {
      font-size: rem(20px);
      color: $color-white;
      text-decoration: none;
      font-weight: 900;
    }

    >a {
      flex: 1;
    }
  }

  &__subnav {
    list-style: none;
    margin: rem(10px) 0 0;
    padding: 0;

    @media screen and (min-width: $break-medium) {
      column-count: 2;
      column-gap: 50px;
    }

    @media (min-width: $break-large-2) {
      background: $color-blue-light;
      column-count: 1;
      width: 100%;
      margin: 0;
      padding: rem(25px) rem(20px);
    }

    a {
      @include focus-light;
      font-size: rem(16px);
      font-weight: 400;
      line-height: 1.5;

      @media (min-width: $break-large-2) {
        @include focus-dark;
        color: $color-blue-dark;
        font-weight: 700;
        text-decoration: underline;
        font-size: rem(18px);
      }
    }

    &-wrap {
      display: none;
      width: 100%;

      @media screen and (min-width: $break-medium) {
        padding-bottom: rem(19px);
      }

      @media (min-width: $break-large-2) {
        opacity: 0;
        display: grid;
        grid-template-rows: 1fr;
        visibility: hidden;
        padding: 0;
        transition: all .3s;
        position: absolute;
        width: rem(256px);
        top: 100%;
        left: rem(-20px);
        z-index: 6;
        margin-top: -7px;
        background: $color-blue-light;
        border-radius: .5rem;
        overflow: hidden;
        box-shadow: 0 4px 24px 0 rgba(85, 62, 0, 0.15);
        transition: opacity 0.1s ease, visibility 0s 0.1s;
      }
    }

    &-container {
      @media (min-width: $break-large-2) {
        overflow: hidden;
      }
    }

    li {
      margin-top: 0;
      margin-bottom: rem(12px);

      &:last-child {
        margin-bottom: .2rem;
      }
    }
  }

  &__toggle-btn {
    position: relative;
    width: rem(44px);
    height: rem(44px);
    margin-left: auto;
    color: $color-black;
    background-color: $color-gold;
    border: none;
    border-radius: 100%;
    transition: all .3s;

    @media (min-width: $break-large-2) {
      display: none;
    }

    &.js-expanded {
      color: $color-blue-dark;
      background-color: $color-blue-light;

      &:before {
        opacity: 0;
      }
    }

    &:before,
    &:after {
      opacity: 1;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      content: '';
      border: .1rem solid currentColor;
      transition: opacity .3s;
    }

    &:before {
      height: rem(20px);
    }

    &:after {
      width: rem(20px);
    }
  }
}

.search {
  &__wrap {
    position: relative;

    @media screen and (min-width: $break-large-2) {
      position: absolute;
      right: rem(31px);
      bottom: rem(20px);
      margin-left: 1.5rem;
    }
  }

  &__toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: rem(35px);
    height: rem(35px);
    padding: rem(5px);
    color: $color-white;
    background-color: $color-blue;
    border: none;
    border-radius: 100%;
    transition: all .3s;

    @media screen and (min-width: $break-medium) {
      width: rem(43px);
      height: rem(43px);
    }

    &::before,
    &::after {
      content: '';
      opacity: 0;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) rotate(45deg);
      width: rem(16px);
      height: 0;
      border: 1px solid currentColor;
      background-color: currentColor;
      transition: opacity .15s, border-color 0.3s ease;
    }

    &::after {
      transform: translate(-50%, -50%) rotate(-45deg);
    }

    .open-search & {
      color: $color-white;
      background-color: $color-black;

      &::before,
      &::after {
        opacity: 1;
      }
    }

    &:hover {
      background-color: $color-black;

      svg path {
        fill: $color-white;

        @media (forced-colors: active) and (prefers-color-scheme: light) {
          fill: $color-black;
        }
      }

      .open-search & {
        background-color: $color-gold;

        &::before,
        &::after {
          border-color: $color-black;
        }
      }
    }
  }

  &__icon {
    width: rem(15px);
    height: rem(15px);

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

    @media (forced-colors: active) {
      @media (prefers-color-scheme: dark) {
        svg path {
          fill: $color-white;
        }
      }
    }
  }

  &__toggle-icon {
    opacity: 1;
    transition: opacity .15s;

    .open-search & {
      opacity: 0;
    }
  }

  &__form {
    display: none;
    position: absolute;
    right: 46px;
    display: block;
    top: 0;
    width: calc(100svw - rem(84px));
    visibility: hidden;
    opacity: 0;
    z-index: -1;
    transition: all .3s;
    max-width: 0;
    overflow: hidden;

    @media screen and (min-width: $break-medium) {
      right: 3.5rem;
    }

    .open-search & {
      opacity: 1;
      visibility: visible;
      z-index: 1000;
      max-width: calc(100svw - rem(84px));

      @media screen and (min-width: $break-medium) {
        max-width: 20.8rem;
      }
    }

    &__search-wrap {
      position: relative;
    }

    .search__btn {
      @include focus-dark(-4px);
      position: absolute;
      top: .2rem;
      right: .2rem;
      display: flex;
      align-items: center;
      height: calc(100% - .4rem);
      padding: .5rem 1rem;
      background: none;
      border: none;
      border-radius: .5rem;

      svg path {
        fill: $color-blue-dark;
        transition: fill 0.3s ease;

        @media (forced-colors: active) {
          @media (prefers-color-scheme: dark) {
            fill: $color-white;    
          }
        }
      }
    }

    .search__input {
      @include focus-dark(-4px);
      width: 100%;
      padding: 4px 4rem 4px 1.3rem;
      border-radius: 15px;
      border-color: $color-blue-dark;

      @media screen and (min-width: $break-medium) {
        padding: 9px 4rem 9px 1.1rem;
        border-radius: 20px;
      }
    }
  }
}

.open-menu {
  overflow: hidden;
}

html:not(.open-menu) .home.header-top .header .header__wrapper {
  background: transparent;
}

html .header__logo img {
  @media (forced-colors: active) and (prefers-color-scheme: light) {
    filter: invert(1);
  }
}

html .home .header__logo img {
  @media (forced-colors: active) and (prefers-color-scheme: light) {
    filter: invert(0);
  }
}

html.open-menu .header__logo img {
  @media (forced-colors: active) and (prefers-color-scheme: light) {
    filter: invert(1);
  }
}

html .sticky-header .header__logo img {
  @media (forced-colors: active) and (prefers-color-scheme: light) {
    filter: invert(1);
  }
}