/*
 * Shared print stylesheet for every Tsunami Unleashed site (PUBLISH-SPEC.md,
 * "Printing ordinary pages"). Kept in tu-distro and copied into each site's
 * build output; linked with media="print". Fits Letter and A4 alike.
 */

@page {
  margin: 0.6in;
}

html,
body {
  background: #fff !important;
  color: #000 !important;
}

/* The system sans stack the sites use on screen; no web fonts. */
body {
  font:
    11pt/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
}

main,
article,
.piece {
  max-width: 7.3in;
  margin: 0 auto;
}

/*
 * Navigation, toolbars and anything interactive have no use on paper: the
 * share row, galleries, download links, the service-worker banner.
 */
nav,
header nav,
aside.piece-derivatives,
.piece-infographic,
.share-row,
.gallery,
a[download],
.sw-banner,
.pagination,
.no-print,
button,
input,
video,
audio,
iframe {
  display: none !important;
}

/*
 * The page footer stays off paper, except what must travel with every
 * copy: a copyright notice the page's content requires (NIV quotations,
 * .notice-copyright) and anything the theme marks .print-keep (the site's
 * licence and where to find it). A footer inside a quote or figure is its
 * citation, and prints.
 */
footer:not(blockquote footer, figure footer):not(
    :has(.notice-copyright, .print-keep)
  ),
footer:not(blockquote footer, figure footer)
  :not(.notice-copyright, .print-keep):not(
    :has(.notice-copyright, .print-keep)
  ):not(.print-keep *) {
  display: none !important;
}

footer:not(blockquote footer, figure footer):has(
    .notice-copyright,
    .print-keep
  ),
footer:not(blockquote footer, figure footer)
  :has(.notice-copyright, .print-keep) {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

footer:not(blockquote footer, figure footer) {
  margin-top: 1.5em !important;
}

footer .notice-copyright,
footer .print-keep {
  display: block !important;
  max-width: none !important;
  margin: 0 0 0.6em !important;
  font-size: 8.5pt;
  font-style: normal;
  text-align: left;
}

footer .print-keep a {
  text-decoration: none;
}

/* The link text is the address already; don't print it twice. */
footer .print-keep a::after {
  content: none !important;
}

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

h1 + p,
h2 + p,
h3 + p {
  break-before: avoid;
}

p,
li,
blockquote {
  orphans: 3;
  widows: 3;
}

img,
svg,
figure {
  max-width: 100% !important;
  height: auto !important;
  break-inside: avoid;
}

a {
  color: #000;
  text-decoration: underline;
}

/* Links print as text: show where an outbound link goes. */
.piece-body a[href^='http']::after {
  content: ' (' attr(href) ')';
  font-size: 0.85em;
  word-break: break-all;
}

/* Scripture references print as the plain reference the writer typed. */
a.scripture-ref {
  color: inherit;
  text-decoration: none;
}

.piece-body a.scripture-ref::after,
a.scripture-ref::after {
  content: none !important;
}

/* Popups and other enhancements stay off the page. */
[role='tooltip'],
.popup,
.scripture-popup {
  display: none !important;
}
