@import '../../style/themes/index';
@import '../../style/mixins/index';

@typography-prefix-cls: ~'@{ant-prefix}-typography';
// =============== Basic ===============
.@{typography-prefix-cls} {
  color: @text-color;
  overflow-wrap: break-word;

  &&-white {
    color: @white;
  }

  &&-primary {
    color: @text-color;
  }

  &&-brand {
    color: @primary-color;
  }

  &&-secondary {
    color: @text-color-secondary;
  }

  &&-success {
    color: @success-color;
  }

  &&-warning {
    color: @warning-color;
  }

  &&-danger {
    color: @error-color;

    a&:active,
    a&:focus {
      color: @error-color-active;
    }

    a&:hover {
      color: @error-color-hover;
    }
  }

  &&-link {
    color: @link-color;

    a&:active,
    a&:focus {
      color: @link-active-color;
    }

    a&:hover {
      color: @link-hover-color;
    }
  }

  &&-disabled {
    color: @disabled-color;
    cursor: not-allowed;
    user-select: none;
  }

  &&-placeholder {
    color: @color-gray-400;
  }

  &&-background {
    color: @color-gray-50;
  }

  // Tag
  // div&,
  p {
    .typography-paragraph();
  }


    h1&,
  h2&,
  h3&,
  h4&,
  h5&,
  h6& {
    .@{typography-prefix-cls} + & {
      margin-top: @typography-title-margin-top;
    }
  }

  div,
  ul,
  li,
  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    + h1,
    + h2,
    + h3,
    + h4,
    + h5,
    + h6 {
      margin-top: @typography-title-margin-top;
    }
  }

  a&-ellipsis,
  span&-ellipsis {
    display: inline-block;
    max-width: 100%;
  }

  a&,
  a {
    .operation-unit();
    text-decoration: @link-decoration;

    &:active,
    &:hover {
      text-decoration: @link-hover-decoration;
    }

    &[disabled],
    &.@{typography-prefix-cls}-disabled {
      color: @disabled-color;
      cursor: not-allowed;

      &:active,
      &:hover {
        color: @disabled-color;
      }

      &:active {
        pointer-events: none;
      }
    }
  }

  code {
    margin: 0 0.2em;
    padding: 0.2em 0.4em 0.1em;
    font-size: 85%;
    background: rgba(150, 150, 150, 0.1);
    border: 1px solid rgba(100, 100, 100, 0.2);
    border-radius: 3px;
  }

  kbd {
    margin: 0 0.2em;
    padding: 0.15em 0.4em 0.1em;
    font-size: 90%;
    background: rgba(150, 150, 150, 0.06);
    border: 1px solid rgba(100, 100, 100, 0.2);
    border-bottom-width: 2px;
    border-radius: 3px;
  }

  mark {
    padding: 0;
    background-color: @gold-3;
  }

  u,
  ins {
    text-decoration: underline;
    text-decoration-skip-ink: auto;
  }

  s,
  del {
    text-decoration: line-through;
  }

  strong {
    font-weight: 600;
  }

  // Operation
  &-expand,
  &-edit,
  &-copy {
    .operation-unit();

    margin-left: 4px;
  }

  &-copy-success {
    &,
    &:hover,
    &:focus {
      color: @success-color;
    }
  }

  // Text input area
  &-edit-content {
    position: relative;

    div& {
      left: -@input-padding-horizontal - 1px;
      margin-top: -@input-padding-vertical-base - 1px;
      margin-bottom: calc(1em - @input-padding-vertical-base - 1px);
    }

    &-confirm {
      position: absolute;
      right: 10px;
      bottom: 8px;
      color: @text-color-secondary;
      // default style
      font-weight: normal;
      font-size: @font-size-base;
      font-style: normal;
      pointer-events: none;
    }

    // Fix Editable Textarea flash in Firefox
    textarea {
      // https://stackoverflow.com/a/7695964/3040605
      height: 1em;
      margin: 0 !important;
      /* stylelint-disable-next-line property-no-vendor-prefix */
      -moz-transition: none;
    }
  }

  // list
  ul,
  ol {
    margin: 0 0 1em;
    padding: 0;

    li {
      margin: 0 0 0 20px;
      padding: 0 0 0 4px;
    }
  }

  ul {
    list-style-type: circle;

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

  ol {
    list-style-type: decimal;
  }

  // pre & block
  pre,
  blockquote {
    margin: 1em 0;
  }

  pre {
    padding: 0.4em 0.6em;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: rgba(150, 150, 150, 0.1);
    border: 1px solid rgba(100, 100, 100, 0.2);
    border-radius: 3px;

    // Compatible for marked
    code {
      display: inline;
      margin: 0;
      padding: 0;
      font-size: inherit;
      font-family: inherit;
      background: transparent;
      border: 0;
    }
  }

  blockquote {
    padding: 0 0 0 0.6em;
    border-left: 4px solid rgba(100, 100, 100, 0.2);
    opacity: 0.85;
  }

  // ============ Ellipsis ============
  &-single-line {
    white-space: nowrap;
  }

  &-ellipsis-single-line {
    overflow: hidden;
    text-overflow: ellipsis;

    // https://blog.csdn.net/iefreer/article/details/50421025
    a&,
    span& {
      vertical-align: bottom;
    }
  }

  &-ellipsis-multiple-line {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }
}

p {
  .typography-paragraph();
}
  // MSB modified heading 1,2,3,4,5,6
  each(range(6), {
    @size: "heading-@{value}-size";
    @lineHeight: "heading-@{value}-line-height";
    h@{value}&,  div&-h@{value},
    div&-h@{value} > textarea,
    h@{value}{
      .typography(
        @@size,
        @typography-font-semibold,
        @@lineHeight,
        @typography-title-margin-bottom
      );
    }
    @media only screen and (max-width: @mobile-max-width) {
      @size: "mobile-heading-@{value}-size";
      @lineHeight: "mobile-heading-@{value}-line-height";
      h@{value}&,  div&-h@{value},
      div&-h@{value} > textarea,
      h@{value}{
        .typography(
          @@size,
          @typography-font-semibold,
          @@lineHeight,
          @typography-title-margin-bottom
        );
      }
    }
  });
  // MSB modified typography-heading
  .typography-generate-v2(heading, 6, false, 6);
  @media only screen and (max-width: @mobile-max-width) {
    .typography-generate-v2(heading, 6, mobile, 6);
  }

  // MSB modified typography-title
  .typography-generate(title, 6, false, 6);
  @media only screen and (max-width: @mobile-max-width) {
    .typography-generate(title, 6, mobile, 6);
  }
  // MSB modified typography-subtile
  .typography-generate(subtitle, 6, false, 0);
  @media only screen and (max-width: @mobile-max-width) {
    .typography-generate(subtitle, 3, mobile, 0);
  }
  // MSB modified typography-caption
  .typography-generate(caption, 2, false, 0);
  @media only screen and (max-width: @mobile-max-width) {
    .typography-generate(caption, 2, mobile, 0);
  }
  // MSB modified typography-note
  .typography-generate(note, 4, false, 0);
  @media only screen and (max-width: @mobile-max-width) {
    .typography-generate(note, 4, mobile, 0);
  }

  .typography-title-v2 {
    .typography(@title-size-v2, @typography-font-base, @title-line-height-v2, 0)
  }

  .typography-base-v2 {
    .typography(@base-size-v2, @typography-font-base, @base-line-height-v2, 0)
  }

  .typography-base-small-v2 {
    .typography(@base-small-size-v2, @typography-font-base, @base-small-line-height-v2, 0)
  }

  .typography-caption-v2 {
    .typography(@caption-size-v2, @typography-font-base, @caption-line-height-v2, 0);
  }

  .typography-tiny-v2 {
    .typography(@tiny-size-v2, @typography-font-base, @tiny-line-height-v2, 0);
  }

  // MSB modified generate font-weight
  /* stylelint-disable-next-line at-rule-no-unknown */
each(@font-weight-type, {
    &.font-@{value} {
      @font-weight: 'typography-font-@{value}';
      font-weight: @@font-weight;
    }
  })

@import './rtl';
