/* Quarto supplies the equation number; display it using LaTeX's \eqref style. */
a.quarto-xref[href*="#eq-"]::before {
  content: "(";
}

a.quarto-xref[href*="#eq-"]::after {
  content: ")";
}

/* Keep margin notes at their source position instead of pairing them with
   Quarto's preceding body block. */
.page-columns > .margin-anchor {
  height: 0;
  grid-column: body-content-start / body-content-end;
}

@media (min-width: 768px) {
  .page-columns > .margin-anchor + .column-margin.no-row-height {
    height: 0;
  }
}

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;
}

details.complements {
  margin: 1rem 0;
  border: 1px solid #d4d7db;
  border-left: 4px solid #8a8f98;
  border-radius: 0.25rem;
  background-color: #f1f3f5;
}

details.complements > summary {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
  color: #3f434a;
  background-color: #e1e5ea;
}

details.complements > summary::-webkit-details-marker {
  display: none;
}

details.complements > summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 0.55rem;
  border-top: 0.35em solid transparent;
  border-bottom: 0.35em solid transparent;
  border-left: 0.45em solid currentColor;
  transition: transform 0.15s ease;
}

details.complements[open] > summary::before {
  transform: rotate(90deg);
}

details.complements > *:not(summary) {
  margin-left: 0.85rem;
  margin-right: 0.85rem;
}

details.complements > summary + * {
  margin-top: 0.85rem;
}

details.complements > :last-child {
  margin-bottom: 0.85rem;
}
