/* ============================================================
   COMPARE TABLE — «Birch vs …» (from /manage and /revealbot-alternative)
   Requires: tokens.css, page.css, patterns.css (.block-head)

   A real <table>, text left-aligned in Paragraph SM. Rows are split by hairlines (1, as the menu's rows), the line
   under the header row is --border-thin (2); the last row has none (1.5/3 read heavy). Lines: white on dark pages, Surface muted on
   light ones (the Birch column's family, not a neutral grey). The Birch column carries a fill from top to bottom (Surface on light
   pages, Background/Grey on dark ones — as cards do); other products' text is grey, Birch's is the text colour.
   Group rows («Rule engine») are a heading row. Yes = a check, no = a cross in the grey text token.
   Tablets and desktop: the header row sticks under the menu while the table scrolls by (the block does not clip
   sideways there — a scroll box would stop the sticky header). Phones: the block scrolls sideways, the feature
   column is sticky with the page fill under it.
   One density for every table (no dense variant).
   ============================================================ */

.compare {
  --compare-line: var(--color-surface-muted);
  --compare-fill: var(--color-surface);
  --compare-page: var(--color-bg-white);
  --compare-other: var(--color-text-grey-inverted);
  --compare-pad: var(--space);
  --compare-rule: var(--border-hairline);
}
.theme-dark .compare {
  --compare-line: var(--color-border-strong); /* white lines on dark */
  --compare-fill: var(--color-bg-grey);
  --compare-page: var(--color-bg);
  --compare-other: var(--color-text-grey);
}
.compare:focus-visible { outline: var(--border-thick) solid var(--color-accent-indigo); outline-offset: var(--border-thin); border-radius: var(--radius-md); }

.compare__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
.compare__table :is(th, td) {
  padding: var(--compare-pad);
  border-bottom: var(--compare-rule) solid var(--compare-line);
  text-align: left;
  vertical-align: middle;
  text-wrap: pretty;
}
.compare__table tbody th[scope="row"] { width: 22%; }
.compare__table td:not(.is-birch) { color: var(--compare-other); }
/* rows from 768: Reading M's 16, a step closer to the header's H6 (14 read small under it); the values in its Medium 500,
   the row names keep 600 as the column's labels. Phones keep Paragraph SM's 14 (the table scrolls sideways there). */
@media (min-width: 48rem) {
  .compare__table tbody :is(th, td) { font-size: var(--text-reading-m-size); line-height: var(--text-reading-lh); }
  .compare__table tbody td { font-weight: 500; }
}

/* header row: sticky under the menu, a heavier line under it, the page fill so rows slide under it */
.compare__table thead :is(th, td) {
  position: sticky;
  top: var(--nav-height, 0rem);
  z-index: 2;
  padding-block: var(--space) var(--space-sm); /* 24 over the names, 16 to the line */
  border-bottom: var(--border-thin) solid var(--compare-line);
  background: var(--compare-page);
}
.compare__product { display: inline-flex; align-items: center; gap: var(--space-xs); }
.compare__icon { width: 1.5rem; height: 1.5rem; object-fit: contain; border-radius: var(--radius-xs); background: var(--color-bg-white); } /* a white tile: some marks are dark on transparent */
.compare__logo { display: block; width: 100%; max-width: 7.5rem; height: auto; max-height: 2rem; object-fit: contain; object-position: left; }

/* the Birch column: a fill with rounded top and bottom ends; the last row has no line (a line under a rounded
   corner bends with it) */
.compare__table .is-birch { background: var(--compare-fill); }
.compare__table thead .is-birch { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.compare__table tbody tr:last-child .is-birch { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.compare__table tbody tr:last-child :is(th, td) { border-bottom: 0; }

/* a group row is the heading of the rows under it: 32 above (48 read loose), 8 below, no line between it and its first row
   (32 above / 24 below and a line read as neither a row nor a heading) */
.compare__table .compare__group :is(th, td) { padding-top: var(--space-md); padding-bottom: var(--space-xs); border-bottom: 0; vertical-align: bottom; }

.compare__mark { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: middle; background: currentColor; }
.compare__mark--yes { -webkit-mask: url("../icons/check.svg") center / contain no-repeat; mask: url("../icons/check.svg") center / contain no-repeat; }
.compare__mark--no { color: var(--compare-other); -webkit-mask: url("../icons/close.svg") center / contain no-repeat; mask: url("../icons/close.svg") center / contain no-repeat; }
.compare__icons { display: inline-flex; flex-wrap: wrap; gap: var(--space-xs); }
.compare__icons img { width: 1.5rem; height: 1.5rem; object-fit: contain; }

/* phones: scroll sideways inside the block, the feature column stays put (the header is not sticky there).
   Less air in the cells, and every product column at least 9rem so its text reads — the table
   is as wide as its columns need (--compare-cols, set by the component), the block scrolls. The block runs to the
   right edge of the screen, so a cut column shows the table goes on; the Birch column keeps 16 at the sides. */
@media (max-width: 47.9375rem) {
  .compare { overflow-x: auto; overscroll-behavior-x: contain; --compare-pad: var(--space-sm) var(--space-xs); margin-right: calc(var(--pad-horizontal) * -1); padding-right: var(--pad-horizontal); }
  .compare__table .is-birch { padding-inline: var(--space-sm); }
  .compare__table .compare__group :is(th, td) { padding-top: var(--space); } /* phones: 24 above a group, 8 below */
  .compare__table { width: calc(8rem + var(--compare-cols, 4) * 9rem); min-width: 100%; }
  .compare__table thead :is(th, td) { position: static; padding-block: var(--space-sm) var(--space-xs); }
  .compare__table tbody th:is([scope="row"], [scope="rowgroup"]), .compare__table thead td:first-child {
    position: sticky;
    top: auto; /* the header cell must not keep the desktop's sticky top: it slid down over the line */
    left: 0;
    z-index: 1;
    width: 8rem;
    padding-left: 0;
    background: var(--compare-page);
  }
}

/* ---------- Panel head (live /manage) ----------
   The block head in a Primary panel with the product's picture under it, cut by the panel's bottom edge (no bottom
   padding, the picture's lower corners square); the table right under the panel, one block gap below it. */
.compare-panel { /* + .panel--center .panel--bleed (surface.css) */
  margin-bottom: var(--block-gap);
  background: var(--color-primary);
  color: var(--color-text-inverted);
}
.theme-dark .panel.compare-panel { background: var(--color-primary); }
.compare-panel .block-head__lead { color: var(--color-text-inverted); }
.compare-panel__picture {
  display: block;
  width: calc(10 / 12 * 100%);
  height: auto;
  border-radius: var(--radius-md); /* the lower corners squared by .panel--bleed */
}
@media (max-width: 47.9375rem) {
  .compare-panel__picture { width: 100%; }
}
