////
///Placeholder for Copyright ///
////

// ----------------------------------------------------------------------------
// Rules
// ----------------------------------------------------------------------------

// Sidebar
.md-sidebar {
  position: sticky;
  top: px2rem(48px);
  flex-shrink: 0;
  align-self: flex-start;
  width: px2rem(242px);
  padding: px2rem(24px) 0;

  // [print]: Hide sidebar
  @media print {
    display: none;
  }

  // [tablet -]: Show navigation as drawer
  @include break-to-device(tablet) {

    // Primary sidebar with navigation
    &--primary {
      position: fixed;
      top: 0;
      left: px2rem(-242px);
      z-index: 3;
      display: block;
      width: px2rem(242px);
      height: 100%;
      background-color: var(--md-default-bg-color);
      transform: translateX(0);
      transition:
        transform  250ms cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 250ms;

      // Adjust for right-to-left languages
      [dir="rtl"] & {
        right: px2rem(-242px);
        left: initial;
      }

      // Show sidebar when drawer is active
      [data-md-toggle="drawer"]:checked ~ .md-container & {
        @include z-depth(8);

        transform: translateX(px2rem(242px));

        // Adjust for right-to-left languages
        [dir="rtl"] & {
          transform: translateX(px2rem(-242px));
        }
      }

      // Stretch scroll wrapper for primary sidebar
      .md-sidebar__scrollwrap {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        margin: 0;
        scroll-snap-type: none;
        overflow: hidden;
      }
    }
  }

  // [screen +]: Show navigation as sidebar
  @include break-from-device(screen) {
    height: 0;

    // [no-js]: Switch to native sticky behavior
    .no-js & {
      height: auto;
    }
  }

  // Secondary sidebar with table of contents
  &--secondary {
    display: none;
    order: 2;

    // [tablet landscape +]: Show table of contents as sidebar
    @include break-from-device(tablet landscape) {
      height: 0;

      // [no-js]: Switch to native sticky behavior
      .no-js & {
        height: auto;
      }

      // Sidebar is visible
      &:not([hidden]) {
        display: block;
      }

      // Ensure smooth scrolling on iOS
      .md-sidebar__scrollwrap {
        touch-action: pan-y;
      }
    }
  }

  // Sidebar scroll wrapper
  &__scrollwrap {
    margin: 0 px2rem(4px);
    overflow-y: auto;
    // Hack: promote to own layer to reduce jitter
    backface-visibility: hidden;
    // Hack: Chrome 81+ exhibits a strange bug, where it scrolls the container
    // to the bottom if `scroll-snap-type` is set on the initial render. For
    // this reason, we disable scroll snapping until this is resolved (#1667).
    // scroll-snap-type: y mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--md-default-fg-color--lighter) transparent;

    // Sidebar scroll wrapper on hover
    &:hover {
      scrollbar-color: var(--md-accent-fg-color) transparent;
    }

    // Webkit scrollbar
    &::-webkit-scrollbar {
      width: px2rem(4px);
      height: px2rem(4px);
    }

    // Webkit scrollbar thumb
    &::-webkit-scrollbar-thumb {
      background-color: var(--md-default-fg-color--lighter);

      // Webkit scrollbar thumb on hover
      &:hover {
        background-color: var(--md-accent-fg-color);
      }
    }
  }
}

// [tablet -]: Show overlay on active drawer
@include break-to-device(tablet) {

  // Sidebar overlay
  .md-overlay {
    position: fixed;
    top: 0;
    z-index: 3;
    width: 0;
    height: 0;
    background-color: hsla(0, 0%, 0%, 0.54);
    opacity: 0;
    transition:
      width     0ms 250ms,
      height    0ms 250ms,
      opacity 250ms;

    // Show overlay when drawer is active
    [data-md-toggle="drawer"]:checked ~ & {
      width: 100%;
      height: 100%;
      opacity: 1;
      transition:
        width     0ms,
        height    0ms,
        opacity 250ms;
    }
  }
}
