#header {
  align-items: end;
  background: var(--kbin-header-bg);
  color: var(--kbin-header-text-color);
  font-size: .85rem;
  position: relative;
  z-index: 10;
  height: 3.25rem;
  line-height: normal;

  #logo {
    height: 1.75rem;
  }

  .dropdown__menu {
    display: none;
  }

  .dropdown:focus-within,
  .dropdown:hover {
    .dropdown__menu {
      display: block;

      @include media-breakpoint-down(sm) {
        left: auto;
        top: 100%;
        transform: none;
        right: 0;
        min-width: 10rem;
      }
    }

  }

  menu {
    .dropdown__menu {
      left: -3.75rem;
      opacity: 1;
    }

    .dropdown:last-of-type .dropdown__menu {
      left: auto;
    }
  }

  .kbin-container {
    display: grid;
    grid-template-areas: 'sr-nav brand magazine nav menu';
    grid-template-columns: min-content max-content max-content auto max-content;
    position: relative;
    height: 100%;

    & > menu {
      @include media-breakpoint-down(lg) {
        margin-right: .5rem;
      }
    }
  }

  .fixed-navbar & {
    position: sticky;
    top: 0;
  }

  .topbar & {
    padding-top: 1.25rem;
    height: 4.5rem;
  }

  .login,
  .counter a {
    font-weight: normal;
  }

  .user-name {
    height: 1.25rem;
  }

  .login {

    @include media-breakpoint-down(sm) {

      white-space: nowrap;

      .user-name {
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 12vw;
        padding: 0 .25rem
      }

    }

  }

  .login.has-avatar {
    display: flex;
    align-items: center;
    gap: .3rem;

    .user-avatar {
      border-radius: 50%;
      height: 1.5625rem;
      width: 1.5625rem;
    }

    @include media-breakpoint-down(sm) {

      .user-name {
        display: none;
      }
    }

  }

  .counter a {
    min-width: unset;
  }

  .badge {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: 1.5625rem;
    min-width: 1.5625rem;
  }

  a {
    color: var(--kbin-header-link-color);

    &:hover {
      color: var(--kbin-header-link-hover-color);
    }
  }

  nav {
    display: flex;
    grid-area: nav;
  }

  menu {
    grid-area: menu;
    display: flex;
    align-items: center;
    list-style: none;

    .sidebar-link {
      display: none;
    }

    .icon i {
      font-size: .85rem;
    }

    li {
      display: flex;
      align-items: center;
      height: 100%;
    }

    li a {
      border-bottom: 3px solid transparent;
      padding: 3px 1rem 0;
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 3rem;
      height: 100%;

      @include media-breakpoint-down(sm) {
        padding: 3px 0 0;
        min-width: 2.5rem;
      }
    }

    li a:hover {
      border-bottom: var(--kbin-header-hover-border);

    }

    li .active {
      border-bottom: var(--kbin-header-hover-border);
    }

    .magazine {
      align-self: center;
      margin-left: 1rem;
      padding-top: .2rem;

      span {
        color: var(--kbin-header-text-color);
        font-weight: 100;
        opacity: .75;
      }
    }
  }

  .sr-nav {
    grid-area: sr-nav;
    z-index: 100;

    a {
      background-color: white;
      border: 0;
      clip: rect(0, 0, 0, 0);
      font-size: 1.3rem;
      font-weight: bold;
      height: 1px;
      left: 0;
      overflow: hidden;
      padding: .5rem 1rem;
      position: absolute;
      top: 0;
      white-space: nowrap;
      width: 1px;

      &:focus {
        clip: auto;
        color: black;
        height: auto;
        outline: solid 4px darkorange;
        overflow: visible;
        position: absolute;
        white-space: normal;
        width: auto;
      }
    }
  }

  .brand {
    display: flex;
    font-weight: 400;
    text-decoration: none;
    height: 100%;

    div {
      display: none;
      font-size: .9rem;
      cursor: pointer;
    }

    a {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 1rem;
      height: 100%;

      span {
        font-size: clamp(.6875rem, 3.5vw, 1.5rem);
      }
    }

    @include media-breakpoint-down(sm) {
      div {
        min-width: 2.5rem;
      }
    }

    @include media-breakpoint-down(lg) {

      a {
        gap: .5rem;
        padding: 0;

        span {
          line-height: normal;
        }
      }

      #logo {
        height: 1.5rem;
      }

      div {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 3rem;
        height: 100%;
      }
    }
  }

  .head-title {
    align-items: center;
    display: flex;
    height: 100%;

    span {
      font-weight: lighter;
      font-size: .75rem;
    }

    a {
      padding-left: 0;

      &:hover {
        border-bottom-color: transparent;
      }
    }

    @include media-breakpoint-down(lg) {
      color: var(--kbin-meta-text-color);

      span {
        padding-left: 1rem;
      }

      a {
        padding-left: 0;
        font-weight: bold;
      }
    }
  }

  .head-nav {

    @include media-breakpoint-down(lg) {

      &__menu {
        display: none;
      }
    }

    @include media-breakpoint-up(lg) {
      li {
        text-align: center;
      }
      li a.active {
        background: var(--kbin-header-link-active-bg);
      }
    }
  }
}
