/* ============================================
   Certificate of Completion — print-ready
   ──────────────────────────────────────────
   Modern, accessible, verifiable certificate.
   Screen: centered on dark page with action bar.
   Print:  A4 landscape, exact colors, controls hidden.
   ============================================ */

:root {
  --cert-ink:       #11261c;   /* deep green-black text */
  --cert-ink-soft:  #4a5b52;
  --cert-paper:     #fffdf7;   /* warm paper */
  --cert-paper-2:   #f6f3e9;
  --cert-gold:      #b8893b;
  --cert-gold-soft: #e8d9b5;
  --cert-green:     #00a855;
  --cert-green-dk:  #00351f;
  --cert-line:      rgba(17, 38, 28, 0.14);
}

/* ── Page shell (screen only) ── */
.cert-page {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(0,204,102,0.10), transparent 60%),
    var(--bg-primary, #000);
  padding: clamp(1rem, 4vw, 3rem) 1rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.cert-status {
  color: var(--text-secondary, #bbb);
  text-align: center;
  padding: 4rem 1rem;
  font-size: 1rem;
}

/* Mount stretches full width so the sheet (max-width 1000) can center */
#cert-mount {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* ── Action bar (screen only) ── */
.cert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: center;
  width: 100%;
  max-width: 1000px;
}
.cert-actions .btn { white-space: nowrap; }

/* ── The certificate sheet ── */
.certificate {
  position: relative;
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 1.414 / 1;            /* A4 landscape */
  background:
    linear-gradient(135deg, var(--cert-paper) 0%, var(--cert-paper-2) 100%);
  color: var(--cert-ink);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 2px 0 rgba(255,255,255,0.6) inset;
  overflow: hidden;
  container-type: inline-size;
  font-family: var(--font-ar-primary, 'GretaArabic', system-ui, sans-serif);
}
html[lang="en"] .certificate {
  font-family: var(--font-en-secondary, 'CenturyGothic', system-ui, sans-serif);
}

/* Ornamental double frame */
.cert-frame {
  position: absolute;
  inset: 2.4cqw;
  border: 2px solid var(--cert-gold);
  border-radius: 6px;
  pointer-events: none;
}
.cert-frame::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--cert-gold-soft);
  border-radius: 4px;
}

/* Subtle guilloché / watermark */
.cert-watermark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0.05;
  pointer-events: none;
}
.cert-watermark img { width: 46%; filter: grayscale(1); }

/* Corner flourishes */
.cert-corner {
  position: absolute;
  width: 7cqw; height: 7cqw;
  border: 0 solid var(--cert-gold);
  pointer-events: none;
}
.cert-corner.tl { top: 3.4cqw; inset-inline-start: 3.4cqw; border-top-width: 3px; border-inline-start-width: 3px; }
.cert-corner.tr { top: 3.4cqw; inset-inline-end: 3.4cqw; border-top-width: 3px; border-inline-end-width: 3px; }
.cert-corner.bl { bottom: 3.4cqw; inset-inline-start: 3.4cqw; border-bottom-width: 3px; border-inline-start-width: 3px; }
.cert-corner.br { bottom: 3.4cqw; inset-inline-end: 3.4cqw; border-bottom-width: 3px; border-inline-end-width: 3px; }

/* Content layout */
.cert-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: 4.6cqw 7cqw 5.2cqw;
  display: flex;
  flex-direction: column;
  text-align: center;
}

/* Header — standalone, centered logo */
.cert-head {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .8cqw;
}
.cert-head img { height: 5.4cqw; width: auto; }

.cert-eyebrow {
  margin-top: .4cqw;
  font-size: 1.45cqw;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--cert-gold);
  font-weight: 700;
}
.cert-title {
  font-size: 3.9cqw;
  font-weight: 800;
  color: var(--cert-green-dk);
  margin: .15cqw 0 .1cqw;
  line-height: 1.05;
}
html[lang="en"] .cert-title { font-family: var(--font-en-primary, 'Chonburi', Georgia, serif); }

.cert-rule {
  width: 14cqw; height: 3px;
  margin: .7cqw auto 1cqw;
  background: linear-gradient(90deg, transparent, var(--cert-gold), transparent);
}

.cert-presented { font-size: 1.6cqw; color: var(--cert-ink-soft); }

.cert-name {
  font-size: 4.4cqw;
  font-weight: 800;
  color: var(--cert-ink);
  margin: .6cqw auto .3cqw;
  padding-bottom: .8cqw;
  border-bottom: 2px solid var(--cert-line);
  max-width: 78%;
  line-height: 1.1;
}
html[lang="en"] .cert-name { font-family: var(--font-en-primary, 'Chonburi', Georgia, serif); }

.cert-body {
  font-size: 1.6cqw;
  color: var(--cert-ink-soft);
  line-height: 1.55;
  max-width: 82%;
  margin: 1cqw auto 0;
}
.cert-course {
  color: var(--cert-green-dk);
  font-weight: 800;
  font-size: 2.1cqw;
  display: block;
  margin: .4cqw 0;
}

/* Meta chips (hours / outcome / standards) */
.cert-meta {
  display: flex;
  gap: 1.2cqw;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.1cqw;
}
.cert-meta .chip {
  font-size: 1.35cqw;
  color: var(--cert-ink);
  background: rgba(0,168,85,0.08);
  border: 1px solid rgba(0,168,85,0.28);
  border-radius: 999px;
  padding: .5cqw 1.4cqw;
  font-weight: 600;
}

/* Bottom group (signatures + verification) pinned to the foot */
.cert-bottom { margin-top: auto; }

/* Footer: date · seal · signature */
.cert-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 2cqw;
  padding-top: 1.6cqw;
}
.cert-sigblock { text-align: center; }
.cert-sigline {
  font-size: 2.6cqw;
  color: var(--cert-green-dk);
  font-weight: 700;
  line-height: 1;
  margin-bottom: .4cqw;
}
html[lang="en"] .cert-sig-name { font-family: var(--font-en-primary, 'Chonburi', Georgia, serif); }
.cert-sigblock .ln {
  border-top: 1.5px solid var(--cert-ink);
  width: 80%;
  margin: 0 auto .5cqw;
}
.cert-sigblock .lbl { font-size: 1.3cqw; color: var(--cert-ink-soft); }
.cert-sigblock .lbl strong { color: var(--cert-ink); display: block; font-size: 1.45cqw; }

/* Official seal — smaller, lifted above the signature baseline */
.cert-seal {
  width: 8.5cqw; height: 8.5cqw;
  align-self: center;
  margin-bottom: 2cqw;
  position: relative;
  display: grid;
  place-items: center;
}
.cert-seal svg { width: 100%; height: 100%; }

/* Verification strip */
.cert-verify {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 1.4cqw;
  justify-content: space-between;
  margin-top: 1.4cqw;
  padding-top: 1.2cqw;
  border-top: 1px solid var(--cert-line);
  text-align: start;
}
.cert-verify .qr {
  width: 7.5cqw; height: 7.5cqw;
  flex-shrink: 0;
  background: #fff;
  padding: .4cqw;
  border-radius: 6px;
  border: 1px solid var(--cert-line);
}
.cert-verify .qr svg { width: 100%; height: 100%; display: block; }
.cert-verify .vtext { flex: 1; min-width: 0; font-size: 1.25cqw; color: var(--cert-ink-soft); line-height: 1.6; }
.cert-verify .vtext .cid {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-weight: 700;
  color: var(--cert-ink);
  font-size: 1.4cqw;
  letter-spacing: .5px;
}
.cert-verify .vtext .url { color: var(--cert-green); word-break: break-all; }
.cert-verify .vnote { font-size: 1.05cqw; color: var(--cert-ink-soft); opacity: .85; }

/* ── Print ──
   نُبقي الشهادة داخل المساحة القابلة للطباعة مع هامش أمان، فلا تفيض
   آخر سطر (شريط التحقّق) إلى صفحة ثانية حتى لو فرض المتصفّح هوامش افتراضية.
   الأبعاد 263×186مم تحافظ على نسبة A4 الأفقية (1.414) وتترك ~17مم أفقيًا
   و~12مم رأسيًا — أكبر من أي هامش طباعة افتراضي. */
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body {
    width: auto; height: auto;
    margin: 0 !important; padding: 0 !important;
    background: #fff !important;
    overflow: hidden !important;
  }
  #site-header, #site-footer, .cert-actions, .cert-status, .skip-link { display: none !important; }
  .cert-page {
    padding: 0 !important; margin: 0 !important;
    min-height: 0 !important; gap: 0 !important;
    display: block !important; background: #fff !important;
  }
  #cert-mount { width: auto !important; height: auto !important; display: block !important; }
  .certificate {
    width: 263mm !important; height: 186mm !important; max-width: none !important;
    aspect-ratio: auto !important;
    margin: 12mm auto !important;
    border-radius: 0 !important; box-shadow: none !important;
    overflow: hidden !important;
    page-break-after: avoid; page-break-inside: avoid; break-inside: avoid;
  }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ── Small screens: keep readable, scale down gracefully ── */
@media (max-width: 560px) {
  .cert-eyebrow { letter-spacing: .2em; }
}

/* ============================================
   Verification page
   ============================================ */
.verify-shell {
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1rem 5rem;
  text-align: center;
}
.verify-shell h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin: 0 0 .5rem; }
.verify-shell .lead { color: var(--text-secondary); margin-bottom: 1.75rem; }
.verify-box {
  display: flex; gap: .5rem; max-width: 460px; margin: 0 auto 1.5rem;
}
.verify-box .input { flex: 1; text-align: start; }
#verify-result { display: none; }
.verify-card {
  text-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 1rem;
  padding: 1.75rem 1.5rem;
  margin-top: 1rem;
}
.verify-card .vbadge {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.7rem; font-weight: 800;
  margin: 0 auto 1rem;
}
.verify-card .vtitle { text-align: center; margin: 0 0 1rem; font-size: 1.3rem; }
.verify-card.tone-ok    { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.verify-card.tone-ok    .vbadge { background: var(--accent-soft); color: var(--accent); }
.verify-card.tone-warn  .vbadge { background: rgba(184,137,59,0.15); color: #d2a14f; }
.verify-card.tone-bad   { border-color: rgba(255,107,107,0.5); }
.verify-card.tone-bad   .vbadge { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.verify-card .vmsg { color: var(--text-secondary); line-height: 1.7; margin: 0 0 1rem; }
.vdetails { border-top: 1px solid var(--border-subtle); }
.vrow {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .7rem 0; border-bottom: 1px solid var(--border-subtle); font-size: .95rem;
}
.vrow .vlabel { color: var(--text-tertiary); }
.vrow .vval { font-weight: 700; text-align: end; }
.verify-card .vfoot {
  margin: 1.1rem 0 0; font-size: .8rem; color: var(--text-tertiary);
  text-align: center; line-height: 1.6;
}
