/* =============================================================================
   css/print.css
   The receipt on paper (docs/05-ux-spec.md section 10, PAY-06).

   Loaded with media="print", so it costs nothing on screen. When
   printReceipt() in js/ui/receipt.js fills the [data-receipt] slot in
   index.html and opens the print dialog, this file hides the app and lays
   the slot out for an 80 mm thermal roll. There is no printer yet (the PRD
   lists it under Should); the layout is ready for one, and on a laptop the
   same page prints on A4 at the same width, centred.

   Values here are tokens where a token fits. Paper has its own rules: the
   roll is 80 mm wide with about 72 mm printable, and thermal print is
   black on white only, so there are no colours in this file at all.
   ============================================================================= */

@page {
  size: 80mm auto;
  margin: 4mm;
}

@media print {

  /* Only the receipt prints. The app's frame, toasts and any open dialog
     are hidden rather than removed, so the page is untouched afterwards. */
  .app,
  .toast-area,
  dialog {
    display: none !important;
  }

  [data-receipt] {
    display: block !important;
  }

  html,
  body {
    background: white;
    color: black;
    margin: 0;
  }

  .receipt {
    width: 72mm;
    margin: 0 auto;
    font-family: var(--font-family);
    font-size: 10pt;
    line-height: 1.3;
    position: relative;
  }

  .receipt__shop {
    text-align: center;
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px dashed black;
  }

  /* The horizontal logo carries the shop's name; the alt text stands in
     for it if the picture cannot load. */
  .receipt__logo {
    display: block;
    width: 48mm;
    height: auto;
    margin: 0 auto var(--space-1);
  }

  .receipt__head {
    padding-bottom: var(--space-2);
    border-bottom: 1px dashed black;
  }

  .receipt__row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-2);
  }

  .receipt__row span:last-child {
    text-align: right;
  }

  .receipt__lines {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-2) 0;
  }

  .receipt__lines th,
  .receipt__lines td {
    padding: 1px 0;
    vertical-align: top;
    text-align: left;
  }

  .receipt__lines th {
    font-weight: var(--font-bold);
    border-bottom: 1px solid black;
  }

  .receipt__lines th:not(:first-child),
  .receipt__lines td.num {
    text-align: right;
    padding-left: var(--space-1);
    white-space: nowrap;
  }

  .receipt__lines small {
    font-size: 8pt;
    font-style: italic;
  }

  .receipt__summary {
    padding-top: var(--space-2);
    border-top: 1px dashed black;
  }

  .receipt__row--total {
    font-size: 13pt;
    font-weight: var(--font-bold);
    margin: var(--space-1) 0;
  }

  .receipt__row--owed {
    font-weight: var(--font-bold);
  }

  .receipt__footer {
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px dashed black;
    text-align: center;
    font-size: 9pt;
  }

  /* VOID, PROVISIONAL or ENTERED LATER across the middle, in outline so
     the figures underneath still read. */
  .receipt__stamp {
    position: absolute;
    top: 40%;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 26pt;
    font-weight: var(--font-bold);
    letter-spacing: 0.1em;
    color: transparent;
    -webkit-text-stroke: 1px black;
    transform: rotate(-20deg);
    opacity: 0.5;
  }

  .num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
  }
}
