/* Center all images */
img, figure {
  display: block !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Center H1 headings */
h1 {
  text-align: center;
}

/* Apply minimal padding and margin to all callouts */
div.callout {
  padding: 0.25rem 0.25rem 0.25rem 1rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0 !important;
  margin-left: 0.25rem !important;
  border-radius: 0.25rem !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  font-size: 0.9rem;
  line-height: 1.4;
  border-left: none !important; /* Removes default Quarto heavy left border */
}

/* Keep the callout header visible so collapsible callouts can be toggled */
div.callout-header {
  display: flex !important;
  align-items: center !important;
}

div.callout-btn-toggle {
  display: inline-block !important;
}

/* Remove default padding from the body since the header is gone */
div.callout-body {
  padding: 0 !important;
}

/* 
  Custom colored boxes 
  Usage in Quarto: ::: {.example-callout} 
*/
:where(.theorem-callout, .proposition-callout, .definition-callout, .example-callout, .corollary-callout, .remark-callout, .lemma-callout) {
  padding: 0.75rem 1rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
  margin-left: 0.25rem !important;
  border-radius: 0.25rem !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  line-height: 1.4;
  border-left: none !important;
}

:where(.theorem-callout, .proposition-callout, .definition-callout, .example-callout, .corollary-callout, .remark-callout, .lemma-callout) :is(h1, h2, h3, h4, h5, h6) {
  font-size: 1.3em !important;
  line-height: 1.2 !important;
  margin-top: 0.6em !important;
  margin-bottom: 0.4em !important;
  border-bottom: none !important;
}

/* Ensure the callout only wraps its exact content and doesn't stretch vertically */
:where(.theorem-callout, .proposition-callout, .definition-callout, .example-callout, .corollary-callout, .remark-callout, .lemma-callout) {
  height: fit-content !important; 
}

/* Remove the default 1rem bottom margin from the final paragraph inside your custom callouts */
:where(.theorem-callout, .proposition-callout, .definition-callout, .example-callout, .corollary-callout, .remark-callout, .lemma-callout) p:last-child {
  margin-bottom: 0 !important;
}

/* Forcefully hide any empty paragraphs caused by accidental trailing blank lines in Markdown */
:where(.theorem-callout, .proposition-callout, .definition-callout, .example-callout, .corollary-callout, .remark-callout, .lemma-callout) p:empty {
  display: none !important;
}

/* Native collapsible boxes */
details.example-callout,
details.theorem-callout,
details.proposition-callout,
details.definition-callout,
details.corollary-callout,
details.remark-callout,
details.lemma-callout {
  padding: 0.75rem 1rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
  margin-left: 0.25rem !important;
  border-radius: 0.25rem !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  line-height: 1.4;
}

details.example-callout summary,
details.theorem-callout summary,
details.proposition-callout summary,
details.definition-callout summary,
details.corollary-callout summary,
details.remark-callout summary,
details.lemma-callout summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

details.example-callout summary::-webkit-details-marker,
details.theorem-callout summary::-webkit-details-marker,
details.proposition-callout summary::-webkit-details-marker,
details.definition-callout summary::-webkit-details-marker,
details.corollary-callout summary::-webkit-details-marker,
details.remark-callout summary::-webkit-details-marker,
details.lemma-callout summary::-webkit-details-marker {
  display: none;
}

details.example-callout[open] summary,
details.theorem-callout[open] summary,
details.proposition-callout[open] summary,
details.definition-callout[open] summary,
details.corollary-callout[open] summary,
details.remark-callout[open] summary,
details.lemma-callout[open] summary {
  margin-bottom: 0.75rem;
}

.theorem-callout {
  background-color: rgba(211, 47, 47, 0.65) !important;
  color: #000000;
}

.proposition-callout {
  background-color: #e6f0ff !important;
  color: #000000;
}

.definition-callout {
  background-color: #ffff7f !important;
  color: #000000;
}

.example-callout {
  background-color: rgba(153, 153, 153, 0.5) !important;
  color: #000000;
}

.corollary-callout {
  background-color: #ffcc80 !important;
  color: #000000;
}

.remark-callout {
  background-color: rgb(198, 242, 241) !important;
  color: #000000;
}

.lemma-callout {
  background-color: rgba(153, 153, 153, 0.5) !important;
  color: #000000;
}

/* Print/Export: avoid splitting callouts */
@media print {
  div.callout {
    page-break-inside: avoid;
    box-shadow: none !important;
  }
}

/* =========================================================
   FOLDABLE PROOF BOX (No color, collapsed by default)
   ========================================================= */

details.proof-callout {
  padding: 0.75rem 1rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
  margin-left: 0.25rem !important;
  border-radius: 0.25rem !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  line-height: 1.4;
  background-color: transparent !important;
  border: 1px solid #eaeaea; 
}

details.proof-callout summary {
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9em;
  list-style: none; 
  margin: 0;
}

details.proof-callout summary::-webkit-details-marker {
  display: none;
}

details.proof-callout summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 0.5em;
  font-size: 0.8em;
  transition: transform 0.2s ease-in-out;
}

details.proof-callout[open] summary::before {
  transform: rotate(90deg);
}

details.proof-callout[open] summary {
  margin-bottom: 0.75rem;
}

details.proof-callout p:first-of-type {
  margin-top: 0 !important;
}