//-----------------------------
// Modules
//-----------------------------

@import '../../globals/scss/vars';
@import '../../globals/scss/colors';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/layer';
@import '../../globals/scss/typography';
@import '@carbon/import-once/scss/import-once';
@import '../../globals/scss/css--reset';
@import '../../globals/scss/css--typography';
@import '../Link/link';

@mixin text {
  code {
    @extend .#{$prefix}--text__code;
  }
  p {
    @extend .#{$prefix}--text__p;
  }

  h2 {
    @extend .#{$prefix}--text__h2;
  }

  i {
    @extend .#{$prefix}--text__i;
  }

  h3 {
    @extend .#{$prefix}--text__h3;
  }

  h4 {
    @extend .#{$prefix}--text__h4;
  }

  h5 {
    @extend .#{$prefix}--text__h5;
  }

  a {
    @extend .#{$prefix}--text__a;
  }

  sup {
    @extend .#{$prefix}--text__sup;
  }

  b,
  strong {
    @extend .#{$prefix}--text__b;
  }

  /* All the line spacings */

  .#{$prefix}--blockquote {
    & + p,
    & + h3 {
      margin-top: $spacing-lg;
    }
  }

  p + .#{$prefix}--blockquote {
    margin-top: $spacing-sm;
  }

  p + h2 {
    margin-top: $spacing-2xl;
  }

  ul + h2 {
    margin-top: $spacing-xl;
  }

  p + h3 {
    margin-top: $spacing-2xl;
  }

  h1 + h2 {
    margin-top: $spacing-lg;
  }

  h2 + h3 {
    margin-top: $spacing-lg;
  }

  p + ul,
  h3 + ul,
  h4 + ul {
    margin-top: $spacing-md;
  }

  h3 + p {
    margin-top: $spacing-sm;
  }

  button + p {
    margin-top: $spacing-sm;
  }

  div + h4,
  h3 + h4 {
    margin-top: $spacing-lg;
  }

  .wfp--text__h4 + div,
  h4 + div {
    margin-top: $spacing-md;
  }

  h1 + .wfp--list,
  h2 + .wfp--list,
  h3 + .wfp--list,
  h4 + .wfp--list,
  h5 + .wfp--list,
  .wfp--text__h1 + .wfp--list,
  .wfp--text__h2 + .wfp--list,
  .wfp--text__h3 + .wfp--list,
  .wfp--text__h4 + .wfp--list,
  .wfp--text__h5 + .wfp--list {
    margin-top: $spacing-md;
  }

  h1 + iframe,
  h2 + iframe,
  h3 + iframe,
  h4 + iframe,
  h5 + iframe {
    margin-top: $spacing-xs;
  }

  iframe + h1,
  iframe + h2,
  iframe + h3,
  iframe + h4,
  iframe + h5 {
    margin-top: $spacing-md;
  }

  .#{$prefix}--text__list {
    list-style-position: outside;
    line-height: 1.6em;
    margin: $spacing-md 0 $spacing-md 1.5em;

    li {
      list-style-type: disc;
    }
  }

  .#{$prefix}--text__sub-heading {
    @include typescale('zeta');
    font-weight: normal;
    color: var(--ui-05);
    margin-top: $spacing-2xs !important;
    margin-bottom: $spacing-2xs;
    font-style: italic;
    //text-transform: uppercase;
    font-weight: 400;

    //letter-spacing: 0.05em;
  }

  .#{$prefix}--text__type-beta {
    margin-bottom: $spacing-lg;
  }

  .#{$prefix}--markup {
    font-style: italic;
    @include typescale('delta');
    margin-bottom: $spacing-lg;
  }

  .#{$prefix}--inline-highlight {
    display: inline-block;
    font-weight: 600;
    background: var(--ui-03);
    padding: 0.05em 0.1em;
  }

  .#{$prefix}--text__divider {
    border: 1px solid var(--ui-04);
  }

  .#{$prefix}--text__divider--lg {
    border: 2px solid var(--ui-04);
  }
}

@include exports('text') {
  .#{$prefix}--text {
    @include reset;
    @include font-family;
    &__center {
      text-align: center;
    }

    &__full-height {
      min-height: 65vh;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
    @include text;
  }
  .#{$prefix}--text {
    @include text;
  }

  .#{$prefix}--text__a {
    &:hover {
      text-decoration: underline;
    }
    //@extend .wfp--link;
  }

  a.#{$prefix}--btn {
    &:hover {
      text-decoration: none;
    }
  }

  .#{$prefix}--blockquote {
    p {
      margin: 0;
    }
  }

  .#{$prefix}--text__title {
    @include typescale('mega');
    font-weight: 300;
    margin-bottom: $spacing-xl;
    margin-left: -0.058em;
  }

  .#{$prefix}--text__content-title {
    @include typescale('alpha');
    font-weight: 300;
    margin-bottom: $spacing-lg;
    margin-left: -0.058em;
  }

  .#{$prefix}--text__subtitle {
    @include typescale('zeta');
    font-weight: normal;
    color: var(--interactive-01);
    margin-top: $spacing-xl;
    margin-bottom: $spacing-2xs;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
  }

  .#{$prefix}--text__code {
    @include typescale('epsilon');
    font-family: monospace;
  }

  .#{$prefix}--text__p {
    margin-top: $spacing-md;
    line-height: 1.6em;

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

  .#{$prefix}--text__i {
    font-style: italic;
  }
  .#{$prefix}--text__h2 {
    margin-top: $spacing-xl;

    &.before--img {
      margin-bottom: 0;
    }
  }

  .#{$prefix}--text__h3 {
    margin-top: $spacing-xl;
  }

  .#{$prefix}--text__h4 {
    margin-top: $spacing-lg;
    // @include typescale('epsilon');
  }

  .#{$prefix}--text__h5 {
    margin-top: $spacing-lg;
    // @include typescale('epsilon');
  }

  .#{$prefix}--text__caption {
    @include typescale('omega');
  }

  .#{$prefix}--text__sup {
    font-size: 0.7em;
    background: var(--ui-03);
    vertical-align: top;
    position: relative;
    top: -0.5em;

    > a {
      text-decoration: none;

      &:before {
        content: '[';
      }

      &:after {
        content: ']';
      }
    }
  }

  .#{$prefix}--text__inline-highlight {
    display: inline-block;
    font-weight: 600;
    background: var(--ui-03);
    padding: 0.05em 0.1em;
  }

  .docblock-source {
    margin-top: $spacing-xs !important;
  }
  .#{$prefix}--text__bold {
    font-weight: 600;
  }

  .#{$prefix}--text__b,
  .#{$prefix}--text__strong {
    font-weight: 600;
  }

  @each $size, $glyph in $spacing-map {
    .#{$prefix}--text-top-#{$size} {
      margin-top: map-get($spacing-map, $size);
    }
    .#{$prefix}--text__spacing-bottom-#{$size} {
      margin-bottom: map-get($spacing-map, $size);
    }
  }
}
