/**
 * What We Test — Why Testing Matters (Section 2) + Biomarker Explorer
 * (Section 3).
 *
 * ── WHY TESTING MATTERS ──────────────────────────────────────────────
 * Desktop background-position follows the tube's position in the photo
 * (~22% from the left), so background-size: cover doesn't crop it out on
 * common desktop widths. Background image: /images/whatwetest-why-v2.jpg (a
 * static theme image, not an ACF field).
 *
 * custom.css's .reveal is scoped to .faqs-section, so this page's reveal
 * observer lives in whatwetest-sections.js.
 *
 * ── BIOMARKER EXPLORER ───────────────────────────────────────────────
 * Responsive rules are kept in their own @media blocks, separate from Why
 * Testing Matters', so each section's behaviour is easy to find.
 *
 * Phone layer (≤880px, same breakpoint as Why Testing Matters so the two
 * switch together): title → lead → search → panels (2 columns) →
 * categories (2 columns, radio-style) → results, 22px gutters. At ≤600px
 * the row's name and "+" toggle are placed explicitly in the grid —
 * otherwise auto-placement swaps them, names wrap one word per line and
 * long ones widen the page.
 */

/* ─────────────── SECTION 2 — WHY TESTING MATTERS (full-bleed) ─────────────── */
.wtm {
  position: relative;
  background: #c9c8c6;
  background-image: url("../images/whatwetest-why-v2.jpg");
  background-size: cover;
  background-position: 22% center;
  min-height: clamp(580px, 84vh, 860px);
  display: flex;
  align-items: center;
}

/*
 * .wtm__inner's width/margin repeats custom.css's .wrap formula
 * (min(1240px, 92vw), centred) because this element also needs the
 * two-column grid below.
 */
.wtm__inner {
  width: min(1240px, 92vw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 0.5fr 1.5fr;
  gap: clamp(24px, 4vw, 56px);
}

.wtm__copy {
  grid-column: 2;
  width: 100%;
  padding-right: clamp(12px, 2vw, 32px);
}

.wtm__title {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.025em;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1.02;
  color: #ffffff;
  margin: 0 0 clamp(22px, 3vh, 34px);
  text-wrap: balance;
}

/*
 * wtm_points is a restricted WYSIWYG field, so the output is
 * <div class="wtm__list"><ul><li>...</li></ul></div>. The default disc
 * marker is replaced with a small round dot (Lumart, 15 Nov: circles, not diamonds).
 */
.wtm__list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.2vh, 22px);
}
.wtm__list li {
  position: relative;
  padding-left: 26px;
  font-family: var(--sans);
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.6;
  color: #ffffff;
  text-wrap: pretty;
}
.wtm__list li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.55em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffffff;
}
/*
 * Fallback for a plain <p> pasted without the list button — styled close
 * to .wtm__list li so it doesn't look broken.
 */
.wtm__list p {
  margin: 0 0 clamp(16px, 2.2vh, 22px);
  font-family: var(--sans);
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.6;
  color: #ffffff;
  text-wrap: pretty;
}
.wtm__list p:last-child { margin-bottom: 0; }

/*
 * Phones (≤880px): the tube pinned to the right edge, a dark wash from the
 * left, white copy. The full photo is scaled to 260vw so the tube sits on
 * the right; the grey gradient underneath fills any height the photo
 * doesn't cover, and the copy's right padding keeps it off the tube.
 */
@media (max-width: 880px) {
  .wtm {
    background-image: url("../images/whatwetest-why-v2.jpg"), linear-gradient(180deg, #7a7571 0%, #b9b5b0 100%);
    background-repeat: no-repeat;
    background-size: 260vw auto, 100% 100%;
    background-position: -5.5vw center, 0 0;
    min-height: 0;
    padding: clamp(64px, 12vh, 120px) 0;
  }
  .wtm::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(10, 9, 8, 0.72) 0%, rgba(10, 9, 8, 0.52) 45%, rgba(10, 9, 8, 0.18) 78%, rgba(10, 9, 8, 0) 100%);
  }
  .wtm__inner {
    position: relative;
    z-index: 1;
    grid-template-columns: 1fr;
  }
  .wtm__copy {
    grid-column: 1;
    padding-right: clamp(64px, 19vw, 110px);
  }
  .wtm__title { color: #fff; font-size: clamp(31px, 8.6vw, 40px); }
  .wtm__list li,
  .wtm__list p { color: #fff; font-size: 16px; line-height: 1.55; }
}

/*
 * Phones, take two (Dylan: "the image is small, it's behind text"). The photo
 * now sits as its own band above the copy, cropped on the tube, and the copy
 * reads dark on the page background below it. Overrides the block above.
 */
@media (max-width: 880px) {
  .wtm {
    background: var(--bg);
    padding: calc(clamp(260px, 72vw, 360px) + clamp(32px, 6vh, 48px)) 0 clamp(56px, 9vh, 88px);
  }
  .wtm::before {
    inset: 0 0 auto 0;
    height: clamp(260px, 72vw, 360px);
    background: url("../images/whatwetest-why-v2.jpg") 22% 40% / cover no-repeat;
  }
  .wtm__copy { padding-right: 0; }
  .wtm__title { color: var(--ink); }
  .wtm__list li::before { background: var(--accent); }
  .wtm__list li,
  .wtm__list p { color: var(--ink-soft); }
}

/* ─────────────── SECTION 3 — BIOMARKER EXPLORER ─────────────── */
.wwt {
  background: var(--bg);
  padding: clamp(48px, 7vh, 96px) 0 clamp(80px, 12vh, 150px);
}
.wwt__inner {
  width: min(1240px, 92vw); margin: 0 auto;
  display: grid;
  grid-template-columns: clamp(220px, 22vw, 268px) 1fr;
  gap: clamp(36px, 5vw, 80px);
  align-items: start;
}

/* ── sticky sidebar ── */
.wwt__aside {
  position: sticky; top: 104px;
  max-height: calc(100vh - 128px);
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-width: thin; scrollbar-color: rgba(12,12,13,0.22) transparent;
}
.wwt__aside::-webkit-scrollbar { width: 5px; }
.wwt__aside::-webkit-scrollbar-thumb { background: rgba(12,12,13,0.18); border-radius: 4px; }

.filter-group { margin-bottom: clamp(28px, 3.4vh, 40px); }
.filter-group__title {
  font-family: var(--sans); font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink); margin: 0 0 14px; padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

/* panel checkboxes */
.panel-opt {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: 0; cursor: pointer; text-align: left;
  padding: 9px 2px; font: inherit; color: var(--ink-soft);
  transition: color 0.16s ease;
}
.panel-opt:hover { color: var(--ink); }
.panel-opt__box {
  flex: none; width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--line); display: grid; place-items: center;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.panel-opt__box svg { width: 11px; height: 11px; opacity: 0; transform: scale(0.6); transition: opacity 0.16s ease, transform 0.16s ease; color: #fff; }
.panel-opt.is-on .panel-opt__box { background: var(--accent); border-color: var(--accent); }
.panel-opt.is-on .panel-opt__box svg { opacity: 1; transform: none; }
.panel-opt.is-on { color: var(--ink); }
.panel-opt__name { font-size: 14.5px; font-weight: 500; flex: 1; }
.panel-opt.is-on .panel-opt__name { font-weight: 600; }
.panel-opt__count { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

/* category nav (built by whatwetest-sections.js) */
.cat-nav { display: flex; flex-direction: column; gap: 1px; }
.cat-nav__item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; cursor: pointer; text-align: left;
  padding: 8px 2px 8px 0; font: inherit;
  font-size: 14.5px; font-weight: 500; color: var(--ink-faint);
  transition: color 0.18s ease;
}
.cat-nav__item:hover { color: var(--ink-soft); }
.cat-nav__tick {
  width: 14px; height: 1.5px; background: currentColor; flex: none;
  opacity: 0; transform: scaleX(0.3); transform-origin: left;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.cat-nav__item.is-active { color: var(--ink); font-weight: 600; }
.cat-nav__item.is-active .cat-nav__tick { opacity: 1; transform: none; color: var(--accent); }
.cat-nav__count { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); }

/* ── main column ── */
.wwt__main { min-width: 0; }
.wwt__title {
  font-family: var(--sans); font-weight: 600; letter-spacing: -0.03em;
  font-size: clamp(38px, 5vw, 64px); line-height: 1.0; color: var(--ink); margin: 0;
}
.wwt__lead {
  margin: clamp(20px, 2.6vh, 30px) 0 0; max-width: 60ch;
  font-size: clamp(16px, 1.25vw, 19px); line-height: 1.6; color: var(--ink-soft); text-wrap: pretty;
}

/* search */
.wwt__search { position: relative; margin: clamp(30px, 4vh, 46px) 0 clamp(8px, 1vh, 14px); }
.wwt__search svg {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--ink-faint); pointer-events: none;
}
.wwt__search input {
  width: 100%; padding: 18px 22px 18px 52px;
  border: 1px solid var(--line); border-radius: 16px; background: #fff;
  font-family: var(--sans); font-size: 16px; color: var(--ink); outline: none;
  box-shadow: 0 1px 2px rgba(12,12,13,0.03);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.wwt__search input::placeholder { color: var(--ink-faint); }
.wwt__search input:focus { border-color: rgba(12,12,13,0.32); box-shadow: 0 6px 22px -16px rgba(12,12,13,0.4); }

.wwt__count {
  margin: 0 0 clamp(34px, 5vh, 56px); font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint);
}

/* ── category section ── */
.cat-sec { scroll-margin-top: 116px; padding-top: clamp(20px, 3vh, 36px); }
.cat-sec + .cat-sec { margin-top: clamp(40px, 6vh, 72px); }
.cat-sec__head { display: flex; align-items: center; gap: 14px; margin-bottom: clamp(18px, 2.4vh, 26px); }
.cat-sec__name {
  font-family: var(--sans); font-size: clamp(22px, 2.2vw, 30px); font-weight: 600;
  letter-spacing: -0.02em; color: var(--ink); margin: 0;
}
.cat-sec__count { font-family: var(--sans); font-weight: 400; color: var(--ink-faint); margin-left: 4px; }

/* column labels */
.bm-cols {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) 44px;
  gap: clamp(16px, 2.5vw, 40px); padding: 0 2px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint);
}
.bm-cols span:last-child { text-align: right; }

/* biomarker row */
.bm { border-bottom: 1px solid var(--line); }
.bm.is-hidden { display: none; }
.bm__row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) 44px;
  gap: clamp(16px, 2.5vw, 40px); align-items: center;
  width: 100%; background: none; border: 0; cursor: pointer; text-align: left;
  padding: clamp(17px, 2.1vh, 22px) 2px; font: inherit;
  transition: background 0.16s ease;
}
.bm__row:hover { background: rgba(12,12,13,0.018); }
.bm__name {
  font-family: var(--sans); font-size: clamp(15px, 1.2vw, 17px); font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink); min-width: 0;
  overflow-wrap: break-word;
}
.bm__panels {
  font-family: var(--sans); font-size: clamp(13px, 1vw, 14.5px); line-height: 1.45;
  color: var(--ink-faint); text-wrap: pretty;
}
.bm__panels .ptag { transition: color 0.16s ease; }
.bm__panels .ptag.is-sel { color: var(--accent); font-weight: 600; }
.bm__panels .psep { color: var(--ink-faint); }
.bm__toggle {
  position: relative; justify-self: end; flex: none; width: 26px; height: 26px;
  background: none; border: 0; cursor: pointer;
}
.bm__toggle::before, .bm__toggle::after {
  content: ""; position: absolute; top: 50%; left: 50%; background: var(--ink-soft);
  transform: translate(-50%, -50%); transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
}
.bm__toggle::before { width: 14px; height: 1.6px; }
.bm__toggle::after { width: 1.6px; height: 14px; }
.bm__row:hover .bm__toggle::before, .bm__row:hover .bm__toggle::after { background: var(--accent); }
.bm.is-open .bm__toggle::before, .bm.is-open .bm__toggle::after { background: var(--accent); }
.bm.is-open .bm__toggle::after { opacity: 0; transform: translate(-50%, -50%) rotate(90deg); }

/* expandable client explanation */
.bm__panel { max-height: 0; overflow: hidden; transition: max-height 0.36s cubic-bezier(0.22,1,0.36,1); }
.bm__panel-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) 44px;
  gap: clamp(16px, 2.5vw, 40px);
  padding: 0 2px clamp(22px, 3vh, 30px);
}
.bm__desc {
  grid-column: 1 / 3;
  font-family: var(--sans); font-size: clamp(14.5px, 1.1vw, 16px); line-height: 1.65;
  color: var(--ink-soft); margin: 0; text-wrap: pretty; max-width: 64ch;
}

/* empty state */
.wwt__empty { display: none; padding: 70px 0; text-align: center; color: var(--ink-soft); }
.wwt__empty.is-on { display: block; }
.wwt__empty strong { color: var(--ink); font-weight: 600; }

/* ── Explorer responsive ── */

/* Phones + small tablets: one column in the order
   title → lead → search → panels → categories → results.
   .wwt__aside and .wwt__main dissolve (display: contents) so their
   children can be ordered together in .wwt__inner's flex column. */
@media (max-width: 880px) {
  .wwt { padding: clamp(48px, 8svh, 72px) 0 clamp(64px, 10svh, 96px); }
  .wwt__inner {
    display: flex; flex-direction: column; align-items: stretch; gap: 0;
    width: calc(100% - 44px);
  }
  .wwt__aside, .wwt__main { display: contents; }
  .wwt__main > * { order: 6; }

  .wwt__title { order: 1; font-size: clamp(34px, 9.4vw, 44px); }
  .wwt__lead { order: 2; font-size: 17px; line-height: 1.5; margin-top: 14px; max-width: none; }
  .wwt__search { order: 3; margin: 26px 0 0; }
  .wwt__aside .filter-group { margin: 0; }
  .wwt__aside .filter-group:first-child { order: 4; margin-top: 30px; }
  .wwt__aside .filter-group:nth-child(2) { order: 5; margin-top: 26px; }
  .wwt__count { margin: 26px 0 8px; }

  .filter-group__title { font-size: 16px; margin-bottom: 8px; padding-bottom: 12px; }

  /* panels — two columns of checkbox rows, 44px tap height */
  #panelFilter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; }
  .panel-opt { padding: 11px 0; gap: 10px; min-height: 44px; }
  .panel-opt__name { font-size: 15px; min-width: 0; }

  .wwt__search input { padding: 15px 18px 15px 48px; border-radius: 14px; }
  .wwt__search svg { left: 18px; }

  /* categories — same two-column rows, with a radio-style marker */
  .cat-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; }
  .cat-nav__item {
    min-height: 44px; padding: 11px 0; gap: 10px;
    font-size: 15px; font-weight: 500; color: var(--ink-soft);
  }
  .cat-nav__tick {
    position: relative; width: 18px; height: 18px; flex: none;
    border-radius: 50%; border: 1.5px solid var(--line); background: transparent;
    opacity: 1; transform: none; transition: border-color 0.16s ease;
  }
  .cat-nav__tick::after {
    content: ""; position: absolute; inset: 3.5px; border-radius: 50%;
    background: var(--accent); transform: scale(0); transition: transform 0.16s ease;
  }
  .cat-nav__item.is-active { color: var(--ink); font-weight: 600; }
  .cat-nav__item.is-active .cat-nav__tick { border-color: var(--accent); }
  .cat-nav__item.is-active .cat-nav__tick::after { transform: scale(1); }
  .cat-nav__count { font-size: 12px; }

  .cat-sec { scroll-margin-top: 96px; }
  .cat-sec__name { font-size: 23px; }

  .bm-cols, .bm__row, .bm__panel-inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) 40px; gap: 14px; }
  .bm__name { font-size: 16px; }
  .bm__panels { font-size: 14px; }
  .bm__desc { font-size: 15.5px; line-height: 1.6; }
}

/*
 * Phones: each row becomes name + "+" on line one, panels underneath.
 * Name and toggle are placed explicitly — see the note at the top of this
 * file.
 */
@media (max-width: 600px) {
  .bm-cols { grid-template-columns: minmax(0, 1fr) 40px; }
  .bm-cols span:nth-child(2) { display: none; }
  .bm__row { grid-template-columns: minmax(0, 1fr) 40px; row-gap: 6px; align-items: start; }
  .bm__name    { grid-column: 1; grid-row: 1; }
  .bm__panels  { grid-column: 1; grid-row: 2; }
  .bm__toggle  { grid-column: 2; grid-row: 1; }
  .bm__panel-inner { grid-template-columns: 1fr; }
  .bm__desc { grid-column: 1; }
}
/* Phones, take three (Lumart, 12 Nov: "this picture placed here looks so out
   of place", with Superpower's page as the reference). The copy leads; the
   photo follows inside the page gutter as a rounded portrait card, with the
   tube centred. Overrides the band above. */
@media (max-width: 880px) {
  .wtm { padding: clamp(56px, 9vh, 88px) 0; }
  .wtm::before { display: none; }
  .wtm__inner { display: block; }
  .wtm__inner::after {
    content: ""; display: block;
    margin-top: 36px; aspect-ratio: 4 / 5; border-radius: 16px;
    background: url("../images/whatwetest-why-v2.jpg") 21% 50% / cover no-repeat;
  }
}

/* Lumart, 12 Nov: too much space between the end of the marker list and
   "Why testing matters" (it was the list's bottom padding plus the section's
   top padding, ~160px on phones). */
.wwt { padding-bottom: clamp(36px, 5vh, 60px); }
@media (max-width: 860px) {
  .wwt { padding-bottom: 28px; }
  .wtm { padding-top: 36px; }
}

/* Dylan, 12 Nov: the tube sat left of centre in the phone card (21% put it
   ~29% across). The card is 4:5 and the photo 1920×900, so the tube is
   centred at 8.3% at every phone width. */
@media (max-width: 880px) {
  .wtm__inner::after { background-position: 8.3% 50%; }
}

/* Phones (Lumart, 12 Nov, after Superpower): search, then a sticky bar with
   the panel dropdown and horizontally scrolling category tabs that jump to
   their section (nothing is filtered out). whatwetest-sections.js builds the
   bar and moves the category nav into it. The checkbox panel list and the
   "Category" heading are desktop only. */
@media (max-width: 880px) {
  .wwt__aside .filter-group { display: none; }
  .wwt-bar {
    order: 3; position: sticky; top: var(--wwt-top, 64px); z-index: 6;
    margin: 0 -22px; padding: 14px 22px 0; background: var(--bg);
  }
  .wwt__search { order: 3; }
  .wwt-bar__select {
    -webkit-appearance: none; appearance: none; width: 100%; min-height: 50px;
    padding: 12px 44px 12px 18px; border-radius: 14px; border: 1.5px solid var(--ink);
    background: #f1f0ec url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230c0c0d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 18px center;
    font-family: var(--sans); font-size: 16px; font-weight: 500; color: var(--ink);
  }
  .wwt-bar .cat-nav {
    display: flex; grid-template-columns: none; gap: 26px; margin: 6px -22px 0; padding: 0 22px;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--line);
  }
  .wwt-bar .cat-nav::-webkit-scrollbar { display: none; }
  .wwt-bar .cat-nav__item {
    flex: none; white-space: nowrap; min-height: 48px; padding: 0; gap: 6px;
    font-size: 15.5px; font-weight: 500; color: var(--ink);
    border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  }
  .wwt-bar .cat-nav__tick { display: none; }
  .wwt-bar .cat-nav__item.is-active { border-bottom-color: var(--ink); font-weight: 600; }
  .wwt-bar .cat-nav__count { font-size: 15.5px; color: var(--ink-faint); font-family: var(--sans); }
  .wwt-bar .cat-nav__count::before { content: "("; }
  .wwt-bar .cat-nav__count::after { content: ")"; }
  .wwt__count { margin: 18px 0 0; }
  .cat-sec { scroll-margin-top: 200px; }
  .cat-sec + .cat-sec { margin-top: 28px; }
}
@media (max-width: 880px) {
  .wwt-bar .cat-nav { flex-direction: row; flex-wrap: nowrap; }
  .wwt-bar .cat-nav__item { width: auto; justify-content: flex-start; }
  .wwt-bar .cat-nav__count { margin-left: 0; }
}

/* Lumart, 12 Nov: the biomarker dropdowns opened too dramatically. A short,
   plain ease-out; the "+" just becomes "−" without spinning. */
.bm__panel { transition: max-height 0.2s ease-out; }
.bm__toggle::before, .bm__toggle::after { transition: opacity 0.15s ease, background 0.15s ease; }
.bm.is-open .bm__toggle::after { transform: translate(-50%, -50%); }
.wwt__count[hidden] { display: none; }

/* Lumart, 15 Nov (iPhone Safari): the bar is only sticky once it reaches the
   top half of the screen (whatwetest-sections.js adds .is-armed), so Safari
   never sees a pinned bar on the bottom edge and lets the page run behind its
   bottom bar. */
@media (max-width: 880px) {
  .wwt-bar:not(.is-armed) { position: relative; top: auto; }
}

/* Lumart, 2 Dec: "darken the background image" (desktop, white copy on the
   photo). A dark wash over the photo, under the copy. Phones show the photo
   as a card below dark copy, so they're left as they are. */
@media (min-width: 881px) {
  .wtm::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(10, 9, 8, 0.38);
  }
  .wtm__inner { position: relative; z-index: 1; }
}
