/* =========================================================================
   QAM TABLE - the look of tables printed by the table module
   (inc/table-editor/, qm_table_render()). Every selector starts with
   .qm-table, the wrapper the module prints:

     div.qm-table.qm-table--simple|--compare.qm-table--cards|--scroll
        [.qm-table--accent] [.qm-table--fixed] [.qm-table--first-bold]
        [style="--qm-table-accent:#hex"]
       > table > [colgroup > col[style="--qm-table-w:NN%"]]
                 [thead > tr > th]  tbody > tr > td[data-label] > div.qm-table__cell

   Colours are custom properties on the wrapper (defaults: the dark site
   design); a page re-colours tables by setting them on .qm-table. Spacing
   round the table (margins) is the page's.

   Watch out: the parent theme's additional.css has
     `.article-content table, th, td { text-align: center !important }`
   - the commas make it apply to EVERY table cell on the site, hence the
   !important on the alignments here.
   ========================================================================= */

.qm-table {
  --qm-table-text: #f9f7ff;      /* cell text */
  --qm-table-line: #2b2734;      /* Simple: row lines */
  --qm-table-head: #cbb9f9;      /* column headings; phone card labels */
  --qm-table-head-bg: #5336a1;   /* Compare: header row; phone label panel */
  --qm-table-row-bg: #1a1622;    /* Compare: rows */
  overflow-x: auto;              /* wide tables scroll sideways in place */
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar of a table that scrolls sideways (phones: Mobile view "Scroll"),
   same look as the tag list in the Knowledge Base filters: 4px, no arrows;
   track #211F25 radius 4px, thumb #CBB9F980 radius 2px.
   Chrome / Edge / Safari: the ::-webkit-scrollbar parts. The standard
   scrollbar-width / scrollbar-color must NOT be set for them - since Chrome
   121 those switch the webkit parts off and bring back the native bar, with
   arrows on Windows. */
.qm-table::-webkit-scrollbar { height: 4px; }
.qm-table::-webkit-scrollbar-track { background: #211f25; border-radius: 4px; }
.qm-table::-webkit-scrollbar-thumb { background: #cbb9f980; border-radius: 2px; }
.qm-table::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
/* Firefox (no ::-webkit-scrollbar): the standard properties - thin, no arrows;
   it does not support the radii. */
@supports not selector(::-webkit-scrollbar) {
  .qm-table {
    scrollbar-width: thin;
    scrollbar-color: #cbb9f980 #211f25;
  }
}

.qm-table table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  background: transparent;
  color: var(--qm-table-text);
  font-size: 14px;
  line-height: 22px;
}
.qm-table :is(th, td) {
  padding: 16px 16px 16px 0;
  border: 0;
  border-bottom: 1px solid var(--qm-table-line);
  background: transparent;
  color: inherit;
  text-align: left !important;   /* see the note at the top */
  vertical-align: middle;
}
.qm-table thead th {
  padding-top: 0;
  color: var(--qm-table-head);
  font-weight: 700;
}
/* Bold text pasted into a heading (Google Docs wraps headings in <b>) keeps
   the heading's colour. */
.qm-table thead :is(b, strong) { color: inherit; }

/* First column bold (setting "First column bold"). */
.qm-table--first-bold tbody td:first-child { font-weight: 700; }

/* Alignment: the cell's own, or else its column's (left = no class). */
.qm-table .qm-table__align-center { text-align: center !important; }
.qm-table .qm-table__align-right { text-align: right !important; }

/* Column widths (Narrow / Normal / Wide): proportions, as percentages on <col>. */
.qm-table--fixed table { table-layout: fixed; }
.qm-table--fixed col { width: var(--qm-table-w, auto); }

/* ---------- Compare: a coloured header row, rows as cards ---------- */
.qm-table--compare table {
  border-collapse: separate;
  border-spacing: 0 8px;
  min-width: 640px;
  font-size: 12px;
  line-height: 16px;
}
.qm-table--compare :is(th, td) { padding: 16px; border: 0; vertical-align: top; }
.qm-table--compare thead th {
  padding: 22px 16px;
  background: var(--qm-table-head-bg);
  color: var(--qm-table-head);
  vertical-align: middle;
}
.qm-table--compare thead th:first-child { border-radius: 12px 0 0 12px; }
.qm-table--compare thead th:last-child { border-radius: 0 12px 12px 0; }
.qm-table--compare tbody td { background: var(--qm-table-row-bg); }
.qm-table--compare tbody td:first-child { border-radius: 8px 0 0 8px; }
.qm-table--compare tbody td:last-child { border-radius: 0 8px 8px 0; }

/* ---------- Accent colour (--qm-table-accent on the wrapper) ----------
   Simple - the column headings; Compare - the header background, white text. */
.qm-table--accent:not(.qm-table--compare) thead th { color: var(--qm-table-accent); }
.qm-table--compare.qm-table--accent thead th {
  background: var(--qm-table-accent);
  color: #fff;
}

/* ---------- Phones: Mobile view "Cards" - every row a card ----------
   Each value with its column's heading (data-label on the cell). The header
   row is hidden from view, not from screen readers. Widths do not apply.
     Simple   heading - value pairs, a line between the cards.
     Compare  a coloured panel with the headings, a dark one with the values.
   "Scroll" (and every table without a header row) keeps the table as it is,
   scrolling sideways. */
@media (max-width: 767px) {
  .qm-table.qm-table--cards table,
  .qm-table.qm-table--cards :is(tbody, tr) { display: block; width: 100%; min-width: 0; }
  .qm-table.qm-table--cards thead {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .qm-table.qm-table--cards tbody td {
    display: grid;
    grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    column-gap: 16px;
    padding: 6px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    /* Always left in a card, whatever the column's or cell's Align: alignment
       is for scanning a column down, and a card has no columns. Outweighs
       .qm-table .qm-table__align-* (both !important). */
    text-align: left !important;
  }
  .qm-table.qm-table--cards tbody td::before {
    content: attr(data-label);
    color: var(--qm-table-head);
    font-weight: 700;
  }

  /* Simple */
  .qm-table--simple.qm-table--cards tbody tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--qm-table-line);
  }
  .qm-table--simple.qm-table--cards tbody tr:first-of-type { padding-top: 0; }
  .qm-table--simple.qm-table--cards.qm-table--accent tbody td::before { color: var(--qm-table-accent); }

  /* Compare: the two panels are the row's ::before / ::after, so each spans
     the whole card whatever the number of cells. */
  .qm-table--compare.qm-table--cards table { border-spacing: 0; font-size: 12px; line-height: 16px; }
  .qm-table--compare.qm-table--cards tbody tr {
    position: relative;
    isolation: isolate;
    margin: 0 0 16px;
    padding: 8px 0;
  }
  .qm-table--compare.qm-table--cards tbody tr:last-child { margin-bottom: 0; }
  .qm-table--compare.qm-table--cards tbody tr::before,
  .qm-table--compare.qm-table--cards tbody tr::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: -1;
    border-radius: 8px;
  }
  .qm-table--compare.qm-table--cards tbody tr::before { left: 0; width: 40%; background: var(--qm-table-head-bg); }
  .qm-table--compare.qm-table--cards tbody tr::after { left: calc(40% + 8px); right: 0; background: var(--qm-table-row-bg); }
  .qm-table--compare.qm-table--cards tbody td {
    column-gap: 24px;
    padding: 8px 16px 8px 0;
  }
  .qm-table--compare.qm-table--cards tbody td::before { padding-left: 16px; }
  .qm-table--compare.qm-table--cards.qm-table--accent tbody tr::before { background: var(--qm-table-accent); }
  .qm-table--compare.qm-table--cards.qm-table--accent tbody td::before { color: #fff; }
}
