@use 'sass:map';
@use '../../global/scss/tools' as nsw;

.nsw-header {
  background-color: var(--nsw-white);
  position: relative;
  border-bottom: solid 1px var(--nsw-grey-04);

  @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
    border-bottom: 0;
  }

  &--simple {
    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      border-bottom: solid 1px var(--nsw-grey-04);
    }
  }

  &__container {
    @include nsw.container;
    position: relative;
  }

  &__inner {
    position: relative;

    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      display: flex;
    }
  }

  &__menu,
  &__search {
    button,
    a {      
      font-weight: var(--nsw-font-bold);
      border-radius: var(--nsw-border-radius);
      color: var(--nsw-brand-dark);
      width: nsw.rem(48px);
      height: nsw.rem(48px);
      background: none;
      border: 0;
      padding: 0;
      text-align: center;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      cursor: pointer;

      @include nsw.font-size('xxs');

      &:hover {
        @include nsw.nsw-hover;
      }

      &:focus {
        @include nsw.nsw-focus;
      }

      .nsw-material-icons {
        font-size: nsw.rem(map.get(nsw.$nsw-icon-sizes, 24));
      }
    }

  }

  &__menu {
    position: absolute;
    top: nsw.rem(12px);
    left: nsw.rem(-6px);

    button {      
      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        display: none;
      }
    }
  }

  &__search {
    position: absolute;
    top: nsw.rem(12px);
    right: nsw.rem(-4px);

    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      right: 0;
      top: 50%;
      margin-top: nsw.rem(-24px);
    }

    button {      
      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        > span:last-child {
          @include nsw.sr-only;
        }

        .nsw-material-icons {
          font-size: nsw.rem(map.get(nsw.$nsw-icon-sizes, 36));
        }
      }
    }
  }

  &__main {
    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      position: relative;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      margin: nsw.rem(20px) nsw.rem(72px) nsw.rem(20px) 0;

      &:focus-within {
        @include nsw.nsw-focus;
      }
    }

    .nsw-header__rectangular-logo {
      @include nsw.breakpoint('lg') {
        height: nsw.rem(60px);
        margin-top: nsw.rem(8px);
        margin-bottom: nsw.rem(8px);
      }
    }
  }

  &__waratah {
    padding: nsw.rem(12px) nsw.rem(48px);
    display: flex;
    justify-content: center;

    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      padding: 0;
    }

    svg {
      height: nsw.rem(48px);
      display: block;

      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        height: nsw.rem(76px);
      }

      &.nsw-header__waratah-gov {
        height: nsw.rem(55px);

        @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
          height: nsw.rem(76px);
        }
      }
    }

    a {
      display: flex;
      color: var(--nsw-brand-dark);
      text-decoration: none;
      align-items: center;

      &:hover {
        background: transparent;
        outline-width: 0;
      }

      &:focus {
        outline-width: 3px;

        @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
          outline: none;
        }
      }

      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        @include nsw.pseudo-clickable-block;
      }

      svg:not(:first-child) {
        margin-left: nsw.rem(24px);

        @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
          margin-left: nsw.rem(40px);
        }
      }      
    }
  }

  &__waratah-gov {
    margin-bottom: nsw.rem(-7px);

    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      margin-bottom: 0;
    }

    .hide {
      display: none;

      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        display: inline;
      }
    }
  }

  &__name {
    padding: nsw.rem(12px) 0;
    color: var(--nsw-brand-dark);

    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      padding: 0;
      margin-left: nsw.rem(40px);
    }
  }

  &__title {
    font-weight: var(--nsw-font-bold);
    color: var(--nsw-brand-dark);
    display: flex;
    align-items: center;
    text-wrap: balance;

    @include nsw.font-size('lg');

    @include nsw.breakpoint('lg') {
      line-height: nsw.rem(28px);
    }

    .nsw-tag {
      margin-left: nsw.rem(24px);
    }
  }

  &__description {
    color: var(--nsw-brand-dark);
    text-wrap: balance;

    @include nsw.font-size('xs');
  }

  &__logo {
    display: flex;
    justify-content: center;

    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      justify-content: flex-start;
    }

    svg {
      height: nsw.rem(48px);
      display: block;

      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        height: nsw.rem(76px);
      }
    }
  }
  
  &__search-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;

    @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
      width: nsw.rem(394px);
      left: auto;
      right: nsw.rem(16px);
      top: 50%;
      transform: translateY(-50%);
    }

    button {
      position: absolute;
      right: 0;
      top: 0;
      bottom: 0;
      cursor: pointer;
    }

    > button {
      border-radius: 0;
      
      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        display: none;
      }
    }

    form,
    div {
      button {
        display: none;
        padding: 0;
        width: nsw.rem(48px);

        @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
          display: flex;
        }
      }

      .nsw-material-icons {
        font-size: nsw.rem(map.get(nsw.$nsw-icon-sizes, 36));
      }
    }

    input {
      background: var(--nsw-off-white);
      padding: nsw.rem(8px) nsw.rem(72px) nsw.rem(8px) nsw.rem(16px);
      color: var(--nsw-text-dark);
      width: 100%;
      appearance: none;
      border: 0;
      height: nsw.rem(72px);
      
      @include nsw.font-size('md');

      &:focus {
        @include nsw.nsw-focus;
      }

      @include nsw.breakpoint(nsw.$nsw-desktop-breakpoint) {
        border-radius: var(--nsw-border-radius);
        height: nsw.rem(48px);
        padding: 0 nsw.rem(16px);
      }
    }
  }
}
