/* ============================================================================
   QR code label (QrCodePopUp).

   The class form stores the label size and every position in centimetres, which
   is what the legacy printout used. Laying the label out in cm keeps it at its
   real size both on screen and on the printer, so what is configured is what
   comes out of the label printer.
   ============================================================================ */

.qrcode-label {
    position: relative;
    box-sizing: border-box;
    min-width: 3cm;
    min-height: 3cm;
    padding: 0;
    background: #ffffff;
    border: 1px dashed var(--jump-border-color, #d0d5dd);
    overflow: hidden;
}

.qrcode-label-image {
    position: absolute;
    /* The PNG already carries the configured QRCodeScale; leaving it at its natural
       size is what reproduces the scale the class defines. */
    image-rendering: pixelated;
}

.qrcode-label-field {
    position: absolute;
    /* The legacy printout drew the fields in Microsoft Sans Serif 8pt. */
    font-family: "Microsoft Sans Serif", Arial, sans-serif;
    font-size: 8pt;
    line-height: 1.1;
    color: #000000;
    white-space: pre;
}

/* A direct print (QrCodePopUp with PrintImmediately) lays the label out away from the screen
   instead of hiding it: the print measures it to centre the content, and an element with
   `display: none` has no size to measure. */
.qrcode-label-offscreen {
    position: fixed;
    left: -10000px;
    top: 0;
    pointer-events: none;
}

/* The configured positions keep the content's own arrangement, and jumpQrCode.centerContent
   moves the block as a whole to the middle of the label. It writes the two shifts on the label
   rather than on each element, so the copy made for printing carries them with it.

   --qrcode-content-scale is the class's label scale (QRCodeEtiquetaTamanho.QRCodeEscalaEtiqueta),
   written on the label by QrCodePopUp, which also scales each position. Every element grows from
   its own top left corner, so together they draw the block scaled as a whole. The shift comes
   first in the list, so it moves the element in the label's pixels and is not scaled itself;
   the centring measures the scaled boxes, which getBoundingClientRect already returns. */
.qrcode-label-image,
.qrcode-label-field {
    transform: translate(var(--qrcode-shift-x, 0px), var(--qrcode-shift-y, 0px)) scale(var(--qrcode-content-scale, 1));
    transform-origin: 0 0;
}

/* While printing, the sheet is the label and nothing else is on it.

   The label is not printed where it sits: `jumpQrCode.printLabel` copies it into
   `#qrcode-label-print-container` at the end of the body, which is what lets the rest of the
   application be dropped with `display: none`. Hiding it with `visibility` instead — which is
   what this did before — left every box of the application taking up room on the paper, so the
   label ended up in the corner of a sheet the size of the whole page.

   The paper size itself comes from the class's configured label size, written into an `@page`
   rule at print time: a `@page` cannot read a CSS variable. */
@media print {
    body.jump-printing-qrcode > *:not(#qrcode-label-print-container) {
        display: none !important;
    }

    /* Nothing on the sheet may be wider than the label. css/Radzen.css (a full Bootstrap 4 build)
       sets `body { min-width: 992px !important; }` for print, and Chrome shrinks a page whose content
       is wider than the paper as far as it allows: the 3 x 3 cm label came out at two thirds of its
       size, the 8 pt texts at 5,3 pt, on the same printer that printed it right from aTrans V3. */
    body.jump-printing-qrcode {
        min-width: 0 !important;
    }

    /* The user's interface scale (site.js, a `zoom` on the root) is for the screen; at 80% it would
       shrink the label on paper by as much. */
    html:has(> body.jump-printing-qrcode) {
        zoom: 1 !important;
    }

    body.jump-printing-qrcode,
    body.jump-printing-qrcode #qrcode-label-print-container {
        background: #ffffff;
        height: auto;
        margin: 0;
        overflow: visible;
        padding: 0;
        width: auto;
    }

    /* The dashed guide belongs to the preview, not to the label. */
    body.jump-printing-qrcode .qrcode-label-printing {
        border: 0;
        margin: 0;
        page-break-after: avoid;
        page-break-inside: avoid;
    }
}
