/* Layout and typography for _layouts/research-post.html.
   Sans-serif prose, a tinted title band, light section headings over a hairline,
   grouped citations, and a contents list in the left margin on wide screens. */

.rp {
  --rp-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --rp-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --rp-ink: #262a26;
  --rp-text: #33372f;
  --rp-muted: #6b6f68;
  --rp-faint: #9a9d96;
  --rp-line: #e3e1da;
  --rp-link: #2f4aa6;
  --rp-tint: #eef0f8;
  --rp-tint-line: #d6dcf0;
  --sans: var(--rp-sans);
  --mono: var(--rp-mono);
  --ink: var(--rp-ink);
  --muted: var(--rp-muted);
  --accent: var(--rp-link);
  color: var(--rp-text);
  font-family: var(--rp-sans);
}

/* Title band */
.rp-band {
  background: var(--rp-tint);
  box-shadow: 0 0 0 100vmax var(--rp-tint);
  clip-path: inset(0 -100vmax);
}
.rp-band-inner { max-width: 760px; margin: 0 auto; padding: 40px 0 44px; }
.rp-back { display: inline-block; margin-bottom: 28px; color: var(--rp-muted); font-size: 14px; text-decoration: none; }
.rp-back:hover { color: var(--rp-link); }
.rp h1 { margin: 0 0 16px; color: var(--rp-ink); font: 700 clamp(36px, 5vw, 50px)/1.1 var(--rp-sans); letter-spacing: -.5px; text-wrap: balance; }
.rp-subtitle { max-width: 700px; margin: 0; color: #4c5049; font: 300 21px/1.5 var(--rp-sans); }

/* Author / affiliation / date */
.rp-meta { display: flex; flex-wrap: wrap; gap: 14px 64px; max-width: 760px; margin: 0 auto; padding: 22px 0 24px; border-bottom: 1px solid var(--rp-line); }
.rp-meta div { min-width: 140px; }
.rp-meta dt { margin-bottom: 2px; color: var(--rp-muted); font-size: 13.5px; font-weight: 600; }
.rp-meta dd { margin: 0; color: var(--rp-ink); font-size: 15.5px; }
.rp-meta a { color: var(--rp-link); text-decoration: none; }

/* Body and contents list */
.rp-body { position: relative; padding-top: 40px; }
.rp-toc { display: none; }
@media (min-width: 1240px) {
  .rp-toc { display: block; position: absolute; top: 40px; bottom: 0; width: 180px;
    left: max(calc(50% - 650px), calc((100% - 100vw) / 2 + 20px)); }
}
.rp-toc-inner { position: sticky; top: 28px; font-size: 14px; line-height: 1.35; }
.rp-toc p { margin: 0 0 10px; color: var(--rp-ink); font-weight: 600; }
.rp-toc ol { margin: 0; padding: 0; list-style: none; }
.rp-toc li { margin: 0 0 9px; }
.rp-toc a { color: var(--rp-faint); text-decoration: none; transition: color .15s; }
.rp-toc a:hover, .rp-toc a.on { color: var(--rp-ink); }

/* Prose */
.rp .rp-prose { max-width: 760px; font: 18px/1.62 var(--rp-sans); color: var(--rp-text); }
.rp .rp-prose :is(p, ul, ol, blockquote):not(.xf *) { margin-bottom: 1.05em; }
.rp .rp-prose strong:not(.xf *) { color: var(--rp-ink); font-weight: 650; }
.rp .rp-prose a:not(.xf *) { color: var(--rp-link); text-decoration: underline; text-decoration-color: rgba(39, 68, 165, .35); text-underline-offset: .18em; }
.rp .rp-prose a:hover { text-decoration-color: currentColor; }
.rp .rp-prose li:not(.xf *) + li { margin-top: .35em; }
.rp .rp-prose h2 { margin: 2.1em 0 .75em; padding-bottom: .3em; border-bottom: 1px solid var(--rp-tint-line); color: var(--rp-ink); font: 300 32px/1.2 var(--rp-sans); letter-spacing: -.2px; }
.rp .rp-prose h3 { margin: 1.7em 0 .55em; color: var(--rp-ink); font: 600 22px/1.3 var(--rp-sans); letter-spacing: -.1px; }
.rp .rp-prose h4:not(.xf *) { font: 600 18px/1.4 var(--rp-sans); }
.rp .rp-prose :not(pre) > code:not(.xf *) { padding: .1em .32em; background: #efeee9; border-radius: 4px; font: .84em var(--rp-mono); color: var(--rp-ink); }
.rp .rp-prose pre:not(.xf *) { margin: 1.4em 0; padding: 16px 18px; background: #f7f6f2; border: 1px solid var(--rp-line); border-radius: 6px; font: 13.5px/1.6 var(--rp-mono); }
.rp .rp-prose pre code { font: inherit; }
.rp .rp-prose blockquote:not(.xf *) { border-left-color: var(--rp-tint-line); color: var(--rp-muted); }
.rp .rp-prose hr { border-top-color: var(--rp-line); }

/* TL;DR box */
.rp .rp-tldr { margin: 0 0 2.4em; padding: 18px 22px 6px; background: #f3f4f7; border: 1px solid var(--rp-tint-line); border-radius: 6px; font-size: 17.5px; }
.rp .rp-tldr-label { display: block; margin-bottom: 6px; color: var(--rp-ink); font-size: 14px; font-weight: 700; }

/* Citations: [1, 2, 3] instead of [1][2][3] */
.rp .rp-prose sup[role="doc-noteref"] { font-size: .72em; line-height: 0; }
.rp .rp-prose a.footnote { color: var(--rp-link); font-weight: 650; text-decoration: none; }
.rp .rp-prose sup.rp-cite-more a.footnote::after { content: ""; }
.rp .rp-prose sup.rp-cite-cont a.footnote::before { content: ", "; }

/* References */
.rp .footnotes { margin-top: 56px; padding-top: 8px; border-top: 1px solid var(--rp-tint-line); font-size: 15.5px; color: var(--rp-muted); }
.rp .footnotes::before { content: "References"; margin: 12px 0 14px; color: var(--rp-ink); font: 300 26px/1.2 var(--rp-sans); letter-spacing: 0; text-transform: none; }
.rp .footnotes ol { padding-left: 1.6em; }
.rp .footnotes li { margin: 0 0 6px; }
.rp .footnotes p { margin: 0; }
.rp .footnotes .reversefootnote { text-decoration: none; }

.rp-end { max-width: 760px; margin: 56px auto 0; padding-top: 22px; border-top: 1px solid var(--rp-line); font-size: 15px; }
.rp-end a { color: var(--rp-muted); text-decoration: none; }
.rp-end a:hover { color: var(--rp-link); }

@media (max-width: 620px) {
  .rp-band-inner { padding: 28px 0 32px; }
  .rp-subtitle { font-size: 18px; }
  .rp-meta { gap: 12px 32px; }
  .rp .rp-prose { font-size: 17px; }
  .rp .rp-prose h2 { font-size: 27px; }
  .rp .rp-tldr { padding: 14px 16px 4px; font-size: 16.5px; }
}
.rp code, .rp pre { font-variant-ligatures: none; }

/* Numbered references and bracketed citations that link to them */
.rp .rp-prose a[href^="#ref-"] { text-decoration: none; white-space: nowrap; }
.rp .rp-prose ol.rp-refs { padding-left: 1.6em; font-size: 15px; line-height: 1.5; color: var(--rp-muted); }
.rp .rp-prose ol.rp-refs li { margin-bottom: .7em; padding-left: .2em; }
.rp .rp-prose ol.rp-refs li:target { background: var(--rp-tint); }
.rp .rp-prose ol.rp-refs li::marker { color: var(--rp-faint); font-variant-numeric: tabular-nums; }

/* Contents: nested sections that unfold smoothly */
.rp .rp-prose :is(h2, h3, h4) { scroll-margin-top: 24px; }
.rp-toc li { margin: 0; }
.rp-toc li > a { display: block; padding: 4px 0; }
.rp-toc .rp-toc-l2 > a { padding: 5px 0; }
.rp-toc .rp-toc-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s cubic-bezier(.16,1,.3,1); }
.rp-toc .rp-toc-sub > div { overflow: hidden; min-height: 0; }
.rp-toc li.open > .rp-toc-sub { grid-template-rows: 1fr; }
.rp-toc .rp-toc-sub ol { margin: 2px 0 6px; padding-left: 11px; border-left: 1px solid var(--rp-line); font-size: 13px; line-height: 1.3; }
.rp-toc .rp-toc-sub li > a { opacity: 0; transform: translateY(-3px); transition: color .15s, opacity .25s ease .05s, transform .3s cubic-bezier(.16,1,.3,1) .05s; }
.rp-toc li.open > .rp-toc-sub > div > ol > li > a { opacity: 1; transform: none; }
.rp-toc .rp-toc-sub a.on { color: var(--rp-link); }
.rp-toc li.has-sub.open > a { color: var(--rp-ink); }
@media (prefers-reduced-motion: reduce) { .rp-toc .rp-toc-sub, .rp-toc .rp-toc-sub li > a { transition: none; } }

/* Band top row: back link on the left, the project's logo on the right */
.rp-band-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.rp-band-top .rp-back { margin-bottom: 0; }

/* Takeaways: a box of their own at the end of a section */
.rp .rp-prose .rp-takeaway { margin: 1.8em 0 2.2em; padding: 14px 18px 2px 18px; border: 1px solid var(--rp-tint-line); border-radius: 8px; background: var(--rp-tint); }
.rp .rp-prose .rp-takeaway-label { display: block; margin-bottom: 4px; color: var(--rp-link); font-size: 13.5px; font-weight: 700; }
.rp .rp-prose .rp-takeaway p { color: var(--rp-ink); font-size: 17px; }
@media (min-width: 1240px) and (max-width: 1360px) { .rp-toc { width: 168px; } .rp-toc-inner { font-size: 13.5px; } }

/* Highlighted key sentences and terms with a hover definition */
/* highlights are a crayon stroke under the sentence, one per line, so the words stay on a clean ground */
.rp .rp-prose mark { padding: 0 .08em .06em; background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 400 14%22 preserveAspectRatio=%22none%22%3E%3Cfilter id=%22r%22 x=%22-2%25%22 y=%22-60%25%22 width=%22104%25%22 height=%22220%25%22%3E%3CfeTurbulence type=%22fractalNoise%22 baseFrequency=%220.035 0.9%22 numOctaves=%222%22 seed=%227%22 result=%22n%22/%3E%3CfeDisplacementMap in=%22SourceGraphic%22 in2=%22n%22 scale=%225%22/%3E%3C/filter%3E%3Cg filter=%22url(%23r)%22 fill=%22none%22 stroke-linecap=%22round%22%3E%3Cpath d=%22M4 7 C 60 4.5%2C 120 9.5%2C 200 6.8 S 330 5%2C 396 7.6%22 stroke=%22%23ffd43b%22 stroke-width=%227%22 opacity=%22.9%22/%3E%3Cpath d=%22M8 9.5 C 90 8%2C 190 11%2C 392 9%22 stroke=%22%23ffc107%22 stroke-width=%222%22 opacity=%22.35%22/%3E%3C/g%3E%3C/svg%3E") no-repeat 0 100% / 100% .5em; color: inherit; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.rp .rp-prose .rp-def { position: relative; border-bottom: 1.5px dotted var(--rp-faint); cursor: help; }
.rp .rp-prose .rp-def::after { content: attr(data-def); position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 30; width: max-content; max-width: min(320px, 80vw);
  padding: 8px 11px; border: 1px solid var(--rp-line); border-radius: 6px; background: #fff; box-shadow: 0 6px 18px rgba(38, 42, 38, .12);
  color: var(--rp-text); font: 400 14px/1.45 var(--rp-sans); opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .15s, transform .2s cubic-bezier(.16,1,.3,1); }
.rp .rp-prose .rp-def:hover::after, .rp .rp-prose .rp-def:focus::after { opacity: 1; transform: none; }
.rp .rp-prose .rp-def:focus-visible { outline: 2px solid var(--rp-link); outline-offset: 2px; }
/* the definition only exists while shown, so it never widens the page */
.rp .rp-prose .rp-def::after { display: none; opacity: 1; transform: none; transition: none; }
.rp .rp-prose .rp-def:hover::after, .rp .rp-prose .rp-def:focus::after { display: block; animation: rp-def-in .2s cubic-bezier(.16,1,.3,1); }
@keyframes rp-def-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
