/* ============================================================================
   The board, on paper. Loaded as media="print", so a screen visitor never
   applies it and the wall is untouched.

   THE RULE: paper is just another panel. tv.css says the board "is NOT a
   responsive layout. It is a fixed canvas, 16:9 or 9:16, scaled as one piece
   to whatever screen it lands on" — a sheet is one more such screen. What the
   shop sees on the wall is what comes out of the printer: same columns, same
   line breaks, same everything, one page. Nothing reflows and nothing
   paginates.

   That is why this file is mostly four lines of arithmetic. It gives the stage
   a paper-sized canvas of the SAME aspect ratio as the screen canvas, and
   because every rule in tv.css is expressed as a multiple of --u (1% of canvas
   height), the whole board follows in proportion with no further instruction.

   In particular --scale is deliberately NOT reset. It is the fit loop's answer
   to "how big can this menu be inside its canvas", it is canvas-relative, and
   the paper canvas has the same shape as the screen one — so the same value
   reproduces the same board. Pinning it would make the sheet disagree with the
   wall, which is the one thing this file exists to prevent.

   Why it exists: a shop with a queue and no screen — a falafel counter, a
   bakery — still needs today's prices readable from the back of the line, and
   nobody in that queue is scanning a QR code. Same data, same design, third
   surface. See the pwa-install-offline skill.
   ========================================================================== */

/* The page orientation has to follow the board's, or a 16:9 board on a
   portrait sheet is letterboxed down to a stripe. An @page rule cannot be
   scoped to a selector, so tv.js injects the right one; this is the fallback
   for a bare Ctrl+P, matching the default board (data-orient="h"). */
@page { size: A4 landscape; margin: 10mm; }

@media print {

  html, body {
    height: auto;
    overflow: visible;
    background: #fff;
  }

  /* ---------------- the canvas, paper-sized ---------------- */

  /* Printable area is the sheet minus 10mm margins, minus a 10mm strip at the
     foot for the rate stamp. The canvas is then the largest 16:9 (or 9:16) box
     that fits, and --u is 1% of its height exactly as on screen.

                        printable      canvas          --u
     A4 landscape       277 x 180      277 x 155.81    1.558mm
     A4 portrait        190 x 267      150.19 x 267    2.67mm
     A3 landscape       400 x 267      400 x 225       2.25mm
     A3 portrait        277 x 390      219.38 x 390    3.90mm

     The strip is 10mm, not the 7mm this first used: the stamp's own top margin
     and line box together came to about 7.8mm, so portrait spilled a millimetre
     onto a second sheet. Landscape hid it, because landscape has spare height
     anyway — so the bug only showed in half the combinations. Any change to the
     stamp's size must come back here.

     --pad-top centres the canvas in whatever height is left over; portrait is
     height-bound and has none, so it is zero. */
  body[data-orient="h"] {
    --stage-w: 277mm; --stage-h: 155.81mm; --u: 1.558mm; --pad-top: 12.1mm;
  }
  body[data-orient="v"] {
    --stage-w: 150.19mm; --stage-h: 267mm; --u: 2.67mm; --pad-top: 0mm;
  }
  body[data-paper="a3"][data-orient="h"] {
    --stage-w: 400mm; --stage-h: 225mm; --u: 2.25mm; --pad-top: 21mm;
  }
  body[data-paper="a3"][data-orient="v"] {
    --stage-w: 219.38mm; --stage-h: 390mm; --u: 3.9mm; --pad-top: 0mm;
  }

  /* On screen the stage is absolutely centred in the viewport and then rotated
     and scaled to fit the panel. On paper it is simply a block of known size:
     --k is a screen-fit factor, and --turn carries the automatic quarter turn
     plus whatever data-rot the shop pressed to correct a badly-hung panel.
     Neither means anything here, because a sheet of paper is corrected by
     turning it round in your hand. Everything else about the stage — the
     column flex, the header, the footer — is left exactly as tv.css set it. */
  .stage {
    position: static;
    width: var(--stage-w);
    height: var(--stage-h);
    margin: var(--pad-top) auto 0;
    transform: none;
    background: none;
  }

  /* ---------------- what paper does not get ---------------- */

  /* A clock printed on a sheet is wrong from the moment it leaves the printer,
     and reads as a broken page rather than a static one. */
  .tv-clock { display: none; }

  /* Setup UI belongs to whoever mounts the screen, not to the sheet. */
  .ui-open, .setup { display: none; }

  /* The shop may have left the board in slides mode, which shows one category
     at a time — printing that would silently produce a sheet with most of the
     menu missing. Paper always gets the whole menu. Specificity matches the
     [data-mode="slides"] rules in tv.css and wins on source order, so neither
     of these needs !important. */
  body[data-mode] .slides { display: none; }
  body[data-mode] .board  { display: block; }

  /* ---------------- ink ---------------- */

  /* The board is cream-on-ink, so it needs no inversion: browsers drop
     background colours by default and what is left is exactly right, ink text
     on white paper with no toner spent on a full-bleed ground. Do NOT add
     print-color-adjust: exact. Category headings and the logo are coloured
     TEXT, which prints in colour on a colour printer and as legible grey on a
     mono one either way. */

  /* The rate is the one thing paper needs that the screen must not have. The
     board dropped it on purpose: on a wall the prices reprice themselves, so
     printing the rate there invites arithmetic and dates the screen. A sheet
     IS dated — that is what a sheet is — and the rate it was printed at is
     exactly what tells the shop when to reprint. It sits in the 7mm strip
     reserved above, outside the canvas, so the board itself is untouched.
     tv.js builds it at print time and removes it on afterprint.

     Sized in mm, NOT in --u. It is not part of the board, so it must not grow
     with it: at A3's --u the stamp came to ~11mm and spilled past the 10mm
     strip onto a second sheet, while A4 fitted — the classic bug that only
     appears in one of four combinations. A constant physical size keeps the
     reserve above valid on every paper. */
  .print-stamp {
    width: var(--stage-w);
    margin: 3mm auto 0;
    text-align: center;
    font-family: var(--f-body);
    font-size: 3.2mm;
    line-height: 1.3;
    color: var(--muted);
  }
  .print-stamp b { font-family: var(--f-num); color: var(--text); direction: ltr; }

  /* Links print as their text; a bare URL after every one would be noise. */
  a[href]::after { content: none; }
}
