/* Royanova research pages: shared stylesheet.
   Part 1: fonts and the site chrome (nav, footer), matched to royanova.com.
   Part 2: the reading and chart styles used by every research page.
   Part 3: pieces used only by the written research pieces.
   Fonts are self-hosted (SIL Open Font License, see fonts/), so these pages make no outside requests. */

@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400; font-display: swap; src: url("/research/fonts/newsreader-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400; font-display: swap; src: url("/research/fonts/newsreader-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 500; font-display: swap; src: url("/research/fonts/newsreader-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Spline Sans Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/research/fonts/spline-sans-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Spline Sans Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/research/fonts/spline-sans-mono-latin-500-normal.woff2") format("woff2"); }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
::selection { background: rgba(107, 110, 73, 0.22); }
body { text-rendering: optimizeLegibility; }

/* Skip link for keyboard users */
.rc-skip { position: absolute; left: -9999px; top: 8px; z-index: 40; background: #23201A; color: #F1EADC; padding: 8px 12px; font-family: "Spline Sans Mono", monospace; font-size: 12px; }
.rc-skip:focus { left: 12px; }

/* Nav: same as the homepage */
.rc-nav { position: sticky; top: 0; z-index: 30; background: #F1EADC; border-bottom: 1px solid rgba(35, 32, 26, 0.14); }
.rc-wrap { max-width: 1200px; margin: 0 auto; padding-left: 48px; padding-right: 48px; }
.rc-navwrap { padding-top: 20px; padding-bottom: 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.rc-logo { text-decoration: none; color: #23201A; font-family: "Newsreader", Georgia, serif; font-size: 21px; letter-spacing: 0.05em; white-space: nowrap; }
.rc-navlinks { display: flex; gap: 38px; font-family: "Spline Sans Mono", monospace; font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.rc-navlinks a { text-decoration: none; color: #5F5747; transition: color 0.2s; }
.rc-navlinks a:hover, .rc-navlinks a[aria-current="page"] { color: #23201A; }
.rc-navlinks a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }

/* Footer: same as the homepage, plus a quiet row of research links */
.rc-foot { border-top: 1px solid rgba(35, 32, 26, 0.14); margin-top: 72px; }
.rc-footwrap { padding-top: 38px; padding-bottom: 38px; display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 16px; }
.rc-footbrand { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.rc-footname { font-family: "Newsreader", Georgia, serif; font-size: 18px; letter-spacing: 0.04em; color: #23201A; }
.rc-footlabel, .rc-copy { font-family: "Spline Sans Mono", monospace; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #8A8272; }
.rc-copy { letter-spacing: 0.12em; }
.rc-footlinks { display: flex; flex-wrap: wrap; gap: 8px 22px; font-family: "Spline Sans Mono", monospace; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.rc-footlinks a { color: #5F5747; text-decoration: none; }
.rc-footlinks a:hover { color: #23201A; }

/* Breadcrumb */
.r-crumb { font-family: "Spline Sans Mono", monospace; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #8A8272; padding-top: 30px; }
.r-crumb a { color: #5F5747; text-decoration: none; }
.r-crumb a:hover { color: #23201A; }
.r-crumb span[aria-hidden] { margin: 0 8px; }

@media (max-width: 960px) { .rc-wrap { padding-left: 32px; padding-right: 32px; } }
@media (max-width: 620px) { .rc-wrap { padding-left: 22px; padding-right: 22px; } .rc-navlinks { gap: 20px; } }
@media (max-width: 520px) { .rc-navwrap { flex-wrap: wrap; gap: 8px; padding-top: 14px; padding-bottom: 12px; } .rc-navlinks { gap: 6px 18px; flex-wrap: wrap; } }

/* Part 2: reading and chart styles */
:root {
  /* Royanova look: warm paper, ink, olive accent, Newsreader with Spline Sans Mono labels. Single light theme by choice.
     Layout: one reading column, each section a question, a chart that answers it, then a short reading of the chart. */
  --paper: #F1EADC; --ink: #23201A; --text: #4C4638; --muted: #6D6455; --line: rgba(35, 32, 26, 0.14); --line-strong: rgba(35, 32, 26, 0.26);
  --accent: #6B6E49; --accent-text: #5A5D3B; --tint: rgba(35, 32, 26, 0.04);
  --s1: #3F6FA8; --s2: #C8642A; --s3: #1F9A84; --s4: #C9A227; --s5: #8E5A9C;   /* chart series, validated on the paper surface */
  --display: "Newsreader", Georgia, "Times New Roman", serif; --body: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 48px 8px; }
.brand { font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent-text); }
.brand b { color: var(--ink); font-weight: 500; }
.meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); letter-spacing: 0.04em; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(36px, 6.4vw, 58px); line-height: 1.08; letter-spacing: -0.012em; margin: 22px 0 16px; max-width: 18ch; }
h2 { font-size: clamp(25px, 4.2vw, 34px); line-height: 1.14; letter-spacing: -0.01em; }
h3 { font-size: 19px; font-weight: 500; }
p { margin: 0 0 12px; max-width: 65ch; color: var(--text); }
.lead { font-size: 19px; color: var(--text); max-width: 60ch; }
.eyebrow { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 8px; }
section { padding: 34px 0 10px; border-top: 1px solid var(--line); margin-top: 26px; }
section:first-of-type { border-top: 0; }
.reading { border-left: 2px solid var(--accent); padding: 2px 0 2px 14px; margin: 14px 0 6px; }
.reading p { margin: 0 0 6px; }
.num { font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.chip { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.02em; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); padding: 7px 11px; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip:hover { border-color: var(--ink); }
.chip:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sticky { position: sticky; top: var(--navh, 67px); z-index: 5; background: var(--paper); padding: 6px 0 10px; border-bottom: 1px solid var(--line); }
.sticky .label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.chart { position: relative; width: 100%; margin: 16px 0 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--mono); font-size: 12px; color: var(--text); margin: 10px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 12px; line-height: 1.45; padding: 8px 10px; border-radius: 6px; max-width: 260px; opacity: 0; transition: opacity 0.12s; z-index: 10; }
.tip b { font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }
details.numbers { margin: 10px 0 0; }
details.numbers summary { font-family: var(--mono); font-size: 12px; color: var(--accent-text); cursor: pointer; letter-spacing: 0.04em; }
.tablewrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; border-top: 1px solid var(--line-strong); margin: 16px 0 8px; }
.tile { padding: 14px 14px 14px 0; border-bottom: 1px solid var(--line); }
.tile .v { font-size: 26px; line-height: 1.1; }
.tile .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.tile .s { font-size: 14px; color: var(--muted); margin-top: 4px; }
.formula { font-family: var(--mono); font-size: 13px; background: var(--tint); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; overflow-x: auto; white-space: pre; line-height: 1.6; color: var(--ink); }
.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px 28px; margin-top: 16px; }
.idea h3 { margin-bottom: 6px; }
.note { font-size: 14.5px; color: var(--muted); }
ol.sources { padding-left: 20px; font-size: 14.5px; color: var(--text); }
ol.sources li { margin-bottom: 6px; }
a { color: var(--accent-text); }
@media (max-width: 640px) { .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; } .chip { flex: 0 0 auto; } }
@media (max-width: 520px) { body { font-size: 16px; } .lead { font-size: 17.5px; } .tile .v { font-size: 22px; } }

/* Part 3: written research pieces and the research index */
.col { max-width: 860px; }
.r-head { padding: 6px 0 8px; }
.r-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 14px 0 22px; }
.r-meta time { color: var(--ink); }
.r-sub { font-style: italic; font-size: 19px; color: var(--muted); margin: 0 0 10px; max-width: 60ch; }
.r-endnote { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line-strong); font-family: var(--mono); font-size: 11.5px; line-height: 1.7; color: var(--muted); max-width: 860px; }
.r-endnote a { color: var(--accent-text); }
.r-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); border-top: 1px solid var(--line-strong); margin: 18px 0 6px; }
.r-keys > div { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); }
.r-keys .v { font-size: 30px; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.r-keys .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 6px; line-height: 1.5; }
figure.r-fig { margin: 18px 0 6px; }
figure.r-fig figcaption { font-size: 14.5px; color: var(--muted); margin-top: 8px; max-width: 70ch; }
figure.r-fig figcaption b { color: var(--ink); font-weight: 500; }
.r-fig .chart { margin-top: 8px; }
.r-box { border-left: 2px solid var(--accent); padding: 2px 0 2px 16px; margin: 16px 0; }
.r-box p:last-child { margin-bottom: 0; }
.r-list { list-style: none; padding: 0; margin: 12px 0; border-top: 1px solid var(--line-strong); }
.r-list > li { border-bottom: 1px solid var(--line); padding: 20px 0 22px; display: grid; grid-template-columns: 64px 1fr; gap: 4px 18px; }
.r-list .no { font-family: var(--mono); font-size: 12px; color: var(--accent-text); letter-spacing: 0.08em; padding-top: 6px; }
.r-list h2 { font-size: clamp(23px, 3.6vw, 29px); margin: 0 0 6px; }
.r-list h2 a { color: var(--ink); text-decoration: none; }
.r-list h2 a:hover { color: var(--accent-text); }
.r-list p { margin: 0 0 8px; }
.r-list .tag { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.r-related { margin-top: 8px; }
.r-related a { display: inline-block; margin: 0 18px 6px 0; }
ul.r-bul { padding-left: 20px; margin: 8px 0 12px; max-width: 65ch; color: var(--text); }
ul.r-bul li { margin-bottom: 6px; }
.r-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 32px; }
.chart .hit { cursor: pointer; }
.chart .hit:focus { outline: none; }
.chart .hit:focus-visible { outline: 2px solid var(--accent); }
@media (max-width: 960px) { .wrap { padding-left: 32px; padding-right: 32px; } }
@media (max-width: 620px) { .wrap { padding-left: 22px; padding-right: 22px; } .r-list > li { grid-template-columns: 1fr; } .r-list .no { padding-top: 0; } .r-two { grid-template-columns: 1fr; } .r-keys .v { font-size: 25px; } }
@media print { .rc-nav, .rc-foot, .r-crumb, .chips, .tip { display: none !important; } .sticky { position: static; } }
.chart svg.n-only { display: none; }
@media (max-width: 620px) { .chart svg.w-only { display: none; } .chart svg.n-only { display: block; } }
.heat td.h { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
.heat th.h { text-align: right; }
.heat td:first-child { white-space: nowrap; color: var(--ink); }
@media (min-width: 1220px) { figure.r-wide { width: 1104px; } }
.heat th.h { white-space: normal; min-width: 64px; }
/* Language switch: beside the logo on small screens; the nav links get their own row and never break mid-label */
@media (max-width: 767px) { .rc-navwrap { position: relative; flex-wrap: wrap; gap: 8px; } .rc-navlinks { width: 100%; flex-wrap: wrap; gap: 6px 18px; } .rc-navlinks a { white-space: nowrap; } .rc-navlinks a.rc-lang { position: absolute; top: 20px; right: 32px; height: 21px; display: flex; align-items: center; } }
@media (max-width: 620px) { .rc-navlinks a.rc-lang { right: 22px; } }
/* Loan ledger (money page): columns may shrink, and long values wrap on phones instead of pushing the page sideways */
main .ledger .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 620px) { main .ledger .it { flex-wrap: wrap; } main .ledger .it .v { white-space: normal; overflow-wrap: anywhere; } }
/* Consistency with the homepage (the reference design): same nav height, phone padding, hover, focus ring and entrance motion */
.rc-logo, .rc-navlinks { line-height: normal; }
@media (max-width: 520px) { .rc-navwrap { padding-top: 20px; padding-bottom: 20px; } }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip, .steps button { transition: background-color 0.2s, color 0.2s, border-color 0.2s; }
@keyframes rcRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
main .col > .r-crumb { animation: rcRise 0.8s cubic-bezier(0.2, 0.65, 0.2, 1) 0.04s both; }
main .col > h1, main .col > .r-head { animation: rcRise 0.85s cubic-bezier(0.2, 0.65, 0.2, 1) 0.12s both; }
main .col > .lead { animation: rcRise 0.85s cubic-bezier(0.2, 0.65, 0.2, 1) 0.22s both; }
main .col > .r-meta, main .col > .r-keys, main .col > .r-list { animation: rcRise 0.85s cubic-bezier(0.2, 0.65, 0.2, 1) 0.34s both; }
@media (prefers-reduced-motion: reduce) { main .col > * { animation: none !important; } .chip, .steps button { transition: none; } }
