/* Certificate page: exact A4 landscape, used both for preview (scaled) and print (1:1). */

.cert {
  --primary: #10243a;
  --accent: #c9a24a;
  --accent-deep: #8f6b1f;
  --paper: #fffdf6;
  --ink: #1d232b;
  --muted: #4a525c;

  position: relative;
  width: 297mm;
  height: 210mm;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(135deg, #fffaf0 0%, var(--paper) 45%, #fbf4e4 100%);
  color: var(--ink);
  font-family: 'Kantumruy Pro', sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  box-sizing: border-box;
}
.cert *,
.cert *::before,
.cert *::after { box-sizing: border-box; }

.cert.theme-maroon { --primary: #5e1820; --accent: #c9a24a; --accent-deep: #8f6b1f; }
.cert.theme-green { --primary: #123f2e; --accent: #c9a24a; --accent-deep: #8a6a20; }

/* Frame: thin gold line, thick colour band, thin gold line inside */
.cert::before {
  content: '';
  position: absolute;
  inset: 5mm;
  border: 0.35mm solid var(--accent);
}
.cert-frame {
  position: absolute;
  inset: 7mm;
  border: 2.6mm solid var(--primary);
}
.cert-frame::after {
  content: '';
  position: absolute;
  inset: 1.3mm;
  border: 0.45mm solid var(--accent);
}

.cert-corner {
  position: absolute;
  width: 24mm;
  height: 24mm;
  color: var(--accent);
}
.cert-corner svg { width: 100%; height: 100%; display: block; }
.cert-corner.tl { top: 9.6mm; left: 9.6mm; }
.cert-corner.tr { top: 9.6mm; right: 9.6mm; transform: scaleX(-1); }
.cert-corner.bl { bottom: 9.6mm; left: 9.6mm; transform: scaleY(-1); }
.cert-corner.br { bottom: 9.6mm; right: 9.6mm; transform: scale(-1, -1); }

.cert-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 105mm;
  height: 105mm;
  transform: translate(-50%, -46%);
  object-fit: contain;
  opacity: 0.06;
  pointer-events: none;
}

.cert-content {
  position: absolute;
  inset: 15mm 26mm 14mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Header */
.cert-logo { height: 17mm; width: auto; max-width: 40mm; object-fit: contain; margin-bottom: 1.5mm; }
.cert-org-kh { font-family: 'Moul', serif; font-size: calc(12.5pt * var(--fs-text, 1)); color: var(--primary); line-height: 1.7; }
.cert-org-en {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: calc(9pt * var(--fs-text, 1));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Title */
.cert-title-kh {
  margin: 3mm 0 0;
  font-family: 'Moul', serif;
  font-weight: 400;
  font-size: calc(30pt * var(--fs-title, 1));
  line-height: 1.55;
  color: var(--primary);
}
.cert-title-en {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: calc(14pt * var(--fs-title, 1));
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.cert-divider {
  display: flex;
  align-items: center;
  gap: 2.5mm;
  width: 80mm;
  margin: 2.5mm 0 3mm;
  color: var(--accent);
}
.cert-divider::before,
.cert-divider::after { content: ''; flex: 1; height: 0.35mm; background: currentColor; }
.cert-divider i { width: 2.4mm; height: 2.4mm; background: currentColor; transform: rotate(45deg); }

/* Body */
.cert-lead { margin: 0; font-size: calc(10.5pt * var(--fs-text, 1)); color: var(--muted); line-height: 1.6; }
.cert-lead em { font-family: 'Cormorant Garamond', serif; font-size: calc(12.5pt * var(--fs-text, 1)); }

.cert-name-kh,
.cert-name-en,
.cert-fit {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
}
.cert-name-kh { font-family: 'Moul', serif; font-size: calc(23pt * var(--fs-name, 1)); line-height: 1.75; color: var(--primary); margin-top: 1mm; }
.cert-name-en {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: calc(15pt * var(--fs-name, 1));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 2.5mm;
}

.cert-course-kh {
  max-width: 220mm;
  margin-top: 1mm;
  font-weight: 700;
  font-size: calc(14pt * var(--fs-course, 1));
  line-height: 1.6;
  color: var(--primary);
}
.cert-course-en {
  max-width: 220mm;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: calc(15pt * var(--fs-course, 1));
  line-height: 1.25;
  color: var(--ink);
}
.cert-period { margin-top: 1.5mm; font-size: calc(9.5pt * var(--fs-text, 1)); color: var(--muted); line-height: 1.55; }
.cert-period em { font-family: 'Cormorant Garamond', serif; font-size: calc(11pt * var(--fs-text, 1)); }

/* Footer: [signer 2] [QR + number] [date + signer 1] */
.cert-footer {
  margin-top: auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 42mm 1fr;
  align-items: end;
  column-gap: 6mm;
}
.cert-sign { text-align: center; font-size: calc(9.5pt * var(--fs-text, 1)); line-height: 1.5; }
.cert-sign .date-kh { color: var(--ink); }
.cert-sign .date-en { font-family: 'Cormorant Garamond', serif; font-style: italic; font-size: calc(11pt * var(--fs-text, 1)); color: var(--muted); }
.cert-sign .role-kh { margin-top: 1mm; font-family: 'Moul', serif; font-size: calc(10pt * var(--fs-text, 1)); line-height: 1.8; color: var(--primary); }
.cert-sign .role-en { font-family: 'Cinzel', serif; font-weight: 700; font-size: calc(7.5pt * var(--fs-text, 1)); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.cert-sign .space { position: relative; height: 15mm; }
/* Scanned signature sits on the signature line; the seal overlaps its left part, as on official papers */
.cert-sign .sig-img {
  position: absolute;
  left: 50%;
  bottom: -2.5mm;
  transform: translateX(-50%);
  max-width: 52mm;
  max-height: 19mm;
  object-fit: contain;
  z-index: 1;
}
.cert-sign .seal-img {
  position: absolute;
  left: 50%;
  /* stay above the content's bottom edge, or the overflow warning fires falsely */
  bottom: -1.5mm;
  width: 27mm;
  height: 27mm;
  margin-left: -31mm;
  object-fit: contain;
  opacity: 0.92;
  z-index: 2;
}
.cert-sign .name { display: inline-block; min-width: 55mm; padding-top: 1mm; border-top: 0.3mm solid var(--accent); font-weight: 700; font-size: calc(10.5pt * var(--fs-text, 1)); color: var(--ink); }

.cert-seal { display: flex; flex-direction: column; align-items: center; gap: 1.2mm; }
.cert-qr { width: 22mm; height: 22mm; padding: 1mm; background: #fff; border: 0.3mm solid var(--accent); }
.cert-qr svg { width: 100%; height: 100%; display: block; }
.cert-no { font-family: 'Cinzel', serif; font-weight: 700; font-size: calc(7.5pt * var(--fs-text, 1)); letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; }
