/* Kpopownia design system — the print layer.
 *
 * A sheet of A4 the panel prints: the slip that goes into the parcel, the
 * packing sheet the shop keeps, and a goods receipt (PZ) for the archive; and
 * the one the storefront hands out, the return form a customer fills in by
 * hand. Linked by the print pages (framework/printsheet, after tokens, base
 * and components) and by the styleguide, never by either frontend's layout.
 *
 * Every rule sits under a .print-* class. The styleguide loads this file next
 * to everything else, so a bare element selector here would restyle the whole
 * catalogue. The one exception is @page, which only a printout reads.
 *
 * Paper is always the light theme: the print page puts data-theme="light" on
 * <html>, so every token below already resolves to the light values, and a
 * sheet drawn in the styleguide sits in a light-themed frame for the same
 * reason. print-color-adjust keeps the pink rule and the total's colour, which
 * browsers otherwise drop to save ink.
 */

@page {
  size: A4;
  margin: 10mm;
}

/* The page around the sheet on screen: a grey desk with the paper on it. */
.print-body {
  margin: 0;
  background: var(--stage);
  color: var(--ink);
  font-family: var(--font-body);
}

/* Screen only: back to the order, and print again. */
.print-toolbar {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4);
}

/* A line under the toolbar saying what the page left out; on screen only. */
.print-notice {
  max-width: 190mm;
  margin: 0 auto var(--space-4);
  padding: 0 var(--space-4);
  text-align: center;
  color: var(--ink-muted);
}

.print-sheet {
  box-sizing: border-box;
  max-width: 190mm;
  margin: 0 auto var(--space-8);
  padding: 12mm;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 9pt;
  line-height: 1.3;
  box-shadow: var(--shadow-2);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.print-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8mm;
  padding-bottom: 2mm;
  margin-bottom: 3mm;
  border-bottom: 2px solid var(--primary);
  break-after: avoid;
}

.print-head__logo {
  display: block;
  max-height: 11mm;
  max-width: 60mm;
  width: auto;
  height: auto;
}

/* The shop's name where the logo would stand, for a shop that uploaded none. */
.print-head__brand {
  font-size: 14pt;
  line-height: 1.2;
}

.print-head__shop {
  text-align: right;
  font-size: 8pt;
  color: var(--ink-soft);
}

.print-head__name {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 9.5pt;
  color: var(--ink);
}

.print-title {
  margin: 0 0 1mm;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 13pt;
  line-height: 1.2;
  color: var(--ink);
  break-after: avoid;
}

.print-title__sub {
  margin: 0 0 3mm;
  font-size: 8pt;
  color: var(--ink-muted);
}

/* A stripe under a title that sets the sheet, or one order on it, apart at a
   glance: where an order on the packing sheet was sold. Each tone keeps its
   colour on paper (print-color-adjust on .print-sheet). On a black-and-white
   printer Allegro is a dark band with white letters, the shop a light one
   with dark letters, so the two still differ. */
.print-stripe {
  --print-stripe: #ff5a00;
  --print-stripe-ink: var(--white);
  display: block;
  margin: 0 0 3mm;
  padding: 0.8mm 2.5mm;
  border-radius: 1mm;
  background: var(--print-stripe);
  color: var(--print-stripe-ink);
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 8.5pt;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  break-after: avoid;
}

.print-stripe--allegro {
  --print-stripe: #ff5a00;
  --print-stripe-ink: var(--white);
}

.print-stripe--shop {
  --print-stripe: #dccbf7;
  --print-stripe-ink: #3f2380;
}

.print-table__group .print-stripe {
  margin: 1mm 0 0;
}

.print-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(45mm, 1fr));
  gap: 2mm 6mm;
  margin-bottom: 3mm;
}

.print-meta__label {
  margin-bottom: 0.5mm;
  font-size: 7pt;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--secondary);
}

.print-meta__value {
  white-space: pre-line;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4mm;
}

/* The head repeats on every page a long table runs to; browsers mostly do
   it already, and saying so costs nothing. */
.print-table thead {
  display: table-header-group;
}

.print-table th {
  padding: 1mm 1.5mm;
  border-bottom: 1.5px solid var(--ink);
  text-align: left;
  font-size: 7pt;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.print-table td {
  padding: 0.8mm 1.5mm;
  border-bottom: 1px solid var(--line-solid);
  vertical-align: top;
}

.print-table tr {
  break-inside: avoid;
}

.print-table__num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.print-table__nowrap {
  white-space: nowrap;
}

/* A number never breaks, but its column's heading may: a long heading over a
   narrow figure (a packaging material on the BDO report) would otherwise
   widen the table past the paper's edge. */
.print-table th.print-table__num {
  text-align: right;
  white-space: normal;
}

.print-table__check {
  width: 6mm;
}

.print-table__sub {
  display: block;
  font-size: 7.5pt;
  color: var(--ink-muted);
}

/* A receipt under its line on the packing sheet: smaller, indented, and no
   rule between it and the line it belongs to. */
.print-table tr.print-table__source td {
  padding-top: 0.3mm;
  padding-bottom: 0.3mm;
  border-bottom: 0;
  font-size: 8pt;
  color: var(--ink-soft);
}

.print-table tr.print-table__source td:first-child + td {
  padding-left: 6mm;
}

.print-table tr.print-table__note td {
  padding-top: 0.3mm;
  border-bottom: 0;
  font-size: 8pt;
  font-style: italic;
  color: var(--ink-muted);
}

/* A section row opens a block of the table of its own — on the packing
   sheet, everything besides the products that goes into the box: a small
   capital heading across the table under a light grey rule, never left
   alone at the foot of a page. */
.print-table tr.print-table__section {
  break-after: avoid;
}

.print-table tr.print-table__section td {
  padding-top: 3mm;
  border-top: 1px solid var(--line-strong);
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.print-check {
  display: inline-block;
  width: 4mm;
  height: 4mm;
  border: 1.5px solid var(--ink);
  border-radius: 1mm;
  vertical-align: middle;
}

.print-totals {
  margin-left: auto;
  width: 65mm;
  margin-bottom: 4mm;
}

.print-totals__row {
  display: flex;
  justify-content: space-between;
  gap: 4mm;
  padding: 0.5mm 0;
  font-variant-numeric: tabular-nums;
}

.print-totals__grand {
  margin-top: 1mm;
  padding-top: 1.5mm;
  border-top: 2px solid var(--primary);
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 11pt;
  color: var(--primary);
}

.print-foot {
  padding-top: 3mm;
  border-top: 1px solid var(--line-solid);
  text-align: center;
  font-size: 8pt;
  color: var(--ink-muted);
}

.print-foot__thanks {
  margin: 0 0 1mm;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 10pt;
  color: var(--ink);
}

/* The bottom of a document that goes to the archive: a line to sign on above
   each label, side by side. Kept on the page with the table's end rather than
   left alone at the top of the next sheet. */
.print-signatures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50mm, 1fr));
  gap: 12mm;
  margin-top: 12mm;
  break-inside: avoid;
}

.print-signature {
  padding-top: 1.5mm;
  border-top: 1px solid var(--ink);
  text-align: center;
  font-size: 8pt;
  color: var(--ink-muted);
}

@media print {
  .print-body {
    background: var(--white);
  }

  .print-toolbar,
  .print-notice {
    display: none;
  }

  .print-sheet {
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
}

/* A group row: a product's name across the whole table, its deliveries
   under it as source rows. */
/* It never ends a page: a heading left alone at the foot of a sheet, with
   its lines over the page, is the one thing a batch packer would misread. */
.print-table__group {
  break-after: avoid;
}

.print-table__group td {
  padding-top: 1.5mm;
  border-top: 1px solid var(--line-strong);
  font-weight: 700;
}

.print-table__group .print-table__sub {
  font-weight: 400;
}

/* Groups apart (the batch packing sheet): each group is an order of its
   own, so a heavy rule opens it and the order before it ends with room to
   spare. The first group sits under the header and needs neither. */
.print-sheet[data-groups="apart"] tbody tr:has(+ tr.print-table__group) td {
  padding-bottom: 4mm;
}

/* Under each order's number, where it goes: read at the packing table, so in
   full ink and a size up from an ordinary sub-line. */
.print-sheet[data-groups="apart"] .print-table__group .print-table__sub {
  margin-top: 0.5mm;
  font-size: 8.5pt;
  color: var(--ink);
}

.print-sheet[data-groups="apart"] tbody tr.print-table__group:not(:first-child) td {
  border-top: 2px solid var(--ink);
  padding-top: 2.5mm;
}

/* A figure in a tone: a margin's level on the margins printout. Text only —
   the paper carries no tinted rows. */
.print-tone { font-weight: 600; }
.print-tone--loss { color: var(--danger); }
.print-tone--low { color: var(--caution); }
.print-tone--warn { color: var(--warning); }
.print-tone--ok { color: var(--success); }
.print-tone--muted { color: var(--ink-muted); font-weight: 400; }

/* A plain sheet keeps colour for its figures alone: the head's rule is ink,
   not the brand's pink, so a coloured margin is the only colour on the page. */
.print-sheet[data-tone="plain"] .print-head { border-bottom-color: var(--ink); }
.print-sheet[data-tone="plain"] .print-table thead th { color: var(--ink); }

/* A sheet is its own page: the till codes' second list starts on a fresh
   one instead of running on from the first one's table. */
.print-sheet + .print-sheet {
  break-before: page;
}

/* A sheet filled in by hand — the stock count — keeps a row tall enough to
   write a number in, however tight the rest of the paper is. */
.print-sheet[data-handwritten] .print-table tbody td {
  height: 7mm;
  vertical-align: bottom;
}

/* A sheet filled in by hand — the return form: small-capital labels over
   groups, blank lines to write on with what goes there under each, a box to
   tick per option, and the small print. */
.print-label {
  margin-bottom: 1mm;
  font-size: 7pt;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--secondary);
}

.print-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5mm 6mm;
  margin-bottom: 4mm;
}

.print-field--wide {
  grid-column: 1 / -1;
}

.print-field__line {
  height: 7mm;
  border-bottom: 1px solid var(--ink-soft);
}

.print-field__hint {
  margin-top: 0.6mm;
  font-size: 7pt;
  color: var(--ink-muted);
}

.print-statement {
  margin: 0 0 2mm;
  font-weight: 700;
  font-size: 9.5pt;
}

.print-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2mm 7mm;
  margin-bottom: 4mm;
}

.print-option {
  display: inline-flex;
  align-items: center;
  gap: 1.5mm;
}

.print-option__line {
  display: inline-block;
  width: 45mm;
  border-bottom: 1px solid var(--ink-soft);
  height: 4mm;
}

/* The small print in one tinted box with the brand's rule down its left
   edge, so a customer sees it is the rules and not more lines to fill. */
.print-notes {
  margin: 0 0 3mm;
  padding: 2.5mm 4mm;
  list-style: none;
  font-size: 7.5pt;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--primary) 4%, var(--white));
  border-left: 2px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.print-notes li + li {
  margin-top: 0.6mm;
}

/* Ways to do one thing, side by side, one card each — where a parcel can
   go back to. The title is in the brand's colour, the lines under it in
   ink, a code in bold. */
.print-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(45mm, 1fr));
  gap: 3mm;
  margin-bottom: 2mm;
}

.print-choice {
  padding: 2.5mm 3mm;
  border: 1px solid color-mix(in srgb, var(--secondary) 30%, var(--white));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--primary) 3%, var(--white));
}

.print-choice__title {
  margin-bottom: 1mm;
  font-weight: 700;
  color: var(--primary);
}

/* One line with a bold label in front: who the parcel is addressed to,
   where to ask. */
.print-aside {
  margin: 0 0 4mm;
}

.print-aside__label {
  margin-right: 1.5mm;
  font-weight: 700;
  color: var(--secondary);
}

.print-table__ordinal {
  width: 7mm;
  color: var(--ink-muted);
}

/* A phone shows the sheet before it is printed; one line to a row there. */
@media (max-width: 480px) {
  .print-fields { grid-template-columns: minmax(0, 1fr); }
}

/* The thank-you card ----------------------------------------------------
 *
 * A 10 × 15 cm card an order is given with a discount code for the next
 * purchase, printed from the order page and put in the parcel. It is not a
 * sheet of A4: its print page links print-card.css, which makes the paper
 * the card's own, no margin, the ground to the paper's edge. Every line stands where the template puts it, measured from the
 * top of the card in millimetres, so the card prints the same whatever the
 * printer does to an A4 flow; the text keeps at least 8 mm off the sides,
 * so a printer that cannot print borderless trims only ground.
 *
 * Its colours and faces are the --card-* tokens, which a skin redeclares;
 * the brand line is the shop's own brand text.
 */
.thank-you {
  position: relative;
  box-sizing: border-box;
  width: 100mm;
  height: 150mm;
  margin: 0 auto var(--space-8);
  overflow: hidden;
  background: var(--card-ground);
  color: var(--card-ink);
  font-family: var(--card-font-text);
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow-2);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Every block is a band across the card at its own height. */
.thank-you > * {
  position: absolute;
  left: 8mm;
  right: 8mm;
  margin: 0;
}

.thank-you__title {
  top: 17.42mm;
  font-family: var(--card-font-title);
  font-size: 7.05mm;
  font-weight: 700;
  line-height: 1;
}

.thank-you__text {
  font-size: 4.6mm;
  font-weight: 700;
  line-height: 1.375;
}

/* One row per line of the catalogue's sentence, spaces kept: the template
   starts some rows with one, which moves them off the centre a little. */
.thank-you__text > span {
  display: block;
  white-space: pre;
}

.thank-you__text--body {
  top: 34.8mm;
}

.thank-you__text--surprise {
  top: 74.46mm;
  font-size: 4.53mm;
  font-weight: 500;
  line-height: 1.336;
}

/* The heart hangs after the last row and takes no width, so the row is
   centred without it, as the template has it. */
.thank-you__heart {
  display: inline-block;
  position: relative;
  left: 0.93mm;
  top: 0.21mm;
  width: 4.57mm;
  height: 4.57mm;
  margin-right: -4.57mm;
  vertical-align: -0.2em;
}

.thank-you__heart svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: var(--card-heart);
}

.thank-you__code {
  top: 98.51mm;
  font-size: 3.82mm;
  font-weight: 700;
  /* Heavier than the face's heaviest weight, as the template sets it. */
  -webkit-text-stroke: 0.17mm currentColor;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* The dotted rule under the code: round dots in the ink. */
.thank-you__dots {
  top: 103.45mm;
  left: 27.88mm;
  right: auto;
  width: 44.4mm;
  height: 0.93mm;
  fill: var(--card-ink);
}

.thank-you__expiry {
  top: 107.3mm;
  font-size: 2.39mm;
  font-weight: 700;
  -webkit-text-stroke: 0.06mm currentColor;
  line-height: 1;
}

.thank-you__mark {
  left: auto;
  right: auto;
  height: auto;
}

.thank-you__mark--left {
  top: 60.65mm;
  left: 6.85mm;
  width: 6.4mm;
}

.thank-you__mark--right {
  top: 112.2mm;
  left: 78.3mm;
  width: 7.9mm;
}

.thank-you__sign {
  top: 121.91mm;
  font-size: 4.25mm;
  font-weight: 700;
  line-height: 1;
}

.thank-you__brand {
  top: 133mm;
  font-size: 6.63mm;
  line-height: 1;
}

/* The shop's name in its brand treatment, minus the glow, which paper
   would print as a smudge; the domain's ending small beside it in the
   card's ink, taking no width, so the name itself is what is centred. */
.thank-you__name {
  /* Room round the letters: Chrome's PDF leaves a hairline of the gradient
     at the edge of a text-clipped box, and this keeps it off the paper's
     ink by putting the edge where no letter is. */
  display: inline-block;
  padding: 0 1.5mm;
  margin: 0 -1.5mm;
  font-family: var(--font-brand);
  font-weight: 700;
  letter-spacing: var(--tracking-brand);
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.thank-you__tld {
  display: inline-block;
  position: relative;
  left: 0.59mm;
  width: 0;
  font-family: var(--font-brand);
  font-size: 0.66em;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: 0.1em;
}

/* The card without a code: the thanks with its rows set wider apart, the
   marks, the sign-off and the bare name, the whole stood in the middle of
   the card instead of around the code's band. */
.thank-you--plain .thank-you__title {
  top: 26mm;
}

.thank-you--plain .thank-you__text--body {
  top: 43.4mm;
  line-height: 2;
}

.thank-you--plain .thank-you__mark--left {
  top: 81.6mm;
}

.thank-you--plain .thank-you__mark--right {
  top: 94mm;
}

.thank-you--plain .thank-you__sign {
  top: 103.7mm;
}

.thank-you--plain .thank-you__brand {
  top: 114.8mm;
}

@media print {
  .thank-you {
    margin: 0;
    box-shadow: none;
  }
}
