/* Public institute palette. Mint welcomes, ice frames navigation and diagrams,
   blush marks the founder's letter, and lilac marks interactive navigation.
   Scientific status and plot colors remain owned by each lesson. */
body[data-rpi-page] {
  --rpi-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --rpi-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --rpi-display: "Archivo Black", "Inter", sans-serif;
  --rpi-ink: #182623;
  --rpi-muted: #4e625d;
  --rpi-gray: #4e625d;
  --rpi-paper: #fafcf9;
  --rpi-line: #c4d4cc;
  --rpi-mint: #e9ffe9;
  --rpi-ice: #e6f7ff;
  --rpi-blush: #f7eaf0;
  --rpi-lilac: #eae7fa;
  --rpi-accent: #d7e8ff;
  --rpi-link: #275f50;
  --rpi-wash-start: var(--rpi-mint);
  --rpi-wash-middle: #effbf5;
  --rpi-wash-end: var(--rpi-ice);
  --rpi-wash-height: 76rem;
  --ink: var(--rpi-ink);
  --gray: var(--rpi-muted);
  --muted: var(--rpi-muted);
  --line: var(--rpi-line);
  --paper: var(--rpi-paper);
  --green: var(--rpi-link);
  --accent: var(--rpi-lilac);
  --display: var(--rpi-sans);
  font-family: var(--rpi-sans);
  color: var(--rpi-ink);
  /* Fade to the page's white canvas before the color layer ends. */
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0) 40%, #fff 98%)
      0 0 / 100% var(--rpi-wash-height) no-repeat,
    linear-gradient(165deg, var(--rpi-wash-start), var(--rpi-wash-middle) 48%, var(--rpi-wash-end))
      0 0 / 100% var(--rpi-wash-height) no-repeat,
    #fff;
}
/* Related subjects share a quiet wash; the institute masthead stays mint. */
body:is([data-rpi-page="mathematics"], [data-rpi-page="cambrian"],
  [data-rpi-page="quantum-computing"], [data-rpi-page="noa"]) {
  --rpi-wash-start: var(--rpi-lilac);
  --rpi-wash-middle: #f2edf9;
  --rpi-wash-end: var(--rpi-ice);
}
body:is([data-rpi-page="gravity"], [data-rpi-page="gravity-lab"],
  [data-rpi-page="igp24"], [data-rpi-page="publications"],
  [data-rpi-page="progress"], [data-rpi-page="document"]) {
  --rpi-wash-start: var(--rpi-ice);
  --rpi-wash-middle: #eef8fc;
  --rpi-wash-end: var(--rpi-mint);
}
body:is([data-rpi-page="economics"], [data-rpi-page="health"],
  [data-rpi-page="fusion"], [data-rpi-page="jonathan-washburn"]) {
  --rpi-wash-start: var(--rpi-blush);
  --rpi-wash-middle: #fbf2f3;
  --rpi-wash-end: var(--rpi-lilac);
}
body[data-rpi-page] h1 { font-family: var(--rpi-sans); font-weight: 500; letter-spacing: -.05em; }
body[data-rpi-page] h2 { font-family: var(--rpi-sans); letter-spacing: -.025em; }
/* Compact chrome for reports, lesson appendices and the artwork archive.
   It does not impose a new reading width on these specialized documents. */
body[data-rpi-document] .rpi-document-nav {
  box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center;
  gap: .35rem .6rem; width: 100%; max-width: none; margin: 0 auto 1.5rem;
  padding: 1rem clamp(1rem, 3vw, 2rem); border: 1px solid var(--rpi-line);
  background: var(--rpi-mint); color: var(--rpi-ink);
  font: 400 .85rem/1.5 var(--rpi-sans); text-transform: none; letter-spacing: normal;
}
body[data-rpi-document] .rpi-document-nav a {
  display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box;
  padding: .5rem .7rem; color: inherit; border: 1px solid transparent;
  text-decoration: none; text-transform: capitalize;
}
body[data-rpi-document] .rpi-document-nav .rpi-document-brand {
  margin-right: auto; padding-left: 0; font-weight: 600; letter-spacing: -.025em;
}
body[data-rpi-document] .rpi-document-nav a:hover { background: var(--rpi-ice); border-color: #96aaa4; }
body[data-rpi-document] .rpi-document-nav a[aria-current] { background: var(--rpi-lilac); border-color: #a9a5bc; }
body[data-rpi-document] :is(.abs,.focal,.moved,.callout) {
  background: var(--rpi-ice); color: var(--rpi-ink); border-color: var(--rpi-line); box-shadow: none;
}
body[data-rpi-document] table { display: block; max-width: 100%; overflow-x: auto; }
body[data-rpi-document] pre { max-width: 100%; overflow-x: auto; }
body[data-rpi-document] :not(pre) > code { overflow-wrap: anywhere; }
body[data-rpi-document] h1 { overflow-wrap: anywhere; }
body[data-rpi-page] ::selection { background: #d2defa; color: #182623; }
body[data-rpi-page] .rpi-top { background: var(--rpi-mint); border-bottom-color: var(--rpi-line); }
body[data-rpi-page] .rpi-brand { color: var(--rpi-ink); }
body[data-rpi-page] > .rpi-interior-nav {
  background: #f0fbf1;
  border-bottom-color: var(--rpi-line);
}
body[data-rpi-page] .rpi-interior-nav > .rpi-container { gap: .5rem; padding-block: .7rem; }
body[data-rpi-page] .rpi-interior-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .55rem 1rem;
  color: var(--rpi-ink);
  border: 1px solid transparent;
  text-decoration: none;
}
body[data-rpi-page] .rpi-interior-nav a:first-child { margin-left: -1rem; }
body[data-rpi-page] .rpi-interior-nav a:hover {
  background: var(--rpi-ice);
  border-color: #96aaa4;
}
body[data-rpi-page] .rpi-interior-nav a[aria-current="page"] {
  background: var(--rpi-lilac);
  border-color: #a9a5bc;
  font-weight: 500;
}
body[data-rpi-page] .rpi-hero h1 {
  font-family: var(--rpi-sans);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -.065em;
}
body[data-rpi-page] .rpi-panel {
  background: var(--rpi-ice);
  color: var(--rpi-ink);
  border: 1px solid #99b3b1;
  box-shadow: none;
}
body[data-rpi-page] .rpi-panel .rpi-panel-label { color: var(--rpi-muted); }
body[data-rpi-page] .rpi-panel a { color: var(--rpi-link); }
body[data-rpi-page] .rpi-panel .rpi-panel-links { border-top-color: #b4ccc9; }
body[data-rpi-page] :is(a,button,input,select,summary):focus-visible,
body[data-rpi-page] .rpi-panel :is(a,button,input):focus-visible {
  outline: 3px solid #275f50 !important;
  outline-offset: 4px;
}
body[data-rpi-page] .rpi-bottom { background: var(--rpi-mint); }

/* The homepage keeps the institute's reading order and all publication links. */
body[data-rpi-page="home"] .rpi-hero { padding-block: 4rem 5rem; }
body[data-rpi-page="home"] .rpi-hero h1 { font-size: clamp(3rem, 6.8vw, 6rem); max-width: 11ch; }
body[data-rpi-page="home"] .rpi-hero .lead { max-width: 31rem; }
body[data-rpi-page="home"] .rpi-home-links li { border-top-color: #b4ccc9; }
body[data-rpi-page="home"] .rpi-home-links a { color: var(--rpi-ink); }
body[data-rpi-page="home"] .rpi-home-links a::before { color: var(--rpi-muted); }
body[data-rpi-page="home"] .rpi-home-links small { color: var(--rpi-muted); }
body[data-rpi-page="home"] .rpi-home-links strong { font-weight: 500; }
body[data-rpi-page="home"] .letter {
  background: var(--rpi-blush);
  border: 1px solid #d6c7cf;
  padding: 2.75rem 3rem;
  max-width: 52rem;
  margin-bottom: 5rem;
}
body[data-rpi-page="home"] .letter .sign { border-top-color: #d6c7cf; }
body[data-rpi-page="home"] .wrap > h2 {
  color: var(--rpi-muted);
  border-top: 1px solid var(--rpi-line);
}
body[data-rpi-page="home"] #people,
body[data-rpi-page="home"] #papers {
  padding: 1rem 1.25rem;
  background: var(--rpi-mint);
  border-bottom: 1px solid var(--rpi-line);
}
body[data-rpi-page="home"] :is(ul.people,ul.papers) li { border-bottom-color: var(--rpi-line); }
body[data-rpi-page="home"] .topic {
  color: var(--rpi-muted);
  background: var(--rpi-ice);
  border-color: #b4ccc9;
}
body[data-rpi-page="home"] .badge-accepted { background: var(--rpi-mint); }
body[data-rpi-page="home"] .site-footer { background: var(--rpi-mint); padding: 1.5rem; }

/* Page-owned panels previously assumed white text on charcoal. */
body[data-rpi-page="introduction"] .intro-sequence { border-color: #b4ccc9; }
body[data-rpi-page="introduction"] .intro-sequence span { color: var(--rpi-muted); }
body[data-rpi-page="introduction"] :is(.equation,.worked-example,.quiz,.route-break) { background: var(--rpi-ice); }
body[data-rpi-page="introduction"] .shift-cue { background: var(--rpi-lilac); }
body[data-rpi-page="introduction"] :is(.intro-start,.intro-feature-link) {
  background: var(--rpi-link); color: #fff;
}
body[data-rpi-page="economics"] .rpi-hero .definition,
body[data-rpi-page="cambrian"] .rpi-panel .intro { color: var(--rpi-ink); }
body[data-rpi-page="cambrian"] .rpi-panel .hero-status { color: var(--rpi-muted); border-top-color: #b4ccc9; }
body[data-rpi-page="cambrian"] .rpi-panel .hero-definition { color: var(--rpi-muted); }
body[data-rpi-page="mathematics"] .origin-diagram.rpi-panel { background: var(--rpi-ice); color: var(--rpi-ink); }
body[data-rpi-page="mathematics"] .origin-diagram.rpi-panel :is(li,p,span,strong,small,figcaption) { color: inherit; border-color: #b4ccc9; }
body[data-rpi-page="mathematics"] :is(.experiment,.winding-figure) { background: var(--rpi-ice); }
body[data-rpi-page="mathematics"] .foundation-feature { background: #ffffffa8; }
body[data-rpi-page="mathematics"] .refinement-lab { background: #182f29; }
body[data-rpi-page] :is(.refinement-lab,.entry-card,.lock-card) :is(a,button,input):focus-visible { outline-color: var(--rpi-ice) !important; }
body[data-rpi-page="gravity"] .hero-art svg { border: 1px solid #99b3b1; }
body[data-rpi-page="gravity"] .hero-art svg > rect:first-of-type { fill: var(--rpi-ice); }
body[data-rpi-page="gravity"] .hero-art svg text { fill: var(--rpi-ink); }
body[data-rpi-page="gravity"] .hero-art svg :is(path,circle)[stroke="#c4cdf6"],
body[data-rpi-page="gravity"] .hero-art svg circle[stroke="#bac5f7"] { stroke: #416c62; }
body[data-rpi-page="gravity"] .hero-art svg g[stroke="#39445a"] { stroke: #acc9c6; }
body[data-rpi-page="gravity"] .hero-art svg :is(g,path)[fill="#c4cdf6"] { fill: #416c62; }
body[data-rpi-page="gravity"] .hero-art svg circle[fill="#4b5178"] { fill: #d2e5d9; }
body[data-rpi-page="gravity"] .hero-art svg rect[fill="#e5b99c"] { fill: #ebdce8; }
body[data-rpi-page="gravity"] .research-card { background: var(--rpi-lilac); }
body[data-rpi-page="gravity"] .takeaway { background: var(--rpi-ice); color: var(--rpi-ink); }
body[data-rpi-page="gravity"] .takeaway span { color: var(--rpi-muted); }

@media (max-width: 760px) {
  body[data-rpi-page] { --rpi-wash-height: 92rem; }
  body[data-rpi-document] .rpi-document-nav { gap: .2rem; padding: .7rem; font-size: .78rem; }
  body[data-rpi-document] .rpi-document-nav .rpi-document-brand { flex-basis: 100%; }
  body[data-rpi-document] .rpi-document-nav a { padding: .4rem .55rem; }
  body[data-rpi-page] .rpi-interior-nav > .rpi-container { gap: .2rem; padding-block: .45rem; }
  body[data-rpi-page] .rpi-interior-nav a { padding: .45rem .65rem; }
  body[data-rpi-page] .rpi-interior-nav a:first-child { margin-left: -.65rem; }
  body[data-rpi-page="home"] .rpi-hero { padding-block: 2.5rem 3rem; }
  body[data-rpi-page="home"] .rpi-hero h1 { font-size: clamp(3rem, 11vw, 4.5rem); }
  body[data-rpi-page="home"] .letter { padding: 1.5rem; margin-bottom: 3rem; }
}
@media (max-width: 380px) {
  body[data-rpi-page="home"] .rpi-hero h1 { font-size: 2.9rem; }
  body[data-rpi-page="home"] .letter { padding: 1.15rem; }
}
@media print {
  body[data-rpi-page] { background: #fff; color: #182623; }
  body[data-rpi-page] :is(.rpi-top,.rpi-panel,.rpi-bottom),
  body[data-rpi-page="home"] :is(.letter,#people,#papers,.site-footer) { background: #fff; }
  body[data-rpi-page="home"] .letter { padding: 1rem; }
  body[data-rpi-page="home"] .rpi-hero h1 { font-size: 32pt; }
}
