@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* Shared by both themes. The colors are palette roles (--book-*) set by
   _includes/theme-light.scss (blue/teal of the chapter PDFs, no dark boxes) and
   _includes/theme-dark.scss (navy, cyan and gold of the book cover). The layout and components follow
   the author's metricsai book (no top bar, parts in the sidebar, a TOC card with the cover, framed
   mind maps); only the colors are this book's. */
/* Inter and JetBrains Mono (mainfont/monofont in _quarto.yml), with fallbacks while they load */
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
code, pre, kbd, samp, .sourceCode { font-family: "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }  /* show <= and != as typed, not as ≤ and ≠ */

h1, .sidebar-title { color: var(--book-h1); }
h2 { color: var(--book-h2); border-left: 4px solid var(--book-h2); padding-left: .75rem; }
h3, h4 { color: var(--book-h3); }
a { color: var(--book-blue); }
details { background: var(--book-panel-teal); border-left: 4px solid var(--book-teal);
          padding: .4rem .8rem; margin: .6rem 0; border-radius: 4px; }
details summary { cursor: pointer; font-weight: 600; color: var(--book-teal); }
blockquote { background: var(--book-panel-blue); border-left: 4px solid var(--book-blue);
             padding: .8rem 1.15rem; margin: 1rem 0; border-radius: 4px; color: inherit; }
blockquote strong { color: var(--book-h2); }

/* Lists, tables, code and outputs */
main li { margin-bottom: .35rem; }
ul li::marker { color: var(--book-blue); }
ol li::marker { color: var(--book-h2); font-weight: 600; }
main table thead th { border-bottom: 2px solid var(--book-blue) !important; }
main table tbody tr:nth-child(even) { background-color: var(--book-stripe); }
div.sourceCode { border-left: 3px solid var(--book-blue) !important; border-radius: 4px; }
.cell-output-stdout pre, .cell-output-display pre {
  border-left: 3px solid var(--book-teal); background: var(--book-panel-teal); border-radius: 4px; padding: .75rem;
}

/* Content links: no underline, a rule on hover (badges and mind maps excluded) */
main a:not(.nav-link):not(.sidebar-link):not(.chapter-mindmap):not(:has(> img)) {
  text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .2s;
}
main a:not(.nav-link):not(.sidebar-link):not(.chapter-mindmap):not(:has(> img)):hover {
  border-bottom-color: var(--book-accent);
}
/* the external-link icon is for text links only */
a.external:has(> img)::after, a.chapter-mindmap::after { display: none !important; }

/* Chapter mind map at the top of each chapter (managed by /write-slides) */
.chapter-mindmap img { display: block; width: 100%; margin: .6rem 0 1.2rem; border: 2px solid var(--book-blue);
                       border-radius: 8px; box-shadow: 0 4px 12px var(--book-shadow);
                       transition: transform .3s ease, box-shadow .3s ease; }
.chapter-mindmap:hover img { transform: scale(1.01); box-shadow: 0 8px 18px var(--book-glow); }

/* ── Book layout ────────────────────────────────────────────────────────────────────────────── */

/* The Preface heading (the title block names the book) and the breadcrumbs are hidden */
#preface > h1 { display: none; }
.quarto-page-breadcrumbs { display: none !important; }

/* Title block: a soft panel with an accent rule (the cover's gold rule in dark mode) */
header#title-block-header {
  background: var(--book-title-bg); border-bottom: 3px solid var(--book-accent);
  padding: 1.5rem; margin-bottom: 2rem; border-radius: 0 0 8px 8px;
}
.quarto-title-meta-heading {
  color: var(--book-h2) !important; font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .5px;
}

/* Google Translate widget */
.book-translate { padding: 8px 0; min-height: 40px; max-width: 100%; overflow: hidden; }
.book-translate .goog-te-gadget span { white-space: normal !important; }
.book-translate .goog-te-combo {
  background: var(--book-panel); color: inherit; border: 1px solid var(--book-rule); border-radius: 4px;
  padding: .15rem .4rem; font-size: .85rem;
}
.book-translate .goog-te-gadget { color: var(--book-muted); font-size: .75rem; }

/* Left sidebar: title, tools (GitHub, light/dark), search, then the parts */
.sidebar-item-section > .sidebar-item-container > .sidebar-item-text {
  color: var(--book-h2) !important; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  font-size: .85rem; padding-bottom: .25rem; border-bottom: 1.5px solid var(--book-h2-line);
}
#quarto-sidebar .sidebar-item:not(.sidebar-item-section) > .sidebar-item-container > .sidebar-item-text .menu-text {
  color: var(--book-blue);
}
.sidebar-link { transition: background-color .2s; }
.sidebar-link:hover { background-color: var(--book-tint-soft) !important; }
.sidebar-link.active {
  background-color: var(--book-tint) !important; border-left: 3px solid var(--book-accent); padding-left: .5rem;
}
.sidebar-item-text.sidebar-link.active .menu-text { font-weight: 700; }
.aa-Autocomplete .aa-Form, .aa-DetachedSearchButton {
  border: 2px solid var(--book-rule) !important; border-radius: 6px !important; transition: all .2s;
}
.aa-Autocomplete .aa-Form:focus-within {
  border-color: var(--book-blue) !important; box-shadow: 0 0 0 3px var(--book-tint) !important;
}

/* Light/dark toggle (in the sidebar tools): a sun in dark mode (click for light) and a moon in
   light mode, from the Bootstrap Icons font. */
.quarto-color-scheme-toggle .bi::before {
  background-image: none !important; font-family: "bootstrap-icons" !important;
  width: auto; height: auto; font-size: 1.15rem; line-height: 1; vertical-align: -.15em;
}
body.quarto-dark .quarto-color-scheme-toggle .bi::before { content: "\f5a1"; color: #f5c842; }
body.quarto-light .quarto-color-scheme-toggle .bi::before { content: "\f495"; color: #16528c; }

/* Right sidebar: the cover above a table-of-contents card */
#toc-cover-image { display: block; text-align: center; padding: 0 .5rem 1rem; margin-bottom: .75rem;
                   border-bottom: 1px solid var(--book-rule); }
#toc-cover-image img { max-width: 100%; border-radius: 6px; box-shadow: 0 2px 8px var(--book-shadow);
                       transition: transform .2s; }
#toc-cover-image:hover img { transform: translateY(-2px); }
#TOC { background: var(--book-toc-bg); border: 1px solid var(--book-rule); border-radius: 8px; padding: .75rem; }
#TOC h2 { color: var(--book-h2) !important; font-size: .95rem; font-weight: 700; border-left: none; padding-left: 0;
          border-bottom: 2px solid var(--book-accent); padding-bottom: .4rem; margin-bottom: .75rem; }
#TOC a.nav-link { color: var(--book-muted) !important; padding: .25rem .5rem; border-radius: 4px;
                  border-left: 3px solid transparent; transition: all .2s; }
#TOC a.nav-link:hover { background-color: var(--book-tint-soft); color: var(--book-blue) !important; }
#TOC a.nav-link.active { color: var(--book-blue) !important; font-weight: 600; background-color: var(--book-tint);
                         border-left: 3px solid var(--book-accent); }
@media (min-width: 992px) { #TOC ul { display: block !important; } }

/* Previous / next chapter: buttons under an accent rule */
nav.page-navigation { border-top: 2px solid var(--book-accent); padding-top: 1.5rem; margin-top: 3rem; }
nav.page-navigation .nav-page a {
  display: inline-block; padding: .6rem 1.2rem; background-color: var(--book-panel); border: 1px solid var(--book-rule);
  border-radius: 6px; text-decoration: none !important; color: var(--book-blue) !important; font-weight: 500;
  box-shadow: 0 1px 3px var(--book-shadow); transition: all .3s;
}
nav.page-navigation .nav-page a:hover {
  background-color: var(--book-blue); color: var(--book-on-blue) !important; border-color: var(--book-blue);
  box-shadow: 0 4px 12px var(--book-glow); transform: translateY(-1px);
}
nav.page-navigation .nav-page a:hover .menu-text, nav.page-navigation .nav-page a:hover i { color: var(--book-on-blue); }

/* Sidebars scroll without visible scrollbars */
#quarto-sidebar, #quarto-margin-sidebar, #TOC, .mobile-toc-content { scrollbar-width: none; -ms-overflow-style: none; }
#quarto-sidebar::-webkit-scrollbar, #quarto-margin-sidebar::-webkit-scrollbar, #TOC::-webkit-scrollbar,
.mobile-toc-content::-webkit-scrollbar { display: none; }

/* Phones: "On this page" button (Quarto's secondary bar) and its slide-in panel (_includes/book-layout.html) */
.mobile-toc-nav-btn { margin-left: .25rem; -webkit-tap-highlight-color: transparent; }
.mobile-toc-nav-btn i { font-size: 1.1rem; }
@media (min-width: 992px) { .mobile-toc-nav-btn { display: none !important; } }
.mobile-toc-overlay { position: fixed; inset: 0; z-index: 1055; background: rgba(0, 0, 0, .5);
                      opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
.mobile-toc-overlay.active { opacity: 1; visibility: visible; }
.mobile-toc-panel { position: fixed; top: 0; right: 0; width: 300px; max-width: 85vw; height: 100%; z-index: 1060;
                    overflow-y: auto; -webkit-overflow-scrolling: touch; transform: translateX(100%);
                    transition: transform .3s ease; background: var(--book-page); color: inherit;
                    border-left: 2px solid var(--book-accent); }
.mobile-toc-panel.active { transform: translateX(0); }
.mobile-toc-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem;
                     border-bottom: 1px solid var(--book-rule); position: sticky; top: 0; background: inherit; z-index: 1; }
.mobile-toc-title { margin: 0; font-size: 1rem; font-weight: 600; color: var(--book-h2); }
.mobile-toc-close { background: none; border: none; color: var(--book-muted); font-size: 1.75rem; cursor: pointer;
                    padding: 0; line-height: 1; -webkit-tap-highlight-color: transparent; }
.mobile-toc-close:hover { color: var(--book-accent); }
.mobile-toc-content { padding: .75rem 1rem; }
.mobile-toc-content ul { list-style: none; padding: 0; margin: 0; }
.mobile-toc-content li { margin: 0; }
.mobile-toc-content ul ul { padding-left: 1rem; }
.mobile-toc-content a { display: block; padding: .5rem .75rem; text-decoration: none !important; border-radius: 4px;
                        border-left: 3px solid transparent; font-size: .9rem; color: var(--book-muted) !important; }
.mobile-toc-content ul ul a { font-size: .85rem; padding: .35rem .75rem; }
.mobile-toc-content a:hover, .mobile-toc-content a.active {
  background-color: var(--book-tint); color: var(--book-blue) !important; border-left-color: var(--book-accent);
}

/* Desktops: chevrons on the left and right edges hide or show the two sidebars */
.sidebar-toggle { display: none; }
@media (min-width: 992px) {
  .sidebar-toggle { position: fixed; top: 50%; transform: translateY(-50%); z-index: 1040; width: 24px; height: 48px;
                    display: flex; align-items: center; justify-content: center; padding: 0; font-size: .75rem;
                    cursor: pointer; opacity: .45; transition: opacity .2s;
                    background: var(--book-panel); color: var(--book-muted); border: 1px solid var(--book-rule); }
  .sidebar-toggle:hover { opacity: 1; color: var(--book-accent); }
  .sidebar-toggle-left { left: 0; border-radius: 0 6px 6px 0; border-left: none; }
  .sidebar-toggle-right { right: 0; border-radius: 6px 0 0 6px; border-right: none; }
  body.left-collapsed #quarto-sidebar { display: none !important; }
  body.toc-collapsed #quarto-margin-sidebar { display: none !important; }
  body.left-collapsed .sidebar-toggle-left i, body.toc-collapsed .sidebar-toggle-right i { transform: scaleX(-1); }
}

/* Matplotlib charts (Appendix G) are saved twice by its show() helper, light and dark; show the one that
   matches the theme. Colab shows the light one, because the dark image carries an inline display:none. */
.book-mpl img { max-width: 100%; height: auto; }
body.quarto-dark .book-mpl .book-mpl-light { display: none !important; }
body.quarto-dark .book-mpl .book-mpl-dark { display: inline !important; }

/* Chart controls (_includes/plotly-controls.html): the menus, buttons and sliders of each Plotly chart,
   drawn as web controls above it so they work with a finger on tablets and phones (user decision,
   2026-10-19). 16px text keeps iOS Safari from zooming in when a menu is tapped. */
.book-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem .9rem; margin: .4rem 0 .5rem; }
.book-ctl-select, .book-ctl-button {
  font: inherit; font-size: 16px; min-height: 40px; color: var(--bs-body-color);
  background-color: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 6px;
}
.book-ctl-select { max-width: 100%; padding: .3rem 2rem .3rem .6rem; }
.book-ctl-buttons { display: inline-flex; flex-wrap: wrap; }
.book-ctl-button { padding: .3rem .8rem; cursor: pointer; margin-right: -1px; border-radius: 0; }
.book-ctl-button:first-child { border-radius: 6px 0 0 6px; }
.book-ctl-button:last-child { border-radius: 0 6px 6px 0; margin-right: 0; }
.book-ctl-button:only-child { border-radius: 6px; }
.book-ctl-button[aria-pressed="true"] { background-color: var(--book-blue); border-color: var(--book-blue);
                                        color: var(--bs-body-bg); }
.book-ctl-slider { flex: 1 1 260px; min-width: 200px; }
.book-ctl-readout { font-size: .9rem; margin-bottom: .1rem; }
.book-ctl-range { width: 100%; height: 32px; accent-color: var(--book-blue); }
.book-ctl-ticks { display: flex; justify-content: space-between; font-size: .75rem; opacity: .8; gap: .3rem; }
.book-ctl-ticks span { flex: 0 1 auto; text-align: center; overflow-wrap: anywhere; }
.cell-output-display .js-plotly-plot { max-width: 100%; }
.book-ctl-title { font-weight: 600; font-size: .95rem; line-height: 1.35; margin: .2rem 0 .3rem; }
.book-ctl-title:empty { display: none; }
.js-plotly-plot.book-narrow .g-gtitle { display: none; }


/* On a phone, long equations and wide tables scroll sideways on their own instead of widening the page */
span.math.display, mjx-container[display="true"] { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
/* Inline math only on phones: as an inline-block it leaves the text baseline (a bar accent like d̄ sat low),
   and a bar's 1px overflow drew a scrollbar, so it stays plain inline math on wider screens */
@media (max-width: 576px) {
  span.math.inline mjx-container { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden;
                                   vertical-align: middle; scrollbar-width: none; }
  span.math.inline mjx-container::-webkit-scrollbar { display: none; }
}
main table { display: block; max-width: 100%; overflow-x: auto; }

/* Model overview boxes (write-notebook conventions §2 item 4): Quarto callouts restyled in the book
   palette. Big idea and Recap are blue, In words is teal, Key result is gold, Check your understanding
   is a neutral panel. Quarto's own icon is replaced by a line icon of the Bootstrap Icons font that
   Quarto already loads (lightbulb, chat-quote, key, question-circle, list-check); .mo-takeaway is the one-line pull quote that closes a block. */
.callout.mo-bigidea, .callout.mo-recap, .callout.mo-inwords, .callout.mo-key, .callout.mo-check {
  border: 1px solid var(--book-rule) !important; border-left-width: 5px !important;
  border-radius: 6px; margin: 1.4rem 0;
}
.callout.mo-bigidea, .callout.mo-recap { border-left-color: var(--book-blue) !important; background: var(--book-panel-blue); }
.callout.mo-inwords { border-left-color: var(--book-teal) !important; background: var(--book-panel-teal); }
.callout.mo-key { border-left-color: var(--book-gold) !important; background: var(--book-panel-gold); }
.callout.mo-check { border-left-color: var(--book-muted) !important; background: var(--book-panel); }
.callout.mo-bigidea .callout-header, .callout.mo-recap .callout-header, .callout.mo-inwords .callout-header,
.callout.mo-key .callout-header, .callout.mo-check .callout-header { background: transparent !important; border: 0 !important; }
.callout.mo-bigidea .callout-title-container, .callout.mo-recap .callout-title-container { color: var(--book-blue); font-weight: 700; }
.callout.mo-inwords .callout-title-container { color: var(--book-teal); font-weight: 700; }
.callout.mo-key .callout-title-container { color: var(--book-gold); font-weight: 700; }
.callout.mo-check .callout-title-container { color: var(--book-blue); font-weight: 700; }
.callout.mo-bigidea .callout-icon-container, .callout.mo-recap .callout-icon-container,
.callout.mo-inwords .callout-icon-container, .callout.mo-key .callout-icon-container,
.callout.mo-check .callout-icon-container { display: none !important; }
.callout.mo-bigidea .callout-title-container::before, .callout.mo-recap .callout-title-container::before,
.callout.mo-inwords .callout-title-container::before, .callout.mo-key .callout-title-container::before,
.callout.mo-check .callout-title-container::before {
  font-family: "bootstrap-icons"; font-weight: normal; font-size: 1.05em; line-height: 1;
  margin-right: .5rem; vertical-align: -.12em;
}
.callout.mo-bigidea .callout-title-container::before { content: "\f46b"; }  /* lightbulb */
.callout.mo-inwords .callout-title-container::before { content: "\f255"; }  /* chat-quote */
.callout.mo-key .callout-title-container::before { content: "\f44f"; }      /* key */
.callout.mo-check .callout-title-container::before { content: "\f505"; }    /* question-circle */
.callout.mo-recap .callout-title-container::before { content: "\f473"; }    /* list-check */
.callout.mo-key .callout-body-container { font-size: 1.02rem; }
.callout.mo-check details { background: transparent; border-left-width: 3px; }
.callout table { background: transparent; }
.mo-takeaway {
  margin: 1.8rem auto; max-width: 38rem; padding: .9rem 1rem; text-align: center;
  font-size: 1.12rem; font-weight: 600; line-height: 1.5; color: var(--book-h2);
  border-top: 2px solid var(--book-h2-line); border-bottom: 2px solid var(--book-h2-line);
}
.mo-takeaway::before {
  content: "Takeaway"; display: block; margin-bottom: .35rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--book-accent);
}
.mo-takeaway p:last-child { margin-bottom: 0; }
/* Folded code of '## Model in code' (/improve-model-code): the Setup and Drawing tools subsections sit in a
   collapsed callout, a quiet neutral panel with a code-slash line icon, solid border like the .mo-* boxes. */
.callout.mic-fold {
  border: 1px solid var(--book-rule) !important; border-left-width: 5px !important;
  border-left-color: var(--book-muted) !important; border-radius: 6px; margin: 1rem 0 1.4rem;
  background: var(--book-panel);
}
.callout.mic-fold .callout-header { background: transparent !important; border: 0 !important; cursor: pointer; }
.callout.mic-fold .callout-title-container { color: var(--book-blue); font-weight: 600; }
.callout.mic-fold .callout-icon-container { display: none !important; }
.callout.mic-fold .callout-title-container::before {
  content: "\f2c6"; font-family: "bootstrap-icons"; font-weight: normal; font-size: 1.05em; line-height: 1;
  margin-right: .5rem; vertical-align: -.12em;
}
.callout.mic-fold .callout-body-container > .cell { margin-bottom: 1rem; }
