/**
 * Digest Theme - Print Stylesheet
 * Optimized for clean article printing
 */

@media print {
  /* Reset and base */
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Page settings */
  @page {
    margin: 2cm;
    size: A4;
  }

  @page :first {
    margin-top: 3cm;
  }

  /* Typography - use print-friendly fonts */
  body {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 12pt;
    line-height: 1.5;
  }

  h1, h2, h3, h4, h5, h6 {
    font-family: Georgia, 'Times New Roman', serif;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  h1 {
    font-size: 24pt;
    margin-bottom: 12pt;
  }

  h2 {
    font-size: 18pt;
    margin-top: 24pt;
    margin-bottom: 12pt;
  }

  h3 {
    font-size: 14pt;
    margin-top: 18pt;
    margin-bottom: 8pt;
  }

  p {
    orphans: 3;
    widows: 3;
  }

  /* Hide non-essential elements */
  .dg-header,
  .dg-footer,
  .dg-sidebar,
  .dg-newsletter,
  .dg-social-share,
  .dg-related-posts,
  .dg-comments,
  .dg-announcement,
  .dg-nav,
  .dg-mobile-nav,
  .dg-search-form,
  .dg-dark-mode-toggle,
  .dg-skip-link,
  .dg-breadcrumbs,
  .dg-tag-pill,
  .dg-button,
  nav,
  aside,
  form,
  button,
  iframe,
  video,
  audio,
  .no-print {
    display: none !important;
  }

  /* Show main content full width */
  .dg-main,
  .dg-container,
  .dg-post,
  .dg-article,
  .dg-prose {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
  }

  /* Article header */
  .dg-post__header,
  .dg-article__header {
    text-align: left;
    margin-bottom: 24pt;
    padding-bottom: 12pt;
    border-bottom: 1pt solid #ccc;
  }

  .dg-post__title,
  .dg-article__title {
    font-size: 24pt;
    line-height: 1.2;
    margin-bottom: 8pt;
  }

  /* Author byline */
  .dg-author-byline {
    font-size: 10pt;
    color: #666 !important;
    margin-bottom: 8pt;
  }

  .dg-author-byline__avatar {
    display: none;
  }

  /* Images */
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
    page-break-after: avoid;
  }

  figure {
    margin: 12pt 0;
    page-break-inside: avoid;
  }

  figcaption {
    font-size: 9pt;
    font-style: italic;
    color: #666 !important;
    margin-top: 6pt;
  }

  /* Links - show URL */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666 !important;
    word-wrap: break-word;
  }

  /* Don't show URL for internal links and anchors */
  a[href^="#"]::after,
  a[href^="javascript:"]::after,
  .dg-prose a[href]::after {
    content: "";
  }

  /* Show URL for external links in prose */
  .dg-prose a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666 !important;
  }

  /* Blockquotes */
  blockquote {
    margin: 12pt 0;
    padding-left: 12pt;
    border-left: 3pt solid #ccc;
    font-style: italic;
    page-break-inside: avoid;
  }

  /* Code blocks */
  pre,
  code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 10pt;
  }

  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 8pt;
    border: 1pt solid #ccc;
    page-break-inside: avoid;
  }

  code {
    background: #f5f5f5 !important;
    padding: 1pt 3pt;
  }

  /* Tables */
  table {
    border-collapse: collapse;
    width: 100%;
    page-break-inside: avoid;
  }

  th,
  td {
    border: 1pt solid #ccc;
    padding: 6pt 8pt;
    text-align: left;
  }

  th {
    font-weight: bold;
  }

  thead {
    display: table-header-group;
  }

  tr {
    page-break-inside: avoid;
  }

  /* Lists */
  ul,
  ol {
    margin: 12pt 0;
    padding-left: 24pt;
  }

  li {
    margin-bottom: 4pt;
  }

  /* Author box at end of article */
  .dg-author-box {
    margin-top: 24pt;
    padding-top: 12pt;
    border-top: 1pt solid #ccc;
    page-break-inside: avoid;
  }

  .dg-author-box__avatar {
    width: 48pt;
    height: 48pt;
    float: left;
    margin-right: 12pt;
  }

  .dg-author-box__name {
    font-size: 12pt;
    font-weight: bold;
  }

  .dg-author-box__bio {
    font-size: 10pt;
    color: #666 !important;
  }

  /* Print header/footer */
  .print-header {
    display: block !important;
    text-align: center;
    font-size: 10pt;
    margin-bottom: 24pt;
  }

  .print-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 8pt;
    color: #999 !important;
    padding: 6pt;
    border-top: 1pt solid #ccc;
  }

  /* Page breaks */
  .page-break-before {
    page-break-before: always;
  }

  .page-break-after {
    page-break-after: always;
  }

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

  /* Pull quotes */
  .dg-pull-quote {
    font-size: 14pt;
    font-style: italic;
    text-align: center;
    margin: 18pt 36pt;
    padding: 12pt 0;
    border-top: 1pt solid #ccc;
    border-bottom: 1pt solid #ccc;
    page-break-inside: avoid;
  }

  /* Drop caps */
  .dg-drop-cap::first-letter {
    float: left;
    font-size: 48pt;
    line-height: 1;
    padding-right: 8pt;
    font-weight: bold;
  }

  /* URL for print */
  .print-url {
    display: block !important;
    font-size: 9pt;
    color: #666 !important;
    margin-top: 12pt;
  }

  .print-url::before {
    content: "Source: ";
  }

  /* QR code for article URL (if included) */
  .print-qr {
    display: block !important;
    width: 72pt;
    height: 72pt;
    margin: 12pt auto;
  }
}
