// Resets
.top-bar {
  // Resetting styles
  ul { padding: 0; margin: 0;}
  li { list-style: none; margin: 0; }
}

// Component Styles Variables

.top-bar {
  // Off Canvas panel width 
  // for mobile screens
  --panel-width: 280px;
  
  @include breakpoint($medium-up) {
  // for tablet and desktop screens
  --panel-width: 350px;
  }
}

// STRUCTURAL STYLES

// Top-Bar - Structure
.top-bar {
  display: flex;
  position: relative;
  z-index: 1000;
  &__menu { flex: 1; }
  &__menu-trigger { 
    flex: 0; 
    line-height: 1; 
  }

  @media print {
    display: none;
  }
}

// Contextual Menu - Structure
.contextual-menu {
  @include breakpoint($small-only) { display: none; }
  &__item { 
    display: inline-block; 
    vertical-align: -webkit-baseline-middle;
    vertical-align: -moz-middle-with-baseline;
  }
  &__item + &__item { margin-left: -5px; }
  &--disabled { 
    opacity: .4; 
    pointer-events: none; 
  }
}

// Off-canvas Menu - Structure
.off-canvas-menu {
  top: 0;
  bottom: 0;
  z-index: 1000;
  display: block;
  position: fixed;
  box-sizing: border-box;
  width: var(--panel-width);
  left: calc(-1 * var(--panel-width) - 20px);
  overflow-y: scroll;

  &__list { list-style-type: none; }
  &__heading { margin-bottom: 0; }
  
  &__trigger {
    cursor: pointer;
    position: absolute;
    top: 0;
    right: 0;
    border: 0; 
  }
  
  &--disabled { pointer-events: none; }

  &__submenu {

    .submenu__list { 
      padding-left: 16px;
      display: block;
      position: static;
    }
  }
}

.off-canvas-menu__contextual {
  @include breakpoint($medium-up) { display: none; }
}

.off-canvas-menu--expanded { left: 0; }


// Submenu Structure
.submenu { 
  position: relative;

  &__list { 
    width: auto;
    display: none;
    text-align: left;
    position: absolute; 
    white-space: nowrap;
  }
  &__list:last-child { right: 1px; }
  &__item { display: block; } 
  &__button { 
    display: inline-block; 
    box-sizing: border-box;
  }
  
  &__item:not(:first-child) &__button { margin-top: -1px; }

  &:hover &__list { display: block; }
}

// Top-Bar - Visual Styles
.top-bar {
  // Colors Variables
  // These values should follow this format:
  // This way, the css variables can 
  // be used inside the hsla() function
  --bg-color: var(--teal-hsl);
  --text-color: var(--base-hsl);
  --active-color: var(--orange-hsl);

  border-bottom: 1px solid hsla(var(--base-hsl), .2);
  
  &__menu-trigger {
    border: 0;
    padding: 4px 8px 2px;
  }

  &__menu { text-align: right; }
}

// Submenu - Visual Styles
.submenu {
  &__list { width: auto; } // This makes the submenu items have the same width.

  &__button {
    width: 100%;
    padding: 8px 24px 8px;
    border: 1px solid hsla(var(--base-hsl), .1);
    color: hsla(var(--text-color), 1);

    &:hover { background-color: hsla(var(--bg-color), .1); }
  }
}

// Contextual Menu - Visual Styles
.contextual-menu { 
  // &__item { }

  &__button {
    display: inline-block;
    padding: 8px 24px 8px;
    transition: all .5s;
    color: hsla(var(--text-color), 1);

    &:hover {
      color: hsla(var(--text-color), 1);
      background-color: hsla(var(--bg-color), .8);
    }
  }

  &--active { background-color: hsla(var(--active-color), .1); }
  
  .submenu__list { background-color: hsla(var(--white-hsl)); }
}


// Off-canvas Menu - Visual Styles
.off-canvas-menu {
  padding: 48px 32px;
  transition: all .4s ease;
  background-color: hsla(var(--bg-color), 1);
  box-shadow: 4px 4px 16px hsla(var(--bg-color), .2);

  &__list { 
    padding: 0 0 24px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid hsla(var(--text-color), .2);
  }
  
  &__trigger {
    padding: 8px;
    background-color: transparent;
    color: hsla(var(--text-color), .7);
  }

  &__item a {
    display: inline-block;
    padding-bottom: 8px;
    color: hsla(var(--base-hsl), .7);

    &:hover  { color: hsla(var(--base-hsl), 1); }
  }

  &__heading {
    color: hsla(var(--white-hsl), 1);
    font-weight: 400;
    margin-bottom: 8px;
  }

  &__contextual { padding-bottom: 24px; }

  &--disabled { opacity: .4; }
}
