/* ============================================================
   Meet the Officer — mto-pdf.css
   Each PDF page uses the single pre-designed "Meet the Officer" A4
   letterpad (assets/mto-letterhead-a4.jpg) as a full-bleed background
   image — logo, watermark and the header/footer bars are all already
   baked into that artwork. Only the letter text itself is flowed on
   top of it, inside the plain area between the header's double green
   rule and the footer's dark green bar.

   These pages are built off-screen in the live DOM (see mto.js),
   rasterised page-by-page with html2canvas at ~200 DPI, and
   assembled into a real multi-page PDF with jsPDF. Nothing here is
   meant to be read directly by the visitor — it only needs to look
   right the instant before it is captured to an image.

   Pagination itself is no longer automatic (2026-09): the PHP source
   (includes-letter-content.php) places manual '[[PAGE_BREAK]]'
   markers inside the paragraph array, which mto_get_letter_html()
   turns into <div class="mto-page-break-marker"> — a purely
   structural tag, never shown, that mto.js treats as a hard page
   boundary. See that div's rule below.
   ============================================================ */

:root {
  --mto-pdf-green-dark: #0a3d20;
  --mto-pdf-green:      #145c33;
  --mto-pdf-accent:     #27ae60;
  --mto-pdf-ink:        #1a1a1a;
  --mto-pdf-muted:      #4b5f55;
}

/* Structural-only marker (see the file comment above) — mto.js reads
   it and strips it out before anything is added to a PDF page, so
   this is just a safety net in case the source HTML is ever rendered
   somewhere else first. It must never take up space or be visible. */
.mto-page-break-marker { display: none !important; }

/* ── Off-screen rig that hosts the pages while they're captured ──
   Rendered in-flow (not display:none, so layout/fonts/images are
   real) but pushed off the visible canvas. ─────────────────── */
#mto-pdf-rig {
  position: fixed;
  top: 0;
  left: -100000px;
  z-index: -1;
  background: #fff;
}

/* Off-screen measuring lane used to size each content block before
   it is assigned to a page. Same width as a page's content column.
   `overflow: hidden` gives it its own block-formatting context so
   child margins never collapse into it — matching .mto-pdf-content
   below exactly, so a measurement here means the same thing it will
   on the real page. */
#mto-pdf-measure {
  position: fixed;
  top: 0;
  left: -100000px;
  visibility: hidden;
  overflow: hidden;
}

/* ── One A4 page ─────────────────────────────────────────────
   Fixed pixel width/height are set inline by mto.js (computed from
   mm at 96 CSS-px/in so html2canvas's `scale` option lands the
   raster output at the requested DPI). The letterpad image is set
   as an exact-fit background — it is itself an A4-proportioned
   image (2480×3507px), so `100% 100%` never distorts it. ────── */
.mto-pdf-page {
  position: relative;
  overflow: hidden;
  background-color: #ffffff;
  background-repeat: no-repeat;
  background-position: top left;
  background-size: 100% 100%;
  font-family: "Noto Serif Malayalam", "Noto Sans Malayalam", serif;
  color: var(--mto-pdf-ink);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* ── Flowed letter content ───────────────────────────────────
   Positioned to sit entirely inside the letterpad's plain area —
   below the header's double green rule (~55.6mm from the top,
   plus an extra 1cm margin added per the 2026-09 alignment fix, so
   content starts at 66mm). The bottom stop is computed in mto.js
   (CONTENT_PAD_BOTTOM_PX — see the comment there), not hardcoded
   here: the content column runs down to ~264.3mm, never past the
   footer's ~268.3mm ruled top edge. Each page's content is now a
   manually-defined '[[PAGE_BREAK]]' section (see the file comment
   up top), not an automatically-flowed slice of the letter, so
   there is no longer a line-level widow/orphan guard here — mto.js
   instead measures each manual section against this box and logs a
   console warning if one doesn't fit. ── */
.mto-pdf-content {
  position: absolute;
  top: 66mm;
  left: 16mm;
  width: 178mm;
  z-index: 1;
}
.mto-pdf-content > *:first-child { margin-top: 0; }

/* Every piece of the letter text renders at a single consistent size
   (2026-09: 12.5pt → 11.5pt, then → 10.5pt in this pass), with
   justified alignment and normal (not double-spaced) line spacing —
   per the print-finalisation spec. Page count is no longer a function
   of this font size: it's fixed by the manual '[[PAGE_BREAK]]'
   markers in includes-letter-content.php (see mto.js), so shrinking
   the text here only gives each of those manually-defined pages more
   breathing room — it never changes how many pages there are. */
.mto-pdf-content .mto-letter-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10.5pt;
  line-height: 1.4;
  font-family: "Noto Sans Malayalam", sans-serif;
  margin: 6pt 0 4pt;
  color: var(--mto-pdf-green-dark);
  font-weight: 700;
}
.mto-pdf-content .mto-letter-to {
  background: #f4faf6;
  border: 1.4px solid #bfe3cc;
  border-left: 4px solid var(--mto-pdf-green-dark);
  border-radius: 4px;
  padding: 7pt 13pt;
  margin-bottom: 8pt;
  font-size: 10.5pt;
  line-height: 1.4;
  text-align: justify;
}
.mto-pdf-content .mto-letter-to p { margin: 0; }
.mto-pdf-content .mto-salutation {
  font-size: 10.5pt; line-height: 1.4; font-weight: 700; color: var(--mto-pdf-green-dark); margin: 6pt 0 8pt;
}
.mto-pdf-content .mto-letter-subject {
  background: #fff8e1;
  border-left: 4px solid #d99400;
  border-radius: 0 6px 6px 0;
  padding: 7pt 13pt;
  margin-bottom: 10pt;
  font-size: 10.5pt;
  line-height: 1.4;
  text-align: justify;
}
.mto-pdf-content .mto-subject-label {
  font-weight: 700; color: #7a5500; font-family: "Noto Sans Malayalam", sans-serif;
}
.mto-pdf-content p.mto-pdf-para {
  font-size: 10.5pt;
  line-height: 1.4;
  margin: 0 0 6pt;
  text-align: justify;
}
.mto-pdf-content .mto-valediction {
  font-size: 10.5pt; line-height: 1.4; font-weight: 700; color: var(--mto-pdf-green-dark); margin: 4pt 0 6pt;
}
/* Row/block padding trimmed (2026-09 compaction pass) so the sender
   info table + signature row reliably stay on the same page as
   whatever precedes them, instead of occasionally spilling onto a
   page of their own. Font-size/line-height are untouched — the
   10.5pt/1.4, non-double-spaced spec still applies to every cell. */
.mto-pdf-content .mto-sender-block {
  border: 1.4px solid var(--mto-pdf-green-dark);
  border-radius: 8px;
  padding: 5pt 10pt;
  background: #fafcfa;
  margin-top: 2pt;
}
.mto-pdf-content .mto-sig-table { width: 100%; border-collapse: collapse; }
.mto-pdf-content .mto-sl { width: 130px; color: var(--mto-pdf-green-dark); font-weight: 700; font-size: 10.5pt; line-height: 1.4; vertical-align: top; padding: 1pt 6pt; }
.mto-pdf-content .mto-sig-table td { font-size: 10.5pt; line-height: 1.4; vertical-align: top; padding: 1pt 6pt; }
.mto-pdf-content .mto-mid { color: #8a6100; letter-spacing: 1px; }
.mto-pdf-content .mto-sig-row { display: flex; gap: 26px; margin-top: 4pt; padding-top: 4pt; border-top: 1px dashed #aaa; }
.mto-pdf-content .mto-sig-cell { font-size: 10.5pt; line-height: 1.4; color: var(--mto-pdf-green-dark); font-weight: 700; flex: 1; }

/* ── Reference/page tag, pinned to the page foot ──────────────
   The only thing besides the letter text placed on top of the
   letterpad image. No longer part of the flowing content column —
   pinned directly to the page itself, 5mm below the letterpad's own
   printed footer box (which spans ~268.3mm–~279.4mm from the top),
   so it always lands in the same spot regardless of how much letter
   text is on a given page. ("bottom: 12.5mm" = 297mm page height −
   279.4mm footer-box-bottom − 5mm gap ≈ 12.5mm from the page foot.) */
.mto-pdf-page-tag {
  position: absolute;
  left: 16mm;
  right: 16mm;
  bottom: 12.5mm;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: "Noto Sans Malayalam", sans-serif;
  font-size: 8pt;
  line-height: 1.3;
  color: var(--mto-pdf-muted);
}
