/* ============================================================
   Shared certificate styles
   ------------------------------------------------------------
   Used by cert/issue.html (staff) and cert/verify.html (public).
   Each site overrides the colour variables below to match its
   brand. Page-specific layout (the form, the verification card)
   is in <style> blocks inside the individual HTML pages.
   ============================================================ */

:root {
  /* Brand — overridden inline per site */
  --brand: #dc2721;
  --brand-deep: #a51d18;
  --ink: #1a1a1a;
  --ink-2: #3a3d44;
  --muted: #6b6f78;
  --line: #d8d9dd;
  --paper: #ffffff;
  --paper-soft: #faf9f6;
  --accent: var(--brand);
}

.cert-shell {
  min-height: 100vh;
  background: #ebe9e3;
  font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  padding: 32px 16px 64px;
  -webkit-font-smoothing: antialiased;
}

.cert-shell a { color: var(--brand); text-decoration: none; }
.cert-shell a:hover { text-decoration: underline; }

/* ----- Toolbar shown above the certificate ----- */
.cert-toolbar {
  max-width: 297mm;
  margin: 0 auto 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
}
.cert-toolbar .crumb { color: var(--muted); }
.cert-toolbar .crumb a { color: var(--ink-2); border-bottom: 1px dashed var(--line); padding-bottom: 1px; }
.cert-toolbar .crumb a:hover { color: var(--brand); }
.cert-toolbar button,
.cert-toolbar .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.cert-toolbar button:hover,
.cert-toolbar .btn:hover { border-color: var(--brand); color: var(--brand); }
.cert-toolbar .btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.cert-toolbar .btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.cert-toolbar .lang-toggle button { padding: 4px 10px; }
.cert-toolbar .lang-toggle button.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.cert-toolbar .dl-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.cert-toolbar .dl-buttons button { font-size: 12.5px; }

/* ============================================================
   The certificate paper
   ============================================================ */
.cert-page {
  width: 297mm;
  height: 210mm;
  max-width: 100%;
  margin: 0 auto;
  background: var(--paper-soft);
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}

.cert-frame {
  position: absolute;
  inset: 14mm;
  border: 1px solid var(--brand);
  opacity: .55;
  pointer-events: none;
}
.cert-frame::before,
.cert-frame::after {
  content: "";
  position: absolute;
  width: 18mm; height: 18mm;
  border: 1px solid var(--brand);
}
.cert-frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.cert-frame::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.cert-content {
  position: relative;
  z-index: 2;
  padding: 22mm 28mm 18mm;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.cert-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8mm;
}
.cert-logo img,
.cert-logo svg { height: 14mm; width: auto; }
.cert-brand {
  text-align: right;
  font-family: "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 4px;
  text-transform: uppercase;
  font-size: 9pt;
  color: var(--muted);
  line-height: 1.5;
}
.cert-brand strong { color: var(--ink); font-weight: 600; letter-spacing: 5px; }

.cert-body { flex: 1; text-align: center; padding-top: 4mm; }

.cert-eyebrow {
  letter-spacing: 8px;
  text-transform: uppercase;
  font-size: 11pt;
  color: var(--muted);
  margin-bottom: 4mm;
}
.cert-statement {
  font-size: 13pt;
  color: var(--muted);
  margin-bottom: 6mm;
  font-style: italic;
}
.cert-name {
  font-size: 42pt;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.005em;
  color: var(--ink);
  margin: 0 0 6mm;
  font-family: "Helvetica Neue", "Cormorant Garamond", "PingFang SC", serif;
}
.cert-award-label {
  font-style: italic;
  color: var(--muted);
  font-size: 12pt;
  margin-bottom: 3mm;
}
.cert-award {
  font-size: 22pt;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 6mm;
}
.cert-meta {
  color: var(--ink-2);
  font-size: 12pt;
  margin-bottom: 2mm;
}
.cert-meta strong { color: var(--ink); font-weight: 600; }
.cert-meta .sep { color: var(--line); margin: 0 6pt; }

.cert-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10mm;
  align-items: end;
  padding-top: 6mm;
  border-top: 1px solid var(--line);
  margin-top: 4mm;
}
.cert-foot-cell {
  font-size: 9pt;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.cert-foot-cell strong {
  display: block;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-size: 12pt;
  font-weight: 600;
  margin-top: 1mm;
}

.cert-qr-wrap { text-align: center; }
.cert-qr {
  width: 26mm; height: 26mm;
  margin: 0 auto 2mm;
  background: #fff;
  padding: 1.5mm;
  display: inline-block;
}
.cert-qr canvas,
.cert-qr img {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.cert-qr-id {
  font-family: ui-monospace, "SF Mono", Menlo, "Courier New", monospace;
  font-size: 9pt;
  letter-spacing: 1.5px;
  color: var(--ink);
}
.cert-qr-label {
  font-size: 7.5pt;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1mm;
}

.cert-signed { text-align: right; }
.cert-signed .sig {
  border-bottom: 1px solid var(--ink);
  min-width: 50mm;
  display: inline-block;
  padding-bottom: 1mm;
  margin-bottom: 1mm;
  font-style: italic;
  font-size: 12pt;
  color: var(--ink);
  font-family: "Cormorant Garamond", "Helvetica Neue", serif;
}

/* ----- Verification result banner ----- */
.cert-status {
  max-width: 297mm;
  margin: 0 auto 18px;
  padding: 14px 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.cert-status .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 999px;
  font-weight: 700;
  flex-shrink: 0;
}
.cert-status.is-valid .badge { background: #1d6f44; color: #fff; }
.cert-status.is-invalid .badge { background: #c0392b; color: #fff; }
.cert-status.is-info .badge { background: var(--ink); color: #fff; }
.cert-status .body strong { display: block; color: var(--ink); margin-bottom: 2px; }
.cert-status .body span { color: var(--muted); }

/* ----- Lookup form (verify.html when no params) ----- */
.cert-lookup {
  max-width: 540px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 4px 18px rgba(0,0,0,.04);
}
.cert-lookup h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--ink);
}
.cert-lookup p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.cert-lookup label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.cert-lookup textarea {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  resize: vertical;
}
.cert-lookup button {
  margin-top: 14px;
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}
.cert-lookup button:hover { background: var(--brand-deep); }
.cert-lookup .hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ----- Issue form (issue.html) ----- */
.issue-grid {
  max-width: 297mm;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 1.8fr;
  gap: 24px;
  align-items: start;
}
.issue-form {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
}
.issue-form h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--ink);
}
.issue-form .lede { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.issue-form .field { margin-bottom: 14px; }
.issue-form label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
.issue-form input,
.issue-form select,
.issue-form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  background: #fff;
}
.issue-form input:focus,
.issue-form select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.issue-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.issue-form .row .field { margin-bottom: 0; }

.issue-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.issue-form button {
  font: inherit;
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 11px 22px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.issue-form button.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}
.issue-form button:hover { background: var(--brand-deep); }
.issue-form button.secondary:hover { border-color: var(--ink); }

.issue-output {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  font-size: 13px;
  margin-top: 18px;
  display: none;
}
.issue-output.is-shown { display: block; }
.issue-output h3 { margin: 0 0 10px; font-size: 15px; color: var(--ink); }
.issue-output .row { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; margin-bottom: 6px; }
.issue-output .label { color: var(--muted); }
.issue-output .value { color: var(--ink); word-break: break-all; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.issue-output .copy-btn {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.issue-output .copy-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ----- Bilingual text helper ----- */
.t-en { display: inline; }
.t-zh { display: none; }
body[data-lang="zh"] .t-en { display: none; }
body[data-lang="zh"] .t-zh { display: inline; }

/* ----- Responsive scaling so the A4-landscape cert is readable on phones ----- */
@media (max-width: 900px) {
  .issue-grid { grid-template-columns: 1fr; }
  .cert-page { transform: scale(.55); transform-origin: top center; margin-bottom: -45vh; }
}
@media (max-width: 540px) {
  .cert-page { transform: scale(.42); margin-bottom: -55vh; }
  .cert-name { font-size: 38pt; }
}

/* ----- Print: A4 landscape, just the certificate ----- */
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: #fff; }
  .cert-shell { background: #fff; padding: 0; }
  .cert-toolbar, .cert-status, .cert-lookup, .issue-form, .issue-output { display: none !important; }
  .cert-page {
    box-shadow: none;
    width: 297mm; height: 210mm;
    transform: none !important;
    margin: 0 !important;
  }
  .issue-grid { display: block; }
}
