/*

#############################
### ORGANISM: header ########
#############################

*/

@import '_extends.scss';
@import '_functions.scss';
@import '_mixins.scss';
@import '_variables.scss';

@import 'components/atoms/_text.scss';
@import 'components/atoms/_icon.scss';
@import 'components/atoms/_color.scss';


.#{utility('header')} {
  width: 100%;
  max-width: 2020px;
  margin: 0 auto;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 1001;
  background-color: color('white');
  box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.07);

  &.mainmenuopen {
    z-index: 1004;

    & ~ .#{utility('main')} {
      max-width: 100vw;
      overflow-x: hidden;
    }
  }

  @media (min-width: 1024px) {
    top: 0px;

    &.has-banner {
      top: -#{$bannerHeight};
    }
  }
}

.#{organism('header')} {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  max-width: 1460px;
  padding: 10px 0 0 20px;
  margin: 0 auto;

  @media (min-width: 1024px) {
    display: flex;
    padding-left: 30px;
  }

  &-home {
    position: -webkit-sticky;
    position: sticky;
    top: 10px;
    display: flex;
    align-items: center;
    margin-right: auto;
    padding-bottom: 10px;
    overflow: hidden;

      &-logo {
        height: 30px;
        margin-right: 6px;
        width: 30px;
      }

      &-title, &-sub-title {
        margin-left: 4px;
        @include txt-font-accent;
        font-size: 1.5em;
        color: color('blue-ribbon');

        @media (min-width: 1024px) {
          @include txt-lrg;
        }
      }

      &-sub-title {
        color: color('black');
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
  }

  &-main {
    display: none;
    flex: 1 1 auto;
    padding: 0 30px;

    @media (min-width: 1024px) {
      display: flex;
    }

    &-item {
      position: relative;
      display: flex;
      align-items: center;
      margin: 0 18px -5px;
    }

    &-link {
      display: flex;
      align-items: center;
      padding: 0 0 14px 0;
      border: 0;
      background: none;

      &-icon {
        font-size: 8px;
        margin-left: 5px;
        transform: rotate(0deg);
        transition: transform 0.2s cubic-bezier(.25,.1,.25,1);
      }
    }
  }

  &-main-link:hover ~ &-flyout,
  &-main-link:focus ~ &-flyout,
  &-flyout:hover {
    opacity: 1;
    pointer-events: all;
    transition: opacity 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  }

  &-flyout:focus-within {
    opacity: 1;
    pointer-events: all;
    transition: opacity 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  }

  &-flyout {
    @include flyout;
    position: absolute;
    top: 95%;
    left: 0;
    margin: 0;
    padding: 0 0 10px;
    pointer-events: none;
    opacity: 0;
    list-style: none;
    background: color('white');
    border-radius: 0 0 4px 4px;
    transition: opacity 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);

    /* Add a fake shadow to simulate that the flyouts are under the header */
    &:before {
      content: "";
      display: block;
      background: linear-gradient(to bottom, fade_out(color('black'), 0.93) 0%, fade_out(color('white'), 0.93) 100%);
      height: 8px;
      margin-bottom: 10px;
    }

    &-item {

      &-secondary {
        margin: 20px 0;
        white-space: nowrap;
        min-width: 200px;

        a:hover {
          color: color('blue-ribbon');
        }
      }


      &-title {
        @include txt;
        @include txt-2;
        @include txt-strong;
        @include txt-font-accent;
        @include color-black;

        line-height: 1.4em;

        &.secondary {
          padding: 0 15px;
        }
      }

      &-description {
        @include txt;
        @include txt-3;
        opacity: 0.75;

        line-height: 1.25em;
      }
    }

    &-primary-item {
      position: relative;
      width: 300px;

      &:hover &-link {
        @include flyout;
        background-color: color('blue-ribbon');

        &-info > * {
          @include color-white;
        }

        &-info-stories {
          .#{organism('header')}-flyout-item-title {
            @include color-stories;
          }

          .#{organism('header')}-flyout-item-description {
            @include color-stories;
          }
        }

        &-info-email {
          .#{organism('header')}-flyout-item-title {
            @include color-e-mails;
          }

          .#{organism('header')}-flyout-item-description {
            @include color-e-mails;
          }
        }

        &-icon {
          @include fill-websites;

          &.stories {
            @include fill-stories;
          }

          &.email {
            @include fill-e-mails;
          }
        }

        &.websites {
          @include gradient-websites;
        }

        &.stories {
          @include gradient-stories;
        }

        &.ads {
          @include gradient-ads;
        }

        &.email {
          @include gradient-e-mails;
        }
      }

      &-link {
        display: flex;
        align-items: center;
        border-radius: 4px;
        padding: 10px;
        margin: 0 5px;

        &-info {
          margin: 0 20px 0 15px;
        }

        &-icon {
          @include ico;
          width: 2em;
          height: 2em;

          &.websites {
            fill: url(#gradient-websites) #000;
          }
          &.stories {
            fill: url(#gradient-stories) #000;
          }
          &.ads {
            fill: url(#gradient-ads) #000;
          }
          &.email {
            fill: url(#gradient-email) #000;
          }
        }
      }
    }
  }
}

#blm-banner {
  background: #111;
  color: #eee;
  display: block;
  text-align: center;
  padding: 0.5em
}
