@mixin tbd($color: red) { position: relative; padding: 0 .3em; border: 1px dashed lighten($main-font-color, 70); &:after { position: absolute; left: 100%; content: "TBD"; color: lighten($main-font-color, 70); font-size: .6em; line-height: 1; padding: .05em .4em; } } @mixin wide-container() { @media screen and (min-width: $bigscreen-breakpoint) { padding: 0; width: $bigscreen-breakpoint - $gutter * 2; } @media screen and (min-width: $widescreen-breakpoint) { width: $widescreen-breakpoint - $gutter * 2; } } @mixin padded-code-snippet() { padding: 0 1em; margin: 0 .2em; background: rgba($main-font-color, 0.03); border: 1px dashed lighten($main-font-color, 70); border-radius: .5em; font-size: 80%; } @mixin padded-code-snippet--reset() { padding: 0; margin: 0; background: transparent; border: 0; border-radius: 0; font-size: 100%; } @mixin code-snippet-container() { overflow-x: scroll; overflow-y: hidden; line-height: 1.2; @include padded-code-snippet(); padding-top: .5em; padding-bottom: .75em; margin-top: 1em; margin-bottom: 1em; > code { // Avoid bad formatting in case of element nested // inside a
    @include padded-code-snippet--reset();
  }
}

@mixin code-snippet() {
  color: lighten($main-font-color, 24);

  @include padded-code-snippet();
  margin-top: -1px;
  margin-bottom: -1px;

  code {
    // Avoid bad formatting in case of  elements nested
    // into each other (possible with adoc output)
    @include padded-code-snippet--reset();
  }
}

@mixin cta-button($bgcolor, $color) {
  font-weight: 800;
  font-size: 18px;
  padding: 12px 32px;
  display: inline-block;

  .icon {
    margin-right: 10px;
    font-weight: 400;
    position: relative;
    top: 2px;
    font-size: 120%;
  }

  margin-right: 10px;

  &, &:link, &:visited {
    color: $color;
    background-color: $bgcolor;
  }

  transition: box-shadow .2s ease-out;

  &:hover {
    box-shadow: 0 0 0 4px rgba(black, 0.2);
  }
}

@mixin cta-button-mini($bgcolor, $color) {
  @include cta-button($bgcolor, $color);
  font-size: 14px;
  padding: 6px 16px;
}

@mixin hoverable-card($base-y, $base-blur, $color) {
  $hovered-y: $base-y * 2;
  $hovered-blur: $base-blur * 2;

  box-shadow: 0px $base-y $base-blur $color;

  transition: box-shadow .17s ease, transform .17s ease;

  &:hover {
    transform: translateY(-1px);
    box-shadow: 0px $hovered-y $hovered-blur $color;
  }
}

@mixin reset-list() {
  list-style: none;
  margin: 0;
  padding: 0;
}

@mixin static-link-color($color) {
  &:link, &:hover, &:visited {
    color: $color;
  }
}

@mixin asciidoc-markup($highlight-color) {
  // Used for e.g. code listing headings and tip block labels
  .title {
    text-transform: uppercase;
    font-size: 12px;
    border-radius: .25em;
    background-color: $highlight-color;
    color: white;
    font-weight: bold;
    padding: .3em .6em;
  }

  // Used for tip block labels
  .admonitionblock {
    overflow-x: scroll;

    table:first-child {
      margin-top: 0;
    }
    table:last-child {
      margin-bottom: 0;
    }

    td.icon {
      vertical-align: top;
      padding-left: 0;
    }
    .content {
      font-size: 80%;

      > div:first-child {
        > :first-child {
          margin-top: 0;
        }
      }
      > div:last-child {
        > :last-child {
          margin-bottom: 0;
        }
        &.ulist {
          li:first-child > :first-child {
            margin-top: 0;
          }
          li:last-child > :last-child {
            margin-bottom: 0;
          }
        }
      }
    }
  }
}

@mixin docs-page($primary-dark-color) {
  $side-margin: 16px;  // for external links

  flex: 1;
  display: flex;
  flex-flow: column nowrap;

  .external-links {
    margin-left: -$side-margin;

    ul.section-items {
      @include reset-list();
    }

    > .section-items > .item {
      margin-bottom: 10px;
      margin-right: -$side-margin;

      > a {
        @include static-link-color(#444);
        background-color: #F7F7F7;

        display: block;
        font-weight: bold;
        padding: 4px $side-margin 4px $side-margin;
        border-radius: 10px;

        display: flex;
        flex-flow: row nowrap;

        .lbl {
          flex: 1;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .ico {
          flex-shrink: 0;
          text-align: right;
          width: 32px;
          padding-right: 10px;
        }
        .ico-ext {
          flex-shrink: 0;
          text-align: right;
          width: 32px;
          padding-left: 10px;
          padding-right: 10px;
        }
      }
    }
  }

  > .docs-nav {
    padding-top: 50px;
    background: transparent;

    > .sidebar-header, > section {
      margin-bottom: 15px;
    }

    > .sidebar-header {
      display: flex;
      flex-flow: row nowrap;
      align-items: center;

      .title {
        flex: 1;
        white-space: nowrap;
        line-height: 1;
        font-weight: normal;
        font-size: 15px;
        text-transform: uppercase;
        letter-spacing: 0.08em;

        a { @include static-link-color(#444); }
      }
      .logo-container {
        margin-right: 10px;

        .logo > :only-child {
          width: 32px;
          height: 32px;
        }
      }
    }

    > section {
      > .section-title {
        font-size: 20px;
        font-weight: bold;
        margin: 0;
        line-height: 1.8;
      }

      > .section-items {
        @include reset-list;

        line-height: 2;

        > .item {
          font-size: 15px;
          font-weight: normal;

          &.selected {
            span {
              font-weight: bold;
              color: $primary-dark-color;
            }
          }
          a { @include static-link-color(#444); }
        }
      }
    }
  }

  > article {
    @extend .main-article;
    flex: 1;

    background: white;
    z-index: 1;

    > header > nav,
    > footer > nav {
      line-height: 1;

      button, a {
        border: 0;
        padding: 0;
        margin-right: 1em;

        font-family: inherit;
        font-size: 80%;
        font-weight: bold;

        background: white;
        color: $primary-dark-color;
        cursor: pointer;

        text-decoration: none;

        &:last-child {
          margin-right: 0;
        }

        .ico-ext {
          margin-left: .5em;
        }
      }
    }

    > header > nav {
      margin-top: -2em;
      margin-bottom: 4em;
    }

    > footer > nav {
      margin-top: 2em;
      @media screen and (min-width: $bigscreen-breakpoint) {
        margin-left: 2em;
      }
    }

    > header {
      > .title {
        @media screen and (min-width: $bigscreen-breakpoint) {
          display: flex;
          flex-flow: row nowrap;
        }

        border-bottom: 2px solid $primary-dark-color;
        padding-top: 70px;
        padding-bottom: 20px;

        > .logo-container {
          margin-right: 22px;

          > :only-child {
            width: 58px;
            height: 58px;
          }
        }

        .text {
          flex: 1;
          font-size: 36px;

          margin: 0;
          font-weight: 500;
        }
      }
      .lead {
        font-weight: normal;
        font-size: 20px;
      }
    }

    > .body {
      @include asciidoc-markup($primary-dark-color);
    }
  }

  &.docs-landing {
    flex-direction: column-reverse;

    .external-links > .section-items > .item {
      margin: 0 $side-margin $side-margin $side-margin;

      > a {
        @include static-link-color(#fff);
        background-color: $primary-dark-color;
      }
    }

    > .docs-nav {
      padding-top: 0;
    }

    > article {
      max-width: none;  // Overrides .main-article base style

      > header > .title {
        border-bottom-width: 0;
        padding-bottom: 0;
      }
    }
  }

  &.specs {
    > article {
      max-width: none;
    }
  }

  @media screen and (min-width: $bigscreen-breakpoint) {
    flex-flow: row nowrap;

    > .docs-nav {
      flex: 1;
      flex-grow: 1;
      padding-top: 70px;

      > section > .section-items {
        padding-right: 40px;
      }
    }

    > article {
      flex: 2;
      border-left: #F7F7F7 2px solid;

      > header,
      > .body {
        margin-left: 60px;
      }
    }

    &.docs-landing {
      flex-direction: column-reverse;

      > article {
        border-left-width: 0;

        .external-links {
          > .section-items {
            display: flex;
            flex-flow: row nowrap;
            justify-content: space-between;

            > * {
              flex: 1;
            }
          }
        }

        > header,
        > .body {
          margin-left: 0;
        }

        @media screen and (min-width: $bigscreen-breakpoint) {
          > .body {
            padding-top: 70px;
          }
        }
      }
    }
  }

  &.with-expandable-toc {
    // Is enabled by a script.

    position: relative;

    > article {
      border-left-width: 0;
      padding-top: 2em;

      > header, > .body {
        margin-left: 0;
      }
    }

    > .docs-nav {
      z-index: 4;

      &.top-expandable {
        border-bottom: 1px solid silver;
        z-index: 4;

        position: fixed;
        left: 0;
        right: 0;

        padding-top: 0;
        padding-left: 2em;
        padding-right: 2em;

        transition:
          background 200ms cubic-bezier(0.23, 1, 0.32, 1),
          transform 200ms linear;

        overflow: hidden;

        .sidebar-header {
          background: white;
          cursor: pointer;
          padding-top: 10px;
          padding-bottom: 10px;
        }

        &.expanded {
          box-shadow: 0px -5px 20px 0 rgba(black, 0.4);
          z-index: 6;
          overflow-y: scroll;
          background: white;
          border-bottom: none;
        }
      }

      &.pinned {
        z-index: 4;
        transform: translateY(0);
      }
    }
  }
}