/* ==========================================================================
   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 {
    position: relative;
    display: block;
    line-height: 1.2;
    box-sizing: border-box;
  }

  .nav-menu.level-1 {
    flex-wrap: nowrap;
  }
  .nav-item.level-1 {
    position: relative;
    margin-left: 1px;

    > a {
      width: 100%;
      padding: 10px 15px;
      font-family: var(--font-family-secondary-medium);
      font-size: var(--font-size-l);
      text-align: center;
      text-transform: uppercase;

      span {
        display: block;
        position: relative;

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

  .nav-menu.level-2 {
    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: var(--box-shadow-s);
    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);
    }
  }

  .nav-item.level-2 {
    min-height: 1px;
    box-sizing: border-box;

    > a {
      padding: 10px 20px;
      color: var(--color-fg-primary);
      font-family: var(--font-family-secondary-medium);
      font-size: var(--font-size-m);
    }
  }

  .nav-menu.level-3 {
    display: none;
  }

  /* 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: inherit;
    background-color: transparent;

    span:after {
      transform: scaleX(1);
      transform-origin: 0 50%;
    }
  }

  .nav-item.is-active {
    > a {
      &:after {
        content: none;
      }
    }

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

  .nav-item.level-1.is-current > a {
    color: var(--color-fg-primary);
  }

  .nav-item.level-2 {
    > a {
      &:hover,
      &:focus {
        color: var(--color-text-dark);
      }
    }
  }

  .nav-item.level-3 {
    > a {
      &:hover,
      &:focus {
        color: var(--color-fg-primary);
      }
    }
  }

  /* Responsive.
     ========================================================================== */
  @media screen and (max-width: 90em) {
    .nav-item.level-1 > a {
      font-size: calc(var(--font-size-xl) - 1px);
    }

    .nav-item.level-2 > a {
      font-size: var(--font-size-xl);
    }

  }
}

/* ==========================================================================
   Footer.
   ========================================================================== */
.nav--footer {
  .nav-item {
    display: inline-flex;
    align-items: center;
    margin: 0 8px;
    font-family: var(--font-family-secondary-heading);
    font-size: var(--font-size-s);

    /* Responsive.
       ========================================================================== */
    @media screen and (min-width: 80em) {
      + .nav-item {
        &:before {
          content: "•";
          position: relative;
          left: -8px;
          color: var(--color-fg-primary);
        }
      }
    }
  }

  a {
    padding: var(--space-xs) var(--space-m);
    border-radius: 20px;

    &:active,
    &.is-active,
    &:focus,
    &:hover {
      color: var(--color-primary-700);
      background-color: color-mix(in oklab, var(--color-primary-700) 25%, white);
    }
  }
}

/* ==========================================================================
   Breadcrumb.
   ========================================================================== */
.nav--breadcrumb {
  padding: 8px 0 4px;
  font-family: var(--font-family-secondary);
  font-size: var(--font-size-s);

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

  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 {
    display: inline;
    margin: 0 .4em;
    --icon-size: 8px;
  }

  li:last-of-type {
    color: var(--color-fg-primary);
    font-family: var(--font-family-secondary-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.
   ========================================================================== */
.nav--pager {
  margin: var(--space-l) auto;
  text-align: center;

  a {
    display: inline-block;
  }

  .pager-items {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ==========================================================================
   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-secondary-medium);

  .nav-toggle {
    position: relative;
    z-index: 1;
    padding: 0;
    background: var(--color-bg);
    border-radius: 50%;

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

  .nav-content {
    position: absolute;
    z-index: 2;
    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 {
      color: var(--color-fg-primary);
      background-color: var(--color-bg-secondary);
    }
  }

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

    .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: 1px solid var(--color-bg-secondary);
    border-radius: 4px;
    text-align: center;
    color: var(--color-text);
    background: var(--color-bg) 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: inherit;
      box-shadow: 0 30px 40px rgba(0, 0, 0, .1);
      box-shadow: 0 5px 11px rgba(33, 33, 33, .2);
      box-shadow: 0 1px 2px rgba(0, 0, 0, .035),
      0 3px 5px rgba(0, 0, 0, .05),
      0 6px 12px rgba(0, 0, 0, .065),
      0 20px 40px rgba(0, 0, 0, .1);
      transform: scale(1.01);
    }
  }

  .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);

    &:after {
      content: "";
      display: block;
      margin: 1em auto 0;
      width: 120px;
      height: 2px;
      background-color: var(--color-fg-primary);
    }
  }

  .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-secondary-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);
      }
    }
  }
}
