body {
  font-family: serif;
  hyphens: auto;
  hyphenate-limit-chars: 8 4 4;
}

h2 {
  text-align: center;
  margin-top: 8em;
  margin-bottom: 4em;
  font-weight: 300;
  display: block;
  /* Pad box to position the "underline" that's rendered using the border */
  padding: 1em 2em;
  border-bottom: 1px solid;
  font-size: 2em;
  page-break-before: always;
}

p {
  line-height: 1.4em;
  font-size: 1em;
  text-align: justify;
  text-justify: inter-word;
  text-indent: 1.5em;
  margin: 0;
}

h1+p,
h2+p,
h3+p,
h4+p,
h5+p,
h6+p {
  text-indent: 0;
}

p:first-child {
  text-indent: 0;
}

.no-indent {
  text-indent: 0;
}

table {
  border-collapse: collapse;
  margin: 1em auto;
}

tr {
  border-bottom: 0.05em solid black;
}

th, td {
  padding-left: 1em;
  padding-right: 1em;
}

th {
  text-align: left;
}

caption {
  margin-top: 1em;
  caption-side: bottom;
}

dt {
  margin-top: 1em;
  font-weight: bold;
}

dd {
  margin-left: 2.4em;
}

/* using <footnote></footnote> does not produce correct layout for footnote-call */
/* .footnote {
  float: footnote;
}

.footnote::footnote-call {
  content: counter(footnote, decimal) " ";
  vertical-align: super;
  line-height: 0;
  font-size: 0.2em;
}

.footnote::footnote-marker {
  content: counter(footnote, decimal) " ";
  display: inline-block;
  width: 2em;
  padding-right: 1em;
  text-align: right;
} */

code {
  background-color: aliceblue;
  /* line-height: 90%; */
  font-size: 90%;
  font-weight: normal; /* for when used in different contexts (e.g. inside term) */
  font-style: normal;
}

pre:has(> code:first-child) {
  background-color: aliceblue;
} 

/* for math: we are abusing \text{...} to mean \texttt or some \code macro */
mtext {
  background-color: aliceblue;
  font-family: monospace;
  font-size: 90%
}

/* semantic */
type {
  /* inherits from code */
  line-height: 90%;
  font-size: 90%;
  white-space: pre;
  font-family: monospace;
  color: #945200;
  background-color: aliceblue;
  /* mocha */
}

term {
  font-style: italic;
  /* color: purple; */
  /* color: #851780; */
  color: green;
}

definition {
  line-height: 1.4em;
  font-style: italic;
  /* font-size: 1em; */
  text-align: justify;
  text-justify: inter-word;
  text-indent: 1.5em;
  margin: 0;
}

definition>term {
  font-style: normal;
  font-weight: bold;
}

/* TODO: should be more latex-y: centered if shorter than width, else justified */
theorem {
  line-height: 1.4em;
  text-align: justify;
  text-justify: inter-word;
  margin: 0;
}

figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80%; /* default width, override locally */
  margin: 1em auto;
}

img {
  max-width: 100%;
  height: auto;
}

.display { /* for latex, theorem, definition, ... */ /* not: figure */
  display: block;
  margin: 1em 0;
  text-indent: 0;
}

sup { /* avoid increasing line height */
  vertical-align: baseline;
  position: relative;
  top: -0.4em;
  line-height: 0;
}

section.exercises {

  background-color:rgb(249, 245, 240);

  ol > li:not(:last-child) {
    margin-bottom: 2em;
  }
}

/* ... */
@media screen {

  body {
    font-size: 1.4em;
    min-width: 16em;
    max-width: 40em;
    padding: 0 1em;
    margin: 0 auto;
  }

  footnote a {
    text-decoration: none;
  }
}

@page {
  size: A4;
  margin: 15%;
}

@media print {
  h2 {
    page-break-before: always;
  }

  table {
  page-break-inside: avoid;
  }
}
