/* ============================================================
   QD-Rec technical page: a thin overlay on top of distill.pub
   template.v2 (https://distill.pub/template.v2.js).

   template.v2 owns typography, the page grid, <d-cite>, <d-math>
   and the reference list. This file only styles what is ours:
     - the front matter (title, then the authors and the resource links, unlabeled)
     - wide figures, figure grids, sub-captions
     - result tables (generated by gen_tables.py) and the "ingredients" table
     - verbatim example blocks
   ============================================================ */

:root {
  --content-width: 984px;
  --rule: rgba(0, 0, 0, 0.1);
  --muted: rgba(0, 0, 0, 0.55);
  --ink: rgba(0, 0, 0, 0.85);
  --link: #1f5fa8;
  --link-hover: #164a85;
  --best: #cce3fd;           /* same light blue the paper's tables use for best cells */
}

/* ---- Front matter (custom, not d-front-matter) ---- */
.front-matter {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 88px 24px 8px 24px;
  box-sizing: border-box;
}
.article-header { padding: 0; }

h1.title {
  font-size: 36px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 14px 0;
}
p.subtitle {
  font-size: 18px;
  line-height: 1.45;
  color: var(--muted);
  margin: 0 0 36px 0;
  font-weight: 300;
}
p.subtitle strong { color: var(--ink); font-weight: 600; }

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);   /* Authors | Resources */
  gap: 32px;
  padding: 10px 0 8px 0;
  align-items: start;
}
.resource-list { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 1.6;
  display: flex; flex-wrap: wrap; gap: 4px 22px; }   /* the three links on one line */
.resource-list li { margin: 0; }
.resource-list a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--link);
  text-decoration: none;
}
.resource-list a span { border-bottom: 1px solid rgba(31, 95, 168, 0.3); }
.resource-list a:hover { color: var(--link-hover); }
.res-icon { width: 14px; height: 14px; flex: 0 0 14px; display: block; }

.authors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 18px; }
.author p { margin: 0; font-size: 13px; line-height: 1.4; }
.author .name { font-weight: 600; }
.author .affiliation { color: var(--muted); font-size: 12px; margin-top: 2px; }


/* ---- Widen distill's text column to the same 984px as the front matter ---- */
d-article > p,
d-article > h1,
d-article > h2,
d-article > h3,
d-article > h4,
d-article > ul,
d-article > ol,
d-article > blockquote,
d-article > details,
d-article > .table-scroll,
d-article > .ingredients-wrap {
  grid-column: page;
  box-sizing: border-box;
  max-width: var(--content-width);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}
d-article > ul, d-article > ol { padding-left: 48px; }
d-article li { margin-bottom: 6px; }

/* ---- Keep subsection headings closer to the preceding content ---- */
d-article > h3 { margin-top: 24px; }
d-article > h2 + h3 { margin-top: 8px; }

/* ---- Figures ---- */
d-article figure.figure-wide {
  grid-column: page;
  box-sizing: border-box;
  max-width: var(--content-width);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}
d-article figure { margin: 32px 0; text-align: center; }
d-article figure img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
d-article figure img.run-curves { width: 100%; max-width: 840px; }
d-article figure img.narrow { max-width: 720px; }
d-article figure img.narrower { max-width: 600px; }
d-article figcaption {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 12px;
  text-align: left;
}
d-article figcaption strong { color: var(--ink); font-weight: 600; }

.fig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.fig-grid .cell img { width: 100%; }
.fig-grid .sub { font-size: 12.5px; color: var(--muted); margin: 6px 0 0 0; text-align: center; }
/* Row labels in a figure stacked from several full-width images (Figure 2). */
d-article figure p.row-label { font-size: 12.5px; line-height: 1.4; color: var(--muted); margin: 18px 0 4px 0; text-align: center; }
d-article figure p.row-label:first-child { margin-top: 0; }

/* ---- Result tables (filled in by gen_tables.py) ---- */
.table-scroll { overflow-x: auto; margin-top: 24px; margin-bottom: 8px; }
d-article > .table-scroll.results-wide {
  grid-column: 1 / -1;
  max-width: 1600px;
  min-width: 0;
}
table.results {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
table.results th, table.results td {
  font-size: inherit;
  padding: 4px 7px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
table.results thead th { font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--rule); }
table.results thead th.group { text-align: center; border-bottom: 2px solid rgba(0, 0, 0, 0.25); }
table.results th.txt, table.results td.txt { text-align: left; color: var(--ink); }
table.results td.gs { border-left: 1px solid var(--rule); }
table.results td.best { background: var(--best); font-weight: 600; }
table.results .metric-se { font-size: 12px; }
table.results tr.block td { text-align: left; font-style: italic; background: #fafafa; padding-top: 8px; }
table.results.compact { width: auto; min-width: 420px; }
.table-note { font-size: 13px; line-height: 1.55; color: var(--muted); margin-top: 0; }
.table-note strong { color: var(--ink); font-weight: 600; }

/* ---- "Ingredients" table ---- */
.ingredients-wrap { margin-top: 20px; }
table.ingredients { border-collapse: collapse; margin: 0 auto; font-size: 14px; }
table.ingredients th, table.ingredients td { padding: 6px 18px; text-align: center; border-bottom: 1px solid var(--rule); }
table.ingredients th:first-child, table.ingredients td:first-child { text-align: left; }
table.ingredients thead th { font-weight: 600; border-bottom: 2px solid rgba(0, 0, 0, 0.25); }
table.ingredients .yes { color: #2e7d32; font-weight: 700; }
table.ingredients .no { color: #b23b3b; font-weight: 700; }

/* ---- Verbatim examples / details ---- */
d-article details { margin-top: 8px; margin-bottom: 24px; }
d-article details summary { cursor: pointer; color: var(--link); font-weight: 600; font-size: 15px; }
.example-label { font-size: 13px; color: var(--muted); margin: 14px 0 6px 0; }
.example {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  background: #fafafa;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 12px 14px;
  white-space: pre-wrap;
  overflow-x: auto;
  margin: 0 0 20px;
}

/* ---- Bibliography is data-only; the rendered list is d-citation-list ---- */
d-bibliography { display: none; }
d-citation-list {
  display: block !important;
  max-width: var(--content-width);
  margin: 8px auto 64px auto;
  padding: 0 24px;
}
d-citation-list h3 {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 28px 0 10px 0;
  border: none;
}
d-citation-list .references { list-style: decimal; padding-left: 24px; margin: 0; font-size: 14px; line-height: 1.6; grid-column: unset !important; }
d-citation-list .references li { margin: 0 0 10px 0; padding-left: 4px; }
d-citation-list .references .title { font-weight: 600; }
d-citation-list .references a { color: var(--link); font-size: 13px; }

/* ---- Responsive ---- */
@media (max-width: 1000px) {
  .masthead { grid-template-columns: 1fr; gap: 22px; }
  .authors { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  h1.title { font-size: 28px; }
  p.subtitle { font-size: 16px; }
  .authors { grid-template-columns: repeat(2, 1fr); }
  .front-matter { padding-top: 48px; }
  .fig-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .authors { grid-template-columns: 1fr; }
}

/* ============================================================
   ---- Hero replay ----
   The animated band between the masthead and the Introduction (markup:
   #replay-hero in index.html, behaviour: replay.js, data: data/replay.js).
   ============================================================ */
.hero {
  background: transparent;
  width: 100%;
  outline: none;
}
/* template.v2 draws a full-width rule above d-article; with the replay band directly
   above the Introduction that rule is one line too many. Their styles are injected
   after ours, hence the !important. */
d-article { border-top: none !important; padding-top: 4px !important; }
d-article > h2:first-of-type { margin-top: 0.6em; }   /* Introduction sits close under the replay */
.hero-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 12px 24px 0 24px;
  box-sizing: border-box;
}
/* The panels, status lines and counter are styled by replay.js itself. */
.hero-caption {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 12px 0 0 0;
  text-align: left;
}
.hero-caption strong { color: var(--ink); font-weight: 600; }
.hero noscript img { display: block; width: 100%; height: auto; }

/* The hero sits directly above the front matter, which already has its own
   generous top padding; pull that in so the two do not double up. */
.hero + .front-matter { padding-top: 40px; }

@media (max-width: 1000px) {
  .hero-inner { padding: 20px 24px; }
}
@media (max-width: 720px) {
  .hero-inner { padding: 16px 18px; }
  .hero-caption { font-size: 12.5px; }
  .hero + .front-matter { padding-top: 28px; }
}

/* ---- Example tabs (Example recommendations) ----
   A wider box encloses each example and its explanation. The script at the end of
   index.html adds .qd-js; without it the tabs stay hidden and both panels show. */
d-article > .qd-tabs {
  grid-column: page;
  box-sizing: border-box;
  width: calc(100% - 48px);
  max-width: calc(var(--content-width) - 48px);
  margin: 8px auto 40px;
  padding: 24px 28px;
  background: #f6f7f9;
  border: 1px solid #dfe2e7;
  border-radius: 12px;
}
.qd-tablist { display: none; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.qd-js .qd-tablist { display: flex; }
.qd-tablist button {
  font: inherit; font-size: 14px; line-height: 1.4; padding: 7px 16px;
  border-radius: 999px; border: 1px solid #d0d0d0; background: #ffffff; color: var(--ink);
  cursor: pointer;
}
.qd-tablist button:hover { border-color: #999999; }
.qd-tablist button[aria-selected="true"] { background: #1a1a1a; border-color: #1a1a1a; color: #ffffff; }
.qd-tablist button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.qd-js .qd-panel[hidden] { display: none; }
.qd-panel > h3:first-child { margin-top: 0; }
.qd-panel > p:last-child { margin-bottom: 0; }
.qd-panel .example { background: #fff; }
.qd-example-note {
  margin: 24px 0 0;
  padding-top: 16px;
  border-top: 1px solid #d5d9df;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}
d-article .qd-example-note p { margin: 0; font-size: inherit; line-height: inherit; }
d-article .qd-example-note .qd-note-title { margin-bottom: 8px; font-weight: 600; }
.qd-example-note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; border-bottom: none; }
.qd-tabs:not(.qd-js) .qd-panel + .qd-panel {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid #dfe2e7;
}
@media (max-width: 560px) {
  d-article > .qd-tabs { width: calc(100% - 32px); padding: 16px; }
}

/* ---- Influence marks (Example recommendations) ----
   Coloured text marks the passages of a parent hypothesis that the child took up, and the
   passages of the child that reflect them; the same colour marks a matching pair. The three
   colours (Okabe-Ito vermilion and blue, and a darkened bluish green for contrast on white)
   stay distinguishable for colour-blind readers. The page has no dark theme, so there is
   no dark variant. */
.infl-1 { color: #D55E00; }
.infl-2 { color: #0072B2; }
.infl-3 { color: #007A5A; }
/* One-line domain and profile setting under each example's heading. */
.example-setting { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 0 0 4px 0; }
