/* The counter sign page (sign.html): controls on screen, then the sheet exactly as it
   prints. Always an upright A4 page (iPhones ignore "print sideways"):
   Counter signs: two upright A5 signs turned on their side, one above the other, with a
   cut line across the middle. Poster: one sign filling the page. Table signs: four A6
   signs, two by two, with cut lines between them.
   Always black on white, whatever the phone's mode. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  background: #e8e8ec;
  color: #111111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.controls {
  max-width: 640px;
  margin: 0 auto 20px;
}

.controls-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 12px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.controls button {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid #c7c7d1;
  background: #ffffff;
  color: #111111;
  cursor: pointer;
}

.controls button.is-on {
  border-color: #1e3a8a;
  background: #e7ecfd;
}

.controls button.main {
  background: #1e3a8a;
  border-color: #1e3a8a;
  color: #ffffff;
}

.controls button:disabled {
  opacity: 0.5;
}

.controls-step {
  font-size: 15px;
  font-weight: 700;
  margin: 4px 0 8px;
}

.controls-note {
  font-size: 14px;
  color: #555560;
  margin: 4px 0 0;
}

.controls-problem {
  color: #b42318;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

/* The sheet, at its real size (scaled down on small screens). */
.sheet {
  display: flex;
  margin: 0 auto;
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.sheet {
  flex-direction: column;
  width: 210mm;
  height: 297mm;
}

/* While the PDF is drawn: no shadow round the sheet. */
.making-pdf .sheet {
  box-shadow: none;
}

@media screen and (max-width: 820px) {
  .sheet {
    zoom: 0.45;
  }
}

/* Counter signs: each half of the page holds one A5 sign turned on its side. */
.half {
  position: relative;
  width: 210mm;
  height: 148.5mm;
  overflow: hidden;
}

.half + .half {
  border-top: 0.4mm dashed #b8b8c4;
}

.half .sign {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 148.5mm;
  height: 210mm;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.sign {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* Room for the printer's own margins (iPhones add about 1cm). */
  padding: 14mm 12mm;
}

.sign-logo {
  width: 18mm;
  height: 18mm;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 3mm;
}

.sign-shop {
  font-size: 14pt;
  font-weight: 600;
  color: #444450;
  margin: 0 0 2mm;
}

.sign-title {
  font-size: 22pt;
  line-height: 1.15;
  margin: 0 0 2mm;
  color: #111111;
}

.sign-reward {
  font-size: 12.5pt;
  color: #333340;
  margin: 0 0 4mm;
}

.sign-qr {
  width: 58mm;
  height: 58mm;
  padding: 3.5mm;
  border: 1.2mm solid #6e8ef5;
  border-radius: 5mm;
  background: #ffffff;
}

.sign-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sign-scan {
  font-size: 15pt;
  font-weight: 700;
  margin: 4mm 0 1.5mm;
}

.sign-how {
  font-size: 11pt;
  color: #333340;
  margin: 0 0 1mm;
}

.sign-brand {
  display: flex;
  align-items: center;
  gap: 2.5mm;
  margin: 5mm 0 0;
  font-size: 10pt;
  font-weight: 600;
  color: #1e3a8a;
}

/* The OneLoyal ring-and-dot. */
.sign-mark {
  width: 5mm;
  height: 5mm;
  border-radius: 50%;
  border: 0.9mm solid #1e3a8a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sign-mark::after {
  content: "";
  width: 1.8mm;
  height: 1.8mm;
  border-radius: 50%;
  background: #1e3a8a;
}

/* The poster: everything bigger. */
body[data-size="poster"] .sign-logo {
  width: 32mm;
  height: 32mm;
}

body[data-size="poster"] .sign-shop {
  font-size: 22pt;
}

body[data-size="poster"] .sign-title {
  font-size: 36pt;
}

body[data-size="poster"] .sign-reward {
  font-size: 20pt;
}

body[data-size="poster"] .sign-qr {
  width: 100mm;
  height: 100mm;
}

body[data-size="poster"] .sign-scan {
  font-size: 24pt;
}

body[data-size="poster"] .sign-how {
  font-size: 17pt;
}

body[data-size="poster"] .sign-brand {
  font-size: 14pt;
}

/* Table signs (A6, four per sheet, for table holders). Each sign sits inside its quarter
   with a white edge, so all four come out the same however straight the cut. Sizes are
   in --mm (a millimetre of an A6 sign), so the sign shrinks evenly if the page does when
   printing from a phone. */
body[data-size="table"] .sheet {
  flex-direction: row;
  flex-wrap: wrap;
}

.quarter {
  position: relative;
  width: 50%;
  height: 50%;
  container-type: size;
}

.quarter:nth-child(odd) {
  border-right: 0.3mm dashed #b8b8c4;
}

.quarter:nth-child(-n + 2) {
  border-bottom: 0.3mm dashed #b8b8c4;
}

.tsign {
  --mm: calc(100cqh / 148.5);
  position: absolute;
  inset: calc(6 * var(--mm));
  display: flex;
  flex-direction: column;
  border-radius: calc(3 * var(--mm));
  border: 0.3mm solid #dcdce2;
  overflow: hidden;
  background: #ffffff;
  text-align: center;
}

.tsign-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(6 * var(--mm)) calc(5 * var(--mm)) calc(5 * var(--mm));
}

.tsign-tag {
  margin: 0 0 calc(3.5 * var(--mm));
  padding: calc(1 * var(--mm)) calc(3.5 * var(--mm));
  border-radius: calc(4 * var(--mm));
  font-size: calc(3.7 * var(--mm));
  font-weight: 700;
}

.tsign .tsign-logo {
  width: calc(19 * var(--mm));
  height: calc(19 * var(--mm));
  margin: 0 0 calc(2.5 * var(--mm));
  border-radius: 50%;
  border: calc(0.9 * var(--mm)) solid #ffffff;
  background: #ffffff;
  object-fit: cover;
}

.tsign-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(6.5 * var(--mm));
  font-weight: 700;
}

.tsign-shop {
  margin: 0;
  font-size: calc(5.6 * var(--mm));
  font-weight: 700;
  line-height: 1.15;
}

.tsign-reward {
  margin: calc(1 * var(--mm)) 0 0;
  font-size: calc(3.8 * var(--mm));
}

.tsign-bottom {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #111111;
}

.tsign-scan {
  margin: 0 0 calc(2.5 * var(--mm));
  font-size: calc(4.4 * var(--mm));
  font-weight: 700;
}

.tsign-qr {
  width: calc(44 * var(--mm));
  height: calc(44 * var(--mm));
}

.tsign-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tsign-steps {
  margin-top: calc(3 * var(--mm));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(1.4 * var(--mm));
}

.tsign-step {
  display: flex;
  align-items: center;
  gap: calc(1.8 * var(--mm));
  margin: 0;
  font-size: calc(3.5 * var(--mm));
  font-weight: 600;
}

.tsign-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(4.6 * var(--mm));
  height: calc(4.6 * var(--mm));
  border-radius: 50%;
  background: #1e3a8a;
  color: #ffffff;
  font-size: calc(2.9 * var(--mm));
  font-weight: 700;
}

.tsign-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(1.6 * var(--mm));
  margin: 0;
  padding: calc(2.6 * var(--mm));
  background: #1e3a8a;
  color: #ffffff;
  font-size: calc(3.3 * var(--mm));
}

.tsign-foot b {
  font-size: calc(3.7 * var(--mm));
}

.tsign .tsign-mark {
  width: calc(4.2 * var(--mm));
  height: calc(4.2 * var(--mm));
  border: calc(0.8 * var(--mm)) solid #ffffff;
}

.tsign .tsign-mark::after {
  width: calc(1.5 * var(--mm));
  height: calc(1.5 * var(--mm));
  background: #ffffff;
}

/* Printing: only the sheet, at a fixed size that fits inside A4 even after the printer's
   own margins and a phone's header and footer (iPhones add these, ignore "shrink to fit"
   and misreport the page height), and never spilling onto a second page. Each counter-sign half takes exactly
   half; its sign turns to fit that half. */
@media print {
  html,
  body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: #ffffff;
  }
  .controls {
    display: none;
  }
  .sheet {
    box-shadow: none;
    zoom: 1 !important;
    width: 100%;
    height: 255mm;
    margin: 0;
    overflow: hidden;
    break-after: avoid;
  }
  .half {
    width: 100%;
    height: 50%;
    container-type: size;
  }
  .half .sign {
    width: 100cqh;
    height: 100cqw;
  }
}
