/* SPDX-License-Identifier: AGPL-3.0-or-later
 *
 * Paper.
 *
 * Two things in this vault are meant to leave the screen. The recovery codes
 * are printed and put somewhere physical - they are the only way back in if
 * every passkey is on a device that is gone - and the Lectern is a reading
 * surface, which means sooner or later something gets printed from it.
 *
 * A dark app has a specific way of failing at this, and it is not the one
 * people guard against. Browsers already drop background images and colours
 * when printing, so nobody worries. But they do NOT drop foreground colours:
 * --foreground is #e8dcc8, and parchment on white paper is a blank sheet with
 * a faint smell of toner. The codes come out invisible, which is discovered
 * exactly once, at the moment they are needed.
 *
 * So this sheet does not tweak the theme for print. It replaces it.
 */

@media print {
  /* Ink and paper, stated as tokens so every component keeps working
     unchanged - the same reason the themes are tokens. Nothing below this
     block knows it is being printed. */
  :root {
    --background: #ffffff;
    --background-dark: #ffffff;
    --background-darker: #ffffff;
    --background-lighter: #ffffff;
    --foreground: #000000;
    --foreground-dark: #333333;
    --foreground-light: #000000;
    --foreground-bright: #000000;
    --accent: #000000;
    --muted: #555555;
    --selection: transparent;
    --danger: #000000;
    --warning: #333333;
    /* The kind colours mean nothing on paper - they are decoration on screen
       and the word beside them always says the same thing - and on a mono
       printer they arrive as six indistinguishable greys. As ink they still
       do their structural job: a rule down the side of a card, and a mark
       beside a word. */
    --kind-link: #000000;
    --kind-article: #000000;
    --kind-video: #000000;
    --kind-pdf: #000000;
    --kind-image: #000000;
    --kind-note: #000000;
    --edge: 1px solid #999999;
    --shadow: none;
    --shadow-lifted: none;
    --bevel: none;
    --bevel-lit: none;
    /* The room does not print. */
    --atmos-forge-strength: 0%;
    --atmos-sky-strength: 0%;
    --atmos-vignette: transparent;
    --ember-opacity: 0;
    --grain-opacity: 0;
    color-scheme: light;
  }

  /* Belt and braces on the atmosphere: `mix-blend-mode` is rendered
     inconsistently by print pipelines, and a soft-light noise layer over a
     page is at best invisible and at worst a grey wash across every sheet. */
  html::before, html::after, body::before, body::after { display: none !important; }

  body { padding-inline: 0; }

  /* Controls are not paper. A printed button is a grey rectangle with a verb
     in it that nobody can press. */
  button, input[type="submit"], input[type="button"], .forge,
  form.button_to, .drawbridge, .flash, .swatches { display: none !important; }

  /* The masthead's nav is navigation, and navigation is not paper. The kind
     beside it is not navigation - it is what the thing IS - so `nav`
     specifically, rather than `.count`, which both of them wear. */
  .masthead { position: static; }
  .masthead::after, .masthead::before { display: none; }
  /* nav.count, not nav: wall.css sets `.masthead .count { display: flex }`,
     which is (0,2,0) and outranks a (0,1,1) `.masthead nav` - so the
     navigation printed on every sheet while this rule sat there looking
     correct. Matching the class rather than reaching for !important, because
     the next person to read this should be able to see why it wins. */
  .masthead nav.count { display: none; }

  /* The wall prints as a list, not as four columns - a column layout on A4
     puts three characters on the last line of every card. */
  .wall { columns: auto; }
  .card { break-inside: avoid; border: var(--edge); box-shadow: none; }
  .card::before, .card::after { display: none !important; }
  /* Three grey bars standing in for text that has not arrived yet. On screen
     they are a promise being kept; on paper they are three grey bars. The
     line above them says the same thing in words, and words are what paper
     is for. */
  .skeleton { display: none; }

  /* Where a link went is the whole point of an archive, and on paper the
     href is the only thing carrying it. Only absolute ones: printing "(#)"
     after every in-page anchor is noise, and printing it after a rune chip
     would double the length of the runes row.
   *
     And not after a link whose visible text is already its address - on
     paper the Lectern's canonical URL printed twice, side by side. */
  .prose a[href^="http"]:not(.self-evident)::after {
    content: " <" attr(href) ">";
    font-family: var(--font-mono);
    font-size: var(--step--2);
    word-break: break-all;
  }

  /* The measure is set for a screen at arm's length. Paper is closer, the
     contrast is higher, and 11pt Literata on A4 wants a longer line than
     29.4em of a 19px face. */
  .prose {
    max-inline-size: none;
    font-size: 11pt;
    line-height: 1.5;
  }
  /* print.css reset .prose to 11pt and never touched the headings, so a
     Lectern title printed at --step-4 = 36px = 27pt over an 11pt body. A
     2.45 ratio is a poster; a page wants about 1.6. */
  /* The measure is lifted off the prose above, so it has to come off the
     nameplate too - or the hairline between them stops at 470px under a line
     of text that runs the full page.
   *
     `.treasure > .furniture`, matching the selector in wall.css that sets
     it, and not the bare `.furniture` this was written as first. That one is
     0,1,0 against 0,2,0 and lost on specificity no matter which sheet loads
     last, which prints as a rule that is exactly as wrong as no rule at
     all - and looks deliberate. */
  .treasure > .furniture { max-inline-size: none; }

  .prose h1 { font-size: 17pt; }
  .prose h2 { font-size: 13pt; }
  .prose h3 { font-size: 11.5pt; }
  .prose h1, .prose h2, .prose h3 { break-after: avoid; }
  .prose p { orphans: 3; widows: 3; }

  /* The one thing on this site that exists to be printed.
   *
   * Ten codes, each used once, read back under pressure months from now by
   * someone who has lost a phone. So: bigger than the screen sets it, on a
   * sheet that cannot be split across two pages, and with the tracking kept -
   * `l` against `1` and `0` against `O` is exactly the confusion this is
   * guarding against, and the slashed zero typography.css ships is the reason
   * the face was chosen. */
  .plate {
    break-inside: avoid;
    border: 1px solid #000000;
    padding: 1.5rem;
  }
  /* The one artefact of this system that will exist physically. A sheet of
     ten codes in a drawer, years from now, read under pressure by someone
     who has lost a phone, needs to say what it is without anyone having to
     remember. */
  .letterhead {
    display: flex; align-items: center; gap: .5rem;
    margin-block-end: 1rem;
    padding-block-end: .5rem;
    border-block-end: 1px solid #999999;
    font-family: var(--font-display);
    font-size: 12pt; font-weight: 600;
    letter-spacing: .02em;
  }
  /* The seal prints as ink. --accent is black on paper, so the ring and the
     ward come through as a line drawing rather than as a grey blob. */
  .letterhead .mark { --mark-size: 1.6em; }
  .letterhead .mark-field { opacity: 0; }
  .letterhead .mark-ring { opacity: 1; }
  .plate pre {
    font-size: 13pt;
    line-height: 2.1;
    letter-spacing: .08em;
  }

  /* A QR printed on paper is a QR that works. It is the one piece of colour
     the page keeps, because black on white is what a scanner wants and is
     what it already was. */
  .qr-code { border: 1px solid #999999; }
  .qr { break-inside: avoid; }
  .on-touch { display: none !important; }

  /* An aside is closed on screen and prints closed, taking its contents with
     it - which on the Settings page is the entire Shortcut recipe.
   *
     ::details-content is the only thing that actually opens one from CSS. The
     display/visibility tricks that circulate for this do not work: a closed
     <details> hides its contents through the slot mechanism rather than
     through a rule a page can override. Where the pseudo-element is not
     supported the aside prints closed, which is what it does today - a
     progressive improvement, never a regression. */
  details > summary { list-style: none; font-weight: 700; break-after: avoid; }
  details::details-content {
    content-visibility: visible !important;
    block-size: auto !important;
  }
}
