/* GLOBAL MATHJAX + MATHML RESPONSIVE FORMULAS.
   Does not change html/body overflow, code, table, or site navigation.
   Style overrides are optional via --zwcc-math-bg and --zwcc-math-border.
   Supports the portable .zwcc-formula-scroll class and legacy
   .tc-formula-scroll wrappers for backward compatibility.
*/
.entry-content,
.et_pb_post_content,
.et_pb_text_inner,
.et_pb_code_inner,
.wp-site-blocks,
:where(.zwcc-formula-scroll, .tc-formula-scroll) { min-width: 0; box-sizing: border-box; }

.wp-block-math,
:where(.zwcc-formula-scroll, .tc-formula-scroll),
mjx-container[display="true"] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  box-sizing: border-box;
  margin: 24px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--zwcc-math-bg, #f3f7fa);
  border: 1px solid var(--zwcc-math-border, #d9e4eb);
}

/* Display content can be wider than the scrolling formula container. */
.wp-block-math > math,
math[display="block"] {
  width: max-content;
  max-width: none;
}
mjx-container[display="true"] mjx-math,
mjx-container[display="true"] svg {
  max-width: none;
}

/* Inline math must stay inline and should not create page-level overflow. */
mjx-container:not([display="true"]) {
  max-width: 100%;
}

@media (max-width: 767px) {
  .wp-block-math,
  :where(.zwcc-formula-scroll, .tc-formula-scroll),
  mjx-container[display="true"] {
    margin: 22px 0;
    padding: 13px 14px;
  }
  .wp-block-math > math,
  math[display="block"],
  mjx-container[display="true"] mjx-math {
    font-size: 90%;
  }
}