/* Community Library — site styles.
 *
 * Tokens, typography and UI patterns are lifted from the QuantEcon book theme
 * (QuantEcon/quantecon-book-theme, src/quantecon_book_theme/assets/styles):
 * primary #0072bc, secondary #d8655e, ink #23262c, body #444, the #efefef/#ccc
 * toolbar, and 5px bordered cards that fill dark on hover.
 */

:root {
  --qe-blue: #0072bc;
  --qe-blue-dark: #004e80;
  --qe-red: #d8655e;
  --qe-red-dark: #b5504a;
  --qe-teal: #005f5f;
  --qe-amber: #875f00;

  --ink: #23262c;
  --body: #444;
  --body-soft: #4a4a4a;
  --muted: #5a5a5a;
  --muted-soft: #555;
  --dim: #888;

  --line: #ddd;
  --line-soft: #ececec;
  --bar: #efefef;
  --bar-line: #ccc;

  --serif: "PT Serif", Georgia, serif;
  --sans: "Source Sans Pro", system-ui, -apple-system, sans-serif;
  --mono: "Source Code Pro", ui-monospace, SFMono-Regular, monospace;

  --wrap: 1240px;
  --gutter: 40px;
  --bar-h: 50px;
}

/* Derived from the accent so a single token change restyles the site. Kept
   behind @supports because the static fallback above has to hold on older
   Safari, where color-mix() would otherwise drop the declaration entirely. */
@supports (color: color-mix(in srgb, #000 50%, #fff)) {
  :root { --qe-blue-dark: color-mix(in srgb, var(--qe-blue) 68%, #000); }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

body {
  margin: 0;
  background: #fff;
  color: var(--body);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 400; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; }

a {
  color: var(--qe-blue);
  text-decoration: none;
  transition: color .15s linear;
}
a:visited { color: var(--qe-blue); }
a:hover { color: var(--qe-blue-dark); text-decoration: underline; }

::selection { background: rgba(0, 114, 188, .18); }

:focus-visible {
  outline: 2px solid var(--qe-blue);
  outline-offset: 2px;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Shared type utilities ---------------------------------------------------- */

.eyebrow {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dim);
}

.term {          /* an <em> that reads as a defined term, not as emphasis */
  font-style: normal;
  color: var(--qe-teal);
  font-weight: 600;
}

.flag {          /* a commitment or a caveat the reader must not skim past */
  font-weight: 600;
  color: var(--qe-amber);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 40;
  background: #fff;
  color: var(--ink);
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: 5px;
}
.skip-link:focus { left: 12px; top: 12px; }

/* Top bar ------------------------------------------------------------------ */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 20;
  background: var(--bar);
  border-bottom: 1px solid var(--bar-line);
}

.topbar-inner {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand img { height: 30px; width: auto; display: block; }
.brand-rule { width: 1px; height: 20px; background: #c4c4c4; display: block; }
.brand-label {
  font-family: var(--serif);
  font-size: .95rem;
  color: var(--ink);
  white-space: nowrap;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: .82rem;
  letter-spacing: .01em;
}
.topnav a { color: var(--body); }
.topnav a:hover { color: var(--qe-blue); text-decoration: none; }
.topnav .gh { font-family: var(--mono); font-size: .76rem; }

/* Hero --------------------------------------------------------------------- */

.hero { padding: 132px 0 0; }

.hero .wrap {
  display: flex;
  gap: 72px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.hero-main { flex: 1 1 560px; min-width: 0; }

.hero-eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 26px;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  font-size: clamp(2.4rem, 4.4vw, 3.5rem);
  line-height: 1.07;
  letter-spacing: -.015em;
  max-width: 15ch;
}

.hero-lede {
  margin-top: 26px;
  font-size: 1.12rem;
  line-height: 1.62;
  color: var(--body);
  max-width: 60ch;
  text-wrap: pretty;
}

.hero-actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.hero-credit {
  margin-top: 30px;
  font-size: .88rem;
  color: var(--dim);
  line-height: 1.7;
  max-width: 56ch;
}
.hero-credit strong { color: var(--body); font-weight: 600; }

.btn {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 5px;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
  transition: background .15s linear, color .15s linear, border-color .15s linear;
}
.btn:hover { text-decoration: none; }

.btn-solid {
  background: var(--qe-blue);
  border-color: var(--qe-blue);
  color: #fff;
}
.btn-solid:visited { color: #fff; }
.btn-solid:hover {
  background: var(--qe-blue-dark);
  border-color: var(--qe-blue-dark);
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: var(--ink);
  color: var(--ink);
}
.btn-outline:visited { color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: #fff; }

/* Hero side card ----------------------------------------------------------- */

.host-card {
  flex: 0 1 340px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 28px 30px 26px;
  background: #fff;
}
.host-card img { height: 52px; width: auto; display: block; margin-bottom: 20px; }
.host-card h2 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.35;
}
.host-card p {
  margin-top: 10px;
  font-size: .92rem;
  color: var(--muted-soft);
  line-height: 1.6;
}
.host-rule { height: 1px; background: #e6e6e6; margin: 22px 0 20px; }
.host-card .eyebrow { display: block; margin-bottom: 14px; }

.alongside { display: flex; flex-direction: column; gap: 14px; }
.alongside li {
  font-size: .9rem;
  color: var(--muted-soft);
  line-height: 1.55;
  padding-left: 14px;
  border-left: 3px solid var(--qe-blue);
}
.alongside li.is-secondary { border-left-color: var(--qe-red); }
.alongside strong { color: var(--ink); font-weight: 600; }

/* Facts strip -------------------------------------------------------------- */

.facts { padding: 64px 0 0; }

.facts-row {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
}

.fact {
  flex: 1 1 200px;
  padding: 22px 30px;
  border-right: 1px solid #eaeaea;
}
.fact:first-child { padding-left: 0; }
.fact:last-child { padding-right: 0; border-right: 0; }
.fact-value { margin-top: 7px; font-size: .95rem; color: var(--ink); }

/* Body layout: sticky contents rail + main column --------------------------- */

.layout {
  display: flex;
  gap: 64px;
  align-items: flex-start;
}

.rail {
  flex: 0 0 196px;
  position: sticky;
  top: 96px;
  padding-top: 78px;
}
.rail-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.rail ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
}
.rail a {
  display: flex;
  gap: 10px;
  padding: 6px 0 6px 10px;
  font-size: .86rem;
  color: #666;
  border-left: 2px solid transparent;
  transition: color .15s linear, border-color .15s linear;
}
.rail a:hover { color: var(--qe-blue); text-decoration: none; }
.rail a .n { font-family: var(--mono); font-size: .72rem; color: #aaa; }
.rail a.is-active {
  color: var(--qe-blue);
  border-left-color: var(--qe-blue);
  font-weight: 600;
}

.main { flex: 1 1 auto; min-width: 0; }

/* Sections ----------------------------------------------------------------- */

.section {
  padding: 78px 0 0;
  scroll-margin-top: 80px;
}
.section:last-child { padding-bottom: 96px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 22px;
}
.section-head .n {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--qe-blue);
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.9rem;
  line-height: 1.2;
}

.section-lede {
  font-size: 1rem;
  color: var(--body-soft);
  line-height: 1.68;
  max-width: 68ch;
  text-wrap: pretty;
}

/* 01 · Why ----------------------------------------------------------------- */

.why-head { margin-bottom: 34px; }

.two-col {
  display: flex;
  gap: 56px;
  flex-wrap: wrap;
}
.two-col > * { flex: 1 1 300px; min-width: 0; }
.two-col h3 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.18rem;
  margin-bottom: 12px;
}
.two-col p {
  font-size: 1rem;
  color: var(--body-soft);
  line-height: 1.68;
  text-wrap: pretty;
}

.payoffs {
  margin-top: 44px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}
.payoffs .eyebrow { display: block; margin-bottom: 24px; }
.payoff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px 44px;
}
.payoff-grid dt {
  font-size: .98rem;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 5px;
}
.payoff-grid dd {
  margin: 0;
  font-size: .93rem;
  color: var(--muted);
  line-height: 1.6;
}

/* 02 · The library --------------------------------------------------------- */

.models {
  margin-top: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.models-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 26px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
}
.models-head .eyebrow:first-child { color: #666; }

.model {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 22px 26px;
  background: #fff;
}
.model + .model { border-top: 1px solid var(--line-soft); }
.model-name {
  flex: 1 1 300px;
  min-width: 0;
}
.model-name h3 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.14rem;
}
.model-class { margin-top: 4px; font-size: .87rem; color: var(--dim); }

.slots { flex: 0 0 auto; display: flex; gap: 8px; }
.slot {
  border: 1px dashed #c9c9c9;
  border-radius: 4px;
  padding: 5px 11px;
  font-family: var(--mono);
  font-size: .7rem;
  color: #999;
}

.model-template {
  flex: 0 0 118px;
  text-align: right;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--dim);
}

.models-cta {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px 26px;
  background: #fafafa;
  border-top: 1px solid var(--line-soft);
  color: var(--ink);
  transition: background .15s linear, color .15s linear;
}
.models-cta:visited { color: var(--ink); }
.models-cta:hover { background: var(--ink); color: #fff; text-decoration: none; }
.models-cta span:first-child { flex: 1 1 300px; font-size: .95rem; color: inherit; }
.models-cta .go { font-family: var(--mono); font-size: .72rem; color: inherit; opacity: .75; }

.footnote {
  margin-top: 16px;
  font-size: .87rem;
  color: var(--dim);
  line-height: 1.6;
  max-width: 74ch;
}

/* 03 · How it works -------------------------------------------------------- */

.cards {
  margin-top: 32px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.card {
  flex: 1 1 320px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 28px 30px;
  border-top: 3px solid var(--qe-blue);
}
.card.is-secondary { border-top-color: var(--qe-red); }
.card .eyebrow { display: block; margin-bottom: 14px; }
.card h3 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.24rem;
  margin-bottom: 10px;
}
.card p { font-size: .96rem; color: var(--body-soft); line-height: 1.62; }

.aside-note {
  margin-top: 22px;
  padding-left: 20px;
  border-left: 3px solid var(--line);
  font-size: .95rem;
  color: var(--muted);
  line-height: 1.65;
  max-width: 74ch;
}

/* 04 · Baseline templates -------------------------------------------------- */

.steps {
  margin-top: 34px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  background: #e2e2e2;
  border: 1px solid #e2e2e2;
  border-radius: 5px;
  overflow: hidden;
}
.step { background: #fff; padding: 22px 24px; }
.step .n {
  display: block;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--qe-blue);
  margin-bottom: 10px;
}
.step h3 {
  font-size: .98rem;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 6px;
}
.step p { font-size: .89rem; color: var(--muted); line-height: 1.55; }

.panels {
  margin-top: 28px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.panel {
  flex: 1 1 320px;
  background: #fafafa;
  border: 1px solid #e6e6e6;
  border-left: 4px solid var(--qe-blue);
  border-radius: 0 5px 5px 0;
  padding: 24px 26px;
}
.panel.is-secondary { border-left-color: var(--qe-red); }
.panel .eyebrow { display: block; margin-bottom: 16px; color: var(--qe-blue); }
.panel.is-secondary .eyebrow { color: var(--qe-red-dark); }
.panel ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: .94rem;
  color: var(--body-soft);
  line-height: 1.5;
}

.section-note {
  margin-top: 24px;
  font-size: .95rem;
  color: var(--muted);
  line-height: 1.65;
  max-width: 74ch;
  text-wrap: pretty;
}

/* 05 · The ask ------------------------------------------------------------- */

.ask { margin-top: 10px; }
.ask h3 { margin-bottom: 16px; }
.ask-list { display: flex; flex-direction: column; gap: 14px; }
.ask-list li {
  font-size: .96rem;
  color: var(--body-soft);
  line-height: 1.55;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.ask-list li:last-child { padding-bottom: 0; border-bottom: 0; }
.ask-list strong { font-weight: 600; }

.callout {
  margin-top: 24px;
  padding: 18px 20px;
  background: var(--bar);
  border-radius: 5px;
  font-size: .93rem;
  color: var(--body-soft);
  line-height: 1.6;
}

/* 06 · Who does what ------------------------------------------------------- */

.roles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  margin-top: 10px;
}
.role {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 24px 26px;
  transition: border-color .15s linear;
}
.role:hover { border-color: var(--ink); }
.role .eyebrow { display: block; margin-bottom: 12px; }
.role.is-host .eyebrow { color: var(--qe-blue); }
.role h3 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.14rem;
  margin-bottom: 8px;
}
.role p { font-size: .93rem; color: var(--muted); line-height: 1.6; }

/* 07 · Roadmap ------------------------------------------------------------- */

.phases {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.phase {
  flex: 1 1 330px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}
.phase-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: var(--qe-blue);
}
.phase.is-later .phase-head { background: var(--ink); }
.phase-head h3 {
  font-family: var(--serif);
  font-weight: 700;
  color: #fff;
  font-size: 1.08rem;
}
.phase-term {
  font-family: var(--mono);
  font-size: .7rem;
  color: #fff;
  opacity: .85;
}
.phase.is-later .phase-term { opacity: .7; }
.phase ul {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 26px;
  font-size: .94rem;
  color: var(--body-soft);
  line-height: 1.55;
}

/* 08 · Contribute ---------------------------------------------------------- */

.repo-link {
  margin-top: 30px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  border: 1px solid var(--ink);
  border-radius: 5px;
  padding: 22px 26px;
  color: var(--ink);
  transition: background .15s linear, color .15s linear;
}
.repo-link:visited { color: var(--ink); }
.repo-link:hover { background: var(--ink); color: #fff; text-decoration: none; }
.repo-link .about { flex: 1 1 300px; }
.repo-link .name {
  display: block;
  font-family: var(--mono);
  font-size: 1rem;
  color: inherit;
}
.repo-link .desc {
  display: block;
  margin-top: 6px;
  font-size: .9rem;
  color: inherit;
  opacity: .7;
}
.repo-link .go { font-family: var(--mono); font-size: .75rem; color: inherit; opacity: .75; }

.meta-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 26px 40px;
}
.meta-grid > div { padding-top: 16px; border-top: 1px solid var(--line); }
.meta-grid .eyebrow { display: block; margin-bottom: 8px; }
.meta-grid p { font-size: .93rem; color: var(--body-soft); line-height: 1.6; }

/* Closing call to action --------------------------------------------------- */

.cta { background: var(--ink); padding: 74px 0; }
.cta .wrap {
  display: flex;
  gap: 56px;
  align-items: center;
  flex-wrap: wrap;
}
.cta-copy { flex: 1 1 460px; min-width: 0; }
.cta-eyebrow {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #8b9099;
  margin-bottom: 18px;
}
.cta h2 {
  font-family: var(--serif);
  font-weight: 700;
  color: #fff;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -.01em;
}
.cta p {
  margin-top: 18px;
  font-size: 1.02rem;
  color: #b9bdc4;
  line-height: 1.6;
  max-width: 52ch;
}
.cta-actions {
  flex: 0 1 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cta-actions .btn { text-align: center; padding: 15px 26px; font-size: .94rem; }

.btn-light { background: #fff; border-color: #fff; color: var(--ink); }
.btn-light:visited { color: var(--ink); }
.btn-light:hover { background: var(--qe-blue); border-color: var(--qe-blue); color: #fff; }

.btn-ghost { background: transparent; border-color: #4a4f57; color: #e6e8ea; }
.btn-ghost:visited { color: #e6e8ea; }
.btn-ghost:hover { border-color: #fff; color: #fff; background: transparent; }

/* Footer ------------------------------------------------------------------- */

.site-footer {
  background: var(--bar);
  border-top: 1px solid var(--bar-line);
  padding: 44px 0 52px;
}
.footer-top {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
}
.footer-top img { height: 38px; width: auto; display: block; }
.footer-links {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  font-size: .87rem;
}
.footer-links a { color: var(--body); }
.footer-links a:hover { color: var(--qe-blue); }
.footer-links .tbd { color: #999; }

.footer-note {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #dcdcdc;
  font-size: .88rem;
  color: #777;
  line-height: 1.65;
  max-width: 82ch;
}
.footer-legal {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: .74rem;
  color: #999;
}

/* Responsive --------------------------------------------------------------- */

/* Below this the contents rail and the main column can no longer share a row
   without squeezing the prose; the rail duplicates the top bar, so it goes. */
@media (max-width: 1024px) {
  .rail { display: none; }
  .layout { gap: 0; }
}

@media (max-width: 820px) {
  :root { --gutter: 24px; }

  /* The section links live in the contents rail on wide screens and would
     overflow the 50px bar here; the repository link is the one that has no
     other route to it. */
  .topnav li:not(.topnav-gh) { display: none; }

  .hero { padding-top: 104px; }
  .hero .wrap { gap: 40px; }
  .facts { padding-top: 48px; }
  .section { padding-top: 56px; }
  .two-col { gap: 32px; }

  .fact {
    flex: 1 1 100%;
    padding: 16px 0;
    border-right: 0;
  }
  .fact + .fact { border-top: 1px solid #eaeaea; }

  .model { gap: 16px; }
  .model-template { flex: 0 0 auto; text-align: left; }

  .cta { padding: 56px 0; }
  .cta .wrap { gap: 32px; }
  .cta-actions { flex: 1 1 100%; }
}

@media (max-width: 480px) {
  /* Below this the brand and the repository link stop fitting the 50px bar
     side by side at the wider gutter — tightened rather than dropped, so the
     site still names itself and the repository stays one tap away. */
  :root { --gutter: 16px; }
  .topbar-inner { gap: 12px; }
  .brand { gap: 10px; }

  body { font-size: 16px; }
  .models-head { gap: 8px; }
  .slots { flex-wrap: wrap; }
}

@media print {
  .topbar, .rail, .cta-actions { display: none; }
  .hero { padding-top: 0; }
  a { color: inherit; }
}
