/* Long per-course navbar dropdowns (50+ notes) overflow the viewport - scroll them instead. */
.navbar .dropdown-menu {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Figures wider than the content column (e.g. the schemdraw circuit schematic in
   courses/csse2010/week4-lab-lab-7-exercises.qmd) otherwise render at their full
   pixel width and force the page to pan sideways: quarto emits the image with
   explicit width/height attributes and class="figure-img", and bootstrap only
   constrains .img-fluid/.img-thumbnail, never a bare img. Scale to the column and
   let the height follow, so the aspect ratio survives. */
.figure-img,
figure img {
  max-width: 100%;
  height: auto;
}

/* Quarto/bootstrap only give inline code its grey chip inside <p>, <li> and <td>
   (`p code:not(.sourceCode)` and friends). A `code` span in a heading or a table
   header falls through to bootstrap's bare `code` rule instead, which pairs a
   near-white #f8f9fa background with `color: inherit` - under darkly that paints
   the heading's own near-white text onto a near-white chip and the word vanishes,
   e.g. "Question 2 - Designing a `Vertex` class" in
   courses/csse2002/week3-tutorial-stack-heap-and-class-design.qmd. Quarto puts the
   per-theme rules in the theme stylesheets, which custom.css cannot hook into, so
   mirror its two chip colours off the quarto-light/quarto-dark class it sets on
   <body> and reuse them wherever the built-in rules miss. */
body.quarto-light {
  --uninotes-inline-code-bg: rgba(233, 236, 239, 0.65);
}

body.quarto-dark {
  --uninotes-inline-code-bg: rgba(67, 67, 67, 0.65);
}

:is(h1, h2, h3, h4, h5, h6, th, dt, dd, figcaption, caption, summary)
  code:not(.sourceCode) {
  background-color: var(--uninotes-inline-code-bg);
  padding: 0.2em;
}
/* uninotes · the observatory's library wing
   One stylesheet, loaded last: the night design system applied to Quarto's
   rendered notes. Palette lifts the observatory's tokens slightly toward
   paper-dark for long reading. */

@import url("https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;600&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&family=Newsreader:ital,opsz,wght@0,6..72,400..650;1,6..72,400..650&display=swap");

:root, body, body.quarto-light, body.quarto-dark {
  --un-bg: #0a0e22;
  --un-ink: #e6eaff;
  --un-muted: #7a86ad;
  --un-line: rgba(122, 134, 173, 0.28);
  --un-link: #6aa7e8;
  --un-code-bg: #060b20;
  --un-chip: rgba(25, 120, 220, 0.14);
  --uninotes-inline-code-bg: rgba(25, 120, 220, 0.16);
  --bs-body-bg: var(--un-bg);
  --bs-body-color: var(--un-ink);
  --bs-link-color: var(--un-link);
}

body, body.quarto-light, body.quarto-dark {
  background: var(--un-bg) !important;
  color: var(--un-ink) !important;
  font-family: "IBM Plex Sans", system-ui, sans-serif !important;
  font-size: 1.02rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

/* ---- headings & title block ---- */
h1, h2, h3, h4, h5, h6, .quarto-title h1 {
  font-family: "Chakra Petch", "Trebuchet MS", sans-serif !important;
  font-weight: 600;
  color: var(--un-ink) !important;
  letter-spacing: 0.015em;
}
.quarto-title-block, #title-block-header {
  border-bottom: 1px solid var(--un-line);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
}
.quarto-title h1 { font-size: 2rem; }
.quarto-title-meta, .quarto-title-meta-heading, .quarto-categories {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--un-muted) !important;
}
.quarto-category, .quarto-categories .quarto-category {
  background: var(--un-chip);
  border: 1px solid var(--un-line);
  color: var(--un-muted) !important;
}

/* ---- links ---- */
a, a:visited { color: var(--un-link) !important; text-decoration: none; }
a:hover { color: #9cc4f2 !important; text-decoration: underline; text-underline-offset: 3px; }

/* ---- navbar (slim chrome, matches the observatory nav) ---- */
.navbar, .navbar-dark, .navbar-light {
  background: rgba(10, 14, 34, 0.92) !important;
  border-bottom: 1px solid var(--un-line);
  backdrop-filter: blur(6px);
}
.navbar .navbar-brand, .navbar .nav-link {
  font-family: "IBM Plex Mono", monospace !important;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--un-ink) !important;
  opacity: 0.85;
}
.navbar .nav-link:hover { opacity: 1; }
.navbar .dropdown-menu {
  background: rgba(10, 16, 42, 0.96);
  border: 1px solid var(--un-line);
}
.navbar .dropdown-item { color: var(--un-ink); font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; }
.navbar .dropdown-item:hover { background: rgba(25, 120, 220, 0.18); color: var(--un-ink); }

/* ---- table of contents / sidebars ---- */
#quarto-margin-sidebar, #quarto-sidebar, nav[role="doc-toc"] {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
}
nav[role="doc-toc"] > h2, #toc-title {
  font-family: "IBM Plex Mono", monospace !important;
  font-size: 0.66rem !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--un-muted) !important;
}
nav[role="doc-toc"] a { color: var(--un-muted) !important; border-left: 1px solid transparent; }
nav[role="doc-toc"] a.active { color: var(--un-ink) !important; border-left-color: var(--un-link) !important; }

/* ---- code ---- */
pre, pre.sourceCode, div.sourceCode {
  background: var(--un-code-bg) !important;
  border: 1px solid var(--un-line) !important;
  border-radius: 6px;
}
code, pre code { font-family: "IBM Plex Mono", monospace !important; font-size: 0.88em; }
p code:not(.sourceCode), li code:not(.sourceCode), td code:not(.sourceCode),
:is(h1, h2, h3, h4, h5, h6, th, dt, dd, figcaption, caption, summary) code:not(.sourceCode) {
  background: var(--uninotes-inline-code-bg) !important;
  color: #cfe0ff !important;
  border-radius: 4px;
  padding: 0.12em 0.35em;
}

/* ---- tables ---- */
table, .table { color: var(--un-ink) !important; border-color: var(--un-line) !important; }
thead th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--un-muted) !important;
  border-bottom: 1px solid var(--un-line) !important;
}
tbody td, tbody th { border-color: rgba(122, 134, 173, 0.14) !important; }
.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: rgba(25, 120, 220, 0.05);
  color: var(--un-ink);
}

/* ---- callouts, blockquotes, rules ---- */
.callout {
  background: rgba(25, 120, 220, 0.07) !important;
  border: 1px solid var(--un-line) !important;
  border-left: 3px solid var(--un-link) !important;
}
.callout-header, .callout-title-container { color: var(--un-ink) !important; background: transparent !important; }
blockquote {
  border-left: 3px solid var(--un-line);
  color: var(--un-muted);
}
hr { border-color: var(--un-line); opacity: 1; }

/* ---- figures ---- */
figcaption, .figure-caption {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: var(--un-muted) !important;
}

/* ---- footer / misc chrome ---- */
.nav-footer, .page-footer { background: transparent !important; border-top: 1px solid var(--un-line); color: var(--un-muted) !important; }
.quarto-title-banner { background: transparent !important; }
::selection { background: rgba(25, 120, 220, 0.35); }

/* ---- embedded mode: framed inside mattogrady.com's reader, the site
        chrome disappears and the observatory around the panel is the nav ---- */
html.un-embedded #quarto-header,
html.un-embedded .navbar { display: none !important; }
html.un-embedded #quarto-content { padding-top: 0 !important; }

/* ---- the bridge's note furniture: breadcrumb, prev/next, backlinks ---- */
.un-crumb {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--un-muted);
  margin-bottom: 0.4rem;
}
.un-crumb a { color: var(--un-muted) !important; }
.un-crumb a:hover { color: var(--un-ink) !important; }
.un-foot {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--un-line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}
.un-foot .un-label {
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--un-muted);
  margin: 0.9rem 0 0.3rem;
}
.un-foot ul { list-style: none; padding: 0; margin: 0; }
.un-foot li { margin: 0.15rem 0; }
.un-prevnext { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.9rem; }
.un-prevnext a { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the mock's leftover: bootstrap's green TOC active state -> house blue */
nav[role="doc-toc"] a.active, nav[role="doc-toc"] a:hover {
  color: var(--un-ink) !important;
  border-left-color: var(--un-link) !important;
}

/* darkly's green TOC accent resists the earlier rule - out-specify it */
nav[role="doc-toc"] a, #TOC a { color: var(--un-muted) !important; }
nav[role="doc-toc"] a.active, #TOC a.active {
  color: var(--un-ink) !important;
  border-left-color: var(--un-link) !important;
}

/* ---- nothing may widen the page: wide content scrolls within itself,
        the page itself never grows a horizontal scrollbar ---- */
html, body { overflow-x: hidden; }
main table { display: block; max-width: 100%; overflow-x: auto; }
.katex-display, .cell-output-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
main svg { max-width: 100%; height: auto; }

/* embedded in the observatory's reader: the margin TOC steps aside so the
   text gets the whole column (the note's own headings remain) */
html.un-embedded #quarto-margin-sidebar { display: none; }
html.un-embedded #quarto-content.page-columns { display: block; padding: 0 clamp(1.1em, 4vw, 2.4em); }

/* MathJax display equations (client-rendered, so no static class to see):
   wide derivations scroll within their own line, never clipped by the
   page's overflow guard */
mjx-container { max-width: 100%; }
mjx-container[display="true"] {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 4px;
}

/* slim, quiet rails on the self-scrolling bits */
mjx-container[display="true"], main table {
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 134, 173, 0.35) transparent;
}
:is(mjx-container[display="true"], main table)::-webkit-scrollbar { height: 6px; }
:is(mjx-container[display="true"], main table)::-webkit-scrollbar-thumb {
  background: rgba(122, 134, 173, 0.35); border-radius: 3px; }
:is(mjx-container[display="true"], main table)::-webkit-scrollbar-track { background: transparent; }

/* ---- source material block (rendered by observatory-bridge.html from
        sources.json — the original slides/worksheets a note came from) ---- */
.un-sources {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--un-line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}
.un-sources .un-label {
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--un-muted);
  margin-bottom: 0.45rem;
}
.un-sources ul { list-style: none; padding: 0; margin: 0; }
.un-sources li { margin: 0.2rem 0; }
.un-sources .un-meta { color: var(--un-muted); font-size: 0.68rem; }
/* when the furniture block follows, it shouldn't double up the rule */
.un-sources + .un-foot { margin-top: 1.4rem; padding-top: 0; border-top: 0; }

/* Cells rendered with `echo: false` still get quarto's code-copy button, bolted
   onto a `.sourceCode.hidden` block - so the button offers to copy source the
   reader cannot see. Most visible on the sample past-exam notes
   (courses/csse2010/csse2010-sample-midsem-*.qmd), where every question's
   multiple-choice input and its verdict is a hidden-source `ojs` cell and the
   button would otherwise repeat 50+ times a page. Sibling selector, not :has(),
   since the button is emitted after the source block inside the same scaffold. */
.code-copy-outer-scaffold > .sourceCode.hidden ~ .code-copy-button { display: none; }

/* ---- at home in mattogrady.com's reader ----
   Framed there, a note is a page of that site, not a second site in a box:
   it wears the page's own paper, ink and type. The page is near-black with
   warm ink in the dark and cream with dark ink in the light, set in
   Newsreader with IBM Plex Mono for the small print, and follows the
   visitor's own light or dark. A frame is asked the same question and
   gives the same answer, so nothing is sent across for it: the old "dawn"
   message, which painted a navy the page no longer has, is gone.

   The colours are the reader panel's (--panel, --ink, --dim, --rule and the
   page's blue, in site/index.html there): if the page's change, change
   these. Standing alone the notes keep the night skin above; everything
   here is under html.un-embedded and touches nothing else. Most of the
   skin is drawn from the --un-* names, so most of this is those names
   again; what follows them is what the night skin wrote in by hand. ---- */
html.un-embedded, html.un-embedded body,
html.un-embedded body.quarto-light, html.un-embedded body.quarto-dark {
  color-scheme: dark;
  --un-bg: #1a1a16;
  --un-ink: #f2f0e6;
  --un-muted: #aeab9c;
  --un-line: #33322a;
  --un-link: #6aa6ee;
  --un-link-hover: #9cc4f6;
  --un-code-bg: #11110e;
  --un-code-ink: #f2f0e6;
  --un-chip: rgba(242, 240, 230, 0.07);
  --un-tint: rgba(242, 240, 230, 0.045);
  --uninotes-inline-code-bg: rgba(242, 240, 230, 0.09);
  --bs-body-bg: var(--un-bg);
  --bs-body-color: var(--un-ink);
  --bs-link-color: var(--un-link);
}
@media (prefers-color-scheme: light) {
  html.un-embedded, html.un-embedded body,
  html.un-embedded body.quarto-light, html.un-embedded body.quarto-dark {
    color-scheme: light;
    --un-bg: #ece8da;
    --un-ink: #16150f;
    --un-muted: #57544a;
    --un-line: #d6d1bf;
    --un-link: #1a5fb0;
    --un-link-hover: #0f4686;
    /* a block of code keeps its dark ground on the cream page: its
       colouring is the dark theme's, light on dark, and would be lost on
       paper */
    --un-code-bg: #1a1a16;
    --un-code-ink: #f2f0e6;
    --un-chip: rgba(22, 21, 15, 0.06);
    --un-tint: rgba(22, 21, 15, 0.04);
    --uninotes-inline-code-bg: rgba(22, 21, 15, 0.08);
  }
}
html.un-embedded body, html.un-embedded body.quarto-light, html.un-embedded body.quarto-dark {
  font-family: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif !important;
  font-size: 1.14rem;
  line-height: 1.55;
}
html.un-embedded :is(h1, h2, h3, h4, h5, h6), html.un-embedded .quarto-title h1 {
  font-family: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif !important;
  font-weight: 580;
  letter-spacing: -0.012em;
}
html.un-embedded .quarto-title h1 { font-size: 1.9rem; line-height: 1.12; }
html.un-embedded a:hover { color: var(--un-link-hover) !important; }
html.un-embedded pre, html.un-embedded pre.sourceCode, html.un-embedded div.sourceCode { color: var(--un-code-ink); }
html.un-embedded :is(p, li, td) code:not(.sourceCode),
html.un-embedded :is(h1, h2, h3, h4, h5, h6, th, dt, dd, figcaption, caption, summary) code:not(.sourceCode) {
  color: var(--un-ink) !important;
}
html.un-embedded tbody td, html.un-embedded tbody th { border-color: var(--un-line) !important; }
html.un-embedded .table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: var(--un-tint); }
html.un-embedded .callout { background: var(--un-tint) !important; }
html.un-embedded ::selection { background: rgba(57, 135, 229, 0.3); }
/* what only makes sense with this site's own bar and search in view, or
   would send the frame to the page it is already inside */
html.un-embedded .un-alone { display: none; }
html.un-embedded .quarto-category a, html.un-embedded .quarto-categories a { color: var(--un-muted) !important; }
