/* Shared stylesheet for the research summaries linked from the
   Evidence-based content section (humanvsbovine/, hmf/, earlyfeed/).
   Visual style follows the human- vs bovine-derived fortifier review;
   the contents list is a sticky sidebar that collapses above the text
   on narrow screens. No external dependencies. */

:root {
  --ink: #1b1e22;
  --muted: #5b6470;
  --line: #dfe3e8;
  --panel: #f4f6f8;
  --accent: #0f4761;
  --accent-ink: #0b3548;
  --accent-tint: #eaf1f5;
  --good: #1f7a4d;
  --good-bg: #e6f4ec;
  --warn: #9a6a00;
  --warn-bg: #fbf1dc;
  --bad: #a3312a;
  --bad-bg: #faeae9;
  --radius: 6px;
  --measure: 72ch;
  --page: 1240px;
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.09rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid #b4551b; outline-offset: 2px; }
::selection { background: #cfe2ea; }

h1, h2, h3, h4 { font-family: var(--font-ui); color: var(--ink); line-height: 1.3; }
h1 { font-weight: 700; }
h2 { font-weight: 700; font-size: 1.5rem; margin: 0 0 0.6em; padding-bottom: 0.5rem; border-bottom: 2px solid var(--accent-tint); }
h3 { font-weight: 700; font-size: 1.18rem; margin: 2.2em 0 0.6em; color: var(--accent-ink); }
h4 { font-weight: 700; font-size: 1.02rem; margin: 1.6em 0 0.5em; }
p { margin: 0 0 1.15em; }
.measure { max-width: var(--measure); }
code {
  background: var(--panel); border: 1px solid var(--line); border-radius: 3px;
  padding: 0.08em 0.34em; font: 0.84em/1.4 var(--font-mono);
}

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--accent-ink); color: #fff; padding: 0.7rem 1.1rem; border-radius: var(--radius);
  font-family: var(--font-ui); font-weight: 700; text-decoration: none; transition: top 0.15s;
}
.skip-link:focus { top: 1rem; }

.wrap { width: min(100% - 2.5rem, 880px); margin-inline: auto; }
.wrap--wide { width: min(100% - 2.5rem, 1080px); margin-inline: auto; }

/* Masthead */
.masthead { background: var(--accent-ink); color: #fff; padding: 3rem 0 2.5rem; }
.masthead .wrap, .site-footer .wrap { width: auto; max-width: var(--page); padding-inline: 1.5rem; }
.masthead .kicker { font-family: var(--font-ui); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: #a9c7d6; margin: 0 0 1rem; }
.masthead h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem); font-weight: 700; margin: 0 0 1rem; max-width: 32ch; color: #fff; }
.masthead .dek { font-family: var(--font-ui); font-size: 1.05rem; color: #d7e4ea; margin: 0; max-width: 72ch; }
.masthead .dek + .dek { margin-top: 0.75rem; }
.masthead .dek b, .masthead .dek strong { color: #fff; }
.masthead .meta {
  font-family: var(--font-ui); font-size: 0.88rem; color: #a9c7d6; margin-top: 1.5rem;
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem;
}
.masthead .meta strong { color: #fff; font-weight: 600; }

/* Page layout: sidebar contents + article */
.layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 3rem;
  max-width: var(--page); margin: 0 auto; padding: 0 1.5rem;
}
.layout .wrap, .layout .wrap--wide { width: auto; margin-inline: 0; }

/* Sidebar table of contents */
.toc {
  position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto;
  padding: 2rem 1.25rem 3rem 0; border-right: 1px solid var(--line);
  font-family: var(--font-ui); font-size: 0.84rem; line-height: 1.45;
}
.toc h2 {
  font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); border: 0; margin: 0 0 0.85rem; padding: 0 0 0.6rem; border-bottom: 1px solid var(--line);
}
.toc ol, .toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0.4em 0; break-inside: avoid; }
.toc li ul, .toc li ol { padding-left: 0.8rem; border-left: 1px solid var(--line); margin: 0.35em 0 0.6em; }
.toc a { display: block; color: var(--muted); text-decoration: none; padding: 0.08rem 0; }
.toc > ol > li > a, .toc > ul > li > a { color: var(--ink); font-weight: 600; }
.toc a:hover { color: var(--accent); text-decoration: underline; }
.toc .n { float: left; min-width: 1.9em; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 0.08rem; }
.toc .n + a { margin-left: 1.9em; }

/* Article body */
.doc { min-width: 0; padding-block: 1rem 2rem; }
section.block { padding-block: 2.4rem; border-top: 1px solid var(--line); }
section.block:first-of-type { border-top: 0; }
.subsection { margin-top: 2.4rem; }
.subsection:first-child { margin-top: 0; }

/* Flat documents (no section wrappers): same rhythm and measure */
.doc > p, .doc > ul, .doc > ol, .doc > h2, .doc > h3, .doc > h4, .doc > blockquote { max-width: var(--measure); }
.doc > h2 { margin-top: 2.4rem; }
.doc > h2:first-child { margin-top: 1.4rem; }
.doc > hr { border: 0; border-top: 1px solid var(--line); margin: 2.4rem 0 0; }
.doc li { margin-bottom: 0.4em; }

.callout, .doc blockquote {
  background: var(--accent-tint); border-left: 4px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.25rem 1.5rem; margin: 0 0 1.5rem;
}
.doc blockquote { margin: 1.5rem 0; }
.callout p:last-child, .doc blockquote p:last-child { margin-bottom: 0; }

.lead-in { font-weight: 700; font-family: var(--font-ui); font-size: 0.97rem; }

/* Figures */
figure.doc-figure, .doc figure { margin: 1.75rem 0 2.25rem; }
figure.doc-figure img, .doc figure img {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  margin-inline: auto;
}
figure.doc-figure figcaption, .doc figcaption {
  font-family: var(--font-ui); font-size: 0.92rem; line-height: 1.55; color: var(--muted);
  margin: 0.75rem auto 0; text-align: center; max-width: var(--measure);
}
figure.doc-figure figcaption strong, .doc figcaption strong, .doc figcaption .fignum { color: var(--ink); font-weight: 700; }

/* Tables */
.table-scroll, .tw { overflow-x: auto; margin: 1.5rem 0 2rem; border: 1px solid var(--line); border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
table {
  border-collapse: collapse; width: 100%; min-width: 560px;
  font-family: var(--font-ui); font-size: 0.92rem; line-height: 1.5;
}
caption {
  caption-side: top; text-align: left; font-weight: 700; padding: 0.9rem 1rem 0.7rem; color: var(--ink);
  background: var(--panel); border-bottom: 1px solid var(--line);
}
th, td { padding: 0.65rem 0.9rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { background: var(--panel); font-weight: 700; white-space: nowrap; border-bottom: 2px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td:not(:first-child), th:not(:first-child) { font-variant-numeric: tabular-nums; }

.certainty { display: inline-block; font-family: var(--font-ui); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.02em; padding: 0.2rem 0.6rem; border-radius: 999px; white-space: nowrap; }
.certainty--high { background: var(--good-bg); color: var(--good); }
.certainty--moderate { background: var(--accent-tint); color: var(--accent-ink); }
.certainty--low { background: var(--warn-bg); color: var(--warn); }
.certainty--very-low { background: var(--bad-bg); color: var(--bad); }

/* Back to top / footer */
.back-to-top { text-align: center; margin: 2.5rem 0 0; }
.back-to-top a {
  font-family: var(--font-ui); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase;
  text-decoration: none; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.5rem 1.1rem;
}
.back-to-top a:hover { color: var(--accent-ink); border-color: var(--accent); }

.site-footer { background: var(--panel); border-top: 1px solid var(--line); padding: 2rem 0 3rem; margin-top: 1rem; }
.site-footer p { font-family: var(--font-ui); font-size: 0.86rem; color: var(--muted); margin: 0 0 0.5rem; }

/* Narrow screens: contents move above the text */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0 1.25rem; }
  .masthead .wrap, .site-footer .wrap { padding-inline: 1.25rem; }
  .toc { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); padding: 1.5rem 0 1rem; }
  .toc > ol, .toc > ul { columns: 2; column-gap: 2rem; }
  .toc li ul, .toc li ol { display: none; }
}
@media (max-width: 560px) {
  .toc > ol, .toc > ul { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .toc, .back-to-top, .skip-link { display: none !important; }
  .layout { display: block; max-width: none; padding: 0; }
  .masthead { background: #fff !important; color: #000 !important; padding: 0 0 1rem; }
  .masthead h1 { color: #000 !important; }
  .masthead .kicker, .masthead .dek, .masthead .meta, .masthead .meta strong, .masthead .dek b { color: #333 !important; }
  section.block { border-top: 1px solid #ccc; break-inside: avoid-page; }
  figure, .tw, .table-scroll { break-inside: avoid-page; }
  .tw, .table-scroll { overflow: visible; }
  h2, h3 { break-after: avoid; }
  a { color: inherit; text-decoration: none; }
}
