@use '../styles/defaults' as *;
@use '../styles/variables' as *;

.header {
  background-color: $main-color;
  color: $main-background-color;

  @media print {
    & {
      display: none;
    }
  }

  .container {
    @extend .wrapped-center;

    display: flex;
    align-items: center;
    gap: 1em;
    justify-content: space-between;
    padding: .75rem;
  }

  a, button {
    background-color: $main-color;
    border: none;
    color: currentColor;
    font-weight: bold;
    font-size: 1em;
    text-decoration: underline;

    &:hover, &:focus, &[aria-pressed="true"], &[aria-current="page"] {
      text-decoration: none;
    }
  }
}

.logo {
  margin-right: auto;

  img {
    max-height: 2rem;
  }
}

.skiplinks {
  @extend .header;
  @extend .navigation;

  background-color: $main-color;
  gap: 1em;
  padding: 1em;
  position: absolute;
  width: 100%;
  z-index: -1;

  &:focus-within {
    z-index: 1000;
  }
}

.navigation {
  display: flex;

  .menuButton {
    display: flex;

    @media screen and (min-width: $screen-breakpoint) {
      & {
        display: none;
      }
    }
  }

  /*
   * 1. Outils
   */
  .menuLinks {
    display: none;
    margin: 0;

    @media screen and (min-width: $screen-breakpoint) {
      & {
        align-items: center;
        display: flex;
        gap: 1em;
      }
    }
  }

  .menuLinksMobileVisible {
    background-color: $main-color;
    left: 0;
    margin-top: 2em;
    position: absolute;
    width: 100%;
    z-index: 1000;

    .menuLinks {
      @extend .wrapped-center;

      display: flex;
      flex-direction: column;
      padding: 1em 0;

      a, button {
        display: inline-block;
        font-size: 1em;
        font-weight: initial;
        padding: .5em;
      }

      .toggleMenuContainer {
        display: block;
        position: initial;
      }

      .toggleMenuList {
        padding: 0;
      }
    }
  }
}

/*
 * 2. Utilisateur·ice
 */
.userMenu {
  display: flex;
  align-items: baseline;
  gap: 1em;

  @media screen and (min-width: $screen-breakpoint) {
    margin: 0 5em;
  }
}

/*
 * 3. Langues
 */
.languagesMenu {
  position: relative;
}

.languagesMenu > button {
  display: flex;
}

/*
 * Toggleable menu
 * Used by languages and workspaces
   nav.toggleMenu
     button.toggleMenuButton
     div.toggleMenuContainer
      ul.toggleMenuList
 */

.toggleMenuContainer {
  background-color: $main-color;
  left: 0;
  margin-top: .5em;
  position: absolute;
  min-width: max-content;
  width: 100%;
  z-index: 1000;

  @media screen and (min-width: $screen-breakpoint) {
    // compensates .toggleMenuList padding
    left: -1em;
  }
}

.toggleMenuContainerAlignEnd {
  @extend .toggleMenuContainer;
  left: auto;
  right: 0;
  text-align: right;

  @media screen and (min-width: $screen-breakpoint) {
    left: auto;
    right: -1em;
  }

  .toggleMenuList {
    padding: .5em;

    @media screen and (min-width: $screen-breakpoint) {
      padding: 1em;
    }
  }
}

.toggleMenu {
  a, button {
    background-color: transparent;
  }

  @media screen and (min-width: $screen-breakpoint) {
    position: relative;
  }

  .toggleMenuList {
    @extend .wrapped-center;
    padding: .5em;

    @media screen and (min-width: $screen-breakpoint) {
      padding: 1em;
    }

    button, a {
      display: inline-block;
      font-size: 1em;
      font-weight: initial;
      padding: .5em;
    }
  }
}

.logo {
  a {
    text-decoration: none;

    img {
      height: 1em;
      vertical-align: middle;
    }
  }
}

.chip {
  display: inline-block;
  height: .9em;
  width: .9em;
  border-radius: 4px;
  margin-right: 0.5em;
}

.logoAsImg {
  background-color: $main-color;
  height: 1em;
  padding: 0.5em;
  box-sizing: content-box;
}

.consentLabel {
  cursor: pointer;
  font-size: 0.8em;
  vertical-align: middle;
}
