@use '../../abstracts/if_screen' as *;

.cms-navbar--wrapper {
  background: var(--sidebar-left-bg);

  .cms-navbar__brand {
    padding: 0 var(--gutter);
  }
}

.cms-navbar {
  position: relative;
  z-index: 10;

  > * {
    display: block;
  }

  &.is-small {
    background: var(--sidebar-left-bg);
    padding-top: 0;
    padding-bottom: 0;
    height: var(--navbar-small-height);

    img {
      height: 1.5rem;
      width: auto;
    }
  }

  &.is-full-width {
    width: auto;
  }

  a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    margin-right: 0.5rem;
    margin-left: -1rem;
    display: block;

    &.pull-right {
      float: none;
    }

    @include if_screen(">two-columns") {
      &.pull-right {
        margin-left: auto;
      }

      &:last-child {
        margin-right: -1rem;
      }
    }

    &:hover {
      text-decoration: underline;
    }
  }

  a,
  label {
    color: var(--sidebar-left-text);
  }
}

.cms-navbar__links {
  background: var(--sidebar-left-bg);
  display: flex;
  width: 100%;
  align-items: flex-end;

  img {
    margin: -0.5rem 0.4rem -0.5rem 0;
    height: 2rem;
  }
}

.cms-navbar__logo {
  vertical-align: middle;
  height: 2rem;
}

body.no-js .cms-navbar__links .has-js {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/*
 * Navigation using hamburger menu
 *
 * Markup order is significant:
 * 1. <checkbox id="hamburger_checkbox_toggle">
 * 2. <label for="hamburger_checkbox_toggle">...</label>
 * 3. <div class="cms-navbar__links">...</div>
 */
@include if_screen("<=two-columns") {
  .cms-navbar {
    max-height: 4rem;
    overflow: visible;
  }

  .is-hamburger {
    font-size: 1.6rem;
    position: absolute;
    display: block;
    top: 1.2rem;
    right: var(--gutter);

    span {
      font-size: 1rem;
      padding: 0.5rem;
      position: absolute;
      top: -0.5rem;
      right: 1.6em;
    }
  }

  .is-hamburger + .cms-navbar__links {
    display: block;
    box-shadow: var(--chat-header-box-shadow);
    padding: 0 1rem;
    margin-top: var(--gutter-small);
    margin-left: calc(var(--gutter) * -1);
    width: 100vw;
    max-height: 0;
    opacity: 0.3;
    overflow: auto;
    transition: all 0.2s ease-in-out;

    a > i,
    a > img {
      padding-right: 0.3rem;
      width: 1.6rem;
    }

    a > img {
      height: auto;
      vertical-align: middle;
    }

    a:last-child {
      margin-bottom: 1rem;
    }
  }

  input:checked + .is-hamburger + .cms-navbar__links {
    opacity: 1;
    max-height: 80vh;
  }
}

/*
 * All navigation items are visible on big screens.
 * Hamburger and main brand are hidden.
 */
@include if_screen(">two-columns") {
  .cms-navbar--wrapper {
    .cms-navbar__brand,
    .cms-navbar .is-hamburger {
      display: none;
    }
  }
}
