@import '../../partials/variables';
@import '../../lib/functions';

.sidebar {
  display: none;  // hide the sidebar by default, homepage enables it by default

  --easeOutExpo: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: .6s;

  height: calc(100vh - map-deep-get($nav, height));

  font-size: map-deep-get($nav, font-size);

  @media (max-width: $mobile-breakpoint) {
    display: grid;
    grid-template-columns: [nav] 5fr [escape] 1fr;
    height: calc(100vh - map-deep-get($nav, mobile, height));

    font-size: map-deep-get($sidebar, mobile, font-size);

    overflow: hidden auto;
    overscroll-behavior: contain;

    visibility: hidden;
    transform: translateX(-110vw);
    will-change: transform;
    transition:
      transform var(--duration) var(--easeOutExpo),
      visibility 0s linear var(--duration);
  }

  &__nav {
    display: flex;
    flex-direction: column;
    overflow-y: scroll;

    background-color: var(--background-color);

    padding: 10px;
  }

  &__close {
    display: none;

    @media (max-width: $mobile-breakpoint) {
      display: initial;
    }
  }

  &__list {
    list-style: none;
  }

  &__item {
    @media (max-width: $mobile-breakpoint) {
      margin: 10px 0;
    }
  }

  &__container {
    display: flex;
    align-items: center;

    border-bottom-right-radius: .25em;
    border-top-right-radius: .25em;

    padding: 5px;

    @media (max-width: $mobile-breakpoint) {
      padding: 25px 5px;
    }

    &--selected, &:hover {
      background-color: var(--selected-color);
    }
  }

  &__icon {
    &:hover {
      cursor: pointer;
    }
  }

  &__text {
    display: flex;
    justify-content: space-between;

    width: 100%;
    padding: 0 0 0 20px;

    overflow: hidden;
    white-space: nowrap;

    &:hover {
      cursor: pointer;
    }
  }

  .read-button {
    margin: 20px 0 0 10px;
    width: max-content;

    @media (max-width: $mobile-breakpoint) {
      margin: auto 0 20px 10px;
      font-size: inherit;
    }
  }

  & .nav-list {
    display: none;

    &--bordered {
      border-bottom: 2px var(--border-color) solid;
    }

    @media (max-width: $mobile-breakpoint) {
      display: flex;
      flex-direction: column;
      width: 100%;

      &__item {
        margin: 0;

        padding: 25px 15px;
        border-bottom-right-radius: 0.25em;
        border-bottom-left-radius: 0.25em;

        & a {

          color: inherit;
          font-size: inherit;

          align-items: initial;
          justify-content: initial;

          padding: 0;

          &:before {
            @include font-awesome;

            content: "\f35d";
            padding: 0 20px 0 0;
          }
        }
      }
    }
  }
}

@media (max-width: $mobile-breakpoint) {
  #menu-input:checked ~ * .sidebar {
    visibility: visible;
    transform: translateX(0);
    transition: transform var(--duration) var(--easeOutExpo);
  }
}
