/* ==========================================================================
   Code
   ========================================================================== */

* code {
  display: inline-block;
  color: rgba($primary, .6);
  background: rgba($primary, .1);
  font-size: 100%;
  font-family: $font-mono;
  padding: 0 4px;
}

* .code {
  margin: 0;
  background: transparent;
}

p code {
  line-height: 22px;
}
h4 code {
  line-height: 24px;
}
h6 code {
  line-height: 26px;
}

p a:not([class]),
li a:not([class]) {
  border-bottom: 1px dashed rgba($primary, .4);
  color: inherit;

  &:hover {
    border-bottom: 1px dashed $accent;
    color: $accent;
  }
}

/* Navigation Tabs
   ========================================================================== */

.nav.nav-tabs.nav-code-tabs {
  border-width: 0px;
  padding: 0 24px;
}

.nav.nav-tabs.nav-code-tabs > li > button {
  background: transparent;
  border-width: 0px;
  color: rgba($primary, .8);
  font-family: $font-primary;
  font-size: 13px;
  font-weight: 700;
  line-height: 24px;
  text-transform: uppercase;
  padding: 0;
  margin-right: 12px;

  &:hover,
  &:focus {
    background: transparent;
    color: rgba($primary, .6);
    outline: none;
  }
}

.nav.nav-tabs.nav-code-tabs > li:last-child > button {
  margin-right: 0;
}

.nav.nav-tabs.nav-code-tabs > li.active > button {
  border-width: 0px;
  color: $accent;
}

.nav.nav-tabs.nav-code-tabs ~ .code-container {
  margin: 0 0 calc(1rem * #{$lineHeight});
}

/* CodeMirror
   ========================================================================== */

.code-container {
  position: relative;
  margin: calc(1rem * #{$lineHeight}) 0;

  width: calc(100% + 40px);
  left: -20px;

  @media (min-width: $screen-sm-min) {
    width: 100%;
    left: 0px;
  }
}

.code-container .CodeMirror {
  animation: fadeIn .5s cubic-bezier(.3, 0, .3, 1) 0s 1 forwards;
  border-radius: 0px;
  height: auto;
  opacity: 0;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 0;

  @media (min-width: $screen-sm-min) {
    border-radius: 4px;
  }
}

.code-container .CodeMirror-sizer {
  margin-left: 60px !important;
}

.code-container .CodeMirror-gutter-wrapper {
  left: -60px !important;
}

.code-container .CodeMirror-gutter.CodeMirror-linenumbers {
  width: 60px !important;
}

.code-container .CodeMirror-linenumber {
  color: rgba($white, .40);
  font-size: 13px;
  line-height: 24px;
  left: 24px !important;
  padding: 0;
  text-align: left;
  width: 36px !important;
}

.code-container .CodeMirror-lines {
  padding: 12px 0;
}

.code-container .CodeMirror-gutters {
  left: 0 !important;
}

.code-container .CodeMirror,
.code-container pre {
  font-family: $font-mono;
}

.code-container pre {
  border: 0;
  font-size: 14px;
  line-height: 24px;
  margin: 0;
  opacity: 0;
  padding: 12px 4px;
  position: relative;
}

.code-container pre code {
  white-space: pre;
}

.code-container .CodeMirror pre {
  font-size: 13px;
  line-height: 24px;
  opacity: 1;
  padding: 0;
  margin: 0;
  z-index: 6;
}

.code-container .btn-copy:focus, .code-container:hover .btn-copy {
  opacity: 1;
}

.code-container .btn-copy {
  @include anim(all);
  background: $primary;
  border-radius: 4px;
  color: $white;
  height: 36px;
  line-height: 24px;
  padding: 0;
  opacity: 0;
  position: absolute;
  right: 6px;
  top: 6px;
  width: 36px;
  z-index: 999;

  &::before {
    @include anim(background);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: rgba($white, .2);
    z-index: 1;
  }

  &:hover {
    background: $primary;

    &::before {
      background: rgba($white, .4);
    }
  }

  > [class*="icon-"] {
    font-size: 12px;
  }
}

/* Scrollbar
   ========================================================================== */

@mixin scrollbar() {
  ::-webkit-scrollbar {
    width: 16px;
  }

  ::-webkit-scrollbar:horizontal {
    height: 16px;
  }

  ::-webkit-scrollbar-thumb {
    transition: all .3s ease-in-out;
    border-radius: 12px;
  }
}

@mixin scrollbar-dark() {
  @include scrollbar();

  ::-webkit-scrollbar-track {
    background-color: rgba($primary, .8);
  }

  ::-webkit-scrollbar-track:vertical {
    background-color: $color-charade;
    border-width: 0px;
  }

  ::-webkit-scrollbar-track:horizontal {
    background-color: $color-charade;
    border-width: 0px;
  }

  ::-webkit-scrollbar {
    background-color: transparent;
  }

  ::-webkit-scrollbar-thumb {
    background-color: rgba($white, .4);
    border: 4px solid $color-charade;
  }

  ::-webkit-scrollbar-thumb:hover {
    background-color: rgba($white, .6);
  }

  ::-webkit-scrollbar-corner {
    background-color: transparent;
  }
}

@mixin scrollbar-light() {
  @include scrollbar();

  ::-webkit-scrollbar-track {
    background-color: white;
  }

  ::-webkit-scrollbar-track:vertical {
    background-color: $gray-lighter;
    border-width: 0px;
  }

  ::-webkit-scrollbar-track:horizontal {
    background-color: $gray-lighter;
    border-width: 0px;
  }

  ::-webkit-scrollbar {
    background-color: white;
  }

  ::-webkit-scrollbar-thumb {
    background-color: $gray-light;
    border: 4px solid $gray-lighter;
  }

  ::-webkit-scrollbar-thumb:hover {
    background-color: $gray-light;
  }

  ::-webkit-scrollbar-corner {
    background-color: $gray-lighter;
  }
}

.code-container .CodeMirror.cm-s-dracula {
  @include scrollbar-dark();
}
