/* Bayesian Modelling in Practice - site styles. Minimal, typographic, academic. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --fg: #1d1d1b;
  --muted: #62605a;
  --rule: #e5e2d9;
  --rule-strong: #cfcbbf;
  --accent: #1d4f7c;
  --accent-soft: #e8eef5;
  --warm: #9a4a17;
  --warm-soft: #f7ede4;
  --code-bg: #f3f1ec;
  --code-fg: #26261f;
  --tok-kw: #7a2e8a;
  --tok-str: #2f6a2c;
  --tok-num: #a2461b;
  --tok-com: #85837b;
  --tok-fn: #1d4f7c;
  --tok-builtin: #7d5a0f;
  --fig-bg: #ffffff;
  --serif: "Source Serif 4", "Iowan Old Style", Charter, Georgia, serif;
  --sans: Inter, -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 46rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141517; --surface: #1b1c1f; --fg: #e7e5df; --muted: #a3a097; --rule: #2b2c30;
    --rule-strong: #3d3e43; --accent: #94bde6; --accent-soft: #1d2a38; --warm: #e0a472;
    --warm-soft: #2c2119; --code-bg: #1d1f22; --code-fg: #e2e0da; --tok-kw: #d3a0e0;
    --tok-str: #9fd08f; --tok-num: #f0a77c; --tok-com: #7f7d76; --tok-fn: #94bde6;
    --tok-builtin: #e3c07a; --fig-bg: #f4f3ef; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141517; --surface: #1b1c1f; --fg: #e7e5df; --muted: #a3a097; --rule: #2b2c30;
  --rule-strong: #3d3e43; --accent: #94bde6; --accent-soft: #1d2a38; --warm: #e0a472;
  --warm-soft: #2c2119; --code-bg: #1d1f22; --code-fg: #e2e0da; --tok-kw: #d3a0e0;
  --tok-str: #9fd08f; --tok-num: #f0a77c; --tok-com: #7f7d76; --tok-fn: #94bde6;
  --tok-builtin: #e3c07a; --fig-bg: #f4f3ef; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 1.0625rem/1.68 var(--serif);
  font-optical-sizing: auto; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 99; background: var(--surface); padding: .5rem 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- header / footer */
.site-header {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule);
}
.bar { max-width: 76rem; margin: 0 auto; padding: .7rem 1rem; display: flex; align-items: center; gap: 1.5rem; }
.brand { font: 600 .95rem/1 var(--sans); color: var(--fg); text-decoration: none; white-space: nowrap; }
.brand-mark { font: 500 .8rem var(--mono); color: var(--accent); margin-right: .35rem; }
.site-nav { display: flex; gap: 1.25rem; margin-left: auto; font: 500 .875rem var(--sans); overflow-x: auto; }
.site-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; padding: .2rem 0; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--fg); }
.site-nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--accent); }
.theme-toggle {
  border: 1px solid var(--rule); background: none; color: var(--muted); border-radius: 50%;
  width: 2rem; height: 2rem; cursor: pointer; font-size: 1rem; flex: none;
}
.site-footer {
  border-top: 1px solid var(--rule); margin-top: 5rem; padding: 2rem 1rem 3rem;
  font: .8125rem/1.6 var(--sans); color: var(--muted); text-align: center;
}
.site-footer p { max-width: 44rem; margin: 0 auto; }

/* ---------------------------------------------------------------- layout */
.layout { max-width: 76rem; margin: 0 auto; padding: 0 1rem; }
main { max-width: 52rem; margin: 0 auto; min-width: 0; }
.layout.with-toc { display: grid; grid-template-columns: 14rem minmax(0, 52rem); gap: 3.5rem; justify-content: center; }
.layout.with-toc main { margin: 0; }
.toc { position: sticky; top: 4.5rem; align-self: start; max-height: calc(100vh - 5.5rem); overflow-y: auto;
  padding: 2.75rem 0 2rem; font: .8125rem/1.45 var(--sans); }
.toc summary { font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  font-size: .6875rem; cursor: pointer; list-style: none; margin-bottom: .6rem; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a { display: block; padding: .3rem 0 .3rem .85rem; margin-left: -1px; color: var(--muted);
  text-decoration: none; border-left: 2px solid transparent; }
.toc li a:hover { color: var(--fg); }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); }

@media (max-width: 64rem) {
  .layout.with-toc { display: block; }
  .toc { position: static; max-height: none; padding: 1.25rem 0 0; }
  .toc details:not([open]) summary { margin-bottom: 0; }
  .toc summary { font-size: .75rem; }
  .toc summary::after { content: " ▾"; }
}

/* ---------------------------------------------------------------- page head */
.page-head { padding: 2.75rem 0 1.25rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.5rem; }
.eyebrow { font: 500 .75rem/1.4 var(--sans); text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 .75rem; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.22; letter-spacing: -.01em;
  text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); margin: 0 0 1rem; letter-spacing: -.02em; }
.page-head .lede, .lede { font-size: 1.2rem; line-height: 1.55; color: var(--muted); max-width: 42rem; margin: 0; }
.meta { margin: 1.25rem 0 0; display: grid; gap: .55rem; font: .875rem/1.55 var(--sans); }
.meta div { display: grid; grid-template-columns: 8.5rem 1fr; gap: 1rem; }
.meta dt { color: var(--muted); font-weight: 500; }
.meta dd { margin: 0; }
@media (max-width: 40rem) { .meta div { grid-template-columns: 1fr; gap: .1rem; } }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin-top: 1.25rem;
  font: 500 .8125rem var(--sans); }
.page-actions a { text-decoration: none; }
.code-toggle { font: inherit; color: var(--muted); background: none; border: 1px solid var(--rule-strong);
  border-radius: 999px; padding: .25rem .8rem; cursor: pointer; margin-left: auto; }
.code-toggle:hover { color: var(--fg); border-color: var(--fg); }
.spoiler { font: .875rem/1.5 var(--sans); background: var(--warm-soft); color: var(--fg);
  border-left: 3px solid var(--warm); padding: .7rem 1rem; margin: 1.25rem 0 0; }
.stars { color: var(--warm); letter-spacing: .08em; }
.stars .dim, .dim { opacity: .25; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- prose */
.prose { max-width: var(--measure); }
.prose h2 { font-size: 1.6rem; margin: 3.25rem 0 .9rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.prose h3 { font-size: 1.22rem; margin: 2.2rem 0 .6rem; }
.prose h4 { font-size: 1.05rem; margin: 1.8rem 0 .5rem; }
.h-anchor { float: left; margin-left: -1.1em; width: 1.1em; color: var(--rule-strong); text-decoration: none;
  font-weight: 400; opacity: 0; transition: opacity .15s; }
h2:hover .h-anchor, h3:hover .h-anchor, h4:hover .h-anchor { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose li + li { margin-top: .3rem; }
.prose blockquote { margin: 1.25rem 0; padding: .75rem 1.1rem; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 4px 4px 0; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code, .out-md code, .meta code, .card code, td code, .checks code {
  font: .86em var(--mono); background: var(--code-bg); padding: .1em .32em; border-radius: 3px; }
.prose table, .out-md table {
  border-collapse: collapse; margin: 1.25rem 0 1.5rem; font: .875rem/1.5 var(--sans); display: block;
  overflow-x: auto; max-width: 100%;
}
.prose th, .prose td, .out-md th, .out-md td { padding: .45rem .8rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose thead th, .out-md thead th { border-bottom: 1.5px solid var(--fg); font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: .25rem 0; }

/* ---------------------------------------------------------------- code + outputs */
.cell { margin: 1.25rem 0 1.5rem; }
.code { position: relative; }
.code pre, .out-text {
  margin: 0; padding: .9rem 1.1rem; overflow-x: auto; font: .8125rem/1.6 var(--mono);
  background: var(--code-bg); color: var(--code-fg); border-radius: 6px; tab-size: 4;
}
.code.long.collapsed pre { max-height: 22rem; overflow: hidden;
  mask-image: linear-gradient(#000 70%, transparent); -webkit-mask-image: linear-gradient(#000 70%, transparent); }
.expand-code { display: block; margin: .4rem 0 0 auto; font: 500 .75rem var(--sans); color: var(--accent);
  background: none; border: 0; cursor: pointer; padding: .2rem 0; }
.hide-code .cell > .code, .hide-code .cell > .expand-code { display: none; }
.hide-code .cell:not(:has(.outputs)) { display: none; }
.outputs { margin-top: .6rem; }
.outputs > * + * { margin-top: .75rem; }
.out-text { background: transparent; border: 1px solid var(--rule); color: var(--fg); font-size: .78rem; }
.out-error { border-color: #b3261e; color: #b3261e; }
.out-fig { margin: 0; padding: .6rem; background: var(--fig-bg); border-radius: 6px; text-align: center; }
.out-fig img { display: block; margin: 0 auto; }
:root:not([data-theme="dark"]) .out-fig { padding: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .out-fig { padding: .6rem; } }
.out-anim { margin: 0; background: var(--fig-bg); border-radius: 6px; }
.out-anim iframe { width: 100%; border: 0; height: 520px; display: block; }
.out-plotly { width: 100%; min-height: 420px; background: #fff; border-radius: 6px; }
.out-html { overflow-x: auto; font: .8125rem/1.45 var(--sans); }
.out-html table.dataframe, .out-html table {
  border-collapse: collapse; font: .78rem/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.out-df table { border: 0; }
.out-df table th, .out-df table td { padding: .3rem .7rem; border: 0; border-bottom: 1px solid var(--rule); text-align: right; white-space: nowrap; }
.out-df table thead th { border-bottom: 1.5px solid var(--fg); font-family: var(--sans); font-weight: 600; }
.out-df table tbody th { font-family: var(--sans); font-weight: 500; text-align: left; }
.out-df table tbody tr:hover { background: var(--accent-soft); }
.out-xr { background: var(--fig-bg); color: #1d1d1b; border-radius: 6px; padding: .5rem; }
.out-md { max-width: var(--measure); font-size: .98rem; }
.out-latex { overflow-x: auto; font-size: .9rem; padding: .5rem 0; }

/* pygments */
.code .k, .code .kn, .code .kd, .code .kr, .code .ow, .code .kc { color: var(--tok-kw); }
.code .s, .code .s1, .code .s2, .code .sa, .code .sd, .code .sb, .code .se, .code .si, .code .sh { color: var(--tok-str); }
.code .mi, .code .mf, .code .m, .code .mh, .code .il, .code .mb { color: var(--tok-num); }
.code .c, .code .c1, .code .ch, .code .cm, .code .cs { color: var(--tok-com); font-style: italic; }
.code .nf, .code .nc, .code .fm { color: var(--tok-fn); font-weight: 500; }
.code .nb, .code .bp, .code .nd { color: var(--tok-builtin); }

/* ---------------------------------------------------------------- challenges */
.your-turn { font: .875rem var(--sans); color: var(--muted); border: 1px dashed var(--rule-strong);
  border-radius: 6px; padding: .8rem 1rem; margin: 1rem 0; }
.your-turn span { font-weight: 600; color: var(--accent); margin-right: .5rem; text-transform: uppercase;
  letter-spacing: .06em; font-size: .72rem; }
.hints { margin: 1rem 0 2rem; border-top: 1px solid var(--rule); }
.hints-title { font: 600 .72rem var(--sans); text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  margin: .9rem 0 .4rem; }
.hint { border-bottom: 1px solid var(--rule); }
.hint summary { cursor: pointer; font: 500 .9rem var(--sans); padding: .6rem 0; list-style: none; display: flex;
  align-items: center; gap: .6rem; }
.hint summary::-webkit-details-marker { display: none; }
.hint summary::after { content: "Reveal"; margin-left: auto; font-size: .75rem; color: var(--accent); }
.hint[open] summary::after { content: "Hide"; }
.hint-level { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%;
  border: 1px solid var(--rule-strong); font-size: .72rem; color: var(--muted); }
.hint .prose { padding: 0 0 .75rem 2rem; font-size: .96rem; }
.checks { font: .85rem/1.5 var(--sans); color: var(--muted); padding: .75rem 0 0; }
.checks p { margin: 0 0 .3rem; }
.checks ul { margin: 0; padding-left: 1.2rem; }
.solution-cta { margin-top: 3rem; padding: 1.5rem 1.75rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
.solution-cta h2 { margin-top: 0; font-size: 1.35rem; }

/* ---------------------------------------------------------------- pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 4rem 0 0; }
.pager a { display: block; padding: 1rem 1.2rem; border: 1px solid var(--rule); border-radius: 8px;
  text-decoration: none; color: var(--fg); background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; font: 500 .75rem var(--sans); color: var(--muted); margin-bottom: .2rem; }
.pager span { font-weight: 600; line-height: 1.35; }
.pager-next { text-align: right; grid-column: 2; }
@media (max-width: 40rem) { .pager { grid-template-columns: 1fr; } .pager-next { grid-column: 1; } }

/* ---------------------------------------------------------------- index pages */
.hero { padding: 4.5rem 0 2.5rem; }
.hero h1 { font-size: clamp(2.1rem, 1.5rem + 2.8vw, 3.3rem); max-width: 24ch; line-height: 1.12; }
.hero .lede { font-size: 1.25rem; max-width: 40rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.button { display: inline-block; font: 500 .9rem var(--sans); padding: .65rem 1.2rem; border-radius: 6px;
  background: var(--accent); color: var(--bg); text-decoration: none; border: 1px solid var(--accent); }
.button:hover { filter: brightness(1.1); }
.button-quiet { background: transparent; color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule); margin: 1rem 0 1rem; }
.facts div { padding: 1.25rem 1rem 1.25rem 0; }
.facts div + div { padding-left: 1rem; border-left: 1px solid var(--rule); }
.facts strong { display: block; font: 600 1.6rem var(--serif); }
.facts span { display: block; font: .8125rem/1.45 var(--sans); color: var(--muted); }
@media (max-width: 48rem) { .facts { grid-template-columns: 1fr 1fr; }
  .facts div:nth-child(3) { border-left: 0; padding-left: 0; } .facts div:nth-child(n+3) { border-top: 1px solid var(--rule); } }
.essay { margin: 3.5rem 0; }
.essay > h2 { font-size: 1.7rem; margin: 0 0 1rem; }
.narrow { max-width: var(--measure); }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.three h3 { font-size: 1.1rem; margin: 0 0 .5rem; }
.three p { margin: 0; font-size: 1rem; color: var(--fg); }
@media (max-width: 48rem) { .three { grid-template-columns: 1fr; gap: 1.5rem; } }
.figure-wide { margin: 1.75rem 0; overflow-x: auto; }
.workflow { width: 100%; min-width: 44rem; height: auto; color: var(--muted); font-family: var(--sans); }
.wf-box { fill: var(--surface); stroke: var(--rule-strong); stroke-width: 1; }
.wf-check { fill: var(--accent-soft); stroke: var(--accent); }
.wf-label { fill: var(--fg); font-size: 14px; font-weight: 500; }
.wf-arrow, .wf-loop { stroke: currentColor; stroke-width: 1.3; fill: none; }
.wf-loop { stroke-dasharray: 4 3; }
.wf-note { fill: var(--muted); font-size: 12.5px; font-style: italic; font-family: var(--serif); }
.workflow-list { max-width: var(--measure); padding-left: 1.25rem; }
.workflow-list li { margin: .35rem 0; }
.paths { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.path { border: 1px solid var(--rule); border-radius: 8px; padding: 1.25rem 1.4rem; background: var(--surface); }
.path h3 { margin: 0 0 .5rem; font-size: 1.1rem; }
.path p, .path ol { font-size: .98rem; margin: 0 0 .5rem; }
.path ol { padding-left: 1.2rem; }
@media (max-width: 48rem) { .paths { grid-template-columns: 1fr; } }

.jump ol { list-style: none; padding: 0; margin: 0 0 1rem; columns: 2; column-gap: 2rem; font: .9rem/1.9 var(--sans); }
@media (max-width: 40rem) { .jump ol { columns: 1; } }
.series { margin: 3.5rem 0; scroll-margin-top: 4.5rem; }
.series-head { max-width: var(--measure); margin-bottom: 1.25rem; }
.series-head h2 { margin: 0 0 .5rem; font-size: 1.6rem; }
.series-head p:last-child { margin: 0; color: var(--muted); }
.series-head .eyebrow { margin-bottom: .35rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: 1rem; }
.card { display: flex; flex-direction: column; gap: .4rem; padding: 1.1rem 1.25rem 1.2rem; border: 1px solid var(--rule);
  border-radius: 8px; text-decoration: none; color: var(--fg); background: var(--surface);
  transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-id { font: 500 .72rem var(--mono); color: var(--accent); }
.card-title { font: 600 1.08rem/1.3 var(--serif); }
.card-data { font: .8125rem/1.45 var(--sans); color: var(--muted); }
.card-tech { font: .8125rem/1.5 var(--sans); color: var(--fg); opacity: .85; margin-top: .2rem; }
.card-tech code { font-size: .92em; }

.table-wrap { overflow-x: auto; }
.challenge-table, .guide-table { width: 100%; border-collapse: collapse; font: .875rem/1.5 var(--sans); }
.challenge-table th, .guide-table th { text-align: left; font-weight: 600; padding: .5rem .75rem .5rem 0;
  border-bottom: 1.5px solid var(--fg); white-space: nowrap; }
.challenge-table td, .guide-table td { padding: .8rem .75rem .8rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.challenge-table td a { font-weight: 600; text-decoration: none; }
.challenge-table .cid { font-family: var(--mono); font-size: .8rem; }
.challenge-table .stars { white-space: nowrap; }
.guide-table td:first-child { font-weight: 500; width: 34%; }
.guide-table td:last-child { white-space: nowrap; font-family: var(--mono); font-size: .8rem; }
.recipe li { margin: 0 0 .8rem; }
.page-guide .essay > h2, .page-guide .essay .narrow { max-width: var(--measure); }

@media (max-width: 40rem) {
  body { font-size: 1rem; }
  .bar { gap: .75rem; }
  .brand-mark { display: none; }
  .site-nav { gap: .9rem; }
  .hero { padding-top: 2.5rem; }
  .code pre, .out-text { font-size: .75rem; padding: .75rem .85rem; }
  .code-toggle { margin-left: 0; }
}
@media (max-width: 30rem) { .brand { display: none; } .site-nav { margin-left: 0; } }
@media print {
  .site-header, .toc, .pager, .page-actions, .theme-toggle { display: none; }
  .layout.with-toc { display: block; }
}
