/**
 * Readable post/page tables. Gutenberg has-fixed-layout squashes
 * multi-column RTL tables on phones; stack those as cards instead.
 */

.blog-post .post-content table,
.page .post-content table,
.entry-content table,
.wp-block-table table,
.elementor-widget-text-editor table,
.elementor-widget-html table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  margin: 0 0 1.5em;
}

.wp-block-table table.has-fixed-layout {
  table-layout: auto;
}

.blog-post .post-content .wp-block-table,
.page .post-content .wp-block-table,
.entry-content .wp-block-table,
.elementor-widget-text-editor .wp-block-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.blog-post .post-content th,
.blog-post .post-content td,
.page .post-content th,
.page .post-content td,
.entry-content th,
.entry-content td,
.wp-block-table th,
.wp-block-table td,
.elementor-widget-text-editor th,
.elementor-widget-text-editor td,
.elementor-widget-html th,
.elementor-widget-html td {
  padding: 12px 14px;
  border: 1px solid #e6e4e0;
  vertical-align: top;
  text-align: start;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: manual;
  line-height: 1.6;
}

.blog-post .post-content th,
.page .post-content th,
.entry-content th,
.wp-block-table th,
.blog-post .post-content .grads-table-header-row td,
.page .post-content .grads-table-header-row td,
.entry-content .grads-table-header-row td {
  background: #f4f5f7;
  font-weight: 600;
  color: #0a3d62;
}

.grads-table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 1.5em;
}

.grads-table-wrap > table,
.wp-block-table .grads-table-wrap > table {
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .blog-post .post-content table:not(.grads-post-table--stack):has(tr > :nth-child(3)),
  .page .post-content table:not(.grads-post-table--stack):has(tr > :nth-child(3)),
  .entry-content table:not(.grads-post-table--stack):has(tr > :nth-child(3)),
  .wp-block-table table:not(.grads-post-table--stack):has(tr > :nth-child(3)) {
    min-width: 36rem;
  }

  .grads-table-wrap:has(.grads-post-table--stack) {
    overflow: visible;
  }

  .grads-post-table--stack,
  .grads-post-table--stack thead,
  .grads-post-table--stack tbody,
  .grads-post-table--stack tfoot {
    display: block;
    width: 100%;
  }

  .grads-post-table--stack thead,
  .grads-post-table--stack .grads-table-header-row {
    display: none;
  }

  .grads-post-table--stack tr {
    display: block;
    background: #fff;
    border: 1px solid #e8e6e3;
    border-radius: 12px;
    margin: 0 0 14px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(10, 61, 98, 0.05);
  }

  .grads-post-table--stack td,
  .grads-post-table--stack th {
    display: block;
    width: 100% !important;
    border: 0;
    border-bottom: 1px solid #f0f0f0;
    padding: 10px 16px 12px;
    text-align: start;
  }

  .grads-post-table--stack td:last-child,
  .grads-post-table--stack th:last-child {
    border-bottom: 0;
  }

  .grads-post-table--stack td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    line-height: 1.45;
  }

  .grads-post-table--stack td:first-child {
    background: #f7f8fa;
    font-weight: 700;
    font-size: 16px;
    color: #0a3d62;
    padding-top: 14px;
    padding-bottom: 12px;
  }

  .grads-post-table--stack td:first-child::before,
  .grads-post-table--stack td:not([data-label])::before {
    display: none;
  }
}
