// VARIABLES
$showTopMenuWidth: 1048px;
$hideTopMenuWidth: $showTopMenuWidth - 1;
$hamburgerShownMargin: 0 8px 0 0;
$hamburgerHiddenMargin: 0 16px 0 -64px;

// DOCS PAGE / STANDARD: TOPNAV TOOLBAR FIXED
mat-toolbar.app-toolbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.3);

  // HOME PAGE OVERRIDE: TOPNAV TOOLBAR
  .page-home & {
    background-color: $blue;

    @media (min-width: 481px) {
      &:not(.transitioning) {
        background-color: transparent;
        transition: background-color 0.2s linear;
      }
    }
  }

  // MARKETING PAGES OVERRIDE: TOPNAV TOOLBAR AND HAMBURGER
  @include marketing-pages($nestParentSelector: true) {
    box-shadow: none;

    // FIXED TOPNAV TOOLBAR FOR SMALL MOBILE
    @media (min-width: 481px) {
      position: absolute;
    }
  }

  // DOCS PAGES OVERRIDE: HAMBURGER
  @include docs-pages($nestParentSelector: true) {
    @media (min-width: $showTopMenuWidth) {
      .hamburger {
        // Hamburger shown on non-marketing pages even on large screens.
        margin: $hamburgerShownMargin;
      }
    }
  }

  mat-toolbar-row {
    padding: 0 16px 0 0;
  }

  mat-icon {
    color: $white;
  }

  // HAMBURGER BUTTON
  .hamburger {
    height: 100%;
    margin: $hamburgerShownMargin;
    padding: 0;

    @media (min-width: $showTopMenuWidth) {
      // Hamburger hidden by default on large screens.
      // (Will be shown per doc.)
      margin: $hamburgerHiddenMargin;
    }

    @media (max-width: 480px) {
      min-width: 15%;
    }

    &:not(.starting) {
      transition-duration: 0.4s;
      transition-property: color, margin;
      transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    &:hover {
      color: $offwhite;
    }

    & .mat-icon {
      color: $white;
      position: inherit;
    }
  }

  // HOME NAV-LINK
  .nav-link.home {
    cursor: pointer;
    margin: 0 16px 0 0;
    padding: 8px 0;

    &:focus {
      // `outline-offset` is not applied on Chrome on Windows, if `outline-style` is `auto.
      outline: 1px solid $focus-outline-ondark;
      outline-offset: 4px;
    }

    @media screen and (max-width: $hideTopMenuWidth) {
      padding: 4px 0;
    }

    @media screen and (max-width: 480px) {
      margin-right: 8px;
    }

    img {
      position: relative;
      margin-top: -21px;
      top: 12px;
      height: 40px;

      @media (max-width: $hideTopMenuWidth) {
        &:hover {
          transform: scale(1.1);
        }
      }
    }
  }

  // TOP MENU
  aio-top-menu {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 80%;

    ul {
      display: flex;
      flex-direction: row;
      align-items: center;
      list-style-position: inside;
      padding: 0px;
      margin: 0px;

      li {
        padding-bottom: 2px;
        list-style-type: none;
        cursor: pointer;

        &:focus {
          outline: none;
        }

        a.nav-link {
          margin: 0 4px;
          padding: 0px;
          cursor: pointer;

          .nav-link-inner {
            border-radius: 4px;
            padding: 8px 16px;

            &:hover {
              background: rgba($white, 0.15);
            }
          }

          &:focus {
            outline: none;

            .nav-link-inner {
              background: rgba($white, 0.15);
              border-radius: 1px;
              box-shadow: 0 0 1px 2px $focus-outline-ondark;
            }
          }

          &:active {
            .nav-link-inner {
              background: rgba($white, 0.15);
            }
          }
        }

        &.selected {
          a.nav-link {
            .nav-link-inner {
              background: rgba($white, 0.15);
            }
          }
        }
      }
    }
  }

  // SEARCH BOX
  aio-search-box.search-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    min-width: 150px;
    height: 100%;
    margin-right: 16px;

    input {
      color: $darkgray;
      border: none;
      border-radius: 100px;
      background-color: $white;
      padding: 5px 16px;
      margin-left: 8px;
      width: 180px;
      max-width: 240px;
      height: 50%;
      -webkit-appearance: none;

      &:focus {
        outline: none;
      }

      @include placeholder {
        @include font-size(14);
        color: $mediumgray;
      }

      @media (min-width: 1000px) {
        transition: width 0.4s ease-in-out;

        &:focus {
          width: 80%;
        }
      }

      @media (max-width: 480px) {
        width: 150px;
      }
    }
  }

  // EXTERNAL LINK ICONS
  .toolbar-external-icons-container {
    display: flex;
    flex-direction: row;
    flex-shrink: 0; // This is required for the icons to be displayed correctly in IE11.
    height: 100%;

    a {
      display: flex;
      align-items: center;
      padding: 24px;
      margin: 0 -16px;

      &:focus {
        // `outline-offset` is not applied on Chrome on Windows, if `outline-style` is `auto.
        outline: 1px solid $focus-outline-ondark;
        outline-offset: -16px;
      }

      @media screen and (max-width: 480px) {
        margin: 0 0 0 8px;
        padding: 0;
      }

      &:hover {
        opacity: 0.8;
      }

      img {
        height: 24px;
      }
    }
  }
}
