// Copyright (c) 2024, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

.sidebar {
  h5, ol li {
    text-overflow: ellipsis;
    overflow: hidden;
    padding: 3px 0 3px 3px;
  }

  ol {
    list-style: none;
    line-height: 22px;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0 0 15px 0;

    li {
      &.section-title {
        font-size: 18px;
        font-weight: normal;
        text-transform: uppercase;
        padding-top: 25px;
      }

      &.section-subtitle {
        font-weight: 400;
        text-transform: uppercase;

        a {
          color: inherit;
        }
      }

      &.section-subitem {
        margin-left: 12px;
      }

      &:first-child {
        padding-top: 3px;
        margin-top: 0;
      }
    }
  }

  h5 {
    color: var(--main-sidebar-color);
    font-size: 18px;
    margin: 0 0 22px 0;
    padding-top: 0;

    a, a:hover {
      color: var(--main-sidebar-color);
    }
  }
}

#sidenav-left-toggle {
  display: none;
  vertical-align: text-bottom;
  padding: 0;
  color: var(--main-icon-color);
  user-select: none;
  cursor: pointer;

  &:hover {
    color: var(--main-hyperlinks-color);
  }

  @media screen and (max-width: 320px) {
    margin-right: 10px;
    margin-left: 20px;
  }
}

#overlay-under-drawer {
  display: none;

  opacity: 0.4;
  height: 100%;
  z-index: 1999;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: black;
}

.sidebar-offcanvas-left, .sidebar-offcanvas-right {
  // Even as the primary viewport scrolls, the sidebars should remain visible,
  // but below the top header which is always at the top of the viewport.
  position: sticky;
  top: var(--main-header-height);
  overflow-y: auto;
  min-height: 0;
  max-height: calc(100vh - var(--main-header-height));
}

.sidebar-offcanvas-left {
  flex: 0 1 230px;
  order: 1;
  padding: 25px 0 15px 30px;
  margin-right: 20px;

  h5 {
    margin-bottom: 10px;

    &:last-of-type {
      border: 0;
      margin-bottom: 25px;
    }
  }
}

.sidebar-offcanvas-right {
  flex: 0 1 12em;
  order: 3;
  padding: 25px 20px 15px 15px;

  // The right nav should disappear out of view when the window shrinks.
  @media screen and (max-width: 992px) {
    display: none;
  }
}

/* left-nav disappears, and can transition in from the left */
@media screen and (max-width: 840px) {
  #sidenav-left-toggle {
    display: inline;
    width: 24px;
    height: 24px;
    border: none;
    margin-right: 24px;
    margin-left: 24px;
    font-size: 24px;
  }

  #overlay-under-drawer.active {
    display: block;
  }

  .sidebar-offcanvas-left {
    left: -100%;
    position: fixed;
    transition: all .25s ease-out;
    z-index: 2000;
    top: 0;
    width: 280px;
    // Set a max width for narrow layouts that accounts for margin.
    max-width: calc(100% - 20px);
    height: 90%;
    background-color: var(--main-bg-color);
    overflow-y: scroll;
    padding: 10px;
    margin: 10px 10px;
    box-shadow: 5px 5px 5px 5px #444444;

    &.active {
      // Enable animating the drawer into the page view.
      left: 0;
    }
  }

  ol#sidebar-nav {
    font-size: 18px;
    white-space: pre-line;
  }

  header .self-name {
    display: inline-block;
    color: var(--main-hyperlinks-color);
  }
}
