/* Cmd/Ctrl+P (or the browser's Print) on an open chart, in the song sheet or on the full chart page. chart_print.js copies
   the chart into .chart-print-root at the moment of printing and this file prints ONLY that: a page that looks like the
   Print or PDF page's document at its default options (the type rules are shared, in print_ink.css). The root is outside
   the sheet, so a fixed, full-height dialog can never limit the print to one page. Everything else is hidden here.
   The same root and these same rules print any other page that builds one (the shared chart page can call
   window.ChowderPrint.attach(chartElement, headElement) or carry the markup hooks: .performance-chart and
   .chart-print-head inside an .songview or .chart-print-scope element). */

.chart-print-root.chart-print-root { display: none; }

/* A named page, so these margins and the page number apply to the chart only and never to other prints. */
@page chartprint {
  size: auto;
  margin: 0.65in 0.75in 0.8in;
  @bottom-center {
    content: counter(page) " / " counter(pages);
    font: 9pt sans-serif;
    color: var(--print-hairline);
  }
}

/* The cloned heading is hidden on screen (it is only copied for print). */
.chart-print-head[hidden] { display: none; }

/* On screen every section group is invisible to layout, so the chart looks exactly as it did before they existed. */
.chart-section { display: contents; }

@media print {
  html:has(.chart-print-root.chart-print-root),
  html:has(.chart-print-root.chart-print-root) body {
    height: auto !important;
    overflow: visible !important;
    background: var(--print-paper) !important;
    color: var(--print-ink) !important;
  }

  body > :not(.chart-print-root.chart-print-root) { display: none !important; }

  .chart-print-root.chart-print-root {
    display: block !important;
    page: chartprint;
    box-sizing: border-box;
    width: 100%;
    font-size: 11.5pt;
    line-height: 1.25;
    --chart-reading-font: var(--font-ui);
    --chart-font-size: 1em;
  }

  .chart-print-root.chart-print-root * { box-shadow: none !important; text-shadow: none !important; animation: none !important; }

  /* The heading: display face, artist, key and capo. */
  .chart-print-root.chart-print-root .chart-print-head { display: block !important; margin: 0 0 1.4em; }
  .chart-print-root.chart-print-root .pd-title { font-size: 26pt; }
  .chart-print-root.chart-print-root .pd-meta { font-size: 11pt; margin-top: 0.4em; }

  /* The chart itself: plain paper, no screen frame, no scroll box. */
  .chart-print-root.chart-print-root .performance-chart,
  .chart-print-root.chart-print-root .chart-renderer,
  .chart-print-root.chart-print-root .chart-sheet,
  .chart-print-root.chart-print-root .chart-document {
    display: block;
    position: static;
    width: auto;
    height: auto;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: visible;
    background: transparent;
    color: inherit;
    font-size: inherit;
    columns: auto;
  }

  .chart-print-root.chart-print-root .chart-renderer__print-sheet,
  .chart-print-root.chart-print-root .chart-tab-visibility,
  /* The add-note wrapper holds the line itself; only its button and form are hidden. */
  .chart-print-root.chart-print-root .chart-note-add__trigger,
  .chart-print-root.chart-print-root .chart-note-add__form,
  .chart-print-root.chart-print-root .key-banner,
  .chart-print-root.chart-print-root .transpose-banner,
  .chart-print-root.chart-print-root .fg-popover,
  .chart-print-root.chart-print-root .fg-tools { display: none !important; }

  .chart-print-root.chart-print-root .chart-line--section {
    margin: 0 0 0.65em;
    padding: 0;
    border: 0;
    scroll-margin: 0;
  }

  /* Page breaks: a section stays together when it fits on a page, and a label never ends a page. */
  .chart-print-root.chart-print-root .chart-section { display: block; margin: 0 0 1.15em; break-inside: avoid-page; }
  .chart-print-root.chart-print-root .chart-line--section { break-after: avoid-page; }
  .chart-print-root.chart-print-root .chart-line--units,
  .chart-print-root.chart-print-root .chart-tab-block,
  .chart-print-root.chart-print-root .chart-note { break-inside: avoid-page; }
  .chart-print-root.chart-print-root .chart-line--blank { display: none; }

  .chart-print-root.chart-print-root .chart-line--tab { overflow: hidden; }

  /* The screen page's own rules for a line (spacing, size, wrap indent) must not leak into the print. */
  /* The on-screen Aa size (set on the chart wrappers) never reaches paper: 11.5pt everywhere in the print. */
  .chart-print-root.chart-print-root .performance-chart,
  .chart-print-root.chart-print-root .chart-renderer,
  .chart-print-root.chart-print-root .chart-sheet,
  .chart-print-root.chart-print-root .chart-document {
    --chart-font-size: 11.5pt !important;
    font-size: 11.5pt !important;
  }

  .chart-print-root.chart-print-root .chart-sheet--units .chart-line--units {
    margin: 0 0 0.5em;
    font-size: inherit;
    line-height: 1.25;
    padding-left: 1.5em;
    text-indent: -1.5em;
  }

  /* Footers the app already prints (the share address, a CCLI line). */
  .chart-print-root.chart-print-root .print-share-footer { margin-top: 1.2em; }
  .chart-print-root.chart-print-root .chart-print-footer { display: block; margin-top: 1em; font-size: 8.5pt; color: var(--print-hairline); }
}
