@use '../colors';
@use '../breakpoints';

.root {
  color: colors.$basic-gray87;
  font-size: 16px;
  line-height: 24px;

  // сброс отступов
  * {
    border: 0;
    margin: 0;
    padding: 0;
  }

  // ссылки
  a {
    color: colors.$basic-blue;
    text-decoration: none;
    &:hover {
      color: colors.$additional-deep-blue;
    }
  }

  // параграф
  p {
    margin-bottom: 24px;
  }

  // курсив
  i,
  em {
    font-style: normal; // да, вот так по гайдам
  }

  // заголовки
  h1 {
    font-weight: 600;
    font-size: 24px;
    line-height: 32px;
    margin-bottom: 32px;
  }
  h2 {
    font-weight: 600;
    font-size: 20px;
    line-height: 28px;
    margin-bottom: 24px;
  }
  h3 {
    font-weight: 600;
    font-size: 16px;
    line-height: 24px;
    margin-bottom: 24px;
  }
  h4 {
    font-weight: 600;
    font-size: 16px;
    line-height: 24px;
    color: colors.$basic-gray38;
    margin-bottom: 16px;
  }
  h5 {
    font-weight: normal;
    font-size: 14px;
    line-height: 20px;
    color: colors.$basic-gray38;
    margin-bottom: 24px;
  }
  h6 {
    font-weight: normal;
    font-size: 12px;
    line-height: 16px;
    margin-bottom: 24px;
  }

  @include breakpoints.gte('xs') {
    h1 {
      font-weight: bold;
      font-size: 32px;
      line-height: 40px;
      margin-bottom: 32px;
    }
    h2 {
      font-weight: 600;
      font-size: 24px;
      line-height: 32px;
      margin-bottom: 24px;
    }
    h3 {
      font-weight: 600;
      font-size: 20px;
      line-height: 28px;
      margin-bottom: 24px;
    }
    h4 {
      font-weight: 600;
      font-size: 16px;
      line-height: 24px;
      color: colors.$basic-gray38;
      margin-bottom: 16px;
    }
    h5 {
      font-size: 14px;
      line-height: 20px;
      color: colors.$basic-gray38;
      margin-bottom: 24px;
    }
    h6 {
      font-size: 12px;
      line-height: 16px;
    }
  }

  // списки
  ol,
  ul {
    margin-bottom: 24px;
    li + li {
      margin-top: 16px;
    }
  }
  ol {
    // ВАЖНО: экспериментально используем стили таблицы чтобы содержимое элемента списка не залезало под номер
    // это не позволяет сделать отступ от номера 12px по гайдам - согласовано с дизайнерами
    // при возникновении проблем пересмотреть подход
    display: table;
    border-spacing: 0 16px;
    counter-reset: ordered-list;
    list-style: none;
    li {
      display: table-row;
      counter-increment: ordered-list;
    }
    li::before {
      content: counter(ordered-list) '.';
      display: table-cell;

      // ВАЖНО: 10 вместо 12 по гайдам - согласовано с дизайнерами
      // уменьшили потому что при табличной стилизации отступ от номера формируется по самому длинному номеру
      padding-right: 10px;
    }
  }
  ul {
    display: table;
    border-spacing: 0 16px;
    list-style: none;
    li {
      display: table-row;
      counter-increment: ordered-list;
    }
    li::before {
      content: '—';
      display: table-cell;
      padding-right: 10px;
    }
  }

  // таблицы
  table {
    width: 100%;
    margin-bottom: 40px;
    border-collapse: collapse;
  }
  @include breakpoints.gte('xs') {
    table {
      thead {
        color: colors.$basic-gray38;
        font-size: 14px;
        line-height: 20px;
        td,
        th {
          padding-top: 0;
        }
      }
      td {
        border: 0;
        padding: 24px 0;

        // накидываем именно сюда чтобы работало в Safari
        box-shadow: inset 0 -1px 0 colors.$basic-gray12;
        &:not(:last-child) {
          padding-right: 32px;
        }
      }
    }
  }
  @include breakpoints.lt('xs') {
    table,
    tr,
    th,
    td,
    thead,
    tbody {
      display: block;
    }
    table {
      box-shadow: inset 0 1px 0 colors.$basic-gray12;
    }
    thead {
      position: absolute;
      top: -9999px;
      left: -9999px;
    }
    tr {
      padding: 32px 0;
      box-shadow: inset 0 -1px 0 colors.$basic-gray12;
    }
    td + td {
      margin-top: 24px;
    }
    td::before {
      content: attr(data-table-column-title);
      display: block;
      font-size: 14px;
      line-height: 20px;
      color: colors.$basic-gray38;
      margin-bottom: 8px;
    }
  }

  // медиа
  img,
  video {
    display: block;
    max-width: 100%;
    margin-bottom: 32px;
    @include breakpoints.gte('xs') {
      margin-bottom: 40px;
    }
  }

  // цитата
  blockquote {
    position: relative;
    display: block;
    font-weight: 600;
    font-size: 16px;
    line-height: 24px;
    padding-left: 40px;
    &::before {
      content: '';
      position: absolute;
      left: 0;

      /* stylelint-disable-next-line function-url-quotes */
      background-image: url('data:image/svg+xml,%3Csvg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="32" height="32"/%3E%3Cpath d="M15.1665 5.33301H8.36963L2.6665 26.0361H12.1196L15.1665 5.33301ZM28.9165 5.33301H22.1196L16.4165 26.0361H25.8696L28.9165 5.33301Z" fill="%23E0E0E0"/%3E%3C/svg%3E%0A');
      width: 32px;
      height: 32px;
    }
    @include breakpoints.gte('xs') {
      font-size: 20px;
      line-height: 28px;
      padding-left: 72px;
      &::before {
        /* stylelint-disable-next-line function-url-quotes */
        background-image: url('data:image/svg+xml,%3Csvg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="48" height="48"/%3E%3Cpath d="M22.75 8H12.5547L4 39.0547H18.1797L22.75 8ZM43.375 8H33.1797L24.625 39.0547H38.8047L43.375 8Z" fill="%23E0E0E0"/%3E%3C/svg%3E%0A');
        width: 48px;
        height: 48px;
      }
    }
    * {
      margin: 0;
    }
    cite {
      display: block;
      margin-top: 16px;
      font-style: normal;
      font-weight: normal;
      font-size: 16px;
      line-height: 24px;
      color: colors.$basic-gray38;
    }
  }

  // горизонтальная черта
  hr {
    display: block;
    width: 100%;
    height: 1px;
    background: colors.$basic-gray12;
    margin-bottom: 32px;
    @include breakpoints.gte('xs') {
      margin-bottom: 40px;
    }
  }
}
