/*
 * The printed sheet of a published Contenido: «Descargar PDF» (#860,
 * decision #821) is `window.print()` plus this file, nothing generated on
 * the server.
 *
 * Loaded by `ContentArticle` with `<link media="print">`, outside the CSS
 * bundle: the browser fetches it without blocking the first render and the
 * guide routes' screen CSS (budgeted in perf-budgets.json) does not grow.
 * It cannot see CSS Module class names, so it works on markup only: the
 * article carries `data-content-print`, the parts that must not print carry
 * `data-print="hide"`, and the page link carries `data-print-only` (hidden on
 * screen). Every rule is scoped to a page that holds such an article, so
 * the file is inert anywhere else.
 */

@media print {
  /*
   * Only the article prints: every element that contains it hides its
   * other children (the app shell's sidebar, header, banner and tab bar,
   * dialogs and toasts at the end of <body>) and stops being a fixed-height
   * scroll box, so the article flows over as many pages as it needs.
   *
   * Except a `hidden` one: while a streamed page swaps in, React can briefly
   * keep a copy of the article in a `<div hidden id="S:…">` at the end of
   * <body>. It stays hidden, or the sheet would print the body twice.
   */
  :where(:has([data-content-print]):not([hidden])) {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: var(--bg-surface) !important;
  }

  :where(:has([data-content-print])) > :not([data-content-print], :has([data-content-print])) {
    display: none !important;
  }

  [hidden]:has([data-content-print]) {
    display: none !important;
  }

  [data-content-print] {
    max-width: none;
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    print-color-adjust: exact;
  }

  /* Buttons and islands: Compartir, Descargar PDF, «Ver el mapa», a video's play button */
  [data-content-print] [data-print='hide'],
  [data-content-print] button {
    display: none !important;
  }

  /* The page link, at the end of the sheet */
  [data-content-print] [data-print-only] {
    display: block !important;
    margin: var(--space-8) 0 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    overflow-wrap: anywhere;
  }

  /*
   * A comparison table (#842) scrolls sideways on screen; paper cannot, so
   * its box stops scrolling and the cells wrap to fit the sheet's width. A
   * table longer than a page repeats its header row on the next one.
   */
  [data-content-print] :has(> table) {
    overflow: visible !important;
  }

  [data-content-print] table {
    table-layout: fixed;
    overflow-wrap: anywhere;
  }

  [data-content-print] thead {
    display: table-header-group;
  }

  /* A place, a table row, a day's leg or a gallery photo is not cut across two pages */
  [data-content-print] :is(section, figure, li, tr, img) {
    break-inside: avoid;
  }

  [data-content-print] :is(h1, h2, h3) {
    break-after: avoid;
  }

  [data-content-print] img {
    max-width: 100%;
  }

  /*
   * The guides redesign on paper: no theme fills or bands (ink on white
   * saves the reader's printer), every block one column, and every FAQ
   * answer printed, open or not (`::details-content`; a browser without it
   * prints the questions that were open).
   */
  [data-content-print] :where(*) {
    background: none !important;
    box-shadow: none !important;
    color: var(--text-primary) !important;
  }

  [data-content-print] :where(header, div, section, figure) {
    display: block !important;
    max-width: none !important;
    padding: 0 !important;
    overflow: visible !important;
    contain: none !important;
  }

  [data-content-print] :where(header, section, figure, div > div) + * {
    margin-top: var(--space-4);
  }

  [data-content-print] details::details-content {
    content-visibility: visible;
    display: block;
  }

  [data-content-print] summary {
    list-style: none;
  }

  [data-content-print] summary [aria-hidden='true'] {
    display: none;
  }
}
