/* ==========================================================================
   Certificate of Deposit / SKR — document styling
   Portrait A4 certificate with ornate navy border, script title,
   boxed information rows, seals and signature lines.
   Loaded by: lookup.php (result view) and certificate.php (print/PDF).
   ========================================================================== */

.cert-sheet {
  --cert-navy: #1c2a5e;
  --cert-navy-deep: #131c44;
  --cert-purple: #3a2f6e;
  --cert-gold: #c9962e;
  --cert-red: #b8322e;
  --cert-blue-ink: #2456a6;
  --cert-line: #d9deed;

  width: min(860px, 100%);
  margin-inline: auto;
  background:
    repeating-linear-gradient(90deg, rgba(28, 42, 94, .05) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, #ffffff 0%, #f7f8fc 100%);
  color: var(--ink);
}

/* ---------- Ornate border ------------------------------------------------ */

.cert-frame {
  position: relative;
  padding: clamp(8px, 1.6vw, 14px);
  background:
    repeating-linear-gradient(45deg, var(--cert-navy) 0 7px, var(--cert-purple) 7px 12px, var(--cert-navy) 12px 14px);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18), var(--shadow-m);
}

.cert-frame-inner {
  border: 2px solid var(--cert-gold);
  outline: 1px solid rgba(255, 255, 255, .55);
  outline-offset: -6px;
}

.cert-body {
  position: relative;
  margin: 10px;
  padding: clamp(20px, 4vw, 38px) clamp(18px, 4.5vw, 46px);
  background:
    repeating-linear-gradient(90deg, rgba(28, 42, 94, .04) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, #ffffff 0%, #fafbfe 100%);
  overflow: hidden;
}

.cert-corner {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 0 solid var(--cert-gold);
  opacity: .9;
}
.cert-corner.tl { top: 8px; left: 8px; border-top-width: 3px; border-left-width: 3px; }
.cert-corner.tr { top: 8px; right: 8px; border-top-width: 3px; border-right-width: 3px; }
.cert-corner.bl { bottom: 8px; left: 8px; border-bottom-width: 3px; border-left-width: 3px; }
.cert-corner.br { bottom: 8px; right: 8px; border-bottom-width: 3px; border-right-width: 3px; }

/* Faint watermark */
.cert-watermark {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: clamp(64px, 12vw, 118px);
  font-weight: 800;
  letter-spacing: .08em;
  color: rgba(28, 42, 94, .05);
  transform: rotate(-24deg);
  user-select: none;
  white-space: nowrap;
}

/* ---------- Header -------------------------------------------------------- */

.cert-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 16px;
}

.cert-logo {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #ffffff, #eef1f8 58%, #dbe2f1);
  border: 3px double var(--cert-navy);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
}
.cert-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.cert-logo .ic { width: 40px; height: 40px; color: var(--cert-navy); }

.cert-head-center { text-align: center; }

.cert-company {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 3.6vw, 30px);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cert-navy);
  line-height: 1.25;
}

.cert-tagline {
  margin: 2px 0 0;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cert-red);
}

.cert-contact {
  margin: 6px 0 0;
  font-size: .78rem;
  line-height: 1.5;
  color: var(--cert-blue-ink);
  opacity: .95;
}

.cert-ref { text-align: right; font-size: .74rem; color: var(--muted); line-height: 1.5; min-width: 0; }
.cert-ref .mono { font-size: .8rem; font-weight: 700; color: var(--cert-navy); letter-spacing: .04em; word-break: break-all; }

.cert-status {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 12px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.cert-status.ok   { color: #177e4e; background: #e8f5ee; }
.cert-status.warn { color: #b27513; background: #fcf3e2; }

/* ---------- Title --------------------------------------------------------- */

.cert-title-wrap { text-align: center; margin-top: clamp(14px, 3vw, 26px); }

.cert-title {
  margin: 0;
  font-family: "Great Vibes", "Segoe Script", cursive;
  font-size: clamp(34px, 6.4vw, 54px);
  font-weight: 400;
  color: var(--cert-red);
  line-height: 1.15;
}

.cert-title-rule {
  width: min(420px, 70%);
  height: 3px;
  margin: 8px auto 0;
  background: linear-gradient(90deg, transparent, var(--cert-red), var(--cert-gold), var(--cert-red), transparent);
  border-radius: 2px;
}

.cert-subtitle {
  margin: 8px 0 0;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--cert-navy);
  opacity: .85;
}

.cert-desc {
  max-width: 62ch;
  margin: clamp(12px, 2.6vw, 22px) auto 0;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: .88rem;
  line-height: 1.7;
  color: var(--text);
}

/* ---------- Information section ------------------------------------------- */

.cert-info {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: clamp(14px, 2.6vw, 26px);
  margin-top: clamp(16px, 3vw, 28px);
  align-items: start;
}

.cert-photo {
  width: 150px;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--cert-line);
  outline: 1px solid var(--cert-navy);
  outline-offset: 3px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 0;
}
.cert-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cert-photo figcaption {
  font-size: .62rem;
  text-align: center;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px;
}
.cert-photo .ph-empty { text-align: center; font-size: .72rem; color: var(--muted); padding: 10px; }
.cert-photo .ph-empty .ic { width: 28px; height: 28px; margin-bottom: 6px; color: var(--faint); }

.cert-fields { display: grid; gap: 9px; }

.cert-row { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; align-items: stretch; gap: 10px; }
.cert-row.wide { grid-template-columns: 1fr; }

.cert-label {
  display: flex;
  align-items: center;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--cert-navy);
}

.cert-value {
  min-height: 34px;
  padding: 7px 12px;
  border: 1.5px solid var(--cert-navy);
  border-radius: 3px;
  background: #fff;
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: .92rem;
  color: var(--ink);
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.cert-row.wide .cert-value { min-height: 52px; align-items: flex-start; }
.cert-value.mono { letter-spacing: .06em; font-weight: 700; }
.cert-value.pre { white-space: pre-line; font-weight: 400; font-size: .86rem; }

/* ---------- Lower area ----------------------------------------------------- */

.cert-lower {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(14px, 3vw, 30px);
  margin-top: clamp(18px, 3vw, 30px);
  font-size: .8rem;
}

.cert-block-title {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--cert-navy);
  border-bottom: 2px solid var(--cert-gold);
  display: inline-block;
  padding-bottom: 2px;
  margin-bottom: 8px;
}

.cert-custody p, .cert-notice p { margin: 0 0 3px; line-height: 1.55; color: var(--text); }
.cert-notice p strong { color: var(--cert-red); }
.cert-custody .mono { font-size: .78rem; }

/* ---------- Signatures & seals --------------------------------------------- */

.cert-signatures {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(40px, 8vw, 90px);
  margin-top: clamp(46px, 7vw, 64px);
  padding-top: clamp(56px, 9vw, 84px);
}

.cert-sign { text-align: center; position: relative; z-index: 2; }
.cert-sign-name {
  font-family: "Great Vibes", "Segoe Script", cursive;
  font-size: 1.7rem;
  color: var(--cert-navy-2, #102c49);
  line-height: 1;
  margin-bottom: 2px;
}
.cert-sign-line { border-top: 1.5px solid var(--ink); padding-top: 6px; }
.cert-sign-role {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text);
}
.cert-sign-date { font-size: .72rem; color: var(--muted); margin-top: 2px; }

.cert-seal {
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%) rotate(-8deg);
  width: clamp(96px, 15vw, 128px);
  height: auto;
  filter: drop-shadow(0 1px 1px rgba(184, 50, 46, .25));
  pointer-events: none;
  z-index: 3;
}

.cert-stamp {
  position: absolute;
  right: clamp(-8px, -1vw, 0px);
  top: clamp(-34px, -4vw, -20px);
  transform: rotate(-12deg);
  width: clamp(88px, 13vw, 112px);
  height: auto;
  opacity: .85;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 1;
}

/* ---------- Footer note ----------------------------------------------------- */

.cert-footnote {
  margin-top: clamp(16px, 3vw, 26px);
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: .78rem;
  color: var(--cert-red);
}

.cert-meta {
  margin-top: 6px;
  text-align: center;
  font-size: .68rem;
  letter-spacing: .05em;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- Actions under the on-screen certificate -------------------------- */

.cert-actions {
  max-width: min(860px, 100%);
  margin: 14px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* ---------- Responsive ------------------------------------------------------- */

@media (max-width: 640px) {
  /* Slimmer document chrome */
  .cert-frame { padding: 7px; }
  .cert-body { margin: 7px; padding: 18px 14px 22px; }
  .cert-corner { width: 22px; height: 22px; }

  /* Header stacks: logo → name → contacts → reference */
  .cert-head {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 10px;
  }
  .cert-logo { width: 62px; height: 62px; }
  .cert-logo .ic { width: 32px; height: 32px; }
  .cert-company { font-size: 19px; letter-spacing: .1em; }
  .cert-tagline { font-size: .68rem; letter-spacing: .18em; }
  .cert-contact { font-size: .72rem; max-width: 46ch; }

  /* Keep the reference + status — centred under the header */
  .cert-ref {
    display: block;
    text-align: center;
    border-top: 1px dashed var(--cert-line);
    padding-top: 8px;
    width: 100%;
  }
  .cert-status { margin-top: 4px; }

  /* Title & description */
  .cert-title { font-size: clamp(30px, 9vw, 38px); }
  .cert-subtitle { font-size: .64rem; letter-spacing: .22em; }
  .cert-desc { font-size: .8rem; }

  /* Information: photo centred, label stacked above each box */
  .cert-info { grid-template-columns: 1fr; justify-items: center; gap: 16px; }
  .cert-photo { width: 128px; }
  .cert-fields { width: 100%; gap: 10px; }
  .cert-row { grid-template-columns: 1fr; gap: 3px; }
  .cert-label { font-size: .64rem; letter-spacing: .09em; }
  .cert-value { min-height: 36px; font-size: .88rem; }

  /* Lower area stacks */
  .cert-lower { grid-template-columns: 1fr; gap: 16px; margin-top: 20px; font-size: .74rem; }

  /* Signatures flow vertically; seals sit inline instead of floating */
  .cert-signatures {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: 26px;
    padding-top: 0;
    gap: 0;
  }
  .cert-sign { margin-top: 22px; }
  .cert-seal {
    position: static;
    order: 2;
    transform: rotate(-8deg);
    width: 92px;
    margin: 14px auto 0;
    display: block;
  }
  .cert-sign:first-of-type { order: 1; }
  .cert-sign:last-of-type { order: 3; }
  .cert-stamp {
    position: static;
    order: 4;
    transform: rotate(-11deg);
    width: 84px;
    margin: -30px 8% 0 auto;
    display: block;
  }
  .cert-sign-name { font-size: 1.5rem; }

  .cert-footnote { font-size: .72rem; }
  .cert-meta { font-size: .62rem; padding: 0 4px; }
}

@media (max-width: 380px) {
  .cert-body { padding: 14px 10px 18px; }
  .cert-company { font-size: 17px; }
  .cert-title { font-size: 28px; }
  .cert-photo { width: 112px; }
  .cert-actions .btn { width: 100%; justify-content: center; }
}

/* ---------- Print / PDF ------------------------------------------------------
   True one-page A4 certificate: mm-based sizing, paired compact rows,
   exact colour printing. Verified with headless print-to-PDF. */

@media print {
  @page { size: A4 portrait; margin: 0; }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  .site-header, .page-hero, .section, footer.site-footer,
  .track-searchbar, .alert, .cert-actions, .privacy-note,
  .print-toolbar, .no-print {
    display: none !important;
  }

  .track-page-body { background: #fff; padding: 0; }
  .container, .result-shell { max-width: none; padding: 0; margin: 0; }
  main { padding: 0; }
  /* !important: the standalone-page chrome rule below comes later in this
     file and would otherwise win the cascade and blow print onto 2 pages */
  .cert-page { padding: 0 !important; min-height: 0 !important; background: #fff !important; }

  /* Keep every certificate block on one page */
  .cert-sheet,
  .cert-head, .cert-title-wrap, .cert-info,
  .cert-row, .cert-lower, .cert-signatures, footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Sheet sized to fit even printers that ignore @page rules
     (worst case: US Letter + ~10mm default margins).
     Print uses FLAT colours: tiled gradients/rasters are what made
     exported PDFs render with a dark background in some viewers. */
  .cert-sheet {
    width: 184mm;
    min-height: 240mm;
    margin: 0 auto;
    box-shadow: none;
    border-radius: 0;
    background: #fff !important;
    color: #111 !important;
  }
  .cert-frame {
    padding: 3.5mm;
    box-shadow: none;
    border-radius: 0;
    background: var(--cert-navy) !important;
  }
  .cert-frame-inner { padding: 1.8mm; border-width: 1px; outline: none; }
  .cert-body {
    padding: 4.5mm 7mm 4mm;
    margin: 3mm;
    background: #fff !important;
  }
  .cert-watermark {
    display: grid !important;
    font-size: 60pt;
    opacity: 1;
  }
  /* Corner ornaments are plain vector borders - safe and elegant in PDF */
  .cert-corner { width: 9mm; height: 9mm; border-width: 0 !important; opacity: 1; }
  .cert-corner.tl { top: 1.5mm; left: 1.5mm; border-top-width: 2px !important; border-left-width: 2px !important; }
  .cert-corner.tr { top: 1.5mm; right: 1.5mm; border-top-width: 2px !important; border-right-width: 2px !important; }
  .cert-corner.bl { bottom: 1.5mm; left: 1.5mm; border-bottom-width: 2px !important; border-left-width: 2px !important; }
  .cert-corner.br { bottom: 1.5mm; right: 1.5mm; border-bottom-width: 2px !important; border-right-width: 2px !important; }
  .cert-body { position: static; }

  /* Header */
  .cert-logo img, .cert-logo svg { width: 11mm; height: 11mm; }
  .cert-company { font-size: 13pt; letter-spacing: .16em; }
  .cert-tagline { font-size: 6pt; letter-spacing: .3em; margin-top: .6mm; }
  .cert-contact { font-size: 5.8pt; margin-top: .6mm; }
  .cert-ref { font-size: 6pt; line-height: 1.5; }
  .cert-ref .mono { font-size: 6.6pt; }
  .cert-status { font-size: 5.6pt; padding: .7mm 2.2mm; margin-top: .8mm; }

  /* Title */
  .cert-title { font-size: 20pt; margin-top: 1mm; }
  .cert-subtitle { font-size: 6.2pt; letter-spacing: .28em; }
  .cert-desc { margin-top: 1.5mm; font-size: 6pt; line-height: 1.35; }

  /* Information section — same stacked full-width rows as desktop */
  .cert-info { grid-template-columns: 24mm 1fr; gap: 4mm; margin-top: 2mm; }
  .cert-photo { width: 24mm; outline-offset: 1.5px; }
  .cert-photo figcaption { font-size: 4.4pt; padding: .8mm 0; }
  .cert-photo .ph-empty { font-size: 5pt; padding: 1.5mm; }

  /* Fields: identical structure to screen, proportionally smaller */
  .cert-fields { display: grid; gap: 1mm; }
  .cert-row { grid-template-columns: minmax(18mm, 26mm) 1fr; gap: 1.6mm; }
  .cert-label { font-size: 5.2pt; }
  .cert-value { min-height: 5.6mm; padding: .8mm 1.6mm; font-size: 6.8pt; border-width: 1px; }
  .cert-value.mono { font-size: 6.4pt; }
  .cert-value.pre { font-size: 6pt; }
  .cert-row.wide .cert-value { min-height: 9mm; }

  /* Lower area */
  .cert-lower { margin-top: 2mm; gap: 5mm; font-size: 5.8pt; }
  .cert-block-title { font-size: 5.6pt; margin-bottom: 1.2mm; }
  .cert-custody p, .cert-notice p { font-size: 5.8pt; line-height: 1.35; margin-bottom: .6mm; }
  .cert-custody .mono { font-size: 5.6pt; }

  /* Signatures & seals */
  .cert-signatures { margin-top: 3.5mm; padding-top: 5mm; gap: 12mm; }
  .cert-seal { width: 19mm; bottom: -3mm; }
  .cert-stamp {
    width: 17mm;
    top: -6mm;
    mix-blend-mode: normal !important;
    opacity: .9 !important;
  }
  .cert-sign-name { font-size: 15pt; }
  .cert-sign-role { font-size: 5.8pt; }
  .cert-sign-date { font-size: 6pt; }

  /* Footer */
  footer { margin-top: 1.5mm; }
  .cert-footnote { margin-top: 1.5mm; font-size: 6.2pt; }
  .cert-meta { margin-top: .8mm; font-size: 5.6pt; }
}

/* Standalone certificate.php page chrome */
.cert-page {
  min-height: 100vh;
  padding: 24px 16px 48px;
  background: var(--bg-alt, #f5f7fa);
}

.print-toolbar {
  max-width: 860px;
  margin: 0 auto 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.print-toolbar .pt-note { font-size: .82rem; color: var(--muted, #5e7183); }

/* Self-contained button styling for the standalone page
   (site.css is not loaded there). Scoped so the public site is unaffected. */
.print-toolbar .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body, Inter, system-ui, sans-serif);
  font-weight: 700;
  font-size: .9rem;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}
.print-toolbar .btn-primary {
  background: var(--primary, #0f4c81);
  color: #fff;
  box-shadow: var(--shadow-s, 0 1px 4px rgba(13,31,46,.14));
}
.print-toolbar .btn-primary:hover { background: var(--primary-600, #0c3f6b); }
.print-toolbar .ic { width: 17px; height: 17px; }
