/*
 * lc-print.css — print-ready styling for the BMC School Leaving Certificate
 * rendered by components/LeavingCertificate.tsx.
 *
 * - A4 page geometry with government/parchment aesthetic on screen.
 * - Devanagari- and Nastaliq-friendly serif fallbacks for mr/hi/ur.
 * - [dir="rtl"] overrides so Urdu mirrors correctly.
 * - @media print forces a clean white single A4 page.
 */

:root {
  --lc-cream: #fdf6e3;
  --lc-paper: #fffdf7;
  --lc-ink: #1f1a14;
  --lc-muted: #5a5142;
  --lc-gold: #b08d2f;
  --lc-gold-soft: #d9c48a;
  --lc-maroon: #6e1f1f;
  --lc-dotted: var(--lc-muted);
  --lc-serif: "Noto Serif", "Noto Serif Devanagari", "Noto Nastaliq Urdu",
    "Tiro Devanagari Marathi", "Mangal", serif;
}

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

.lc-page {
  box-sizing: border-box;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 16mm 16mm 14mm;
  background: var(--lc-cream);
  color: var(--lc-ink);
  font-family: var(--lc-serif);
  font-size: 11.5pt;
  line-height: 1.9;
  border: 2px solid var(--lc-gold-soft);
}

.lc-page *,
.lc-page *::before,
.lc-page *::after {
  box-sizing: border-box;
}

/* ── Header band ──────────────────────────────────────────────────────── */
.lc-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--lc-gold);
}

.lc-crest {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
}
.lc-crest img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lc-header-titles {
  flex: 1 1 auto;
  text-align: center;
}

.lc-management {
  font-size: 11pt;
  font-weight: 600;
  color: var(--lc-muted);
}

.lc-title {
  margin: 2px 0 0;
  font-size: 17pt;
  font-weight: 700;
  color: var(--lc-maroon);
  letter-spacing: 0.3px;
}

.lc-serial {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 12pt;
}

.lc-serial-label {
  font-size: 9.5pt;
  color: var(--lc-muted);
}

.lc-serial-no {
  font-weight: 700;
  color: var(--lc-maroon);
  letter-spacing: 1px;
}

/* ── Sections ─────────────────────────────────────────────────────────── */
.lc-school,
.lc-student {
  margin-top: 6px;
}

.lc-subtitle {
  margin: 10px 0 6px;
  padding: 3px 0;
  text-align: center;
  font-size: 13pt;
  font-weight: 700;
  color: var(--lc-maroon);
  border-top: 1px solid var(--lc-gold-soft);
  border-bottom: 1px solid var(--lc-gold-soft);
}

/* ── Field rows ───────────────────────────────────────────────────────── */
.lc-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.lc-field {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-width: 130px;
  margin: 1px 0;
}

.lc-field-block {
  width: 100%;
}

.lc-label {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--lc-ink);
}

.lc-value {
  flex: 1 1 auto;
  min-width: 1ch;
  padding: 0 4px;
  border-bottom: 1px dotted var(--lc-dotted);
  text-align: start;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Certifying clause ────────────────────────────────────────────────── */
.lc-clause {
  margin: 14px 0 0;
  font-size: 10.5pt;
  line-height: 1.7;
  text-align: justify;
  color: var(--lc-ink);
}

/* ── Footer + signatures ──────────────────────────────────────────────── */
.lc-footer {
  margin-top: 18px;
}

.lc-signatures {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 36px;
  gap: 24px;
}

.lc-sign {
  flex: 0 0 auto;
  text-align: center;
}

.lc-sign-line {
  width: 180px;
  border-top: 1px solid var(--lc-ink);
  margin-bottom: 4px;
}

.lc-sign-label {
  font-size: 10.5pt;
  font-weight: 600;
}

/* ── RTL overrides (Urdu) ─────────────────────────────────────────────── */
.lc-page[dir="rtl"] .lc-value {
  text-align: start; /* logical; resolves to right under rtl */
}

.lc-page[dir="rtl"] .lc-serial {
  align-items: flex-start;
}

.lc-page[dir="rtl"] .lc-clause {
  text-align: justify;
}

/* ── Print ────────────────────────────────────────────────────────────── */
@media print {
  html,
  body {
    margin: 0;
    background: #fff;
  }

  .lc-page {
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
    background: #fff;
    border: none;
    page-break-after: avoid;
  }

  .lc-crest {
    background: var(--lc-paper);
  }

  /* Ensure accent colors survive print drivers. */
  .lc-title,
  .lc-subtitle,
  .lc-serial-no {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
