/* ERA mobile data tables
 * Stack wide content-area tables into cards below Avada's content breakpoint
 * (800px; --content_break_point: 800). Desktop layout is unchanged: every
 * visual rule lives inside the media query. The companion script only adds
 * data-era-stack, data-label, data-card-suffix and an optional aria-label.
 *
 * This also overrides two existing mobile "scroll the table sideways" rules:
 *   1) era-content-design (functions.php, 800px): overflow-x: auto and
 *      th/td min-width: 150px on .era-design-interior .fusion-content-tb table
 *   2) style.css (767px): min-width: 560px and overflow-x: auto on
 *      body.page-id-13819 .fusion-accordian .panel-body table
 *
 * Colors (from live CSS):
 *   Dues table headers / first-column th: #164f73 (white text)
 *   Site-wide content tables: var(--era-navy, #0e4a71)
 *   Borders: #dce3ea / #e7ebef   Zebra: #f6f8fa   Caption/labels: #164f73
 */

@media (max-width: 800px) {

  /* Stop the page-level sideways scroller once a table has been marked. */
  body.page-id-13819 .fusion-accordian .panel-body:has(table[data-era-stack]),
  .era-dues-accordion .panel-body:has(table[data-era-stack]),
  .era-design-interior .fusion-content-tb:has(table[data-era-stack]) {
    overflow-x: visible !important;
  }

  .era-design-interior .fusion-content-tb table[data-era-stack],
  body.page-id-13819 .fusion-accordian .panel-body table[data-era-stack],
  .era-dues-accordion table[data-era-stack],
  #main table[data-era-stack] {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    margin: 0 0 18px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
    border-collapse: separate;
    border-spacing: 0;
  }

  /* Keep the caption as a visible title above the cards (matches .era-dues-table). */
  [data-era-stack] caption {
    display: block;
    width: 100%;
    padding: 0 0 12px;
    caption-side: top;
    color: #164f73;
    font-size: 18px;
    font-weight: 700;
    text-align: left;
  }

  /* Hide the header row visually; leave it in the accessibility tree. */
  [data-era-stack] thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  [data-era-stack] tbody {
    display: block;
    width: 100%;
  }

  [data-era-stack] tbody tr {
    display: block;
    width: 100%;
    margin: 0 0 14px;
    overflow: hidden;
    border: 1px solid #dce3ea;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(14, 52, 78, 0.06);
  }

  [data-era-stack] tbody th,
  [data-era-stack] tbody td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    box-sizing: border-box;
    padding: 12px 16px !important;
    text-align: left !important;
    vertical-align: top !important;
    border: 0 !important;
    border-bottom: 1px solid #e7ebef !important;
  }

  /* Card header: first column, in the existing navy. */
  [data-era-stack] tbody tr > :first-child {
    color: #fff !important;
    background: var(--era-navy, #0e4a71) !important;
    font-weight: 700;
    font-size: 16px !important;
    line-height: 1.35 !important;
    padding: 13px 16px !important;
    border-bottom: 0 !important;
  }

  body.page-id-13819 [data-era-stack] tbody tr > :first-child {
    background: #164f73 !important;
  }

  /* "1" + " full-time employee" — suffix is set by the script from the column header. */
  [data-era-stack] tbody tr > :first-child[data-card-suffix]::after {
    content: " " attr(data-card-suffix);
    font-weight: 700;
  }

  [data-era-stack] tbody td:not(:first-child),
  [data-era-stack] tbody th:not(:first-child) {
    color: #273746 !important;
    background: #fff !important;
  }

  [data-era-stack] tbody tr:nth-child(even) td:not(:first-child),
  [data-era-stack] tbody tr:nth-child(even) th:not(:first-child) {
    background: #f6f8fa !important;
  }

  [data-era-stack] tbody tr > :last-child {
    border-bottom: 0 !important;
  }

  /* "Label: value" for every cell after the first. ::before is visual-only;
     the thead stays in the accessibility tree so assistive tech still gets
     real column headers. */
  [data-era-stack] tbody td[data-label]:not(:first-child)::before,
  [data-era-stack] tbody th[data-label]:not(:first-child)::before {
    content: attr(data-label) ": ";
    color: #164f73;
    font-weight: 700;
  }

  body.page-id-13819 [data-era-stack] tbody td[data-label]:not(:first-child)::before,
  body.page-id-13819 [data-era-stack] tbody th[data-label]:not(:first-child)::before {
    color: #164f73;
  }
}
