@media print {
  /* Setup global margins and A4 formatting */
  @page {
    size: A4;
    margin: 1in;
  }

  /* Define a named page for full-bleed covers to strip the 1-inch margins */
  @page full-bleed {
    margin: 0;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff;
  }

  /* Hide unnecessary UI elements */
  .side-bar,
  .site-header,
  .main-header,
  .aux-nav,
  .breadcrumb-nav,
  .site-footer,
  .search,
  .nav-list {
    display: none !important;
  }

  .main,
  .main-content-wrap,
  .main-content,
  .page-content,
  .content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }

  /* Front and Back Cover Full-Bleed Configurations */
  .pdf-cover,
  .pdf-cover-back {
    page: full-bleed;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    display: grid;
    place-items: center;
    text-align: center;
    color: #fff;
    background:
      linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
      url("../images/cover.png") center / cover no-repeat !important;
    break-after: page;
    page-break-after: always;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .pdf-cover__panel {
    width: 150mm;
    padding: 18mm 16mm;
    box-sizing: border-box;
    border-radius: 4mm;
    background: rgba(255, 255, 255, 0.14) !important;
    border: 0.4mm solid rgba(255, 255, 255, 0.28);
  }

  .pdf-cover__panel h1,
  .pdf-cover__panel p,
  .pdf-cover__panel a {
    color: #fff !important;
  }

  .pdf-subtitle {
    margin-top: 8mm;
    font-size: 20pt;
  }

  .pdf-author,
  .pdf-date {
    margin-top: 6mm;
    font-size: 13pt;
  }

  /* Copyright Page Formatting */
  .pdf-copyright {
    break-after: page;
    page-break-after: always;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 2in);
    text-align: center;
  }

  .pdf-copyright img {
    max-height: 3.5in;
    width: auto;
    max-width: 100%;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Prevent small icons from displaying as blocks */
  .pdf-copyright img.img-center,
  .pdf-copyright p > img:not([style*="max-width: 1em"]) {
    display: block;
    margin: 1.5rem auto;
  }

  /* Force CC icons to stay inline with text */
  .pdf-copyright img[style*="max-width: 1em"] {
    display: inline-block !important;
    vertical-align: text-bottom;
    margin: 0 0.15em !important;
  }

  /* Ensure blockquotes are left-justified within the centered container */
  .pdf-copyright blockquote {
    text-align: left;
    margin: 1.5rem auto;
    max-width: 90%;
  }

  /* Table of Contents Formatting */
  .pdf-toc {
    break-after: page;
    page-break-after: always;
    font-family: inherit;
  }

  .pdf-toc h1 {
    border-bottom: 2px solid #ccc;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .pdf-toc ul {
    list-style-type: none;
    padding-left: 1.5rem;
  }

  .pdf-toc > ul {
    padding-left: 0;
  }

  .pdf-toc li {
    margin-bottom: 0.6rem;
    line-height: 1.4;
  }

  /* Ensure PDF viewers recognize and style TOC links */
  .pdf-toc a {
    text-decoration: none;
    color: #0052cc;
    font-weight: 600;
  }

  .pdf-toc ul ul a {
    font-weight: normal;
    color: #333;
  }

  /* Chapter and Content Formatting */
  .pdf-chapter {
    break-before: page;
    page-break-before: always;
  }

  .pdf-subchapter {
    break-before: auto;
    page-break-before: auto;
    margin-top: 2rem;
  }

  h1,
  h2,
  h3 {
    break-after: avoid-page;
    page-break-after: avoid;
  }

  img,
  table,
  pre,
  blockquote {
    break-inside: avoid;
    page-break-inside: avoid;
    max-width: 100% !important;
  }
}