/* EYMO #1 maths typesetting. build.py turns the Unicode maths in the notes into native MathML islands;
   this file only styles them. Works offline (no fonts or scripts fetched). Chrome/Android 109+, Safari. */

math {
  font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", "Noto Sans Math", math, serif;
  font-size: 1.1em;            /* math fonts run small next to Inter */
  line-height: normal;
  math-style: normal;          /* display-style fractions: numerator and denominator at full size */
}

/* integrals: a tall sign (CSS-sized so it does not depend on the device having a math font), limits at 80% */
math mo.int {
  font-size: 1.55em;
  padding-inline-end: .04em;
}
math msubsup.lim > :not(:first-child),
math msub > mo.int ~ *,
math msup > mo.int ~ * {
  font-size: .8em;
}
math msubsup.lim + msubsup.lim { margin-inline-start: .06em; }

/* fractions: a little air around stacked fractions in running text; nested fractions shrink by themselves */
math.has-frac { padding: .1em 0; }
math mfrac { padding-inline: .08em; }

/* lines with stacked maths need more room than the paragraph's fixed line-height */
:is(p, li, td, th, dd, div, span):has(> math.has-int, > math.has-frac) { line-height: 1.75; }

/* long expressions: their own line, left-aligned, scroll sideways inside their own box on phones */
math[display="block"] {
  display: block math;
  text-align: left;
  margin: .45em 0;
  padding: .2em 0 .3em;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
math[display="block"]::-webkit-scrollbar { height: 4px; }
math[display="block"]::-webkit-scrollbar-thumb { background: currentColor; opacity: .3; border-radius: 2px; }

/* question headings are already large: maths at the heading size, not above it */
h1 math, h2 math, .cq math, .lk-q math { font-size: 1em; }
.mnw { white-space: nowrap; }

/* answer boxes and worked steps: display size */
.abox math, .s-box math, .s-work math { font-size: 1.16em; }
.s-work :is(p, li):has(> math) { line-height: 1.9; }

/* chemistry keeps chemistry style: upright letters */
math.chem { font-size: 1.12em; }
math.chem mi { font-style: normal; text-transform: none; }
math.chem mfrac > * { font-size: 1em; }

/* inside reveal blurs, headings and quick-fire buttons, keep the island inline with the text colour */
math, math * { color: inherit; }

@media print {
  math[display="block"] { overflow: visible; }
}
