/* ==========================================================================
   Articles: the hub (articles.html) and article pages (articles/*.html).
   Loaded only by those pages. Everything here extends existing components
   (.post, .callout, .badge, .chip, .toc, .prose, .table-scroll) with the
   same tokens, so Articles reads as part of the original BioRx system.
   ========================================================================== */

/* ---------- article head ---------- */
.byline { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .04em; color: var(--inv-muted, var(--fg-subtle)); }
.byline a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* Article headlines are longer than section titles (they carry the search
   question), so they step down a size on phones instead of running to five lines. */
@media (max-width: 480px) {
  .article-head h1 { font-size: clamp(1.6rem, 1.1rem + 3.2vw, 2rem); line-height: 1.12; }
}

/* ---------- layout: sticky contents on desktop, a compact strip on mobile ---------- */
.article-body { min-width: 0; max-width: 760px; }
.toc__title {
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .12em;
  text-transform: uppercase; color: var(--fg-subtle); margin-bottom: var(--sp-3);
}
.article-layout .toc { padding: var(--sp-4); }
.toc__count { font-weight: 400; color: var(--fg-subtle); }

/* Below the sidebar breakpoint the contents is a disclosure, not a strip.
   These articles run to a median of 14 chapters, and a horizontal pill rail
   put roughly a tenth of that on screen: the reader saw two chapters and had
   to swipe sideways through the article's own navigation to find the rest.
   Collapsed it costs less height than the rail did; one tap gives the lot. */
@media (max-width: 1023px) {
  .article-layout .toc { position: static; padding: var(--sp-3) var(--sp-4); }
  .toc__box > summary {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
    min-height: 44px; margin: 0; cursor: pointer; list-style: none;
  }
  .toc__box > summary::-webkit-details-marker { display: none; }
  .toc__box > summary::after {
    content: ""; flex: none; width: 9px; height: 9px; margin-right: 4px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg); transition: transform var(--dur) var(--ease);
  }
  .toc__box[open] > summary::after { transform: rotate(-135deg); }
  .article-layout .toc ul { display: grid; gap: 2px; margin-top: var(--sp-3); }
  .article-layout .toc a {
    display: block; min-height: 44px; padding: 11px var(--sp-3);
    white-space: normal; border-left: 0; border-radius: var(--r-xs);
  }
  .article-layout .toc a.is-active {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent-deep); font-weight: 600;
  }
}

/* On the sidebar layout the contents is always open and reads as a heading,
   so the disclosure affordance is taken away rather than left to be clicked. */
@media (min-width: 1024px) {
  .toc__box > summary { list-style: none; cursor: default; pointer-events: none; }
  .toc__box > summary::-webkit-details-marker { display: none; }
  .toc__count { display: none; }
}
@media (min-width: 1024px) {
  .article-layout .toc { max-height: calc(100vh - var(--nav-h) - var(--sp-8)); overflow-y: auto; }
}

/* ---------- the answer, up front ---------- */
.answer {
  padding: var(--sp-5) var(--sp-6);
  border-radius: var(--r-md);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.prose .answer__title {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent-deep);
}
.prose .answer p { color: var(--fg); font-size: var(--fs-lg); line-height: 1.55; font-family: var(--font-display); letter-spacing: -.01em; }
/* the physician guidance notice on any article that states a dose */
.answer + .answer { margin-top: var(--sp-4); }
.answer--caution { border-color: color-mix(in srgb, var(--ev-limited) 45%, transparent); background: color-mix(in srgb, var(--ev-limited) 10%, var(--surface)); }
.prose .answer--caution p:not(.answer__title) { font-size: var(--fs-md); font-family: inherit; letter-spacing: 0; }

/* ---------- evidence at a glance ---------- */
.ev-cards { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.ev-card {
  display: grid; gap: var(--sp-3); align-content: start;
  padding: var(--sp-5); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border-soft);
}
.ev-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.prose .ev-card__name { margin: 0; font-size: var(--fs-lg); }
.prose .ev-card p { font-size: var(--fs-sm); line-height: 1.6; }
.prose .ev-card__class { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-subtle); }
.ev-card__links { display: grid; gap: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border-soft); }
.ev-card__links .link-arrow { font-size: var(--fs-sm); }

/* ---------- research type labels ---------- */
.rtype {
  display: inline-block; vertical-align: .1em;
  padding: 1px 8px; border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: .72em; font-weight: 700; letter-spacing: .04em;
  border: 1px solid currentColor; line-height: 1.6; white-space: nowrap;
}
.rtype--human       { color: var(--ev-strong); }
.rtype--approved    { color: var(--ev-strong); }
.rtype--animal      { color: var(--ev-limited); }
.rtype--in-vitro    { color: var(--ev-pre); }
.rtype--mechanistic { color: var(--ev-pre); }

/* ---------- citations and references ---------- */
.cite { font-family: var(--font-mono); font-size: .7em; line-height: 0; }
/* The citation marker is the way into the evidence trail, so it has to be
   catchable with a thumb. It stays a ~12px glyph: vertical padding on an inline
   element grows the hit area without changing the line box it sits in, so the
   target reaches 24px+ while the text keeps its spacing. */
.prose .cite a { text-decoration: none; padding: 9px 4px; }
/* The reference list's own PubMed and DOI links are 12px mono on one line. */
.prose ol.refs .ref__links a { display: inline-block; padding-block: 5px; }
.prose .cite a::before { content: "["; }
.prose .cite a::after { content: "]"; }
.ref__note { font-size: var(--fs-sm); }
.prose ol.refs { gap: var(--sp-4); }
.prose ol.refs li { font-size: var(--fs-sm); line-height: 1.6; scroll-margin-top: calc(var(--nav-h) + var(--sp-5)); }
.prose ol.refs li:target { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: var(--r-xs); }
.ref__cite { display: block; color: var(--fg); }
.ref__links { display: block; margin-top: var(--sp-1); font-family: var(--font-mono); font-size: var(--fs-xs); }
.ref__cite + .badge { margin-top: var(--sp-1); }

/* ---------- comparison tables ---------- */
/* Wider than the site's 640px table default, but only where tables are tables:
   below 640px style.css restacks every .table-scroll table as cards. Above it
   the width is asked for, never forced, because .article-body caps the column
   at 760px and a phone in landscape gives less than that; an unconditional
   floor there just put the table back in the sideways scroller the card
   layout exists to avoid. */
@media (min-width: 641px) {
  .compare table { min-width: min(760px, 100%); }
}
.compare td { vertical-align: top; }
/* Row headers are <th scope="row"> for screen readers; style them as the first cell. */
.compare tbody th[scope="row"] { vertical-align: top; text-align: left; font-weight: 600; }
@media (min-width: 641px) {
  .compare tbody th[scope="row"] { padding: var(--sp-4); border-bottom: 1px solid var(--border-soft); }
}
.compare tbody tr:last-child th[scope="row"] { border-bottom: 0; }
.compare caption { caption-side: bottom; text-align: left; padding: var(--sp-3) var(--sp-4); font-size: var(--fs-xs); color: var(--fg-subtle); }

/* ---------- mechanism class list ---------- */
.prose ul.class-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--sp-2) var(--sp-5); }
.class-list .mono { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-subtle); margin-left: var(--sp-1); }

/* ---------- editorial flags (drafts only; a flagged article cannot publish) ---------- */
.ed-flag {
  display: block; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm);
  border: 2px dashed var(--magenta); color: var(--fg);
  background: color-mix(in srgb, var(--magenta) 10%, transparent);
  font-family: var(--font-mono); font-size: var(--fs-sm);
}
mark.ed-flag { display: inline; padding: 0 4px; }
.ed-flag--banner { margin-bottom: var(--sp-4); }

/* ---------- continue: records row ---------- */
.records { margin-top: var(--sp-7); }
.records__title { font-size: var(--fs-lg); margin-bottom: var(--sp-3); }
.records__list { display: grid; gap: var(--sp-2); }
.record-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border-soft);
}
.record-row > a:first-child { flex: 1 1 220px; font-weight: 500; }
.record-row__studies { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--link); text-decoration: underline; text-underline-offset: 3px; }

/* ==========================================================================
   The hub
   ========================================================================== */
/* Topic filters wrap, they do not scroll sideways. Ten chips make a 1212px
   strip, so a nowrap row hid seven of the ten topics behind a swipe on the
   hub's primary navigation. .tag-row already wraps site-wide (style.css). */
.chip-scroll { gap: var(--sp-2); }

/* featured: the one dominant article */
.post--feature { display: grid; gap: 0; }
.post--feature .post__body { padding: var(--sp-6); gap: var(--sp-3); }
.post--feature h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.3rem); line-height: 1.15; letter-spacing: -.02em; }
.post--feature h2 a::after { content: ""; position: absolute; inset: 0; }
.post--feature p { font-size: var(--fs-md); color: var(--fg-muted); max-width: 60ch; }
@media (min-width: 768px) {
  .post--feature { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: stretch; }
  .post--feature .post__media { aspect-ratio: auto; min-height: 100%; }
  .post--feature .post__body { padding: var(--sp-8) var(--sp-7); justify-content: center; }
}
.post h3 { font-size: var(--fs-lg); }
.post h3 a::after { content: ""; position: absolute; inset: 0; }

/* start here: a numbered editorial list rather than more cards */
.start-list { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); column-gap: var(--sp-7); }
.start-item {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: var(--sp-4);
  padding: var(--sp-5) 0; border-top: 1px solid var(--border-soft);
}
.start-item__n { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--accent-deep); font-weight: 700; padding-top: 3px; }
.start-item h3 { font-size: var(--fs-lg); line-height: 1.3; margin: var(--sp-1) 0 var(--sp-2); }
.start-item h3 a::after { content: ""; position: absolute; inset: 0; }
.start-item h3 a:hover { color: var(--accent-deep); }
.start-item p { font-size: var(--fs-sm); color: var(--fg-muted); }

/* browse by topic */
.topics { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.topic {
  display: grid; gap: var(--sp-1); align-content: start;
  padding: var(--sp-5); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border-soft);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.topic:hover { border-color: var(--accent); transform: translateY(-2px); }
.topic strong { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--fg); }
.topic span { font-size: var(--fs-sm); color: var(--fg-muted); }
.topic .topic__count { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent-deep); letter-spacing: .06em; text-transform: uppercase; }
.topics__foot { margin-top: var(--sp-6); font-size: var(--fs-sm); color: var(--fg-muted); }
.topics__foot a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }

[data-hide-when-filtering][hidden] { display: none !important; }
#library-grid > [data-hidden="true"] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .topic, .topic:hover { transition: none; transform: none; }
}
