/* =============================================================
   Theorem, Definition, Proof, and Box Environment Styles
   ============================================================= */

/* --- Base Theorem Environment --- */
.theorem-env {
  margin: 1.75rem 0;
  padding: 1rem 1.25rem;
  border-radius: 0 6px 6px 0;
  position: relative;
}

.theorem-label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.92rem;
  font-variant: small-caps;
  display: inline;
  margin-right: 0.25rem;
}

.theorem-name {
  font-weight: 400;
  font-style: italic;
  display: inline;
}

.theorem-body {
  font-style: italic;
}

/* --- Theorem / Proposition / Lemma / Corollary --- */
.theorem-env.theorem,
.theorem-env.proposition,
.theorem-env.lemma,
.theorem-env.corollary {
  border-left: 4px solid var(--main-color);
  background: #fdf8f6;
}

.theorem-env.theorem > p > .theorem-label,
.theorem-env.proposition > p > .theorem-label,
.theorem-env.lemma > p > .theorem-label,
.theorem-env.corollary > p > .theorem-label {
  color: var(--main-color);
}

.theorem-env.theorem > p > .theorem-name,
.theorem-env.proposition > p > .theorem-name,
.theorem-env.lemma > p > .theorem-name,
.theorem-env.corollary > p > .theorem-name {
  color: var(--text);
}

/* --- Definition --- */
.theorem-env.definition {
  border-left: 4px solid var(--note-blue);
  background: #f0f7ff;
}

.theorem-env.definition > p > .theorem-label {
  color: var(--note-blue);
}

.theorem-env.definition > p > .theorem-name {
  color: var(--text);
}

.theorem-env.definition .theorem-body {
  font-style: normal;
}

/* --- Assumption --- */
.theorem-env.assumption {
  border-left: 4px solid #b8860b;
  background: #fdf8ef;
}

.theorem-env.assumption > p > .theorem-label {
  color: #8b6914;
}

/* --- Remark --- */
.theorem-env.remark {
  border-left: 3px solid var(--border);
  background: transparent;
  padding: 0.75rem 1.25rem;
}

.theorem-env.remark .theorem-label {
  color: var(--text-muted);
}

.theorem-env.remark .theorem-body {
  font-style: italic;
  color: var(--text-muted);
}

/* --- Open Question --- */
.theorem-env.openquestion {
  border-left: 4px solid var(--todo-red);
  background: var(--openquestion-bg);
}

.theorem-env.openquestion .theorem-label {
  color: var(--todo-red);
}

.theorem-env.openquestion .theorem-body {
  font-style: normal;
}

/* --- Proof --- */
.proof-env {
  margin: 1.5rem 0;
  padding: 0;
}

.proof-env .proof-heading {
  font-style: italic;
  font-weight: 400;
  margin-bottom: 0.5rem;
}

.proof-env .proof-heading strong {
  font-style: italic;
}

.proof-env .qed {
  float: right;
  margin-top: -0.5rem;
}

/* --- Linked Theorem / Proof Links --- */
.proof-link,
.return-link {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 500;
  color: var(--main-color);
  background: rgba(139, 37, 0, 0.06);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  text-decoration: none;
  white-space: nowrap;
  display: inline-block;
  margin-left: 0.35rem;
}

.proof-link:hover,
.return-link:hover {
  background: rgba(139, 37, 0, 0.12);
  text-decoration: none;
}

/* --- Linked Proof Block --- */
.linked-proof {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fefefe;
}

.linked-proof .restatement {
  font-style: italic;
  color: var(--text-muted);
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  margin: 0.75rem 0;
}

.linked-proof .proof-heading {
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* --- Collapsible Inline Proof --- */
.collapsible-proof {
  margin: 0.5rem 0 -0.5rem;
  border: none;
  border-top: 1px solid var(--border);
  padding: 0;
}

.collapsible-proof > summary.proof-toggle {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--main-color);
  cursor: pointer;
  padding: 0.35rem 0;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.collapsible-proof > summary.proof-toggle::-webkit-details-marker {
  display: none;
}

.collapsible-proof > summary.proof-toggle::before {
  content: "▶";
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.collapsible-proof[open] > summary.proof-toggle::before {
  transform: rotate(90deg);
}

.collapsible-proof > summary.proof-toggle:hover {
  color: var(--main-color);
  opacity: 0.8;
}

.collapsible-proof > p,
.collapsible-proof > div {
  padding: 0.5rem 0 0.25rem 1rem;
  border-left: 3px solid var(--border);
  margin: 0.25rem 0;
  font-size: 0.95rem;
}

/* --- HighlightBox (tcolorbox blue) --- */
.highlight-box {
  margin: 2rem auto;
  max-width: 680px;
  padding: 1.25rem 1.5rem;
  background: var(--highlight-bg);
  border: 1px solid var(--highlight-border);
  border-radius: 8px;
}

/* --- OpenQuestionBox (tcolorbox red with title badge) --- */
.open-question-box {
  margin: 2rem auto;
  max-width: 680px;
  padding: 1.25rem 1.5rem;
  padding-top: 1.75rem;
  background: var(--openquestion-bg);
  border: 1px solid var(--openquestion-border);
  border-radius: 8px;
  position: relative;
}

.open-question-box .box-title {
  position: absolute;
  top: -0.85rem;
  left: 1rem;
  background: var(--openquestion-border);
  color: white;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.75rem;
  border-radius: 4px;
}

/* --- HighlightBoxFit (inline, green) --- */
.highlight-box-fit {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--highlight-bg);
  border: 1px solid rgba(30, 58, 95, 0.3);
  border-radius: 6px;
  margin: 0.5rem 0;
}

.open-question-box-fit {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #f0fdf4;
  border: 1px solid rgba(26, 127, 55, 0.3);
  border-radius: 6px;
  margin: 0.5rem 0;
  position: relative;
}

/* --- Admonition / Block Environments --- */
.admonition {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--border);
  background: white;
  border-radius: 0 4px 4px 0;
}

.admonition-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-style: italic;
  margin-bottom: 0.5rem;
}

.admonition.note {
  border-left-color: var(--note-blue);
}

.admonition.note .admonition-title {
  color: var(--note-blue);
}

.admonition.tip {
  border-left-color: var(--tip-green);
}

.admonition.tip .admonition-title {
  color: var(--tip-green);
}

.admonition.warning {
  border-left-color: var(--warning-brown);
}

.admonition.warning .admonition-title {
  color: var(--warning-brown);
}

.admonition.todo {
  border-left-color: var(--todo-red);
}

.admonition.todo .admonition-title {
  color: var(--todo-red);
}
