/* RespiratoryTrials.org
 *
 * Identity: the data is the design. Trial acronyms, participant counts, years
 * and PMIDs are set in a tabular mono face so the tables scan like a results
 * printout — the vernacular of the subject. The accent pair is arterial and
 * venous, the two states of the blood the lung exists to change.
 *
 * No web fonts: this gets read on hospital wifi.
 */

:root {
  --paper: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #5c6470;
  --rule: #d9dde4;
  --rule-soft: #e8ebef;
  --venous: #2f4c8f;   /* links, headings, the brand */
  --arterial: #b4232c; /* used sparingly: flags, the mark */
  --focus: #2f4c8f;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 68ch;
  --gap: 1.5rem;
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101318;
    --card: #171b21;
    --ink: #e6e9ee;
    --muted: #98a1ae;
    --rule: #2b313a;
    --rule-soft: #222831;
    --venous: #8fb0ee;
    --arterial: #f08a90;
    --focus: #8fb0ee;
  }
}

:root[data-theme="dark"] {
  --paper: #101318;
  --card: #171b21;
  --ink: #e6e9ee;
  --muted: #98a1ae;
  --rule: #2b313a;
  --rule-soft: #222831;
  --venous: #8fb0ee;
  --arterial: #f08a90;
  --focus: #8fb0ee;
}

:root[data-theme="light"] {
  --paper: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #5c6470;
  --rule: #d9dde4;
  --rule-soft: #e8ebef;
  --venous: #2f4c8f;
  --arterial: #b4232c;
  --focus: #2f4c8f;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  font-synthesis-weight: none;
}

a { color: var(--venous); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 0.4em; }
h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); font-weight: 650; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--card); padding: 0.6rem 1rem;
}
.skip:focus { left: 0; }

.wrap { max-width: 78rem; margin: 0 auto; padding: 0 1.25rem; }

/* --- masthead ---------------------------------------------------------- */

.masthead {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 10;
}

.masthead__bar {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
}

.wordmark {
  text-decoration: none;
  color: var(--ink);
  font-weight: 680;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
  white-space: nowrap;
}
.wordmark__dot { color: var(--arterial); padding: 0 0.15em; }
.wordmark__tld { font-family: var(--mono); font-size: 0.8em; color: var(--muted); font-weight: 500; }

.search { position: relative; margin-left: auto; flex: 1 1 16rem; max-width: 26rem; }
.search input {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.42rem 3rem 0.42rem 0.7rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.search input::placeholder { color: var(--muted); }
.search__hint {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 0.7rem; color: var(--muted);
  border: 1px solid var(--rule); border-radius: 3px; padding: 0.05rem 0.3rem;
  pointer-events: none;
}
.search__results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.14);
  max-height: 60vh; overflow-y: auto; padding: 0.25rem;
}
.search__results a {
  display: block; padding: 0.4rem 0.55rem; border-radius: 2px;
  text-decoration: none; color: var(--ink);
}
.search__results a:hover, .search__results a[aria-selected="true"] { background: var(--rule-soft); }
.search__results .r-acronym { font-family: var(--mono); font-weight: 600; color: var(--venous); }
.search__results .r-meta { color: var(--muted); font-size: 0.8rem; display: block; }

/* --- nav --------------------------------------------------------------- */

.nav {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 1.25rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.4rem;
}

.navgroup { position: relative; }
.navgroup > summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius);
  color: var(--muted);
  white-space: nowrap;
}
.navgroup > summary::-webkit-details-marker { display: none; }
.navgroup > summary:hover { color: var(--ink); background: var(--rule-soft); }
.navgroup[open] > summary { color: var(--ink); background: var(--rule-soft); }
.navgroup > ul {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 25;
  margin: 0; padding: 0.3rem; list-style: none;
  min-width: 13rem;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.14);
}
.navgroup > ul a {
  display: block; padding: 0.3rem 0.5rem; border-radius: 2px;
  text-decoration: none; color: var(--ink); font-size: 0.85rem;
}
.navgroup > ul a:hover { background: var(--rule-soft); }

@media (max-width: 640px) {
  .navgroup { width: 100%; }
  .navgroup > ul { position: static; box-shadow: none; border: 0; padding-left: 0.8rem; }
}

/* --- lede -------------------------------------------------------------- */

.lede { padding: 2.2rem 0 1.4rem; max-width: var(--measure); }
.lede p { color: var(--muted); margin: 0.4rem 0 0; }
.lede--trial h1 { font-family: var(--mono); font-weight: 620; letter-spacing: -0.03em; }
.fullname { font-style: italic; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.eyebrow a { color: var(--muted); }

/* --- the effect glyph: the signature element --------------------------- */

.effect { vertical-align: -2px; flex: none; }
.effect__null { stroke: var(--muted); stroke-width: 1; opacity: 0.55; }
.effect__ci { stroke: var(--ink); stroke-width: 1.25; }
.effect__point { fill: var(--ink); }
.effect--no-difference .effect__ci,
.effect--no-difference .effect__point { opacity: 0.45; }
.effect--harm .effect__ci { stroke: var(--arterial); }
.effect--harm .effect__point { fill: var(--arterial); }
.effect--mixed .effect__ci { stroke-dasharray: 2 2; }

.legend {
  margin: 1.6rem 0 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  max-width: 42rem;
  font-size: 0.85rem;
}
.legend h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-family: var(--mono); font-weight: 600; }
.legend ul { list-style: none; margin: 0.6rem 0; padding: 0; display: grid; gap: 0.35rem 1.4rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.legend li { display: flex; align-items: center; gap: 0.6rem; }
.legend p { color: var(--muted); margin: 0.5rem 0 0; font-size: 0.8rem; }

/* --- tables ------------------------------------------------------------ */

.tablewrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); }

table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }

thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  background: var(--card);
  position: sticky;
  top: 0;
}

tbody td, tbody th {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--rule-soft);
  text-align: left;
  font-weight: 400;
  vertical-align: baseline;
}
tbody tr:first-child td, tbody tr:first-child th { border-top: 0; }
tbody tr:hover { background: var(--rule-soft); }

.c-topic a { text-decoration: none; font-weight: 550; }
.c-topic a:hover { text-decoration: underline; }
.c-group, .c-therapy { color: var(--muted); }
.c-effect { width: 60px; padding-right: 0.4rem; }
.c-trial { white-space: nowrap; }
.c-year { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.c-finding { color: var(--ink); min-width: 20rem; }

.trial-link {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--venous) 35%, transparent);
}
.trial-link:hover { border-bottom-color: var(--venous); }
.year {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 0.4rem;
}

/* Below 720px a rowspan-grouped table cannot reflow, so the master table
   becomes a stack of cards. */
@media (max-width: 720px) {
  .master thead { display: none; }
  .master, .master tbody, .master tr, .master td, .master th { display: block; width: 100%; }
  .master tr {
    border-top: 1px solid var(--rule);
    padding: 0.7rem 0.85rem;
  }
  .master tbody tr:first-child { border-top: 0; }
  .master td, .master th { border: 0; padding: 0.1rem 0; }
  .master .c-topic { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; }
  .master .c-trial { display: inline-block; margin-right: 0.6rem; }
  .master .c-effect { display: inline-block; width: auto; }
  .master .c-group::after { content: " · "; }
  .master .c-group, .master .c-therapy { display: inline; font-size: 0.8rem; }
  .master .c-finding { min-width: 0; margin-top: 0.25rem; }
  .tablewrap { overflow-x: visible; }
}

/* --- topic page -------------------------------------------------------- */

.narrative { max-width: var(--measure); margin: 0 0 2.2rem; font-size: 1.02rem; }
.narrative p { margin: 0 0 0.9rem; }
.narrative strong { font-weight: 620; }

.qgroup { margin: 0 0 2rem; }
.qgroup > h2 {
  font-size: 0.78rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--rule);
  margin-bottom: 0.7rem;
}

.refs { margin: 2.4rem 0; max-width: 58rem; }
.refs__note { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.8rem; }
.refs--pending .reflist { border-left: 2px solid var(--rule); padding-left: 1rem; }

.reflist { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.reflist__head {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1rem 0 0.4rem;
  font-weight: 600;
}
.ref { margin: 0 0 0.55rem; padding-left: 0.9rem; text-indent: -0.9rem; }
.ref__text { color: var(--ink); }
.ref__link { font-family: var(--mono); font-size: 0.75rem; margin-left: 0.35rem; white-space: nowrap; }

/* --- trial page -------------------------------------------------------- */

.trialgrid { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 2rem; align-items: start; }
@media (max-width: 900px) { .trialgrid { grid-template-columns: 1fr; } }

.detail { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); }
.detail th {
  width: 11rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  vertical-align: baseline;
}
.detail td { line-height: 1.5; }
@media (max-width: 620px) {
  .detail, .detail tbody, .detail tr, .detail th, .detail td { display: block; width: auto; }
  .detail th { border-top: 1px solid var(--rule-soft); padding-bottom: 0.1rem; }
  .detail td { border-top: 0; padding-top: 0; }
}

.conclusion {
  margin: 1.6rem 0;
  padding: 0.9rem 1.2rem;
  border-left: 3px solid var(--venous);
  background: var(--card);
}
.conclusion p { margin: 0; font-size: 0.95rem; }
.conclusion cite {
  display: block; margin-top: 0.5rem; font-style: normal;
  font-family: var(--mono); font-size: 0.72rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.aged { margin: 1.8rem 0; max-width: var(--measure); }
.aged h2, .papers h2 {
  font-size: 0.78rem; font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); font-weight: 600;
  padding-bottom: 0.35rem; border-bottom: 2px solid var(--rule); margin-bottom: 0.7rem;
}

.papers { margin: 1.8rem 0; }
.paper {
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule-soft);
}
.paper:first-of-type { border-top: 0; }
.paper h3 { font-size: 0.98rem; font-weight: 600; }
.paper__cite { color: var(--muted); font-size: 0.83rem; margin: 0.2rem 0 0.5rem; }
.paper__findings { margin: 0.4rem 0; padding-left: 1.1rem; font-size: 0.9rem; }
.paper__findings li { margin-bottom: 0.2rem; }
.paper__links { font-family: var(--mono); font-size: 0.76rem; margin: 0.4rem 0 0; }

.verdict {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: sticky;
  top: 5.5rem;
}
.verdict__eyebrow {
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--muted); margin: 0 0 0.35rem;
}
.verdict__text { margin: 0; font-size: 1.02rem; line-height: 1.45; font-weight: 500; }
.verdict__effect {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0.8rem 0 0; font-size: 0.8rem; color: var(--muted);
}
.facts { margin: 1rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--rule-soft); font-size: 0.84rem; }
.facts dt {
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted); margin-top: 0.55rem;
}
.facts dt:first-child { margin-top: 0; }
.facts dd { margin: 0.1rem 0 0; }

.flag {
  border-left: 3px solid var(--arterial);
  background: color-mix(in srgb, var(--arterial) 8%, transparent);
  padding: 0.7rem 1rem;
  margin: 0 0 1.4rem;
  font-size: 0.88rem;
  max-width: 58rem;
}

/* --- topic grid, prose, footer ----------------------------------------- */

.topicgrid { margin: 3rem 0 1rem; }
.topicgrid > h2 {
  font-size: 0.78rem; font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); font-weight: 600;
  padding-bottom: 0.35rem; border-bottom: 2px solid var(--rule); margin-bottom: 1rem;
}
.topicgrid__group { break-inside: avoid; margin-bottom: 1.2rem; }
.topicgrid { columns: 3 15rem; column-gap: 2rem; }
.topicgrid > h2 { column-span: all; }
.topicgrid__group h3 { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.topicgrid__group ul { list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.topicgrid__group li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.12rem 0; }
.topicgrid__group a { text-decoration: none; }
.topicgrid__group a:hover { text-decoration: underline; }
.topicgrid__count { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }

.prose { max-width: var(--measure); }
.prose h2 { margin-top: 1.8rem; }
.prose p { margin: 0 0 0.9rem; }
.prose__disclaimer {
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--rule);
  color: var(--muted); font-size: 0.86rem;
}

.empty { color: var(--muted); font-style: italic; margin: 1rem 0; }

.footer {
  margin-top: 4rem;
  padding-top: 1.2rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.83rem;
}
.footer p { margin: 0 0 0.45rem; max-width: 62rem; }
.footer__disclaimer { color: var(--ink); font-weight: 500; }
.footer__meta { font-family: var(--mono); font-size: 0.74rem; }

/* --- tooltip ----------------------------------------------------------- */

.tip {
  position: absolute;
  z-index: 40;
  max-width: 22rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}
.tip[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  .masthead, .footer__meta, .search, .nav, .tip { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .tablewrap { overflow: visible; border: 0; }
}
