/* ==========================================================================
   Navigation.
   ========================================================================== */
.nav {
  .nav-menu {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  p,
  ul,
  ol {
    margin-bottom: 0;
  }

  li {
    list-style: none;
  }

  .is-active {
    color: inherit;
  }
}

/* ==========================================================================
   Main navigation.
   ========================================================================== */
.nav--main {
  &,
  a {
    color: var(--color-text-dark);
  }
  a {
    display: block;
    line-height: 1.2;
    box-sizing: border-box;
  }

  .nav-menu {
    &.level-1 {
      flex-wrap: nowrap;
    }
    &.level-2,
    &.level-3 {
      position: absolute;
      z-index: -1;
      top: 100%;
      left: 0;
      display: block;
      width: 264px;
      padding: 10px 0;
      background-color: var(--color-bg);
      border: 0;
      visibility: hidden;
      opacity: 0;
      box-shadow: 0 5px 10px rgba(0, 0, 0, .1);
      box-sizing: border-box;
      transition: .3s;

      &:before {
        content: "";
        position: absolute;
        z-index: 5;
        top: -12px;
        left: 40px;
        display: block;
        width: 0;
        height: 0;
        border-style: solid;
        border-width: 0 11px 12px 11px;
        border-color: transparent transparent var(--color-bg);
      }
    }
    &.level-3 {
      top: -10px;
      left: 264px;

      &:before {
        content: none;
      }
    }
  }

  .nav-item {
    &.level-1 {
      position: relative;
      margin-left: 1px;
      font-size: var(--font-size-s);

      > a {
        width: 100%;
        padding: 10px 15px;
        text-align: center;
      }

      + .nav-item.level-1 {
        &:before {
          content: "";
          position: absolute;
          top: 50%;
          left: -1px;
          z-index: 5;
          transform: translateY(-50%);
          display: inline-block;
          width: 1px;
          height: 38px;
          background: rgba(0, 0, 0, .12);
        }
      }
    }

    &:not(.level-1) {
      min-height: 1px;
      box-sizing: border-box;
      font-size: var(--font-size-s);

      > a {
        padding: 10px 20px;
      }
    }
    &.level-2 {
      &.is-parent {
        position: relative;

        > a {
          &:after {
            content: "";
            display: inline-block;
            width: inherit;
            height: inherit;
            mask-repeat: no-repeat;
            mask-position: center;
            mask-size: 11px;
            background: var(--color-fg);
            transition: var(--transition);
            position: absolute;
            top: 50%;
            right: var(--space-m);
            transform: translateY(-50%);
          }
        }
      }
      &.is-active {
        .nav-menu {
          z-index: 100;
          visibility: visible;
          opacity: 1;
        }
      }
    }
    &.level-4 {
      width: 100%;

      > a {
        &:before {
          content: "-";
          margin-right: var(--gutter-xs);
        }
      }
    }
  }

  /* States.
     ========================================================================== */
  .nav-item.level-1 > a:active,
  .nav-item.level-1 > a:focus,
  .nav-item.level-1:hover > a,
  .nav-item.level-1.is-active-trail > a {
    color: var(--color-bg);
    background-color: var(--color-fg-primary);
  }

  .nav-item.is-active {
    > .nav-menu {
      z-index: 100;
      visibility: visible;
      opacity: 1;
    }
  }

  .nav-item:not(.level-1) {
    > a {
      color: var(--color-text-dark);

      &:hover,
      &:focus {
        color: var(--color-fg-primary);
        background: var(--color-bg-primary);
      }
    }
  }
}

/* ==========================================================================
   Secondary navigation.
   ========================================================================== */
.nav--secondary {
  margin-right: var(--gutter-m);

  .nav-item {
    position: relative;
    padding-left: var(--gutter-m);
    padding-right: var(--gutter-m);
    color: var(--color-text-dark);
    font-size: var(--font-size-s);
    font-family: var(--font-family-heading);

    + .nav-item {
      &:before {
        content: "";
        position: absolute;
        top: 4px;
        left: 0;
        width: 1px;
        height: 14px;
        background: var(--color-fg-primary);
      }
    }

    a {
      color: inherit;
      position: relative;

      &:after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 1px;
        width: 100%;
        height: 1px;
        background: var(--color-fg-primary);
        transform: scaleX(0);
        transform-origin: 100% 50%;
        transition: transform .2s ease-out;
      }
      &:not(.active):hover {
        &:after {
          transform: scaleX(1);
          transform-origin: 0 50%;
        }
      }
    }
  }
}

/* ==========================================================================
   Footer.
   ========================================================================== */
.nav--footer {
  .nav-item {
    display: inline-flex;
    align-items: center;
    margin: 0 var(--space-xl);
    font-family: var(--font-family-heading);
    text-transform: uppercase;
    font-size: var(--font-size-s);
  }

  a {
    position: relative;
    color: var(--color-bg);

    &:after {
      content: "";
      position: absolute;
      left: 0;
      bottom: -1px;
      width: 100%;
      height: 1px;
      background: var(--color-bg);
      transform: scaleX(0);
      transform-origin: 100% 50%;
      transition: transform .2s ease-out;
    }
    &:not(.active):hover {
      &:after {
        transform: scaleX(1);
        transform-origin: 0 50%;
      }
    }
  }
}

/* ==========================================================================
   Breadcrumb.
   ========================================================================== */
.nav--breadcrumb {
  padding: var(--space-xs) 0 var(--space-xxs);
  font-size: var(--font-size-s);

  .nav-item {
    margin-bottom: 4px;
    line-height: 1;
  }

  a {
    position: relative;
    display: inline;
    padding: 5px 0;
    color: inherit;

    &:after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 2px;
      width: 20px;
      height: 1px;
      background: var(--color-fg-primary);
      transform: scaleX(0);
      transform-origin: 100% 50%;
      transition: transform .2s ease-out;
    }

    &:not(.active):hover {
      &:after {
        transform: scaleX(1);
        transform-origin: 0 50%;
      }
    }
  }

  .item-separator {
    margin: 0 .5em 0 .25em;
    position: relative;
    top: 3px;
    width: 10px;
    height: 10px;
    background: var(--color-fg-primary);
    border-radius: 50%;

    &:before {
      content: none;
    }
  }

  li:last-of-type {
    color: var(--color-text-dark);
    font-family: var(--font-family-heading);
  }

  /* Responsive.
     ========================================================================== */
  @media screen and (max-width: 80em) {
    li:last-of-type {
      display: none;
    }

    li:nth-last-child(2) {
      .item-separator {
        display: none;
      }
    }
  }
}

/* ==========================================================================
   Classic pager.
   ========================================================================== */
.pager,
.nav--pager {
  margin: var(--space-l) auto;
  text-align: center;

  a {
    position: relative;
    display: inline-block;
    align-items: center;
    justify-content: center;
    min-width: 57px;
    padding: var(--button-padding-vertical) var(--button-padding-horizontal);
    line-height: var(--button-line-height);
    color: var(--button-fg-color);
    font-family: var(--font-family);
    font-size: var(--button-font-size);
    text-decoration: none;
    background-color: var(--color-bg-secondary);
    border: var(--button-border-size) solid transparent;
    border-radius: var(--border-radius-xl);
    cursor: pointer;
    box-sizing: border-box;
    transition: var(--button-transition);

    &:active,
    &.is-active,
    .is-active &,
    &:focus,
    &:hover {
      color: var(--color-fg-primary);
      border-color: transparent;
      background-color: var(--color-bg-primary);
    }
  }

  .pager__items,
  .pager-items {
    display: flex;
    align-items: center;
    justify-content: center;
    list-style: none;
  }
  .pager__item {
    flex-shrink: 0;

    + .pager__item {
      margin-left: var(--gutter-xs);
    }
  }
}

/* ==========================================================================
   Dashboard menu (left sidebar with icons/text).
   ========================================================================== */
.nav--dashboard {
  /* Toggle.
     ========================================================================== */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px 0;
    width: 100%;
    line-height: 1;
    background: none;
    opacity: .3;
    transition: all .2s ease-in-out, width 0s;

    &:active,
    &.is-active,
    &:focus,
    &:hover {
      opacity: .6;
    }

    .icon {
      --icon-size: var(--icon-size-l);

      &:before {
        background-color: var(--color-black);
      }
    }

    .l-menu-dashboard-open & {
      transform: rotateY(180deg);
      width: 54px;
    }
  }

  /* Menu.
     ========================================================================== */
  .nav-menu {
    display: block;

    a {
      display: inherit;
      height: var(--sidebar-width);
      color: rgba(255, 255, 255, .75);

      &:active,
      &.is-active,
      &:focus,
      &:hover {
        color: var(--color-white);

        .icon:before {
          background-color: var(--color-white);
        }
      }

      > span {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;

        .l-menu-dashboard-open & {
          justify-content: normal;
          padding: 0 10px;
        }
      }
    }

    .icon {
      --icon-size: var(--icon-size-xl);

      &:before {
        background-color: rgba(255, 255, 255, .75);
      }

      .l-menu-dashboard-open & {
        padding-right: 10px;
      }
    }

    .item-title {
      position: absolute;
      left: 54px;
      width: 130px;

      font-family: var(--font-family-secondary-medium);
      visibility: hidden;
      opacity: 0;
      transition: all .2s, color 0s;

      .l-menu-dashboard-open & {
        visibility: visible;
        opacity: 1;
      }
    }
  }
}

/* ==========================================================================
   Siblings.
   ========================================================================== */
.nav--siblings {
  .nav-menu {
    /* Responsive.
       ========================================================================== */
    @media screen and (min-width: 48em) {
      flex-wrap: nowrap;
    }
  }

  .nav-item {
    margin: 10px 0;

    .btn {
      display: inline-flex;
    }
  }

  .item-prev {
    margin-right: var(--gutter-m);
  }
  .item-next {
    margin-left: auto;
  }
}

/* ==========================================================================
   Toolbar.
   ========================================================================== */
.nav--toolbar {
  .content-before & {
    padding-left: var(--gutter-m);
  }

  .nav-item {
    position: relative;
    flex-shrink: 0;

    &.is-open {
      > a .icon:before {
        background-color: var(--color-text-dark);
      }
    }
  }

  a {
    padding: 0 6px;
    line-height: 1;

    &:hover,
    &:focus {
      .icon:before {
        background-color: var(--color-text-dark);
      }
    }
  }

  .icon {
    position: relative;
    top: 2px;
    --icon-size: 18px;

    &:before {
      background-color: var(--color-fg-primary);
    }
  }

  /* Admin toolbar.
     ========================================================================== */
  .print-page-header > &,
  &.print-quick-layout-actions {
    position: absolute;
    z-index: 20;
    display: inline-block;
    margin: 0;
    padding: 10px;
    background: rgba(255, 255, 255, .75);
    border: 1px dashed var(--color-border);
    border-radius: 2px;

    .nav-menu {
      margin: 0;
    }
  }

  /* Print.
     ========================================================================== */
  .print-page-header > & {
    top: 0;
    right: -170px;
  }
  &.print-quick-layout-actions {
    right: -110px;
    bottom: 0;
  }

  /* Share.
     ========================================================================== */
  .toolbar-social-share {
    position: absolute;
    right: -2px;
    bottom: -52px;
    z-index: 50;
    display: flex;
    padding: 8px 12px;
    background: var(--color-bg);
    box-shadow: 0 7px 25px 0 rgba(0, 0, 0, .15);
    opacity: 0;
    visibility: hidden;
    transition: .3s;

    &:before {
      content: "";
      position: absolute;
      top: -8px;
      right: 12px;
      width: 0;
      height: 0;
      border-style: solid;
      border-width: 0 6px 8px 6px;
      border-color: transparent transparent #fff;
    }

    .icon:before {
      font-size: 22px;
    }
    .icon--facebook:before {
      color: #4267b2;
    }
    .icon--twitter:before {
      color: rgb(15, 20, 25);
    }
    .icon--linkedin:before {
      color: #007ab9;
    }
  }

  .is-open {
    .toolbar-social-share {
      opacity: 1;
      visibility: visible;
    }
  }
}

/* ==========================================================================
   Dropdown.
   ========================================================================== */
.nav--dropdown {
  position: relative;
  font-family: var(--font-family-heading);

  .nav-toggle {
    position: relative;
    z-index: 5;
    display: block;
    padding: 0;
    height: calc(var(--button-height) + (var(--button-border-size) * 4));
    background: var(--color-bg);
    border: 1px solid var(--color-fg-primary);
    border-radius: 50%;
    box-sizing: border-box;

    .icon {
      --icon-size: var(--icon-size-s);
      width: 42px;
      height: 42px;
      border-radius: inherit;
      transition: .1s;
    }
  }

  .nav-content {
    position: absolute;
    z-index: 10;
    top: 100%;
    right: 50%;
    transform: translate(0, -10px);
    display: block;
    padding: 15px 0 10px;
    width: 200px;
    max-height: 68vh;
    overflow: auto;
    background-color: var(--color-bg);
    box-shadow: 0 7px 25px 0 rgba(0, 0, 0, .1);
    opacity: 0;
    visibility: hidden;
    transition: .3s;
  }

  .nav-item {
    width: 100%;

    .item-content {
      display: block;
      padding: 6px 20px;

      span {
        display: inherit;
      }
    }

    a {
      color: var(--color-text);
      font-size: var(--font-size-l);

      &:hover,
      &:focus {
        color: var(--color-fg-primary);
        background-color: var(--color-bg-primary);
      }
    }

    .item-username {
      color: var(--color-text-dark);
      font-size: 1.1em;
    }
    .item-usermail {
      color: var(--color-text-light);
    }
  }

  /* States.
     ========================================================================== */
  &.is-open .nav-toggle,
  .nav-toggle:hover,
  .nav-toggle:focus {
    .icon {
      background-color: var(--color-fg-primary);

      &:before {
        background-color: var(--color-bg);
      }
    }
  }

  &.is-open {
    .nav-toggle {
      z-index: 15;
    }

    .nav-content {
      visibility: visible;
      opacity: 1;
    }
  }
}

/* ==========================================================================
   Children.
   ========================================================================== */
.nav--children {
  .nav-menu {
    display: grid;
    grid-gap: var(--gutter-l);
    grid-template-columns: 1fr;
    align-items: initial;
  }

  /* Responsive.
     ========================================================================== */
  @media screen and (min-width: 48em) {
    .nav-menu {
      grid-template-columns: 1fr 1fr;
    }

    .l-2-rows {
      grid-row-end: span 2;
    }
  }
  @media screen and (min-width: 90em) {
    .nav-menu {
      grid-template-columns: 1fr 1fr 1fr;
    }
  }

  a {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    overflow: hidden;
    border-radius: var(--border-radius-xl);
    text-align: center;
    color: var(--color-text);
    background: var(--color-bg-primary) no-repeat center;
    background-size: cover;
    transform: scale(1);
    backface-visibility: hidden;
    box-sizing: border-box;
    -webkit-font-smoothing: subpixel-antialiased;
    transition: .2s ease-in-out;

    &:hover,
    &:focus {
      color: var(--color-bg);
      background-color: var(--color-fg-primary);

      .item-title {
        color: inherit;
      }
    }
  }

  .item-wrapper {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--gutter-l);
  }

  .item-title {
    max-width: 380px;
    margin: 1em auto;
    color: var(--color-fg-primary);
    font-size: var(--font-size-xl);
    font-family: var(--font-family-heading);
    transition: .2s;
  }

  .item-content {
    margin: 1em auto;
  }

  /* Dataviz.
     ========================================================================== */
  .item-type--dataviz {
    a {
      background-color: var(--color-bg-secondary);
    }

    .item-title:after {
      content: none;
    }
  }

  /* Thumbnail.
     ========================================================================== */
  .item-type--thumbnail {
    a {
      border-width: 0;

      &:before {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: #000;
        opacity: .4;
      }
    }

    .item-title {
      color: #fff;

      &:after {
        content: none;
      }
    }
  }

  /* Content.
     ========================================================================== */
  .item-type--content {
    .item-keyfacts {
      display: flex;
      align-items: center;
      margin-bottom: -1em;
      text-align: left;
      font-size: var(--font-size-l);

      strong,
      b {
        margin-right: .25em;
        font-size: 3em;
        font-family: var(--font-family-heading);
        white-space: nowrap;
      }
    }
  }
}

/* ==========================================================================
   Sitemap.
   ========================================================================== */
.sitemap-item {
  margin-bottom: var(--space-xl);
}

/* ==========================================================================
   Summary.
   ========================================================================== */
.nav--summary {
  .nav-item {
    width: 100%;
    margin-bottom: var(--space-s);
    cursor: pointer;
    transition: .3s;

    &.is-active {
      font-weight: bold;
    }

    &:not(.l-accordion) {
      &:hover,
      &:focus {
        color: var(--color-fg-primary);
      }
    }
  }

  .nav-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    width: inherit;
    background: none;
    color: var(--color-text);
    text-align: left;
    transition: .3s;

    .icon {
      --icon-size: 13px;
    }

    &:hover,
    &:focus {
      color: var(--color-fg-primary);

      .icon:before {
        background-color: var(--color-fg-primary);
      }
    }

    + .nav-menu {
      display: none;
      margin-top: var(--space-s);
      margin-left: var(--gutter-xs);
    }
  }

  .is-open {
    .nav-menu-trigger {
      .icon {
        transform: rotateX(180deg)
      }
    }
  }
}

/* ==========================================================================
   Users.
   ========================================================================== */
.nav--users {
  max-height: 30vh;
  overflow-y: auto;
  background: #fff;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, .25);
  border: 1px solid var(--input-border-color);
  border-top: 0;

  .nav-item {
    padding: var(--space-s) var(--input-padding-horizontal);
    cursor: pointer;

    &:hover,
    &:focus {
      background-color: var(--color-bg-secondary);
    }

    p {
      margin: 0;
    }
  }

  .item-display-name {
    font-weight: bold;
  }

  .item-name {
    font-size: var(--font-size-s);
  }
}

/* ==========================================================================
   Simple navigation inline with icon.
   ========================================================================== */
.nav--simple {
  .nav-menu {
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    margin: 0;
    list-style: none;
  }

  .nav-item {
    margin-bottom: .7rem;

    a {
      display: inline-flex;
      align-items: center;
      width: 100%;
      height: 100%;
      padding: var(--space-l) var(--gutter-l);
      background: var(--color-bg-primary);
      box-sizing: border-box;

      &:hover,
      &:focus {
        color: #fff;
        background-color: var(--color-fg-primary);
      }
    }

    .item-title {
      font-weight: bold;
      font-size: var(--font-size-l);
    }

    .icon {
      margin-right: var(--gutter-m);
      order: -1;
      --icon-size: 40px;
    }
  }

  /* Responsive.
     ========================================================================== */
  @media screen and (min-width: 48em) {
    .nav-menu {
      flex-direction: row;
      margin-left: -.5%;
      margin-right: -.5%;
    }

    .nav-item {
      padding: 0 .5%;
      width: 24%;
    }
  }
}

/* ==========================================================================
   Detailed navigation with multiple depths.
   ========================================================================== */
.nav--detail {
  .nav-menu {
    flex-direction: column;
    margin: 0;

    .nav-menu:after {
      content: "";
      padding-bottom: var(--space-s);
      width: 100%;
      background: var(--color-bg-secondary);
    }
  }

  .nav-item {
    width: 100%;

    a {
      display: inline-flex;
      align-items: center;
      width: inherit;
      height: 100%;
      padding: var(--space-xs) var(--gutter-l);
      background: var(--color-bg-primary);
      box-sizing: border-box;

      &:not(.btn) {
        text-decoration: none;
      }
    }

    .item-title {
      font-weight: bold;
      font-size: var(--font-size-l);
    }

    .icon {
      display: none;
      margin-right: var(--gutter-m);
      order: -1;
      --icon-size: 40px;
    }

    &.is-active-trail > a,
    a:hover,
    a:focus {
      color: #fff;
      background-color: var(--color-fg-primary);

      &:after {
        color: inherit;
      }
    }
  }
  .level-2 {
    &.is-parent {
      a {
        padding-top: var(--space-xxs);
        padding-bottom: var(--space-xxs);

        &:before {
          content: "-";
          margin-right: var(--gutter-xs);
        }
      }
    }
  }
  .level-3 {
    a {
      padding-left: calc(var(--gutter-s) + 3px);
    }
  }
  .level-4 {
    a {
      padding-left: calc(var(--gutter-s) + 6px);
    }
  }
  .level-5 {
    a {
      padding-left: calc(var(--gutter-s) + 9px);
    }
  }

  /* Accordion.
     ========================================================================== */
  .l-accordion {
    cursor: pointer;

    span {
      position: relative;
    }

    > a:after,
    > span:after {
      --icon-size: var(--icon-size-xxs);
      content: "";
      display: inline-block;
      width: var(--icon-size);
      height: var(--icon-size);
      mask-repeat: no-repeat;
      mask-position: center;
      mask-size: var(--icon-size);
      background: var(--color-fg-primary);
      mask-image: var(--icon-datagone-angle-bottom);
      position: absolute;
      top: 50%;
      right: var(--gutter-m);
      transform: rotateY(0) translateY(-50%);
      transform-origin: 50% 0;
      color: var(--color-fg-primary);
      transition: .2s;
    }

    &.is-open {
      > a:after,
      > span:after {
        transform: rotateX(180deg) translateY(-50%);
      }
    }
  }

  /* Responsive.
     ========================================================================== */
  @media screen and (min-width: 48em) {
    .nav-item.level-1 {
      + .nav-item.level-1 {
        border-top: 1px solid var(--color-fg-primary);
      }
    }
  }
}
