/* =========================================================
   WIG COMPARISON — /wig-comparison/
   Reference-article tables on the site's dark palette: ruled cells,
   shaded headers, sticky row labels, and status cells coloured from
   green (none needed / fully published) to red (high / missing).
   Loaded only on that page ($pageStyles in includes/header.php).
   ========================================================= */

/* A data page: on big screens it uses the width, so the wide tables
   fit without scrolling sideways. */
.container.wc { max-width: 1480px; }

.wc {
  padding-top: 18px;
  padding-bottom: 90px;
  /* Status cell colours. Each text/background pair is >= 7:1. */
  --wc-yes-bg:  #0f3320; --wc-yes-fg:  #bff5cf;
  --wc-good-bg: #22330f; --wc-good-fg: #dcf5b8;
  --wc-mid-bg:  #3a300c; --wc-mid-fg:  #f7e6a6;
  --wc-no-bg:   #3f1318; --wc-no-fg:   #ffc9cd;
  --wc-na-bg:   #15101f;
  --wc-row:     rgba(255, 255, 255, 0.025);
}

/* The filter form and "show more" start hidden until the script runs;
   their display rules below would otherwise override [hidden]. */
.wc [hidden] { display: none !important; }

.wc-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Lead, key box, contents ------------------------------------------ */
/* Prose at a readable measure (~70 characters); tables use the full width. */
.wc-intro { max-width: 64ch; }
.wc-lead { font-size: 17px; margin: 0 0 18px; }

.wc-keybox {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin: 0 0 26px;
}
.wc-keybox-title { font-weight: 600; margin: 0 0 8px; }
.wc-keybox ol { margin: 0 0 10px; padding-left: 22px; }
.wc-keybox li { margin: 6px 0; }
.wc-keybox-foot { margin: 0; font-size: 14.5px; color: var(--text-dim); }

.wc a { color: var(--purple-glow); }
.wc a:hover { color: var(--text); }

.wc-toc {
  display: inline-block;
  min-width: 280px;
  max-width: 100%;
  background: var(--black-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 24px 16px 20px;
  margin: 0 0 12px;
  font-size: 14.5px;
}
.wc-toc-title {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  text-align: center;
}
.wc-toc ol { counter-reset: wc-toc; list-style: none; margin: 0; padding: 0; }
.wc-toc ol ol { padding-left: 20px; }
.wc-toc li { counter-increment: wc-toc; margin: 3px 0; }
.wc-toc li > a::before {
  content: counters(wc-toc, ".") " ";
  color: var(--text-faint);
  margin-right: 4px;
}

/* --- Sections ---------------------------------------------------------- */
.wc-section { margin-top: 44px; }
.wc-section h2 {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.25;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.wc-section h3 {
  font-size: 19px;
  margin: 30px 0 8px;
}
.wc-section > p { max-width: 62ch; }
.wc-small { font-size: 13.5px; color: var(--text-dim); margin: 10px 0 0; max-width: 70ch; }
.wc-dim { color: var(--text-faint); }
.wc-ref { font-size: 0.72em; line-height: 0; margin-left: 1px; }
.wc-ref a { text-decoration: none; }
.wc abbr[title] { text-decoration: underline dotted; cursor: help; }

/* --- Tables ------------------------------------------------------------ */
.wc-scroll {
  /* Positioned, so the visually hidden labels inside cells are placed
     (and clipped) in here rather than escaping to the page, where one
     widened the whole layout on phones. */
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  margin: 12px 0 0;
}
.wc-scroll:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* The long table scrolls inside itself so its header can stay put. */
.wc-scroll-tall { max-height: 78vh; overflow-y: auto; }

/* separate + zero spacing (not collapse) so sticky cells keep borders */
.wc-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 14px;
  line-height: 1.45;
  background: var(--black-soft);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.wc-table th,
.wc-table td {
  padding: 8px 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.wc-table thead th {
  background: var(--surface-2);
  font-weight: 600;
  vertical-align: bottom;
  position: sticky;
  top: 0;
  z-index: 2;
}
.wc-table thead tr + tr th { top: 38px; }
/* The corner heading stays with the row labels when scrolled sideways. */
.wc-table thead tr:first-child th:first-child { left: 0; z-index: 3; }
.wc-table thead th.wc-group { text-align: center; vertical-align: middle; }
.wc-table tbody th[scope="row"] {
  background: var(--surface);
  font-weight: 600;
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 150px;
}
.wc-table tbody tr:nth-child(even) td { background: var(--wc-row); }
.wc-table td.wc-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wc-nowrap { white-space: nowrap; }
/* Prose cells get room to read as a line or two, not a column of
   single words; the table scrolls sideways instead. */
.wc-table td.wc-desc { min-width: 180px; max-width: 300px; }
.wc-table td.wc-panel { min-width: 120px; }

.wc .wc-table td.wc-yes  { background: var(--wc-yes-bg);  color: var(--wc-yes-fg); }
.wc .wc-table td.wc-good { background: var(--wc-good-bg); color: var(--wc-good-fg); }
.wc .wc-table td.wc-mid  { background: var(--wc-mid-bg);  color: var(--wc-mid-fg); }
.wc .wc-table td.wc-no   { background: var(--wc-no-bg);   color: var(--wc-no-fg); }
.wc .wc-table td.wc-na   { background: var(--wc-na-bg);   color: var(--text-faint); text-align: center; }
.wc .wc-table td.wc-yes a, .wc .wc-table td.wc-good a, .wc .wc-table td.wc-mid a, .wc .wc-table td.wc-no a { color: inherit; }
.wc .wc-table td.wc-best {
  font-weight: 700;
  color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent-dim);
}
.wc-matrix td.wc-num { min-width: 84px; }

/* Sort buttons are added by wig-comparison.js. */
.wc-sort {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: flex-end;
  gap: 6px;
}
.wc-sort::after {
  content: "↕";
  font-size: 11px;
  color: var(--text-faint);
}
th[aria-sort="ascending"] .wc-sort::after { content: "▲"; color: var(--accent); }
th[aria-sort="descending"] .wc-sort::after { content: "▼"; color: var(--accent); }
.wc-sort:focus-visible { box-shadow: var(--focus-ring); border-radius: 3px; }

/* --- Every product ----------------------------------------------------- */
.wc-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px 14px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 16px 0 0;
}
.wc-filters label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--text-dim);
}
.wc-filters select,
.wc-filters input[type="number"],
.wc-filters input[type="search"] {
  width: 100%;
  background: var(--black-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}
.wc-filters select:focus-visible,
.wc-filters input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wc-filters .wc-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  padding-bottom: 9px;
}
.wc-filters .wc-check input { width: 18px; height: 18px; accent-color: var(--purple); }
.wc-filters .wc-search { grid-column: span 2; }
.wc-reset {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 18px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.wc-reset:hover { border-color: var(--purple-glow); }
.wc-reset:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.wc-status { font-size: 14px; color: var(--text-dim); margin: 14px 0 0; }
.wc-all tbody th[scope="row"] { font-weight: 500; min-width: 220px; max-width: 340px; }
.wc-more { margin-top: 16px; }

/* --- Notes, see also ---------------------------------------------------- */
.wc-notelist { list-style: none; padding: 0; margin: 0; font-size: 14.5px; max-width: 64ch; }
.wc-notelist li { margin: 8px 0; padding: 4px 8px; border-radius: 6px; }
.wc-notelist li:target { background: var(--surface-2); }
.wc-seealso { padding-left: 20px; margin: 0 0 16px; }
.wc-seealso li { margin: 6px 0; }

@media (max-width: 640px) {
  .wc-lead { font-size: 16px; }
  .wc-keybox { padding: 14px 16px; }
  .wc-toc { display: block; }
  .wc-section h2 { font-size: 23px; }
  .wc-table { font-size: 13px; }
  .wc-table th, .wc-table td { padding: 7px 8px; }
  .wc-table tbody th[scope="row"] { min-width: 120px; }
  .wc-table td.wc-desc { min-width: 170px; }
  .wc-all tbody th[scope="row"] { min-width: 170px; }
  .wc-filters { grid-template-columns: 1fr 1fr; padding: 12px; }
}

/* Laptops (1101–1360px): a little tighter, so the two widest tables fit
   without scrolling sideways at common 1280–1366px widths. */
@media (min-width: 1101px) and (max-width: 1360px) {
  .wc-table { font-size: 13.5px; }
  .wc-table th,
  .wc-table td { padding: 7px 8px; }
  .wc-table td.wc-desc { min-width: 140px; }
  .wc-table td.wc-panel { min-width: 96px; }
  .wc-table tbody th[scope="row"] { min-width: 128px; }
  /* Sixteen columns: the one table that needs a little less padding. */
  #retailers-overview + .wc-scroll .wc-table th,
  #retailers-overview + .wc-scroll .wc-table td { padding-left: 6px; padding-right: 6px; }
}

/* --- Filter toggle (phones only) --------------------------------------- */
.wc-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 0;
  padding: 11px 20px;
  min-height: 44px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--purple-glow);
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.wc-filter-toggle[aria-expanded="true"] { background: var(--surface-2); }
.wc-filter-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wc-filter-count { color: var(--accent); }
@media (min-width: 1101px) {
  .wc .wc-filter-toggle { display: none !important; }
}

/* =========================================================
   PHONES AND TABLETS (up to 1100px): tables become cards
   Nothing scrolls sideways. Each row is a card headed by its row label;
   each cell is a line with its column's name (data-label) on the left.
   ========================================================= */
@media (max-width: 1100px) {
  .wc-filters:not(.is-open) { display: none; }
  .wc-filters { margin-top: 10px; }

  .wc-scroll,
  .wc-scroll-tall { overflow: visible; max-height: none; border-radius: 0; margin-top: 14px; }

  .wc-table,
  .wc-table tbody,
  .wc-table tr,
  .wc-table tbody th,
  .wc-table tbody td { display: block; }
  .wc-table { min-width: 0; width: 100%; border: 0; background: none; font-size: 15px; }
  .wc-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  }
  .wc-table tbody tr {
    background: var(--black-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 0 0 12px;
    overflow: hidden;
  }
  .wc-table tbody th[scope="row"],
  .wc-all tbody th[scope="row"] {
    position: static;
    min-width: 0;
    max-width: none;
    background: var(--surface-2);
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 11px 14px;
    font-size: 16px;
    line-height: 1.35;
  }
  /* Flex, so a label that wraps makes its line taller instead of
     running into the next one. */
  .wc-table tbody td {
    display: flex;
    align-items: baseline;
    gap: 0 6px;
    min-width: 0;
    max-width: none;
    padding: 9px 14px;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
    white-space: normal;
  }
  .wc-table tbody td:last-child { border-bottom: 0; }
  .wc-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    padding-right: 8px;
    color: var(--text-faint);
    font-size: 13.5px;
    line-height: 1.45;
  }
  .wc-table tbody tr:nth-child(even) td { background: none; }
  .wc-table td.wc-num,
  .wc-table td.wc-desc,
  .wc-table td.wc-panel,
  .wc-matrix td.wc-num { min-width: 0; max-width: none; text-align: left; }

  /* In a matrix, a card lists only the retailers that have something. */
  .wc .wc-matrix td.wc-na { display: none; }

  /* Footnote markers: bigger, and a finger can hit them. */
  .wc-ref { font-size: 0.82em; }
  .wc-ref a { display: inline-block; padding: 6px 3px; }

  .wc-more { width: 100%; }

  /* Links in cards: a taller hit area, same line height. */
  .wc-table tbody td a,
  .wc-table tbody th a { display: inline-block; padding: 9px 0; margin: -9px 0; }
}

/* Tablets and small laptops: two cards per row rather than one card
   stretched across the whole width. */
@media (min-width: 640px) and (max-width: 1100px) {
  .wc-table tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
  }
  .wc-table tbody tr { margin: 0; }
}
