/*
 * Printing / PDF.
 * scripts/build_pdf.py renders pages with these rules, and they also apply
 * when a reader prints a page from the browser.
 */

@media print {

  @page {
    size: A4;
  }

  /* Interface elements that make no sense on paper */
  .toc-fab,
  .pdf-actions,
  .md-clipboard,
  .md-top,
  .md-source-file,
  .headerlink {
    display: none !important;
  }

  .md-main__inner > .md-content {
    max-width: none;
  }

  .md-typeset {
    font-size: 10.5pt;
  }

  /* Collapsible boxes (solutions, answers) are printed open */
  .md-typeset details > :not(summary) {
    display: block !important;
  }

  .md-typeset details > summary::after {
    display: none;
  }

  /* All tabs are printed one after the other, each with its title */
  .md-typeset .tabbed-labels {
    display: none !important;
  }

  .md-typeset .tabbed-content > .tabbed-block {
    display: block !important;
  }

  .md-typeset .tabbed-block[data-print-label]::before {
    content: attr(data-print-label);
    display: block;
    margin: .8em 0 .2em;
    font-weight: 700;
    font-size: .8em;
    color: var(--md-primary-fg-color);
  }

  /* Keep blocks together where possible */
  .md-typeset pre,
  .md-typeset .highlighttable,
  .md-typeset table,
  .md-typeset .admonition,
  .md-typeset .mermaid,
  .md-typeset img {
    break-inside: avoid;
  }

  .md-typeset h1,
  .md-typeset h2,
  .md-typeset h3,
  .md-typeset h4 {
    break-after: avoid;
  }

  /* Diagrams: smaller on paper */
  .md-typeset .mermaid svg {
    max-height: 85mm;
    width: auto !important;
  }

  /* Book PDF: each chapter starts on a new page */
  .pdf-chapter {
    break-before: page;
  }

  /* Cover page */
  .pdf-cover {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 250mm;
    text-align: center;
  }

  .pdf-cover img {
    width: 45mm;
    margin-bottom: 12mm;
  }

  .pdf-cover .pdf-cover__college {
    color: #ef6c00;
    font-size: 14pt;
    font-weight: 600;
    margin: 0;
  }

  .pdf-cover h1 {
    font-size: 34pt;
    font-weight: 700;
    color: #283593;
    margin: 4mm 0;
  }

  .pdf-cover .pdf-cover__course {
    font-size: 15pt;
    color: #555;
    margin: 0;
  }

  .pdf-cover .pdf-cover__author {
    margin-top: 25mm;
    font-size: 12pt;
    color: #555;
  }

  .pdf-toc {
    break-before: page;
  }

  .pdf-toc ol {
    font-size: 12pt;
    line-height: 2;
  }
}
