/* refs.css: shared styles for the Bedside References pages (/refs/...). Load after tokens.css and site.css.
   Values come from tokens.css only. Class of recommendation colours follow the ACC/AHA convention
   (I green, IIa yellow, IIb orange, III red) and always carry the class as text too. */

/* ---------- Page header extras ---------- */
.ref-src { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.ref-src li { font-size: var(--fs-xs); color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 2px 10px; }
.ref-src li b { color: var(--ink); font-weight: var(--w-strong); }

/* ---------- Sibling links within a category (filled by nav.js from REFS) ---------- */
.ref-sib ul { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-4) 0 0; padding: 0; list-style: none; }
.ref-sib a { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--link); font-size: var(--fs-sm); text-decoration: none; }
.ref-sib a:hover { border-color: var(--link); background: var(--selected-bg); }
.ref-sib a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ref-sib a[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: var(--surface); font-weight: var(--w-strong); }

/* ---------- Key points callout ---------- */
.keypoints { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--section-mark); border-radius: var(--radius); padding: var(--space-4) var(--space-5); margin: 0 0 var(--space-6); }
.keypoints h2 { margin-bottom: var(--space-3); }
.keypoints ul { margin: 0; padding-left: 18px; }
.keypoints li { margin-top: 6px; font-size: var(--fs-md); }
.keypoints li:first-child { margin-top: 0; }

/* ---------- Content sections ---------- */
.ref-sec { margin: 0 0 var(--space-6); scroll-margin-top: var(--space-5); }
.ref-sec > h2.sec { margin-bottom: var(--space-3); }
.ref-sec h3 { font-size: var(--fs-md); font-weight: var(--w-strong); margin: var(--space-5) 0 var(--space-2); color: var(--title-ink); }
.ref-sec > p, .ref-sec .prose p { max-width: 75ch; margin: 0 0 var(--space-3); }
.ref-note { font-size: var(--fs-sm); color: var(--muted); max-width: 75ch; margin: var(--space-2) 0 0; }
/* Short findings lists (myocarditis page): body-size bullets, a chip may lead the item. */
ul.ref-list { margin: 0 0 var(--space-3); padding-left: 18px; max-width: 75ch; font-size: var(--fs-md); }
ul.ref-list li { margin-top: 6px; }
ul.ref-list li:first-child { margin-top: 0; }
ul.ref-list .grp { margin-right: 4px; }
.tbl-wrap + ul.ref-list { margin-top: var(--space-3); }
.ref-sec .tbl-wrap.stack { margin-top: var(--space-5); }
blockquote.q { margin: var(--space-3) 0; padding: var(--space-2) var(--space-4); border-left: 3px solid var(--line); color: var(--ink); max-width: 75ch; font-size: var(--fs-md); }
blockquote.q cite { display: block; margin-top: 4px; font-style: normal; font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Class of recommendation chips ---------- */
.cls { display: inline-flex; align-items: center; justify-content: center; min-width: 4.4em; font-family: var(--font-num); font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; border-radius: var(--radius-sm); padding: 2px 6px; border: 1px solid transparent; white-space: nowrap; }
.cls-1 { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-line); }
.cls-2a { background: var(--caution-bg); color: var(--caution-fg); border-color: var(--caution-line); }
.cls-2b { background: var(--risk-2); color: var(--risk-2-on); border-color: var(--risk-2); }
.cls-3 { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-line); }
.cls-x { background: var(--surface-2); color: var(--muted); border-color: var(--line-control); }
.loe { font-family: var(--font-num); font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }

/* ---------- Recommendation tables ---------- */
table.rec { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.rec th { text-align: left; font-size: var(--fs-xs); font-weight: var(--w-section); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
table.rec td { vertical-align: top; padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line-subtle); }
table.rec td:first-child { width: 1%; }
@media (min-width: 641px) { table.rec th:first-child, table.rec td:first-child { width: 9.8em; } }
table.rec td.loe-c { width: 1%; padding-right: 0; }
table.rec tr.superseded td { color: var(--muted); }
table.rec caption { text-align: left; caption-side: top; font-size: var(--fs-sm); color: var(--muted); padding: 0 0 6px; }
@media (max-width: 640px) {
  table.rec thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
  table.rec, table.rec tbody, table.rec tr, table.rec td { display: block; width: auto !important; }
  table.rec tr { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line-subtle); }
  table.rec td { padding: 0; border: 0; }
  table.rec td.txt { grid-column: 1 / -1; grid-row: 2; }
  table.rec caption { display: block; width: auto; }
  table.rec td.loe-c { grid-column: 2; grid-row: 1; align-self: center; }
}

/* Parameter tables (one tbody per parameter): a header row names the parameter, with "how to measure" behind an
   info tip, then one row per age group. Each tbody is a filter section, so an age filter hides parameters with no
   values for that age. */
table.rec.params tr.p-head th, table.grade tr.p-head th { padding: 7px 10px 6px; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-size: var(--fs-base); font-weight: var(--w-strong); color: var(--title-ink); }
table.rec.params tbody + tbody tr.p-head th { border-top: 0; }
table.rec.params tr.p-head .p-unit, table.grade tr.p-head .p-unit { font-weight: 400; color: var(--muted); font-size: var(--fs-sm); }
/* Grading and reference tables use the same band, above their column headings; tables stacked in one area are spaced. */
.ref-sec > .p-blk ~ .p-blk { margin-top: var(--space-5); }
@media (max-width: 640px) {
  /* A wide grading table scrolls sideways on phones; its band (title, source, info tip) stays in view. */
  table.grade.wide tr.p-head th { padding: 0; }
  table.grade.wide tr.p-head .p-in { display: block; position: sticky; left: 0; box-sizing: border-box; width: calc(100vw - 2 * var(--gutter)); padding: 8px 10px; }
}
@media (max-width: 640px) {
  table.rec.params tr.p-head { display: block; padding: 0; margin-top: 10px; }
  table.rec.params tr.p-head th { display: block; padding: 8px 10px; }
}

/* ---------- Filter chips (aria-pressed buttons) ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.filters button { font: inherit; font-size: var(--fs-sm); min-height: 32px; padding: 0 12px; border-radius: var(--radius-pill); border: 1px solid var(--line-control); background: var(--field); color: var(--ink); cursor: pointer; }
.filters button:hover { border-color: var(--ink-2); }
.filters button[aria-pressed="true"] { background: var(--link); border-color: var(--link); color: var(--on-link); font-weight: var(--w-strong); }
.filter-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.filter-row > .lab { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); min-width: 5.5em; }
.filter-count { font-size: var(--fs-sm); color: var(--muted); margin: 0 0 var(--space-4); }

/* ---------- Hub cards ---------- */
.ref-search { max-width: 420px; margin: 0 0 var(--space-5); }
.ref-cat { margin: 0 0 var(--space-6); }
.ref-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
.ref-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.ref-card:hover { border-color: var(--link); color: var(--ink); }
.ref-card h3 { margin: 0; font-size: var(--fs-lg); font-weight: var(--w-strong); color: var(--title-ink); }
.ref-card:hover h3 { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.ref-card p { margin: 0; font-size: var(--fs-md); color: var(--ink); }
.ref-card .src { font-size: var(--fs-xs); color: var(--muted); margin-top: auto; padding-top: 6px; }
.ref-empty { color: var(--muted); font-size: var(--fs-md); }

/* ---------- Pre-participation checklist ---------- */
ol.pp { list-style: none; margin: 0; padding: 0; counter-reset: none; }
ol.pp > li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line-subtle); }
ol.pp > li:last-child { border-bottom: 0; }
ol.pp .n { font-family: var(--font-num); font-variant-numeric: var(--num-figures); color: var(--muted); font-size: var(--fs-sm); align-self: start; padding-top: 2px; }
ol.pp .t { font-size: var(--fs-md); min-width: 0; }
ol.pp .t small { display: block; color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
ol.pp .seg-opts { flex-wrap: nowrap; }
ol.pp .seg-opts span { min-height: 34px; padding: 0 12px; min-width: 3.4em; }
ol.pp > li.is-pos { background: linear-gradient(90deg, var(--caution-bg), transparent 70%); }
ol.pp > li.is-pos .n { color: var(--caution-fg); font-weight: 600; }
@media (max-width: 520px) {
  ol.pp > li { grid-template-columns: 2em minmax(0, 1fr); }
  ol.pp .seg-opts { grid-column: 2; justify-self: start; }
}
.pp-sum { list-style: none; margin: var(--space-3) 0 0; padding: 0; font-size: var(--fs-sm); }
.pp-sum li { padding: 3px 0; }
.pp-sum .n { font-family: var(--font-num); color: var(--muted); display: inline-block; min-width: 1.6em; }
.next-step { font-size: var(--fs-md); margin: var(--space-4) 0 0; }
.next-step .fn { display: block; color: var(--muted); font-size: var(--fs-xs); margin-top: 4px; }

/* ---------- Print: references are often printed for clinic ---------- */
@media print {
  .dc-nav, .dc-credit, .filters, .filter-row, .ref-search, .actions, .dock { display: none !important; }
  table.rec tr.is-hidden, .ref-sec.is-hidden { display: revert !important; }
  .results { position: static !important; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Echo references: population chips, grading tables, method boxes ---------- */
@media screen { .is-hidden { display: none !important; } }
.grp { display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: var(--w-strong); letter-spacing: 0.02em; border-radius: var(--radius-pill); padding: 2px 9px; white-space: nowrap; border: 1px solid transparent; }
.grp-neo { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.grp-peds { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand); }
.grp-adult, .grp-x { background: var(--surface-2); color: var(--muted); border-color: var(--line-control); }   /* grp-x: a cohort that is neither an age group nor adult */
.ev { display: inline-block; font-size: var(--fs-xs); color: var(--muted); border: 1px dashed var(--line-control); border-radius: var(--radius-sm); padding: 0 5px; margin-left: 4px; white-space: nowrap; }
table.rec td.src-c { width: 1%; padding-right: 0; font-size: var(--fs-sm); color: var(--muted); min-width: 11em; }
table.rec td .sub-l { display: block; font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
@media (max-width: 640px) {
  table.rec td.src-c { grid-column: 2; grid-row: 1; align-self: center; min-width: 0; }
}
.how { background: var(--surface); border: 1px solid var(--line-subtle); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-3); max-width: 90ch; }
.how h3 { margin: 0 0 4px !important; font-size: var(--fs-sm) !important; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted) !important; }
.how ul { margin: 0; padding-left: 18px; font-size: var(--fs-md); }
.how li { margin-top: 3px; }
table.grade { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.grade.wide { min-width: 560px; }
table.grade caption { text-align: left; caption-side: top; font-size: var(--fs-sm); color: var(--muted); padding: 0 0 6px; }
table.grade th { text-align: left; font-size: var(--fs-xs); font-weight: var(--w-section); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
table.grade th.g-mild { color: var(--success-fg); }
table.grade th.g-mod { color: var(--caution-fg); }
table.grade th.g-sev { color: var(--danger-fg); }
table.grade td { vertical-align: top; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line-subtle); }
table.grade td:first-child { font-weight: var(--w-strong); color: var(--ink); width: 24%; }
table.grade td .spec { font-weight: var(--w-strong); }
table.grade td small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.adult-flag { display: inline-block; font-size: var(--fs-xs); font-weight: var(--w-strong); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border: 1px solid var(--line-control); border-radius: var(--radius-sm); padding: 0 6px; margin-left: 6px; vertical-align: middle; }
.peds-box { border-left: 3px solid var(--brand); background: var(--surface); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); border-radius: 0 var(--radius) var(--radius) 0; max-width: 90ch; }
.peds-box h3 { margin: 0 0 4px !important; }
.peds-box ul, .peds-box ol { margin: 0; padding-left: 18px; }
.peds-box li { margin-top: 3px; }
.ref-group-h { font-family: var(--font-head); font-weight: var(--w-head); font-size: var(--fs-xl); line-height: 1.25; color: var(--title-ink); margin: var(--space-6) 0 var(--space-4); }
.filters-wrap { margin: 0 0 var(--space-4); }

/* ---------- Collapsed detail boxes: secondary content kept off the first read ---------- */
/* Quiet by design: a scanning reader should see the values, not the boxes (Paul, 2026-10-22). */
details.more { margin: var(--space-2) 0 var(--space-3); }
details.more > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 2px 0; cursor: pointer; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; letter-spacing: 0.01em; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+"; font-size: 13px; line-height: 1; width: 10px; text-align: center; flex: none; }
details.more[open] > summary::before { content: "\2212"; }
details.more > summary:hover { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
details.more > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
details.more[open] { padding-left: 12px; border-left: 2px solid var(--line); }
details.more[open] > summary { margin-left: -12px; padding-left: 12px; }
details.more > :last-child { margin-bottom: var(--space-2); }

/* Values first: bold numbers in reference tables carry the strongest ink. */
table.rec td.txt { color: var(--ink-2); }
table.rec td.txt b, table.rec td.txt strong { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
details.more > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--radius); }
details.more > :not(summary) { margin-left: 12px; margin-right: 12px; }
details.more > :last-child { margin-bottom: 12px; }

/* Section heading link to a category hub (e.g. Echocardiography on /refs) */
.sec .sec-link { margin-left: 10px; font-size: var(--fs-sm); font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--link); }

/* Source attributions link to the article (Paul, 2026-10-22): quiet until hovered, like the source text itself. */
table.rec td.src-c a, .ref-src li a, caption a.src, tr.p-head .p-unit a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
table.rec td.src-c a:hover, .ref-src li a:hover, caption a.src:hover, tr.p-head .p-unit a:hover { color: var(--link); text-decoration-color: currentColor; }

/* ==========================================================================
   PHONES (screen, 640px and narrower): values first, sources one tap away (Paul, 2026-10-23).
   Everything in this section applies to phones only; desktop (641px and wider) and print are unchanged.
   Nothing is removed: source chrome is hidden until the reader taps "Show sources" (refs.js sets html.src-on),
   and the collapsed "Sources and how this page was checked" box stays the place to fact-check.
   ========================================================================== */
.src-tog { display: none; }
@media screen and (max-width: 640px) {
  /* Source chrome: pills under the title, plain-citation Source cells (refs.js marks them .src-only; a cell with an
     evidence tag such as "abstract" or "secondary", a class / LOE chip or provenance wording stays visible), and
     caption citations (wrapped in .src-x by refs.js). */
  html:not(.src-on) ul.ref-src,
  html:not(.src-on) table.rec td.src-c.src-only,
  html:not(.src-on) table.rec td.src-c:empty,
  html:not(.src-on) .src-x { display: none; }
  /* Citation links in the text read as plain words (not tappable) until sources are shown. */
  html:not(.src-on) .wrap a[href^="https://doi.org/"]:not(details.method a):not(.tip-pop a) { color: inherit; text-decoration: none; pointer-events: none; }

  /* Rows that lose their Source cell: the age chip leads and the values wrap beside it (one line saved per row).
     Rows whose first cell is a text label keep the label on its own line. */
  html:not(.src-on) table.rec tr:has(> td.src-c:is(.src-only, :empty)):has(> td:first-child > .grp:only-child) { display: flow-root; }
  html:not(.src-on) table.rec tr:has(> td.src-c:is(.src-only, :empty)):has(> td:first-child > .grp:only-child) > td:first-child { float: left; margin: 0 8px 0 0; }
  html:not(.src-on) table.rec tr:has(> td.src-c:is(.src-only, :empty)):has(> td:first-child > .grp:only-child) > td.txt { display: block; }

  /* An info button stays on the line with the word before it (refs.js wraps both in .nobr). */
  .nobr { white-space: nowrap; }

  /* The toggle: small, quiet, beside the filter count (or at the foot of the header on pages without filters). */
  .src-tog {
    display: inline-flex; align-items: center; flex: none; min-height: 40px; margin: 0; padding: 0 2px;
    border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--link);
    font-size: var(--fs-sm); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-control);
  }
  .src-tog:hover { color: var(--link-hover); border-color: transparent; }
  .page-head > .src-tog { display: flex; width: fit-content; margin: 2px 0 -6px auto; }
  .filters-wrap:has(> .src-tog) { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; }
  .filters-wrap:has(> .src-tog) > :not(.filter-count):not(.src-tog) { flex: 1 1 100%; min-width: 0; }
  .filters-wrap:has(> .src-tog) > .filter-count { flex: 1 1 0; min-width: 0; margin: 0; }
  .filters-wrap > .src-tog { margin-left: auto; }

  /* Sibling links and filter chips: one row each that scrolls sideways, 40px tap targets. */
  .ref-sib ul, .filters {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    margin-right: calc(-1 * var(--gutter)); padding: 3px var(--gutter) 3px 3px; margin-left: -3px;
  }
  .ref-sib ul::-webkit-scrollbar, .filters::-webkit-scrollbar { display: none; }
  .ref-sib ul { margin-top: var(--space-3); }
  .ref-sib li, .filters li { flex: none; }
  .ref-sib a, .filters button { min-height: 40px; white-space: nowrap; }
  .filter-row { flex-wrap: nowrap; align-items: center; }
  .filter-row > .lab { flex: none; min-width: 0; max-width: 6.5em; line-height: 1.25; }
  .filter-row > .filters { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }

  /* Pre-participation checklist: No / Yes answers at full phone tap height. */
  ol.pp .seg-opts span { min-height: 40px; }

  /* Wide grading tables scroll inside their box; keep the caption readable within the screen. */
  table.grade caption { max-width: calc(100vw - 2 * var(--gutter)); }

  /* /refs hub: compact cards, two-line descriptions, no source line (each page lists its sources). */
  .ref-cards { gap: var(--space-3); }
  .ref-card { gap: 2px; padding: var(--space-3) var(--space-4); }
  .ref-card p { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .ref-card .src { display: none; }
  .ref-cat { margin-bottom: var(--space-5); }

  /* /refs/echo hub: no blurb (the jump chips list the same measurements); chips in one sideways row. */
  .hubs .hub { padding: var(--space-4); }
  .hubs .hub-h { margin-bottom: var(--space-3); }
  .hubs .hub-blurb { display: none; }
  .hub-list .chips {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    margin: 4px calc(-1 * var(--space-4)) 0 -3px; padding: 3px var(--space-4) 3px 3px;
  }
  .hub-list .chips::-webkit-scrollbar { display: none; }
  .hub-list .chips li { flex: none; }
  .hub-list .chips a { min-height: 40px; white-space: nowrap; }
  .hubs .hub-page { display: inline-flex; align-items: center; flex-wrap: wrap; min-height: 40px; }
}
