/* WhatsApp link generator (olano.sg/tools/whatsapp-link-generator).
   Only what the shared tools skin cannot express: the number row, the QR
   preview tile and the printable counter card / table tent. Colours come from
   /styles.css tokens, except the QR code itself and the printed card, which
   are always black on white because a QR code needs dark modules on a light
   ground to scan. */

/* The hero has no buttons here, so its full section padding left a gap of
   most of a phone screen above the tool. */
.seo-page .seo-hero:has(+ .section > .tool-app) {
  padding-bottom: 28px;
}

.wa-number-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 12px;
  align-items: end;
}

.wa-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wa-status {
  display: grid;
  gap: 8px;
}

.wa-status:empty {
  display: none;
}

.wa-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 0;
}

.wa-status-number {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.tool-code pre.is-placeholder {
  color: var(--text-3);
}

/* Fieldsets group the radio pill bars; the browser's frame is not wanted. */
.tool-app fieldset.tool-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.tool-app fieldset.tool-field > legend {
  margin-bottom: 6px;
  padding: 0;
}

.wa-qr-block {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.wa-qr {
  display: inline-flex;
  flex: 0 0 auto;
  line-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #ffffff;
}

/* The site's icon defaults stroke every svg; a QR code must have none. */
.wa-qr svg,
.wa-print-qr svg {
  display: block;
  stroke: none;
}

.wa-qr.is-empty {
  width: 200px;
  height: 200px;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--surface);
  line-height: 1.5;
  text-align: center;
}

.wa-qr-placeholder {
  margin: 0;
  color: var(--text-3);
  font-size: 13px;
}

.wa-qr-placeholder.is-error {
  color: var(--danger);
}

.wa-qr-side {
  display: grid;
  flex: 1 1 200px;
  gap: 12px;
  min-width: 0;
}

.wa-extras {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.article-prose code.wa-break {
  overflow-wrap: anywhere;
  word-break: break-all;
}

@media (max-width: 480px) {
  .wa-number-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The printable card is built by the script only when someone presses
   "Print card", and shown only while that print runs. Printing the page any
   other way prints the page. */
.wa-print-root {
  display: none;
}

@media print {
  @page {
    margin: 12mm;
  }

  html.wa-printing body > *:not(.wa-print-root) {
    display: none !important;
  }

  html.wa-printing,
  html.wa-printing body {
    background: #ffffff !important;
  }

  html.wa-printing .wa-print-root {
    display: block !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .wa-print-card {
    box-sizing: border-box;
    width: 120mm;
    margin: 0 auto;
    padding: 12mm 10mm;
    border: 0.4mm dashed #888888;
    border-radius: 4mm;
    background: #ffffff;
    color: #000000;
    font-family: var(--font-sans);
    text-align: center;
    break-inside: avoid;
  }

  .wa-print-heading {
    margin: 0 0 6mm;
    font-size: 20pt;
    font-weight: 700;
    line-height: 1.2;
  }

  .wa-print-qr svg {
    width: 80mm;
    height: 80mm;
    margin: 0 auto;
  }

  .wa-print-number {
    margin: 6mm 0 0;
    font-size: 18pt;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
  }

  .wa-print-line {
    margin: 3mm 0 0;
    color: #333333;
    font-size: 12pt;
  }

  /* Table tent: two copies on one sheet, the top one upside down, so the
     sheet folded along the dashed line stands with a code on each face. The
     pair fills the printable height (equal top and bottom margins), which
     puts the fold at the middle of an A4 or a Letter sheet alike. */
  html.wa-printing .wa-print-root.is-tent {
    display: flex !important;
    flex-direction: column;
    height: 100vh;
  }

  .wa-print-root.is-tent .wa-print-card {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    padding: 8mm;
    border: 0;
    border-radius: 0;
  }

  .wa-print-root.is-tent .wa-print-card:first-child {
    transform: rotate(180deg);
  }

  .wa-print-root.is-tent .wa-print-card + .wa-print-card {
    border-top: 0.4mm dashed #888888;
  }

  .wa-print-root.is-tent .wa-print-heading {
    margin-bottom: 4mm;
    font-size: 18pt;
  }

  .wa-print-root.is-tent .wa-print-qr svg {
    width: 65mm;
    height: 65mm;
  }

  .wa-print-root.is-tent .wa-print-number {
    margin-top: 4mm;
    font-size: 16pt;
  }
}
