/* ============================================================================
   Research — the posts (research/<post>/index.html). No post is published
   yet; these styles wait for the first one. The full layout, with sample
   content, is on file in agents/proposals/research/sample-paper/. The list of posts
   (research/index.html), the document head and the back link are the shared
   listing component (listing.css).

   A post is a long read in the role pages' two tracks: the head on the
   gutter (back link, title, byline, authors, actions), then under a full-
   width hairline a sticky Contents list in the left third and the article in
   the right two-thirds: prose at a 66-character measure, figures and tables
   across the track's full width.
   ============================================================================ */

/* --- The head -------------------------------------------------------------- */

.post-head__title {
  max-width: 24ch;
  margin-top: clamp(28px, 4vw, 56px);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, 3.6vw, 52px);
  line-height: 1.12;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.post-head__meta {
  margin-top: clamp(16px, 1.8vw, 22px);
  color: var(--ink-3);
  font-size: 15px;
  line-height: 24px;
}

.post-head__meta span:first-child {
  color: var(--ink-2);
}

.post-head__meta span + span::before {
  content: "·";
  margin-inline: .55em;
}

.post-head__authors {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.5;
}

.post-head__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 28px;
  margin-top: clamp(24px, 3vw, 36px);
}

.post-head__actions .text-link {
  font-size: 16px;
  font-weight: 500;
}

/* --- The body: contents left, article right ------------------------------- */

.post-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  column-gap: clamp(24px, 3vw, 48px);
  margin-top: clamp(64px, 8vw, 120px);
  padding-top: clamp(28px, 3vw, 40px);
  border-top: 1px solid var(--rule);
}

/* clear of the floating header's capsule */
.toc {
  position: sticky;
  top: 112px;
  align-self: start;
}

.toc__name {
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
}

.toc ol {
  margin-top: 16px;
}

/* each entry is marked by the list dash: Rule at rest, Ink when current */
.toc a {
  position: relative;
  display: block;
  padding: 6px 0 6px 28px;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1.4;
  text-decoration: none;
  transition: color var(--fast) var(--ease-out);
}

.toc a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 14px;
  height: 1px;
  background: var(--rule);
  transition: background-color var(--fast) var(--ease-out);
}

.toc a:hover,
.toc a[aria-current="true"] {
  color: var(--ink);
}

.toc a[aria-current="true"]::before {
  background: var(--ink);
}

.article {
  grid-column: 2;
  min-width: 0;
}

.article p,
.article ol {
  max-width: 66ch;
  color: var(--ink-2);
  font-size: clamp(17px, 1.32vw, 19px);
  line-height: 1.62;
  text-wrap: pretty;
}

.article p + p {
  margin-top: 1em;
}

/* the abstract is the lede: larger, in Ink, because for most readers it is
   the whole paper. 22px is a new step (the prose is already 19px at laptop
   width, the Lede's size): to be recorded in DESIGN.md if approved. */
.article .abstract {
  color: var(--ink);
  font-size: clamp(19px, 1.6vw, 22px);
  line-height: 1.5;
}

.article h2 {
  margin-top: clamp(56px, 6vw, 80px);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(24px, 2.2vw, 30px);
  line-height: 1.2;
  letter-spacing: -.015em;
  scroll-margin-top: 112px;
}

.article h3 {
  margin-top: 36px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
}

.article h2 + p,
.article h2 + ol {
  margin-top: 20px;
}

.article h3 + p,
.article h3 + pre {
  margin-top: 10px;
}

.fn {
  font-size: .7em;
  line-height: 0;
  vertical-align: super;
}

.fn a {
  margin-left: 1px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}

.fn a:hover {
  text-decoration: underline;
  text-underline-offset: .2em;
}

/* --- Figures, tables, code, quotes ---------------------------------------- */

.figure {
  margin-block: clamp(40px, 5vw, 56px);
}

.figure svg {
  width: 100%;
  height: auto;
}

.fig-grid path { fill: none; stroke: var(--rule); stroke-width: 1; }
.fig-axis      { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.fig-a         { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.fig-b         { fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-dasharray: 5 5; }
/* in the figure's own units: about 15px at the article's full width */
.fig-label text { fill: var(--ink-3); font-family: var(--text); font-size: 11px; }

.figure figcaption,
.table-wrap caption {
  max-width: 66ch;
  margin-top: 14px;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1.55;
  text-align: left;
  text-wrap: pretty;
}

.figure figcaption b {
  color: var(--ink-2);
  font-weight: 500;
}

.table-wrap {
  margin-block: clamp(32px, 4vw, 48px);
  overflow-x: auto;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.table-wrap caption {
  caption-side: bottom;
}

.table-wrap th,
.table-wrap td {
  padding: 12px 20px 12px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.table-wrap thead th {
  border-bottom-color: var(--ink);
  color: var(--ink);
  font-weight: 500;
}

.table-wrap tbody th {
  color: var(--ink);
  font-weight: 400;
}

.table-wrap td {
  color: var(--ink-2);
}

.table-wrap .num {
  padding-right: 0;
  padding-left: 20px;
  text-align: right;
}

.code {
  margin-block: 24px;
  padding-block: 18px;
  border-block: 1px solid var(--rule);
  overflow-x: auto;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
  tab-size: 4;
}

.pull {
  margin: clamp(40px, 5vw, 56px) 0;
}

.article .pull p {
  max-width: 22ch;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1.2;
  letter-spacing: -.015em;
  text-wrap: balance;
}

.refs {
  padding-left: 1.4em;
  list-style: decimal;
}

.article .refs {
  font-size: 15px;
  line-height: 1.6;
}

.refs li + li {
  margin-top: 10px;
}

.refs li::marker {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.refs__back {
  margin-left: 6px;
  color: var(--ink-3);
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: var(--link-line);
  text-underline-offset: .28em;
}

.refs__back:hover {
  color: var(--ink);
}

.cite {
  position: relative;
  margin-top: 20px;
}

.cite .code {
  margin: 0;
  padding-right: 88px;
}

.copy {
  position: absolute;
  top: 12px;
  right: 0;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease-out);
}

.copy:hover {
  border-color: var(--ink);
}

/* --- Narrower screens ------------------------------------------------------ */

@media (max-width: 900px) {
  .post-body {
    display: block;
  }

  /* on one track the headings carry the structure; contents would only
     push the abstract down */
  .toc {
    display: none;
  }
}

@media (max-width: 640px) {
  .post-head__authors {
    font-size: 16px;
  }

}
