/* Thank-you labels, and the messages sheet.
 *
 * Two halves, as in css/daypack.css: the dialog is ordinary app UI in the app's tokens, and the
 * sheets are paper (plain black on white, no fills). The sheet sizes are millimetres taken from the
 * common A4 label stocks and are checked by test/labels.mjs; they are the same on screen and on
 * paper, and only what hides the rest of the page is inside @media print.
 *
 * Also here, because it is small and belongs to the same piece of work: the "Messages for everyone
 * still waiting" sheet (js/ui/party-message.js) and the tick on a gift's thank-you.
 */

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

.lb-form { gap: var(--space-16); }
.lb-who { border: 0; margin: 0; padding: 0; min-width: 0; }
.lb-who legend { font-weight: 700; font-size: 13.5px; padding: 0 0 var(--space-4); }
.lb-opt { display: flex; align-items: flex-start; gap: var(--space-16); min-height: 44px; padding: var(--space-8) 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.lb-opt:last-child { border-bottom: 0; }
.lb-opt input { width: 20px; height: 20px; margin: var(--space-4) 0 0; accent-color: var(--accent); flex: none; }
.lb-opt-text { display: grid; gap: 0; min-width: 0; }
.lb-opt-name { font-weight: 700; font-size: 14.5px; }
.lb-opt-meta { color: var(--muted); font-size: 13px; line-height: 1.45; }

.lb-pick-wrap { display: grid; gap: var(--space-8); }
.lb-pick-wrap[hidden] { display: none; }
.lb-pick { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.lb-pick li + li { border-top: 1px solid var(--border); }
.lb-pick-row { display: flex; align-items: center; gap: var(--space-16); min-height: 44px; padding: var(--space-8) var(--space-16); cursor: pointer; overflow-wrap: anywhere; }
.lb-pick-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.lb-pick-note { margin-left: auto; color: var(--muted); font-size: 13px; flex: none; }

.lb-skip { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-8) var(--space-16); }
.lb-skip label { font-weight: 700; font-size: 13.5px; }
.lb-skip input { width: 84px; min-height: 44px; font: inherit; font-size: 16px; color: var(--text); background: var(--card); border: 1.5px solid var(--control); border-radius: var(--radius); padding: 0 var(--space-16); }
.lb-skip .dp-hint { flex-basis: 100%; }

.lb-summary { margin: 0; font-weight: 700; font-size: 14.5px; }
.lb-left { margin: 0; padding: var(--space-8) var(--space-16); border-radius: var(--radius); background: var(--surface); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.lb-left[hidden] { display: none; }

/* The first labels, as they will look. Narrower than paper on a phone, never wider than the screen. */
.lb-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--space-8); }
.lb-preview:empty { display: none; }
.lb-preview .lb-label { border: 1px dashed var(--border-strong); border-radius: 6px; min-height: 84px; }

/* ------------------------------------------------------------ the labels ---- */

.lb-label { box-sizing: border-box; padding: 3mm 5mm; overflow: hidden; color: var(--text); font-family: Georgia, 'Times New Roman', serif; font-size: 10pt; line-height: 1.25; overflow-wrap: anywhere; }
.lb-name { font-weight: 700; }

/* ------------------------------------------------------------ the sheets ---- */

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

.lb-sheet {
  box-sizing: border-box; width: 210mm; height: 297mm; display: grid; align-content: start; justify-content: start; overflow: hidden;
  background: var(--card); color: var(--text);
}
/* 2 across, 7 down: 99.1 by 38.1 mm. */
.lb-2x7 { padding: 15.1mm 0 0 4.65mm; grid-template-columns: repeat(2, 99.1mm); grid-auto-rows: 38.1mm; column-gap: 2.5mm; row-gap: 0; }
.lb-2x7 .lb-label { padding: 4mm 6mm; }
/* 3 across, 8 down: 63.5 by 33.9 mm. A little smaller type, since there is less room. */
.lb-3x8 { padding: 12.9mm 0 0 7.2mm; grid-template-columns: repeat(3, 63.5mm); grid-auto-rows: 33.9mm; column-gap: 2.5mm; row-gap: 0; }
.lb-3x8 .lb-label { padding: 2.5mm 4mm; font-size: 9pt; }

@media print {
  /* While labels print, nothing but the labels. 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 untouched. */
  html.lb-printing body > *:not(#labels-print) { display: none !important; }
  html.lb-printing, html.lb-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;
  }
  #labels-print { display: block; }
  /* The @page rule that sets A4 and no margin is added by js/ui/labels.js while printing. */
  .lb-sheet { break-after: page; page-break-after: always; }
  .lb-sheet:last-child { break-after: auto; page-break-after: auto; }
  .lb-label { break-inside: avoid; page-break-inside: avoid; }
}

/* ------------------------------------------------ messages for the waiting ---- */

.pm-status { margin: 0 0 var(--space-16); color: var(--muted); font-size: 14.5px; }
.pm-status:empty { display: none; }
.pm-list { list-style: none; margin: 0; padding: 0; max-height: min(52vh, 420px); overflow-y: auto; }
.pm-list li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-8) var(--space-16); min-height: 52px; padding: var(--space-8) 0; border-top: 1px solid var(--border); }
.pm-list li:first-child { border-top: 0; }
.pm-who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; line-height: 1.35; }
.pm-who b { font-weight: 700; overflow-wrap: anywhere; }
.pm-who span { font-size: 13px; color: var(--muted); }
.pm-actions { display: flex; gap: var(--space-8); flex-wrap: wrap; }
.pm-manual { width: 100%; font: inherit; font-size: 16px; line-height: 1.5; color: var(--text); background: var(--card); border: 1.5px solid var(--control); border-radius: var(--radius); padding: var(--space-16) var(--space-16); resize: vertical; }

/* -------------------------------------------------- the thank-you tick ---- */

/* A real checkbox in the gift's row, so a thank you is one tap. The word beside it says the same
   thing in case the box is missed, and the whole label is the tap target. */
.thank-tick { display: inline-flex; align-items: center; gap: var(--space-8); min-height: 44px; cursor: pointer; }
.thank-tick input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; cursor: pointer; }
.thank-progress { display: flex; flex-wrap: wrap; gap: var(--space-8) var(--space-16); align-items: center; margin: 0 0 var(--space-16); font-size: 14px; color: var(--muted); }
.thank-progress b { color: var(--text); }

/* ---------------------------------------------- QR codes for reply links ---- */
/* js/ui/qr-codes.js: one invitation's code in a dialog, and every code on A4 to print (12 to a page, 3 by 4). */
.qr-dialog { display: grid; justify-items: center; gap: var(--space-16); }
.qr-img { width: min(260px, 70vw); aspect-ratio: 1; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--qr-light); }
.qr-img svg, .qr-card-img svg { display: block; width: 100%; height: 100%; }
.qr-who { margin: 0; font-weight: 700; font-size: 16px; text-align: center; }
.qr-actions { display: flex; flex-wrap: wrap; gap: var(--space-8); justify-content: center; }
.qr-note { max-width: 46ch; text-align: center; }
.qr-loading, .qr-count { margin: 0; color: var(--muted); font-size: 14.5px; text-align: center; }
.qr-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-16); width: 100%; }
.qr-card { display: grid; justify-items: center; align-content: start; gap: var(--space-4); padding: var(--space-8); border: 1px solid var(--border); border-radius: 12px; background: var(--qr-light); color: var(--qr-dark); text-align: center; }
.qr-card-img { width: 100%; max-width: 160px; aspect-ratio: 1; }
.qr-card-name { margin: var(--space-4) 0 0; font-weight: 700; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.qr-card-line { margin: 0; font-size: 12px; }
#qr-print { display: none; }
@media print {
  html.qr-printing body > *:not(#qr-print) { display: none !important; }
  html.qr-printing, html.qr-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;
  }
  #qr-print { display: block; }
  .qr-print-page { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 64mm; gap: 6mm; break-after: page; page-break-after: always; }
  .qr-print-page:last-child { break-after: auto; page-break-after: auto; }
  #qr-print .qr-card { border: 0.3mm dashed var(--qr-dark); border-radius: 0; break-inside: avoid; page-break-inside: avoid; padding: 3mm; }
  #qr-print .qr-card-img { width: 42mm; max-width: none; }
  #qr-print .qr-card-name { font-size: 11pt; }
  #qr-print .qr-card-line { font-size: 9pt; }
}
