/* Math-first canonical reader.
   The textbook page should resemble a mathematical text: statements and
   derivations dominate; pedagogy and Lean remain secondary disclosures. */

.math-first-lessons {
  margin-top: 3.2rem;
  padding-top: 2.1rem;
  border-top: 1px solid var(--line-strong, var(--line));
}

.math-first-lessons > .section-heading {
  margin-bottom: 1.4rem;
}

.math-first-lessons > .section-heading h2 {
  max-width: none;
  font-size: 1.8rem;
  font-family: var(--body-font, Charter, Georgia, serif);
  font-weight: 650;
}

.math-first-theorem {
  margin: 0 0 4rem;
  padding: 0 0 2.5rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
}

.math-theorem-header {
  margin-bottom: 1.4rem;
}

.math-theorem-header .passage-label {
  margin-bottom: 0.45rem;
  color: var(--state-dark, var(--accent));
  font-family: var(--ui-font, Inter, sans-serif);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.math-theorem-header h2 {
  max-width: 32ch;
  margin: 0;
  font-family: var(--body-font, Charter, Georgia, serif);
  font-size: 1.8rem;
  font-weight: 650;
  line-height: 1.25;
}

.math-theorem-statement,
.math-theorem-proof {
  max-width: 76ch;
}

.math-theorem-statement > h3,
.math-theorem-proof > h3 {
  margin: 1.45rem 0 0.7rem;
  font-family: var(--ui-font, Inter, sans-serif);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.math-theorem-statement > p {
  margin-bottom: 0.7rem;
  color: var(--ink);
  font-size: 1rem;
}

.math-first-display {
  margin: 1.05rem 0 1.35rem;
  padding: 0.35rem 0;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.06rem;
}

.math-first-display mjx-container[display="true"] {
  margin: 0.45rem 0 !important;
  text-align: left !important;
}

.math-assumption-disclosure {
  max-width: 72ch;
  margin-top: 0.8rem;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.math-assumption-disclosure summary {
  padding: 0.55rem 0;
  color: var(--muted);
  font-family: var(--ui-font, Inter, sans-serif);
  font-size: 0.75rem;
  font-weight: 650;
}

.math-assumptions {
  margin: 0.15rem 0 0.5rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.math-assumptions li + li {
  margin-top: 0.15rem;
}

.math-proof {
  border-top: 1px solid var(--line);
}

.math-proof-step {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.8rem;
  padding: 1.2rem 0 1.05rem;
  border-bottom: 1px solid var(--line);
}

.math-proof-index {
  padding-top: 0.08rem;
  color: var(--quiet, var(--muted));
  font-family: var(--ui-font, Inter, sans-serif);
  font-size: 0.72rem;
  font-weight: 700;
}

.math-proof-step h4 {
  margin: 0 0 0.35rem;
  font-family: var(--ui-font, Inter, sans-serif);
  font-size: 0.88rem;
  font-weight: 700;
}

.math-proof-step p {
  max-width: 68ch;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.math-proof-step .math-first-display {
  margin: 0.35rem 0 0.35rem;
  font-size: 1rem;
}

.math-lean-correspondence {
  max-width: 76ch;
  margin-top: 1.25rem;
  border-radius: 2px;
}

.math-lean-correspondence summary {
  font-family: var(--ui-font, Inter, sans-serif);
  font-size: 0.8rem;
}

.math-lean-correspondence table {
  font-size: 0.76rem;
}

.math-lean-correspondence td:nth-child(1) {
  width: 2.2rem;
  color: var(--quiet, var(--muted));
}

.math-lean-correspondence td:nth-child(2) span {
  color: var(--muted);
}

.math-source-link {
  margin-top: 0.85rem;
  font-family: var(--ui-font, Inter, sans-serif);
  font-size: 0.76rem;
  font-weight: 650;
}

/* The canonical section is not the place for a long tutorial ladder. */
.undergrad-guide,
.story-ladder,
.guide-depth-note {
  display: none !important;
}

/* Keep infrastructure available, but visually subordinate to the theorem. */
.implicit-prerequisites > .note,
.implicit-prerequisites > .card-meta {
  display: none;
}

.implicit-prerequisites > .section-heading {
  margin-bottom: 1rem;
}

.implicit-prerequisites > .section-heading h2 {
  font-size: 1.55rem;
}

.implicit-prerequisite-card,
.source-card,
.theorem-mini {
  box-shadow: none !important;
}

.implicit-prerequisite-card .supplemental-passage > p {
  max-width: 70ch;
  color: var(--muted);
  font-size: 0.9rem;
}

/* A source statement should lead with its mathematical display. */
.textbook-reader .source-passage .formula {
  margin-top: 0.8rem;
}

.textbook-reader .source-passage > p {
  max-width: 72ch;
  line-height: 1.58;
}

@media (max-width: 700px) {
  .math-first-theorem {
    margin-bottom: 3rem;
  }

  .math-theorem-header h2 {
    font-size: 1.5rem;
  }

  .math-proof-step {
    grid-template-columns: 1.6rem minmax(0, 1fr);
    gap: 0.55rem;
  }

  .math-first-display {
    font-size: 0.95rem;
  }
}
