/* ============================================================
   PORTE OUVERTE — certificate.css
   Certificate styles for screen preview and PDF/print output
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,700&family=Nunito:wght@400;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
  --cert-navy:      #0A0A0A;
  --cert-navy-mid:  #1C1C1C;
  --cert-gold:      #A42137;
  --cert-gold-lt:   #C42D48;
  --cert-blue-lt:   #80D9E0;
  --cert-white:     #FFFFFF;
  --cert-text-lt:   rgba(128, 217, 224, 0.75);
  --cert-border:    rgba(0, 173, 187, 0.5);
}

/* ══════════════════════════════════════
   CERTIFICATE WRAPPER (screen preview)
══════════════════════════════════════ */
.certificate-page {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  aspect-ratio: 297 / 210;   /* A4 landscape */
  background: var(--cert-navy);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 4rem;
  font-family: 'Nunito', sans-serif;
  color: var(--cert-white);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

/* ── Outer border ── */
.certificate-page::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 2px solid var(--cert-gold);
  pointer-events: none;
}

/* ── Inner border ── */
.certificate-page::after {
  content: '';
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(0,173,187,0.35);
  pointer-events: none;
}

/* ── Corner ornaments ── */
.cert-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--cert-gold);
  border-style: solid;
  opacity: 0.7;
}
.cert-corner-tl { top: 18px;  left: 18px;  border-width: 2px 0 0 2px; }
.cert-corner-tr { top: 18px;  right: 18px; border-width: 2px 2px 0 0; }
.cert-corner-bl { bottom: 18px; left: 18px;  border-width: 0 0 2px 2px; }
.cert-corner-br { bottom: 18px; right: 18px; border-width: 0 2px 2px 0; }

/* ── Background radial glow ── */
.cert-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%,   rgba(0,173,187,0.10) 0%, transparent 65%),
    radial-gradient(ellipse 40% 30% at 50% 100%,  rgba(0,173,187,0.06) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Logo ── */
.cert-logo {
  max-height: 64px;
  width: auto;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
}

/* ── Ministry lines ── */
.cert-ministry-1 {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cert-gold);
  position: relative; z-index: 1;
  margin-bottom: 0.2rem;
}

.cert-ministry-2 {
  font-family: 'Nunito', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--cert-blue-lt);
  position: relative; z-index: 1;
  margin-bottom: 0.5rem;
}

/* ── Divider ── */
.cert-divider {
  width: 55%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.4rem auto;
  position: relative; z-index: 1;
}

.cert-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--cert-gold), transparent);
}

.cert-divider-diamond {
  width: 6px; height: 6px;
  background: var(--cert-gold);
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* ── Main title ── */
.cert-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.2rem, 2.5vw, 1.8rem);
  font-style: italic;
  font-weight: 700;
  color: var(--cert-white);
  position: relative; z-index: 1;
  margin: 0.3rem 0 0.15rem;
  line-height: 1.2;
}

/* ── "Décerné à" label ── */
.cert-awarded-to {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cert-blue-lt);
  position: relative; z-index: 1;
  margin-bottom: 0.2rem;
}

/* ── Student name ── */
.cert-student-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  font-style: italic;
  font-weight: 700;
  color: var(--cert-gold);
  text-shadow: 0 0 40px rgba(0,173,187,0.3);
  position: relative; z-index: 1;
  line-height: 1.15;
  margin-bottom: 0.2rem;
}

.cert-name-underline {
  width: 60%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--cert-gold), transparent);
  margin: 0 auto 0.5rem;
  position: relative; z-index: 1;
}

/* ── Body text ── */
.cert-body-text {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(0.7rem, 1.2vw, 0.88rem);
  color: rgba(220, 230, 242, 0.9);
  line-height: 1.7;
  max-width: 65%;
  margin: 0 auto 0.3rem;
  position: relative; z-index: 1;
}

/* ── Course name ── */
.cert-course-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(0.85rem, 1.5vw, 1.1rem);
  font-weight: 700;
  color: var(--cert-white);
  position: relative; z-index: 1;
  margin-bottom: 0.3rem;
}

/* ── Grade badge ── */
.cert-grade-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--cert-gold), var(--cert-gold-lt));
  color: var(--cert-white);
  font-family: 'Nunito', sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.3rem 1.4rem;
  border-radius: 50px;
  letter-spacing: 0.05em;
  position: relative; z-index: 1;
  margin-bottom: 0.25rem;
  box-shadow: 0 4px 16px rgba(0,173,187,0.3);
}

/* ── Date ── */
.cert-date {
  font-family: 'Nunito', sans-serif;
  font-size: 0.72rem;
  font-style: italic;
  color: var(--cert-blue-lt);
  position: relative; z-index: 1;
  margin-bottom: 0.5rem;
}

/* ── Footer row (signature + seal) ── */
.cert-footer-row {
  width: 85%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--cert-border);
  position: relative; z-index: 1;
}

.cert-sig-block {
  text-align: center;
  width: 180px;
}

.cert-sig-img {
  max-height: 44px;
  max-width: 160px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.3rem;
}

.cert-sig-line {
  border-top: 1px solid var(--cert-blue-lt);
  width: 80%;
  margin: 0.25rem auto;
  opacity: 0.6;
}

.cert-sig-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cert-blue-lt);
  opacity: 0.7;
}

/* ── Quote footer ── */
.cert-quote {
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-style: italic;
  color: rgba(168, 196, 224, 0.4);
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 1;
}

/* ══════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════ */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body {
    margin: 0;
    padding: 0;
    background: white;
  }

  .certificate-page {
    width: 297mm;
    height: 210mm;
    max-width: none;
    aspect-ratio: auto;
    margin: 0;
    padding: 20mm 28mm;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Hide everything except the certificate */
  body > *:not(.cert-print-wrapper) { display: none !important; }
  .cert-print-wrapper { display: block !important; }

  @page {
    size: A4 landscape;
    margin: 0;
  }
}

/* ══════════════════════════════════════
   CERTIFICATE PREVIEW MODAL (in site)
══════════════════════════════════════ */
.cert-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.92);
  z-index: 9600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(6px);
}

.cert-preview-wrapper {
  width: 100%;
  max-width: 960px;
  position: relative;
}

.cert-preview-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ══════════════════════════════════════
   RESPONSIVE SCALING
══════════════════════════════════════ */
@media (max-width: 767px) {
  .certificate-page {
    padding: 1.5rem 1.25rem;
  }

  .cert-body-text { max-width: 90%; }
  .cert-footer-row { width: 95%; }
  .cert-sig-block { width: 130px; }

  .cert-student-name { font-size: 1.4rem; }
  .cert-title { font-size: 1.1rem; }
}
