@import '../../../../src/styles/common/colors';
@import '../../../../src/styles/common/mixins';
@import '../../../../src/styles/common/screen';

// TODO: replace all font sizes with variables
.code-example-wrap {
  background: $white;
  border-radius: 2px;
  box-sizing: border-box;
  margin-bottom: 32px;

  header {
    padding: 20px 24px;
    position: relative;

    h3 {
      display: inline;
    }

    // Local Overrides
    button {
      padding: 8px 4px;
      position: absolute;
      top: 15px;
      right: 5px;

      .button-icon-wrap {
        position: relative;
        top: 1px;
        transition: transform .25s ease-out;
      }
      svg:first-child {
        margin-right: -2px;
      }
      svg:nth-child(2) {
        transition: .25s ease-out;
      }

      @media #{$media-small-minus} {
        margin-right: 10px;
      }
    }

    button.active {
      .button-icon-wrap {
        transform: rotate(90deg);
      }
      svg:first-child {
        opacity: 0;
        visibility: hidden;
      }
      svg:nth-child(2) {
        left: -6px;
        position: relative;
        top: 1px;
      }
    }

    @media #{$media-small-minus} {
      padding: 15px 60px 15px 15px;
    }
  }

  .component {
    @include clearfix;
    padding: 20px 24px;

    code {
      display: block;
      margin-top: 1em;
      word-break: break-word;
    }

    > a {
      color: $primary-1;
      text-decoration: none;
    }

    @media #{$media-small-minus} {
      padding: 20px 15px;
    }
  }

  .body {
    height: 0;
    max-height: 0;
    overflow: hidden;
    padding: 0;

    &.open {
      height: auto;
      padding: 20px 24px;
      max-height: 1000px;
      overflow: auto;
      transition: max-height 800ms ease-out;

      @media #{$media-small-minus} {
        padding: 20px 15px;
      }
    }

    > p {
      margin: 0;
    }

    pre, code {
      margin: 0;
      padding: 0;
    }

    pre {
      background: linear-gradient(
        to bottom,
        $neutral-2 50%,
        $neutral-2,
        $white,
        $white 50%
      );
      background-size: 100% 44px;
      padding: 1px 6px;
    }

    code {
      @include monospace;
      margin-bottom: -2px;
      white-space: pre-wrap;
    }
  }

  .description {
    padding: 20px 24px;

    > a {
      color: $primary-1;
    }

    > p {
      color: $base-text;
      font-size: 14px;
      margin: 0;
    }

    code {
      @include monospace;
      background-color: rgba(0,0,0,.04);
      border-radius: 3px;
      margin: 0;
      padding: .2em;
    }

    @media #{$media-small-minus} {
      padding: 20px 15px;
    }
  }

  @media #{$media-small-minus} {
    margin-bottom: 16px;
  }
}

// Styles for Highlight.js
// http://highlightjs.readthedocs.org/en/latest/css-classes-reference.html
:global {
  .hljs {
    display: block;
    overflow-x: auto;
    padding: 0.5em;

    .hljs-string,
    .hljs-section,
    .hljs-function,
    .hljs-selector-class,
    .hljs-template-variable,
    .hljs-deletion {
      color: $red;
    }
    .hljs-string {
      white-space: normal;
    }
    .hljs-keyword {
      color: $black;
      font-weight: bold;
    }
    .hljs-subst {
      color: $black;
    }
  }
}
