/* Native Quarto theorem and proof styling, adapted from the TCD course. */
div.proof:not(.remark) > p:last-child::after,
div.proof:not(.remark) > div:last-child > p:last-child::after,
div.proof:not(.remark) > ul:last-child > li:last-child > p:last-child::after,
div.proof:not(.remark) > ol:last-child > li:last-child > p:last-child::after,
div.proof:not(.remark) > ul:last-child > li:last-child:not(:has(> p:last-child))::after,
div.proof:not(.remark) > ol:last-child > li:last-child:not(:has(> p:last-child))::after,
div.proof:not(.remark) > ul:last-child > li:last-child > ul:last-child > li:last-child > p:last-child::after,
div.proof:not(.remark) > ul:last-child > li:last-child > ol:last-child > li:last-child > p:last-child::after,
div.proof:not(.remark) > ol:last-child > li:last-child > ul:last-child > li:last-child > p:last-child::after,
div.proof:not(.remark) > ol:last-child > li:last-child > ol:last-child > li:last-child > p:last-child::after {
  content: "\25A1";
  float: right;
  margin-left: 0.75em;
}

div.proof:not(.remark) {
  position: relative;
}

div.proof:not(.remark) > p:last-child:has(> span.math.display:last-child),
div.proof:not(.remark) > div:last-child > p:last-child:has(> span.math.display:last-child),
div.proof:not(.remark) > ul:last-child > li:last-child > p:last-child:has(> span.math.display:last-child),
div.proof:not(.remark) > ol:last-child > li:last-child > p:last-child:has(> span.math.display:last-child),
div.proof:not(.remark) > ul:last-child > li:last-child > ul:last-child > li:last-child > p:last-child:has(> span.math.display:last-child),
div.proof:not(.remark) > ul:last-child > li:last-child > ol:last-child > li:last-child > p:last-child:has(> span.math.display:last-child),
div.proof:not(.remark) > ol:last-child > li:last-child > ul:last-child > li:last-child > p:last-child:has(> span.math.display:last-child),
div.proof:not(.remark) > ol:last-child > li:last-child > ol:last-child > li:last-child > p:last-child:has(> span.math.display:last-child) {
  margin-bottom: 0;
}

div.proof:not(.remark) > p:last-child:has(> span.math.display:last-child)::after,
div.proof:not(.remark) > div:last-child > p:last-child:has(> span.math.display:last-child)::after,
div.proof:not(.remark) > ul:last-child > li:last-child > p:last-child:has(> span.math.display:last-child)::after,
div.proof:not(.remark) > ol:last-child > li:last-child > p:last-child:has(> span.math.display:last-child)::after,
div.proof:not(.remark) > ul:last-child > li:last-child > ul:last-child > li:last-child > p:last-child:has(> span.math.display:last-child)::after,
div.proof:not(.remark) > ul:last-child > li:last-child > ol:last-child > li:last-child > p:last-child:has(> span.math.display:last-child)::after,
div.proof:not(.remark) > ol:last-child > li:last-child > ul:last-child > li:last-child > p:last-child:has(> span.math.display:last-child)::after,
div.proof:not(.remark) > ol:last-child > li:last-child > ol:last-child > li:last-child > p:last-child:has(> span.math.display:last-child)::after {
  float: none;
  position: absolute;
  right: 0;
  bottom: 0.1rem;
  margin-left: 0;
}

div.theorem,
div.proof.remark {
  --statement-border: #cfd5ff;
  --statement-header: #f0f2ff;
  --statement-bg: #ffffff;
  margin: 1.15rem 0;
  padding: 0.85rem 1.05rem 0.9rem;
  border: 1px solid var(--statement-border);
  border-radius: 0.35rem;
  background: var(--statement-bg);
  overflow: hidden;
}

div.theorem.definition {
  --statement-border: #d6cdfc;
  --statement-header: #f3f0ff;
}

div.theorem.example {
  --statement-border: #c9decf;
  --statement-header: #eef7f0;
}

div.theorem.lemma,
div.theorem.proposition,
div.theorem.corollary {
  --statement-border: #c5d8ee;
  --statement-header: #edf5ff;
}

div.proof.remark {
  --statement-border: #d7d9dd;
  --statement-header: #f0f1f3;
}

div.theorem > p:first-child,
div.proof.remark > p:first-child {
  margin-top: 0;
}

div.theorem > p:first-child > span.theorem-title:first-child,
div.proof.remark > p:first-child > span.proof-title:first-child {
  display: block;
  margin: -0.85rem -1.05rem 0.8rem;
  padding: 0.38rem 1.05rem 0.42rem;
  border-bottom: 1px solid var(--statement-border);
  background: var(--statement-header);
  color: #17181a;
  line-height: 1.25;
}

div.proof.remark > p:first-child > span.proof-title:first-child em {
  font-style: normal;
  font-weight: 700;
}

div.theorem > :last-child,
div.theorem :is(ul, ol):last-child > li:last-child > p:last-child,
div.proof.remark :is(ul, ol):last-child > li:last-child > p:last-child {
  margin-bottom: 0;
}

/* Match Quarto's link underline position, including links inside <u>. */
u {
  text-underline-offset: 3px;
}

main img[src^="figures/"] {
  zoom: 1.3;
}

.math.display {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: .2rem 0;
}

:is(div.theorem, div.proof.remark) .math.display {
  font-style: normal;
}

#quarto-sidebar .sidebar-logo {
  max-height: 4rem;
  width: auto;
}

h4 {
  margin-top: 1.4rem;
}

/* LaTeX paragraph headings run into the first paragraph. */
section.level5 {
  margin-block: 1.4rem 1rem;
}

section.level5 > h5 {
  display: inline;
  position: relative;
  margin: 0;
  font-size: 1em;
  font-weight: 700;
  line-height: inherit;
}

/* Override the theme's normal link weight inside paragraph headings. */
section.level5 > h5 a {
  font-weight: inherit;
}

/* Keep Quarto's permalink out of the heading's text flow. */
section.level5 > h5 > .anchorjs-link {
  position: absolute;
  top: 0;
  right: calc(100% + .25em);
}

/* Add punctuation only when prose continues on the heading's line. */
section.level5 > h5:has(+ p)::after {
  content: ": ";
}

/* The converter retains a title's final period in its section ID. */
section.level5[id$="."] > h5:has(+ p)::after {
  content: " ";
}

section.level5 > h5 + p {
  display: inline;
}

@media (max-width: 575px) {
  :is(div.theorem, div.proof.remark) {
    padding: .7rem .75rem;
  }
  div.theorem > p:first-child > span.theorem-title:first-child,
  div.proof.remark > p:first-child > span.proof-title:first-child {
    margin: -.7rem -.75rem .7rem;
    padding: .4rem .75rem;
  }
}

.chapter-note {
  color: #555;
  font-size: .95rem;
  border-left: 3px solid #d7d9dd;
  padding-left: .8rem;
  margin-bottom: 1.5rem;
}

#refs .csl-entry {
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
}
