@import 'config/import';
@import 'variables';
@import 'mixins';

.top-bar {
  --indicator-outline: var(--header-bg);
  --dropdown-display: none;

  position: fixed;
  top: 0px;
  left: 0px;
  right: 0px;
  z-index: 101;
  height: $header-height;
  background: var(--header-bg);
  box-shadow: 0 1px 1px var(--header-shadow);

  &,
  &::after,
  &::before,
  & *,
  & *::after,
  & *::before {
    box-sizing: border-box; // todo: make it global when ready
  }

  &__container {
    max-width: $max-width;
    margin: auto;
    display: flex;
    align-items: center;
    position: relative;
  }

  .crayons-indicator {
    position: absolute;
    top: -$su-1;
    right: 0;
    box-shadow: 0 0 0 2px var(--indicator-outline);
  }
}

// Logo
.top-bar--logo {
  display: flex;
  margin-left: $su-2;
  @media (min-width: $breakpoint-m) {
    margin-left: $su-4;
  }

  .logo {
    width: 50px;
    height: 40px;
    padding: 0 7px 0 9px; // TODO: we have to fix SVG for logo a little...
    background: var(--logo-bg);
    fill: var(--logo-color);
    border-radius: $br-default;
  }
}

// Search bar
.top-bar--search {
  max-width: 420px;
  flex: 1 auto;
  margin: 0 $su-2;

  @media (min-width: $breakpoint-s) {
    margin: 0 $su-4;
  }
}

// Actions on right side...
.top-bar__links {
  height: $header-height;
  display: flex;
  align-items: center;
  margin-left: auto;
}

.top-bar__link {
  position: relative;
  display: flex;
  padding: $su-2;
  margin: 0 $su-1;
  border-radius: 50%;
  align-items: center;
  color: var(--header-icons-color);
  outline: 0;
  transition: background $transition-props;

  &:hover,
  &:focus {
    --indicator-outline: var(--header-bg-hover);

    color: var(--header-icons-color-hover);
    background: var(--header-bg-hover);
  }

  &--current {
    --indicator-outline: var(--header-bg-current);

    color: var(--header-icons-color-hover);
    background: var(--header-bg-current);
  }
}

// Dropdown under profile picture / hamburger icon
.top-bar__menu {
  height: 100%;
  display: flex;
  align-items: center;
  z-index: 20;
  &__trigger {
    all: unset;
    padding: $su-1;
    margin: 0 $su-1;
    border-radius: 50%;
    color: var(--header-icons-color);
    cursor: pointer;
  }

  &__dropdown {
    display: var(--dropdown-display);
    top: $header-height;
  }

  &.showing,
  &.desktop:hover,
  &.desktop:focus {
    --dropdown-display: block;

    .top-bar__menu__trigger {
      color: var(--header-icons-color-hover);
      background: var(--header-bg-hover);
    }
  }
}

.skip-content-link {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100px);
  background: var(--body-color);
  color: var(--body-color-inverted);
  z-index: 9999;
  padding: $su-4;
  pointer-events: none;
  opacity: 0;
  border-radius: $br-default;
  outline: 0;

  &:focus {
    pointer-events: auto;
    opacity: 1;
    transform: translate(-50%, $header-height/2);
  }
}

.pwa-nav-buttons {
  height: 100%;
  display: none;
  padding-left: $su-2;
  button {
    all: unset;
    padding: 0 $su-2;
    color: var(--header-icons-color);

    &:hover {
      color: var(--header-icons-color-hover);
    }
  }
  @media (min-width: $breakpoint-m) {
    &.pwa-nav-buttons--showing {
      display: flex;
    }
  }
}
