/* UC San Diego core colors: brand.ucsd.edu/visual-brand/color/.
   Shared tokens also update the widgets; scientific series retain distinct hues. */
:root {
  color-scheme: light;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: var(--sans);
  --reading-size: 16px;
  --artifact-font-size: 16px;
  --figure-width: 1080px;
  --reading-width: var(--figure-width);
  --page-gutter: 32px;
  --navy: #182b49;
  --yellow: #ffcd00;
  --paper: #ffffff;
  --surface: #ffffff;
  --sunken: #f1f5fa;
  --ink: #182b49;
  --muted: #44546a;
  --line: #d5dee8;
  --orange: #00629b;
  --teal: #176d63;
  --coral: #a44530;
  --mint: #176d63;
  --dark: var(--paper);
  --grid: #d5dee8;
  --grid-strong: #8294ab;
  --soft-accent: #fff4c2;
  --rule-cloud: #8d6700;
  --highlight: #182b49;
  --highlight-ink: #ffffff;
  --highlight-border: #182b49;
  --section-rule: #ffcd00;
}

:root[data-theme=dark] {
  color-scheme: dark;
  --paper: #101d32;
  --surface: #182b49;
  --sunken: #203650;
  --ink: #f5f8ff;
  --muted: #c0cede;
  --line: #3e5671;
  --orange: #72c7f0;
  --teal: #89c8b0;
  --coral: #ffb08c;
  --mint: #89c8b0;
  --grid: #344b65;
  --grid-strong: #7990ac;
  --soft-accent: #384058;
  --rule-cloud: #d6b25f;
  --highlight: #182b49;
  --highlight-border: #476589;
  --section-rule: #ffcd00;
}

html { min-height: 100%; background: var(--paper); }
body { min-height: 100vh; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: var(--reading-size); }
button, input, select, textarea { font-family: var(--sans); }
.wrap {
  width: 100%;
  max-width: calc(var(--figure-width) + 2 * var(--page-gutter));
  padding-inline: var(--page-gutter);
  margin-inline: auto;
}
.hero.wrap, .article-intro.wrap, .takeaways.wrap, .closing.wrap, footer.wrap {
  max-width: calc(var(--reading-width) + 2 * var(--page-gutter));
}
.chapter-head, .research-pitch, .essay-prose, .reading-note,
.candidate-derivations > h3, .candidate-derivations > p {
  max-width: var(--reading-width);
  margin-inline: auto;
}
.chapter { padding-top: 40px; padding-bottom: 16px; }
.dark-chapter, .direction-chapter { padding-block: 40px 16px; background: var(--paper); border: 0; }
h1, h2, h3, h4 { font-family: var(--sans); font-variation-settings: normal; text-align: left; }
h2, .chapter-head h2, .closing h2 { max-width: none; font-size: 22px; line-height: 1.35; font-weight: 600; letter-spacing: -.02em; }
h3, .rule-candidates h3, .directional-comparison h3, .sources h3 { font-size: 18px; line-height: 1.4; letter-spacing: -.015em; }
.chapter-head { margin-bottom: 10px; }
.two-col, .sources > p { max-width: var(--reading-width); margin-inline: auto; }
::selection { background: var(--yellow); color: var(--navy); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 5px; }
#reading-progress { position: fixed; z-index: 20; top: 0; bottom: auto; background: var(--yellow); }
.theme-toggle { border: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.primary { background: var(--navy); color: #ffffff; border: 1px solid var(--navy); }
.primary:hover { background: #00629b; border-color: #00629b; }
:root[data-theme=dark] .primary { background: var(--yellow); border-color: var(--yellow); color: var(--navy); }
:root[data-theme=dark] .primary:hover { background: #ffe066; border-color: #ffe066; }
.text-link { color: var(--orange); font-weight: 600; }

/* Text, headings and figures share one aligned content column. */
.hero { display: block; min-height: 0; padding-top: 16px; padding-bottom: 0; text-align: left; }
.hero h1 {
  max-width: none;
  border: 0;
  padding-top: 0;
  font-family: var(--sans);
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: -.03em;
  font-weight: 600;
  text-wrap: pretty;
}
.hero h1::before { content: ''; display: block; width: 56px; height: 3px; background: var(--yellow); margin-bottom: 16px; }
.author-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 32px; margin: 20px 0 0; padding: 0; list-style: none; font-size: var(--reading-size); color: var(--ink); }
.author-list > li { display: grid; align-content: start; gap: 3px; min-width: 0; line-height: 1.5; }
.author-name { font-weight: 600; }
.author-affiliation { color: var(--muted); font-size: 14px; }
.author-email { justify-self: start; color: var(--orange); font-size: 13px; overflow-wrap: anywhere; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.author-email:hover { text-decoration-color: var(--orange); }
.author-list sup { font-size: .72em; margin-left: 2px; }
.author-note { margin-top: 12px; font-size: 13px; color: var(--muted); }
.paper-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.paper-actions .theme-toggle { min-height: 44px; padding: 10px 14px; font-size: 14px; line-height: 1.5; background: var(--sunken); }
.paper-actions .theme-toggle:hover { background: var(--line); }
.hero .paper-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 0;
  padding: 10px 17px;
  min-height: 44px;
  border: 1px solid var(--highlight-border);
  border-radius: 6px;
  background: var(--navy);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
}
.hero .paper-button:hover { background: #00629b; border-color: #00629b; }

/* Prose spans the same column as the interactive figures. */
.prose, .dark-chapter .prose, .candidate-derivations,
.research-pitch p, .component-copy, .reading-note,
.branch-reading, .mechanism-guide, details { color: var(--ink); }
.essay-prose, .dark-chapter .essay-prose { max-width: var(--reading-width); margin-inline: auto; margin-bottom: 24px; font-size: var(--reading-size); line-height: 1.65; text-align: left; }
.article-intro { padding-top: 24px; }
.article-intro .essay-prose { max-width: var(--reading-width); margin: 0 auto; }
/* Natural wrapping uses the same visible measure as the centered callouts. */
.essay-prose p { text-wrap: wrap; }
.essay-prose p + p { margin-top: 16px; }
/* Question callouts share the prose width. */
.question-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  width: 100%;
  max-width: var(--reading-width);
  margin: 20px auto 16px;
}
.article-intro .essay-prose > p:first-child + .question-row { margin-top: 16px; }
.article-intro .opening-question, .scaling-question {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 18px 20px 12px;
  border: 1px solid var(--highlight-border);
  border-radius: 6px;
  background: var(--navy);
  color: #ffffff;
  font-size: var(--reading-size);
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}
.opening-question-label {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 23px;
  padding-top: 1px;
  margin: 0;
  background: var(--yellow);
  color: var(--navy);
  clip-path: polygon(0 0, 100% 0, 100% 80%, 50% 100%, 0 80%);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.question-text { display: block; min-width: 0; }
.research-pitch { max-width: var(--reading-width); border: 0; padding-top: 0; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; margin: 0 auto 16px; }
.research-pitch h3 { max-width: none; font-size: 17px; font-weight: 500; line-height: 1.55; letter-spacing: -.01em; text-wrap: pretty; }
.research-pitch p { max-width: none; }
.pitch-number { color: var(--orange); font-size: 13px; font-weight: 650; padding-top: 5px; }
.light-panel, .sandbox { border-color: var(--line); border-radius: 8px; padding: 24px; }
.closing { display: block; text-align: left; padding-top: 40px; padding-bottom: 32px; }
.closing h2 { position: static; }
.closing-grid { margin-top: 16px; gap: 16px; }
.closing-grid p { color: var(--ink); font-size: var(--reading-size); line-height: 1.65; }

/* Keep notation beside the update, outside the main prose flow. */
:is(.muon-panel, .equation-panel) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin-top: 16px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunken); }
:is(.muon-panel, .equation-panel) > h3 { grid-column: 1 / -1; margin: 0; font-size: 16px; font-weight: 600; line-height: 1.4; letter-spacing: 0; }
:is(.muon-update, .equation-steps) { min-width: 0; }
:is(.muon-update, .equation-steps) > div + div { margin-top: 10px; }
.update-step { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; }
.update-equation { min-width: 0; overflow-x: auto; padding-block: 4px; }
:is(.muon-update, .equation-steps) .blog-math { font-size: 18px; text-align: left; margin: 0; }
:is(.muon-notation, .equation-notation) { min-width: 0; padding-left: 24px; border-left: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
:is(.muon-notation, .equation-notation) dl { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 7px 12px; margin: 0; }
:is(.muon-notation, .equation-notation) dt, :is(.muon-notation, .equation-notation) dd { margin: 0; }
:is(.muon-notation, .equation-notation) dt { color: var(--ink); }
:is(.muon-notation, .equation-notation) .blog-math { font-size: 16px; }
:is(.muon-notation, .equation-notation) p { margin-top: 10px; color: var(--muted); }
@media (max-width: 900px) {
  :is(.muon-panel, .equation-panel) { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; }
  :is(.muon-notation, .equation-notation) { padding: 14px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 600px) {
  :is(.muon-update, .equation-steps) .blog-math { font-size: 16px; }
}

/* A quiet summary panel, with each finding linked to its figure. */
.takeaways { display: block; padding-top: 4px; padding-bottom: 0; }
.takeaway-box { padding: 20px 24px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; }
.takeaways h2 {
  padding: 0;
  margin: 0 0 10px;
  border: 0;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink);
}
.takeaway-list { list-style: decimal; margin: 0; padding: 0 0 0 1.5em; }
.takeaway-list li { padding-left: 5px; }
.takeaway-list li + li { border: 0; margin-top: 6px; }
.takeaway-list a { display: inline; padding: 0; color: var(--ink); text-decoration: underline; text-decoration-color: var(--grid-strong); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.takeaway-list a:hover { color: var(--orange); text-decoration-color: currentColor; }
.takeaway-list li::marker { color: var(--orange); font-weight: 600; }
.takeaway-list p { font-family: var(--sans); font-size: var(--reading-size); font-weight: 400; line-height: 1.65; letter-spacing: 0; color: var(--ink); }

@media (max-width: 760px) {
  :root { --page-gutter: 24px; --reading-size: 15px; --artifact-font-size: 15px; }
  h2, .chapter-head h2, .closing h2 { font-size: 20px; }
  .research-pitch h3 { font-size: 16px; }
  h3, .rule-candidates h3, .directional-comparison h3, .sources h3 { font-size: 17px; }
  .hero { padding-top: 12px; padding-bottom: 0; }
  .hero h1 { font-size: 27px; }
  .author-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 16px 24px; margin-top: 16px; }
  .article-intro { padding-top: 24px; }
  .chapter, .dark-chapter, .direction-chapter { padding-top: 32px; padding-bottom: 12px; }
  .light-panel, .sandbox { padding: 18px; }
  .question-row { margin-block: 20px 16px; }
  .article-intro .opening-question, .scaling-question { padding: 18px 16px 12px; }
  .takeaway-box { padding: 16px 18px; }
  .takeaways h2 { font-size: 16px; }
}

@media (max-width: 370px) {
  :root { --page-gutter: 18px; }
}

@media print {
  :root, :root[data-theme=dark] { --paper: #ffffff; --surface: #ffffff; --ink: #182b49; --muted: #44546a; }
  .wrap { max-width: calc(var(--reading-width) + 2 * var(--page-gutter)); padding-right: var(--page-gutter); }
}

/* Longer metric subscripts need their own space beside definitions. */
.equation-notation dl { grid-template-columns: max-content minmax(0, 1fr); }

/* Put the scaling result and exploration guide before the controls. */
.rule-search-guide { display: grid; gap: 8px; padding-block: 18px; margin-bottom: 22px; border-block: 1px solid var(--line); font-size: var(--reading-size); line-height: 1.65; }
.rule-search-guide p { margin: 0; }
.rule-search-guide p + p { color: var(--muted); }
