@page {
  size: A4;
  margin: 12mm;
}

@media print {
  html, body {
    height: auto;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color: #111;
    background: #fff !important;
  }

  /* скрыть то, что не нужно на бумаге */
  .site-header, .site-footer, .global-nav, .sticky, .floating-actions,
  .back-to-top, .cta-bar, .btn.print-hidden { display: none !important; }

  /* основной контейнер на ширину листа, убрать тени и фоны */
  main, .page-section, .content, .container {
    max-width: 100% !important;
    box-shadow: none !important;
    background-image: none !important;
  }

  /* запрет разрыва важных блоков */
  .card, .unit, .unit-card, .lesson, .lesson-card,
  .callout, .toc, .table-wrap, table, figure, img, blockquote {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* логичные разрывы перед крупными разделами если есть такие id */
  section#overview   { break-before: page; }
  section#units      { break-before: page; }
  section#alignment  { break-before: page; }
  section#skills     { break-before: page; }
  section#toolkit    { break-before: page; }
  section#materials  { break-before: page; }
  section#activities { break-before: page; }

  /* не оставлять заголовки одиночными на нижней строке */
  h1, h2, h3 {
    break-after: avoid;
    page-break-after: avoid;
    margin-bottom: 8px;
  }

  /* таблицы - повтор шапки на каждой странице */
  table { width: 100%; border-collapse: collapse; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr, th, td { break-inside: avoid; page-break-inside: avoid; }

  /* изображения - вписываемся в поле */
  img { max-width: 100% !important; height: auto !important; }

  /* по желанию - выводить URL внешних ссылок */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 10px;
    color: #666;
  }

  /* hide bottom breadcrumbs in print for cleaner output */
  .breadcrumb--bottom { display: none !important; }

  /* нумерация страниц - поддерживается не во всех браузерах */
  @page {
    @bottom-center {
      content: counter(page) " / " counter(pages);
      font-size: 10px;
      color: #777;
    }
  }
}

/* служебный класс для ручной защиты от разрыва */
.no-break { break-inside: avoid; page-break-inside: avoid; }
