/* Research article layout. Loaded after styles.css on /research/* pages only. */
.research-page {
  --ink: #1d1c1a;
  --ink-soft: #3a3733;
  --muted: #6f6a62;
  --rule: #e1dbcf;
  --rule-strong: #cfc8bc;
  --card: #fffdf8;
  --tint: #f6f1e7;
  --teal: #087a7c;
  --teal-soft: rgba(8, 122, 124, 0.09);
  --orange: #c4652d;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #fbf9f4;
  color: var(--ink);
}

.research-page a { text-decoration-color: rgba(8, 122, 124, 0.4); }

/* ---------- article header ---------- */
.a-head {
  width: min(760px, calc(100vw - 40px));
  margin: 0 auto;
  padding: clamp(8px, 2vw, 24px) 0 0;
}
.a-kicker {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  font: 500 0.78rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.a-kicker a { color: var(--ink); text-decoration: none; }
.a-kicker a:hover { color: var(--teal); }
.a-kicker .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--rule-strong); }
.a-kicker .live { color: var(--teal); }
.a-head h1 {
  max-width: none; margin: 20px 0 16px;
  font: 400 clamp(2.6rem, 6vw, 4.2rem)/1.04 var(--serif); letter-spacing: -0.02em; color: var(--ink);
}
.a-deck {
  margin: 0 0 34px; color: var(--muted);
  font: italic 400 clamp(1.15rem, 2vw, 1.4rem)/1.5 var(--serif);
}

.a-hero { margin: 0 0 34px; }
.research-page .a-hero img { display: block; padding: 0; border: 0; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--tint); }

.a-meta {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px;
  padding: 22px 0 26px; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule);
}
.a-meta dt { margin-bottom: 8px; font: 500 0.72rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.a-meta dd { margin: 0 0 4px; font-size: 0.95rem; line-height: 1.5; color: var(--ink); }
.a-meta dd.soft { color: var(--muted); }

/* ---------- body: contents rail + reading column ---------- */
.a-body {
  width: min(1120px, calc(100vw - 40px)); margin: 0 auto; padding: 54px 0 40px;
  display: grid; grid-template-columns: 210px minmax(0, 700px); gap: 0 90px; justify-content: center; align-items: start;
}
.toc { position: sticky; top: 32px; font-size: 0.86rem; }
.toc h2 { margin: 0 0 14px; font: 500 0.72rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.toc ol { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--rule); }
.toc a {
  display: block; margin-left: -1px; padding: 6px 0 6px 14px; border-left: 1px solid transparent;
  color: var(--muted); text-decoration: none; line-height: 1.35;
}
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); border-left-color: var(--teal); font-weight: 600; }

.prose { min-width: 0; max-width: 700px; }
.prose section { margin: 0 0 76px; scroll-margin-top: 28px; }
.prose h2 { margin: 0 0 22px; font: 650 clamp(1.7rem, 3vw, 2.15rem)/1.15 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: -0.015em; }
.prose h3 { margin: 42px 0 12px; font: 650 1.16rem/1.3 ui-sans-serif, system-ui, sans-serif; letter-spacing: -0.005em; }
.prose p, .prose li { color: var(--ink-soft); font-size: 1.06rem; line-height: 1.72; }
.prose p { margin: 0 0 18px; max-width: none; }
.prose ul { padding-left: 1.15em; margin: 0 0 20px; }
.prose li { margin-bottom: 8px; }
.prose li::marker { color: var(--teal); }
.prose strong { color: var(--ink); font-weight: 650; }
.prose ul ul { margin: 8px 0 4px; }

.summary { padding: 22px 24px 6px; margin: 0 0 76px; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; }
.summary h2 { font-size: 1.05rem; margin-bottom: 12px; }

/* ---------- tables ---------- */
.prose .table-wrap {
  max-width: none; margin: 22px 0 28px; overflow-x: auto; background: var(--card);
  border: 1px solid var(--rule); border-radius: 12px;
}
.prose .table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
.prose .table-wrap th {
  padding: 12px 16px; background: var(--tint); border: 0; border-bottom: 1px solid var(--rule-strong);
  font: 500 0.7rem/1.3 var(--mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); text-align: left; white-space: nowrap;
}
.prose .table-wrap td { padding: 13px 16px; border: 0; border-bottom: 1px solid var(--rule); color: var(--ink-soft); line-height: 1.5; vertical-align: top; }
.prose .table-wrap tr:last-child td { border-bottom: 0; }
.prose .table-wrap td:first-child { color: var(--ink); font-weight: 600; }
.prose .table-wrap td.num, .prose .table-wrap th.num { text-align: right; }
.prose .table-wrap tr.is-ours td { background: var(--teal-soft); }
.prose .table-wrap tr.is-ours td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.prose .table-wrap.compact td:first-child { white-space: nowrap; }

/* ---------- figures ---------- */
.prose figure { margin: 28px 0 34px; padding: 0; max-width: none; }
.prose figure a { display: block; }
.prose figure img {
  width: 100%; height: auto; padding: 18px 18px 8px; background: var(--card);
  border: 1px solid var(--rule); border-bottom: 0; border-radius: 12px 12px 0 0;
}
.prose figcaption {
  margin: 0; padding: 12px 18px 14px; background: var(--card); border: 1px solid var(--rule); border-top: 1px dashed var(--rule);
  border-radius: 0 0 12px 12px; color: var(--muted); font-size: 0.86rem; line-height: 1.55; max-width: none;
}
.prose figcaption strong { font: 600 0.7rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); margin-right: 6px; }
.prose figure.small { max-width: 520px; }

/* ---------- callouts, steps, roadmap, timeline ---------- */
.callout {
  margin: 24px 0; padding: 16px 20px 6px; background: #fdf6ea; border: 1px solid #f0e2c8; border-radius: 12px;
}
.callout .label { display: block; margin-bottom: 8px; font: 600 0.7rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--orange); }
.callout p { font-size: 0.98rem; }

.prose ol.diagram { list-style: none; counter-reset: step; margin: 24px 0 30px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.prose ol.diagram li {
  counter-increment: step; margin: 0; padding: 12px 14px; background: var(--card); border: 1px solid var(--rule); border-radius: 10px;
  font-size: 0.9rem; line-height: 1.4; color: var(--ink);
}
.prose ol.diagram li::before { content: counter(step, decimal-leading-zero); display: block; margin-bottom: 6px; font: 500 0.72rem/1 var(--mono); color: var(--teal); }

.prose dl.roadmap { max-width: none; margin: 24px 0 24px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); overflow: hidden; }
.prose dl.roadmap div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 20px; padding: 14px 18px; border: 0; border-bottom: 1px solid var(--rule); }
.prose dl.roadmap div:last-child { border-bottom: 0; }
.prose dl.roadmap div.now { background: var(--teal-soft); }
.prose dl.roadmap dt { font: 500 0.74rem/1.5 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--teal); }
.prose dl.roadmap dd { margin: 0; font-size: 0.97rem; line-height: 1.55; color: var(--ink-soft); }

.prose ol.fails { list-style: none; counter-reset: f; margin: 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.prose ol.fails li { counter-increment: f; position: relative; margin: 0; padding: 16px 0 16px 46px; border-bottom: 1px solid var(--rule); }
.prose ol.fails li::before { content: counter(f, decimal-leading-zero); position: absolute; left: 0; top: 19px; font: 500 0.78rem/1 var(--mono); color: var(--orange); }

.prose ol.timeline { list-style: none; margin: 26px 0 0; padding: 0 0 0 26px; border-left: 2px solid var(--rule-strong); }
.prose ol.timeline li { position: relative; margin: 0 0 26px; padding: 0; }
.prose ol.timeline li::before { content: ""; position: absolute; left: -33px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: #fbf9f4; border: 2px solid var(--teal); }
.prose ol.timeline li.next::before { border-style: dashed; border-color: var(--muted); }
.prose ol.timeline time { display: block; margin-bottom: 4px; font: 500 0.74rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); }
.prose ol.timeline p { margin: 0; font-size: 1rem; }

.refs li { font-size: 0.93rem; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .a-body { grid-template-columns: minmax(0, 700px); gap: 0; }
  .toc { display: none; }
}
@media (max-width: 720px) {
  .a-meta { grid-template-columns: 1fr; gap: 18px; }
  .prose ol.diagram, .prose ol.diagram.two { grid-template-columns: 1fr; }
  .prose dl.roadmap div { grid-template-columns: 1fr; gap: 4px; }
  .prose figure img { padding: 8px 8px 4px; }
  .prose .table-wrap td, .prose .table-wrap th { padding: 11px 12px; }
  .summary { padding: 18px 18px 4px; }
}

/* Align the header with the reading column when the contents rail is visible */
@media (min-width: 1101px) {
  .a-head { width: 700px; margin-left: calc(50% - 200px); margin-right: 0; }
}

/* Wide numeric tables: let headers wrap, keep numbers on one line */
.prose .table-wrap th.num { white-space: normal; text-align: right; line-height: 1.25; }
.prose .table-wrap td.num { white-space: nowrap; }
.prose .table-wrap.wide th, .prose .table-wrap.wide td { padding-left: 12px; padding-right: 12px; }
.prose .table-wrap.wide td:first-child { min-width: 150px; }

.prose ol.diagram.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Research pages: slimmer top bar so the title sits close to the nav */
.research-page .nav { min-height: 64px; }

/* ---------- research index (/research/) ---------- */
.r-index { width: min(760px, calc(100vw - 40px)); margin: 0 auto; padding: clamp(8px, 2vw, 24px) 0 80px; }
.r-index .a-kicker { margin-bottom: 0; }
.r-index h1 { max-width: none; margin: 20px 0 16px; font: 400 clamp(2.6rem, 6vw, 4.2rem)/1.04 var(--serif); letter-spacing: -0.02em; color: var(--ink); }
.r-index .a-deck { margin-bottom: 44px; }
.posts { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--rule-strong); }
.post { border-bottom: 1px solid var(--rule); }
.post a.post-link { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; padding: 28px 0; color: inherit; text-decoration: none; }
.post img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--tint); }
.post .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 2px 0 12px; font: 500 0.74rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.post .meta .live { color: var(--teal); }
.post .meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--rule-strong); }
.post h2 { margin: 0 0 10px; font: 400 clamp(1.7rem, 3vw, 2.2rem)/1.1 var(--serif); letter-spacing: -0.01em; color: var(--ink); }
.post p { margin: 0; color: var(--ink-soft); font-size: 1rem; line-height: 1.6; }
.post .by { margin-top: 12px; color: var(--muted); font-size: 0.86rem; }
.post a.post-link:hover h2 { color: var(--teal); }
@media (max-width: 720px) {
  .post a.post-link { grid-template-columns: 1fr; gap: 16px; padding: 22px 0; }
}
