/* Print Stylesheet - Oppslag er printbart stoff */

@media print {
  /* ========================================
     Reset print-unfriendly elements
     ======================================== */

  *, *::before, *::after {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* ========================================
     Hide non-essential elements
     ======================================== */

  nav,
  .skip-link,
  aside,
  footer,
  .sidebar-section,
  .main-nav {
    display: none !important;
  }

  /* ========================================
     Page setup
     ======================================== */

  @page {
    margin: 2cm;
    size: A4 portrait;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  /* ========================================
     Typography for print
     ======================================== */

  h1 {
    font-size: 24pt;
    margin-bottom: 0.5em;
    page-break-after: avoid;
  }

  h2 {
    font-size: 18pt;
    margin-top: 1em;
    margin-bottom: 0.5em;
    page-break-after: avoid;
  }

  h3 {
    font-size: 14pt;
    margin-top: 0.75em;
    margin-bottom: 0.5em;
    page-break-after: avoid;
  }

  p {
    orphans: 3;
    widows: 3;
    margin-bottom: 0.5em;
  }

  /* ========================================
     Links - Show URLs (nyttig for oppslagsverk!)
     ======================================== */

  a {
    text-decoration: underline;
    color: black;
  }

  /* Show URL after all links (external and internal) */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    font-weight: normal;
    color: #666;
  }

  /* Don't show URL for anchors */
  a[href^="#"]::after {
    content: "";
  }

  /* Don't show URL for skip link */
  .skip-link::after {
    content: "";
  }

  /* ========================================
     Lists
     ======================================== */

  ul, ol {
    page-break-inside: avoid;
  }

  /* ========================================
     Boxes and components
     ======================================== */

  .answer-box,
  .warning-box,
  .note-box {
    border: 2pt solid black;
    padding: 0.5em;
    margin: 1em 0;
    page-break-inside: avoid;
  }

  /* ========================================
     Sources section - Important for print!
     ======================================== */

  .sources {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 2pt solid black;
    page-break-inside: avoid;
  }

  .sources h2 {
    font-size: 12pt;
    font-weight: 600;
    margin-bottom: 0.5em;
  }

  /* ========================================
     Code blocks
     ======================================== */

  pre, code {
    border: 1pt solid #ccc;
    page-break-inside: avoid;
    font-family: "Courier New", Courier, monospace;
    font-size: 10pt;
  }

  pre {
    padding: 0.5em;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  /* ========================================
     Images
     ======================================== */

  img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  /* ========================================
     Updated date
     ======================================== */

  .updated {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1pt solid #ccc;
    font-size: 10pt;
    color: #666;
  }

  /* ========================================
     Layout
     ======================================== */

  .layout-wrapper {
    display: block;
    max-width: 100%;
    padding: 0;
  }

  main, article {
    max-width: 100%;
  }

  /* ========================================
     Tables (if used)
     ======================================== */

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

  th, td {
    border: 1pt solid black;
    padding: 0.25em 0.5em;
    text-align: left;
  }

  th {
    font-weight: 600;
    background: #f0f0f0 !important;
  }
}
