/* Printables: the dialog, and the pages that come out of it (place cards, table signs, menu cards).
 *
 * The pages are plain on purpose, like the day pack's: black on white, no fills (they waste ink and
 * vanish on a photocopy), one thin dashed line where a card is folded or cut. css/print.css puts the
 * text and border tokens back to black and white whatever the theme, and js/ui/print-session.js puts
 * the light theme on for the printing only.
 *
 * The rules for the pages apply on screen as well, because the preview in the dialog is the same page
 * shrunk to fit. Only what hides the rest of the site is inside @media print.
 */

/* ------------------------------------------------------------- the dialog ---- */

.pr-form { display: grid; gap: var(--space-field); }
/* The panels for the kinds not being shown are hidden with the attribute; display: grid below would beat it. */
.pr-form [hidden] { display: none !important; }
.pr-tabs { margin-bottom: var(--space-8); }
.pr-options { display: grid; gap: var(--space-4); }
.pr-field { display: grid; gap: var(--space-8); padding: var(--space-8) 0; justify-items: start; }
.pr-field label, .pr-field-label { font-weight: 700; font-size: 13.5px; }
.pr-field input, .pr-field select { width: 100%; max-width: 360px; }
.pr-seg { max-width: 100%; flex-wrap: wrap; }
.pr-summary { margin: var(--space-4) 0 0; font-size: 14.5px; font-weight: 700; line-height: 1.5; }

/* The first page, shrunk. The page inside keeps its real size and is scaled by the script. */
.pr-preview {
  position: relative; overflow: hidden; width: 100%; max-width: 420px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--card);
}
.pr-preview[hidden] { display: none; }

.pr-print { min-height: 44px; }

@media (max-width: 640px) {
  .pr-tabs { display: flex; }
  .pr-tabs button, .pr-seg button { flex: 1 1 auto; min-height: 44px; }
  .pr-field input, .pr-field select { max-width: none; min-height: 44px; }
}

/* -------------------------------------------------------------- the pages ---- */

/* Drawn into the page ahead of printing, and never seen on screen. */
#printables-print { display: none; }

.pr-sheet {
  display: grid; box-sizing: border-box; overflow: hidden; background: none;
  color: var(--text); font-size: 12pt; line-height: 1.25;
}

/* A card, with a faint dashed line round it to cut along. The empty cells keep their lines so a
   short last page still has a grid to cut along. */
.pr-card {
  position: relative; box-sizing: border-box; overflow: hidden;
  border: .75pt dashed var(--border); background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 8mm;
}

/* The tent card: two panels, the upper one turned over so the name reads from both sides of the
   table once it is folded along the line between them. */
.pr-tent { padding: 0; justify-content: stretch; align-items: stretch; }
.pr-panel {
  flex: 1 1 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6mm 8mm; text-align: center; min-height: 0;
}
.pr-tent .pr-panel + .pr-panel { border-top: .75pt dashed var(--border); }
.pr-flip { transform: rotate(180deg); }

.pr-name { font-weight: 500; line-height: 1.12; overflow-wrap: anywhere; }
.pr-table { margin-top: 3mm; font-size: 13pt; color: var(--muted); }
.pr-meal { margin-top: 1.5mm; font-size: 12pt; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

/* A table sign. */
.pr-sign { padding: 10mm 12mm; }
.pr-sign .pr-name { font-weight: 600; }
.pr-names { margin: 7mm 0 0; padding: 0; list-style: none; column-gap: 10mm; font-size: 14pt; line-height: 1.5; text-align: left; }
.pr-names li { break-inside: avoid; page-break-inside: avoid; }

/* A menu. Sizes are in em, so the whole card scales with the font size the script sets on it. */
.pr-menu { justify-content: flex-start; padding: 14mm 12mm; font-size: 13pt; }
.pr-menu-heading { margin: 0; font-size: 2.1em; font-weight: 500; line-height: 1.1; }
.pr-menu-names { margin: .7em 0 0; font-size: 1.1em; }
.pr-menu-date { margin: .15em 0 0; font-size: .95em; color: var(--muted); }
.pr-course { width: 100%; padding-top: 1.4em; }
.pr-course h3 { margin: 0 0 .5em; font-size: .85em; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.pr-course ul { margin: 0; padding: 0; list-style: none; }
.pr-course li { padding: .25em 0; break-inside: avoid; page-break-inside: avoid; }
.pr-dish { font-weight: 600; }
.pr-codes { font-size: .8em; font-weight: 700; letter-spacing: .04em; }
.pr-desc { font-size: .85em; font-style: italic; color: var(--muted); }

.pr-empty { border-style: dashed; }

/* -------------------------------------------------------------- printing ---- */

@media print {
  /* While printables are printing, nothing but them. The class is on <html> only from the moment
     Print is pressed until the browser says it has finished, so every other print the app makes is
     left exactly as css/print.css has it. */
  html.pr-printing body > *:not(#printables-print) { display: none !important; }
  html.pr-printing, html.pr-printing body {
    position: static !important; top: auto !important; left: auto !important; right: auto !important;
    width: auto !important; height: auto !important; margin: 0 !important; padding: 0 !important;
    overflow: visible !important;
  }
  #printables-print { display: block; }

  /* The @page rule that sets the paper is added by js/ui/print-session.js while printing. */
  #printables-print .pr-sheet { break-after: page; page-break-after: always; }
  #printables-print .pr-sheet:last-child { break-after: auto; page-break-after: auto; }
  .pr-card, .pr-panel { break-inside: avoid; page-break-inside: avoid; }
}
