/* stylelint-disable selector-max-compound-selectors */
/* stylelint-disable no-descending-specificity */
/* stylelint-disable declaration-property-value-disallowed-list */
/* stylelint-disable scss/selector-no-redundant-nesting-selector */
@mixin markdown-table($row: #fff, $head: #f6f8fa, $stripe: #fbfcfd, $edges: #dfe2e5) {
  table {
    border-collapse: collapse;
    border-spacing: 0;
    color: var(--table-text);
    display: table;
    width: 100%;

    thead {
      color: var(--table-head-text, inherit);
    }

    thead tr {
      background: var(--table-head, #{$head});
    }

    tr {
      background-color: var(--table-row, #{$row});

      & + tr {
        border-top: 1px solid var(--table-edges, #{$edges});
      }
    }

    th,
    thead td {
      font-weight: 600;

      &:empty {
        padding: 0;
      }
    }

    td,
    th {
      border: 1px solid var(--table-edges, #{$edges});
      color: inherit;
      padding: 6px 13px;
      vertical-align: middle;

      > :first-child,
      > :only-child {
        margin-top: 0 !important;
      }

      > :last-child,
      > :only-child {
        margin-bottom: 0 !important;
      }
    }

    &:not(.plain) tr:nth-child(2n) {
      background-color: var(--table-stripe, #{$stripe});
    }
  }
}

.markdown-body {
  @include markdown-table;

  .rdmd-table {
    $border-wrap-width: 1px;

    display: block;
    position: relative;

    &-inner {
      box-sizing: content-box;
      min-width: 100%;
      overflow: auto;
      width: 100%;
    }

    table {
      border: 1px solid var(--table-edges, #dfe2e5);

      &:only-child {
        margin: 0 !important;

        thead th {
          background: inherit;
        }

        td:last-child,
        th:last-child {
          border-right: none;
        }

        thead tr,
        thead th:last-child {
          box-shadow: 3px 0 0 var(--table-head);
        }
      }
    }
  }
}
