/* Wateerati — Global Article Tables v1.0
 * Scope: front-end article body only. Works with plain HTML and Gutenberg tables.
 * Requires assets/js/article-tables.js for responsive wrapping of bare HTML tables.
 */
.article-body {
  --wat-table-forest: #20583f;
  --wat-table-forest-dark: #174532;
  --wat-table-border: #dae6dd;
  --wat-table-ink: #22392e;
  --wat-table-muted: #607368;
  --wat-table-cream: #f6f8f3;
  --wat-table-hover: #ebf5ec;
  --wat-table-radius: 16px;
}

/* Each table gets its own horizontal scroll region. Gutenberg already has a figure wrapper;
   plain HTML tables are wrapped by article-tables.js. */
.article-body :is(.wat-table-scroll, figure.wp-block-table) {
  max-inline-size: 100%;
  margin-block: 1.65rem 2rem;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--wat-table-border);
  border-radius: var(--wat-table-radius);
  background: #fff;
  box-shadow: 0 8px 25px rgb(23 69 50 / 7%);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  scrollbar-color: #b2cfbb #f4f8f4;
  scrollbar-width: thin;
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table {
  display: table;
  inline-size: 100%;
  min-inline-size: 100%;
  margin: 0;
  border: 0;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 0;
  box-shadow: none;
  background: #fff;
  color: var(--wat-table-ink);
  font: inherit;
  font-size: clamp(.88rem, 1.2vw, 1rem);
  line-height: 1.8;
  table-layout: auto;
  direction: inherit;
}

/* Markup should use <thead> or <th>; never style an unlabeled data row as a heading. */
.article-body :is(.wat-table-scroll, figure.wp-block-table) > table thead th {
  background: var(--wat-table-forest);
  color: #fff;
  font-weight: 700;
  border-block-end: 1px solid var(--wat-table-forest-dark);
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table tbody th {
  background: #eff5ef;
  color: var(--wat-table-forest-dark);
  font-weight: 700;
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table :is(th, td) {
  padding: .95rem 1rem;
  vertical-align: middle;
  text-align: start;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  border-block-end: 1px solid var(--wat-table-border);
  border-inline-end: 0;
  border-inline-start: 0;
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table tr > * + * {
  border-inline-start: 1px solid var(--wat-table-border);
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table tbody tr:nth-child(even),
.article-body figure.wp-block-table.is-style-stripes > table tbody tr:nth-child(even) {
  background: var(--wat-table-cream);
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table tbody tr:nth-child(odd),
.article-body figure.wp-block-table.is-style-stripes > table tbody tr:nth-child(odd) {
  background: #fff;
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table tbody tr:hover > :is(th,td) {
  background: var(--wat-table-hover);
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table tbody tr:last-child > :is(th,td),
.article-body :is(.wat-table-scroll, figure.wp-block-table) > table tfoot tr:last-child > :is(th,td) {
  border-block-end: 0;
}

.article-body :is(.wat-table-scroll, figure.wp-block-table) > table caption {
  caption-side: top;
  padding: .7rem 1rem;
  color: var(--wat-table-muted);
  font-size: .875rem;
  text-align: start;
  font-weight: 600;
}

.article-body figure.wp-block-table figcaption {
  margin: 0;
  padding: .75rem 1rem;
  background: #f8faf7;
  border-block-start: 1px solid var(--wat-table-border);
  color: var(--wat-table-muted);
  font-size: .875rem;
  line-height: 1.6;
  text-align: start;
}

/* Right-to-left and left-to-right tables both remain accessible.
   Numbers can be tagged <span dir="ltr"> for correct numeral order. */
.article-body :is(.wat-table-scroll, figure.wp-block-table):focus-visible {
  outline: 3px solid #b3dc91;
  outline-offset: 3px;
}

@media (max-width: 700px) {
  .article-body :is(.wat-table-scroll, figure.wp-block-table) {
    margin-block: 1.25rem 1.6rem;
    border-radius: 12px;
  }
  .article-body :is(.wat-table-scroll, figure.wp-block-table) > table {
    min-inline-size: 560px;
    font-size: .88rem;
  }
  .article-body :is(.wat-table-scroll, figure.wp-block-table) > table :is(th,td) {
    padding: .75rem .85rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .article-body :is(.wat-table-scroll, figure.wp-block-table) > table tbody tr > :is(th,td) {
    transition: background-color 150ms ease;
  }
}

@media print {
  .article-body :is(.wat-table-scroll, figure.wp-block-table) {
    overflow: visible;
    box-shadow: none;
    border: 1px solid #bbb;
  }
  .article-body :is(.wat-table-scroll, figure.wp-block-table) > table {
    min-inline-size: 0;
    font-size: 9pt;
  }
  .article-body :is(.wat-table-scroll, figure.wp-block-table) > table thead th {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
