/* ==========================================================
   GOOGLE FONTS — loaded via PHP enqueue
   Great Vibes          → MTL signature lettering
   Cormorant Garamond   → certificate name + body (readable serif)
   Cinzel               → headings / titles (decorative caps)
   ========================================================== */

:root {
    --bmc-gold:         #c8a64d;
    --bmc-gold-deep:    #a8862f;
    --bmc-gold-light:   #e8d08c;
    --bmc-cream:        #fefcf3;
    --bmc-cream-mid:    #f8f2e3;
    --bmc-navy:         #1f2d3d;
    --bmc-brown:        #7b4f18;
    --bmc-muted:        #7f8c8d;
    --bmc-rose:         #d4789a;
    --bmc-rose-light:   #e8b4c8;
    --font-script:      'Great Vibes', cursive;
    --font-serif:       'Cormorant Garamond', Georgia, serif;
    --font-display:     'Cinzel', Georgia, serif;
}

/* ==========================================================
   FORM UI
   ========================================================== */
.bmc-wrap {
    max-width: 640px;
    margin: 60px auto;
    padding: 44px 38px;
    background: linear-gradient(180deg, #fffefb 0%, #fbf7ef 100%);
    border: 1px solid #eadfc4;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.07);
    font-family: var(--font-serif);
    position: relative;
    overflow: hidden;
}

.bmc-wrap::before {
    content: "";
    position: absolute;
    inset: 14px;
    border: 1px solid rgba(200,166,77,.22);
    border-radius: 18px;
    pointer-events: none;
}

.bmc-wrap h2 {
    text-align: center;
    color: var(--bmc-navy);
    font-size: 32px;
    font-family: var(--font-display);
    line-height: 1.2;
    margin: 0 0 14px;
    font-weight: 700;
    letter-spacing: .8px;
}

.bmc-subtext {
    text-align: center;
    color: #7b7b7b;
    font-size: 15px;
    line-height: 1.9;
    margin: 0 auto 30px;
    max-width: 500px;
}

.bmc-badge-wrap { text-align: center; margin-bottom: 20px; }

.bmc-badge {
    display: inline-block;
    padding: 8px 18px;
    background: rgba(200,166,77,.10);
    color: var(--bmc-gold-deep);
    border: 1px solid rgba(200,166,77,.28);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
}

.bmc-field { margin-bottom: 22px; }

.bmc-field label {
    display: block;
    font-size: 12px;
    color: var(--bmc-navy);
    margin-bottom: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
}

.bmc-field input[type=text],
.bmc-field input[type=email],
.bmc-field input[type=file] {
    width: 100%;
    padding: 16px 18px;
    border: 1.5px solid #ddd8c8;
    border-radius: 16px;
    font-size: 15px;
    box-sizing: border-box;
    background: #fff;
    color: #3c3c3c;
    transition: all .25s ease;
    font-family: Arial, sans-serif;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.02);
}

.bmc-field input[type=file] {
    background: #fffdf8;
    padding: 14px 16px;
    cursor: pointer;
}

.bmc-field input::placeholder { color: #a3a3a3; }

.bmc-field input:focus {
    border-color: var(--bmc-gold);
    box-shadow: 0 0 0 4px rgba(200,166,77,.12);
    outline: none;
    background: #fffefc;
}

.bmc-btn {
    width: 100%;
    padding: 17px 20px;
    background: linear-gradient(135deg, var(--bmc-navy), #30465d);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all .28s ease;
    box-shadow: 0 14px 30px rgba(31,45,61,.18);
    letter-spacing: .4px;
    font-family: Arial, sans-serif;
}

.bmc-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--bmc-gold-deep), var(--bmc-gold));
    color: #1d1d1d;
}

.bmc-btn:disabled {
    background: #a7adb4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    color: #fff;
}

.bmc-msg {
    padding: 14px 18px;
    border-radius: 14px;
    margin-top: 18px;
    font-size: 14px;
    text-align: center;
    display: none;
    font-family: Arial, sans-serif;
    border: 1px solid transparent;
    line-height: 1.7;
}

.bmc-msg.error   { background: #fdeeee; color: #b53a3a; border-color: #f2c6c6; display: block; }
.bmc-msg.success { background: #eef8f0; color: #1d6b35; border-color: #cfe8d5; display: block; }
.bmc-msg.info    { background: #fff8e6; color: #8a6d1f; border-color: #ead9a5; display: block; }

#bmc-preview-wrap {
    display: none;
    text-align: center;
    margin-bottom: 20px;
    padding: 22px;
    background: #fffdf8;
    border: 1px dashed rgba(200,166,77,.45);
    border-radius: 18px;
}

#bmc-img-preview {
    max-width: 180px;
    width: 100%;
    border-radius: 18px;
    border: 4px solid var(--bmc-gold);
    box-shadow: 0 14px 32px rgba(0,0,0,.08);
}

/* spacers between multiple certs */
.cert-spacer     { height: 56px; }
.cert-spacer--sm { height: 20px; }

/* ==========================================================
   PER-CERT ACTION BAR
   ========================================================== */
.bmc-cert-actions-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 1000px;
    margin: 0 auto 14px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #fefcf3, #f8f2e4);
    border: 1px solid rgba(200,166,77,.30);
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,.05);
}

.bmc-cert-actions-bar--all {
    background: linear-gradient(135deg, var(--bmc-navy), #30465d);
    border-color: transparent;
}

.bmc-cert-actions-bar--all .cert-bar-btn--dl {
    background: var(--bmc-gold);
    color: #1a1a1a;
    flex: 1;
    text-align: center;
    font-size: 15px;
}

.cert-bar-label {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--bmc-gold-deep);
    margin-right: auto;
}

.bmc-cert-actions-bar--all .cert-bar-label {
    color: rgba(255,255,255,.6);
}

.cert-bar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: Arial, sans-serif;
    transition: opacity .2s, transform .15s;
    white-space: nowrap;
}

.cert-bar-btn:hover  { opacity: .82; transform: translateY(-1px); }
.cert-bar-btn:active { transform: translateY(0); }

.cert-bar-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.cert-bar-btn--dl     { background: var(--bmc-navy); color: #fff; }
.cert-bar-btn--print  { background: #e8f0fe; color: #1a56db; }
.cert-bar-btn--change { background: var(--bmc-gold); color: #1a1a1a; }

/* ==========================================================
   CERTIFICATE CARD — SHARED
   ========================================================== */
.bmc-cert-card {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    background: linear-gradient(160deg, #fefdf5 0%, #f9f3e2 100%);
    border: 3px solid var(--bmc-gold);
    border-radius: 6px;
    overflow: hidden;
    box-shadow:
        inset 0 0 0 10px rgba(200,166,77,.08),
        0 24px 70px rgba(0,0,0,.13);
    font-family: var(--font-serif);
   
}

.bmc-cert-card::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(200,166,77,.35);
    border-radius: 3px;
    pointer-events: none;
    z-index: 1;
}

.cert-bg-butterflies {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.cert-bg-butterfly {
    display: block;
    position: absolute;
}

/* ==========================================================
   CERTIFICATE INNER LAYOUT
   ========================================================== */
.cert-inner {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 280px;
    height: 100%;
}

.cert-left {
    padding: 40px 36px 32px 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    overflow: hidden;
}

.cert-main-title {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 4px;
    line-height: 1;
    margin: 0 0 4px;
    text-transform: uppercase;
}

.cert-subtitle {
    font-family: var(--font-serif);
    font-size: 32px;
    font-style: italic;
    font-weight: 400;
    color: var(--bmc-gold-deep);
    letter-spacing: 1px;
    margin: 0 0 8px;
}

.cert-rule {
   
}

.cert-certify {
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #999;
    margin: 0 0px;
    margin-bottom:12px !important;
}

/* ── PARTICIPANT NAME — Cormorant Garamond SemiBold Italic (readable) ── */
.cert-name {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 600;
    font-style: italic;
    color: #1a1a1a;
    line-height: 1.15;
    margin: 0 0px;
    letter-spacing: 0.5px;
}

.cert-divider-thin {
    width: 80%;
    height: 1px;
    background: black;
    margin: 6px 0 10px;
}

.cert-body {
    font-family: var(--font-serif);
    font-size: 1.05rem;        /* was 26px !important — that killed all breakpoints */
    color: black;
    line-height: 1.8;
    margin: 0 0 4px;
    max-width: 100%;
    margin-bottom: 10px !important;
}

.cert-body-small {
    font-size: 0.95rem;        /* was 26px !important */
    color: black;
    line-height: 1.75;
}
/* ==========================================================
   FOOTER / SIGNATURE
   ========================================================== */
.cert-footer {
    display: flex;
    align-items: flex-end;
    gap: 32px;
    margin-top: 10px;
}

.cert-sig-block {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* MTL in Great Vibes — visually a signature, not a screenshot */
.cert-sig-mtl {
    font-family: var(--font-script);
    font-size: 42px;
    color: var(--bmc-brown);
    line-height: 1;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.cert-sig-rule {
    width: 190px;
    height: 1.5px;
    background: var(--bmc-gold-deep);
    margin-bottom: 5px;
}

.cert-sig-name {
    font-family: var(--font-display);
    font-size: 16px !important;
    font-weight: 600;
    color: var(--bmc-gold-deep);
    letter-spacing: .5px;
    display: block;
}

/* Multi-line title — each line on its own row */
.cert-sig-title {
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: #888;
    display: block;
    margin-top: 1px;
    line-height: 1.55;
}

.cert-date-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.cert-issued-label {
    font-family: Arial, sans-serif;
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: black;
}

.cert-issued-date {
    font-family: var(--font-serif);
    font-size: 13px !important;
    color: black;
    font-style: italic;
}

/* ==========================================================
   RIGHT COLUMN
   ========================================================== */
.cert-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 32px 24px;
    background: rgba(200,166,77,.04);
    border-left: 1px solid rgba(200,166,77,.18);
}

.cert-logo-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(200,166,77,.10);
    border: 1px solid rgba(200,166,77,.30);
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
}

.cert-logo-butterfly {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.cert-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    overflow: hidden;
}

.cert-logo-line1 {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 10px;
    color: var(--bmc-gold-deep);
}

.cert-logo-line2,
.cert-logo-line3 {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    color: var(--bmc-navy);
    letter-spacing: 1.5px;
    white-space: nowrap;
}

/* ── PHOTO FRAME — square, handles portrait & landscape equally ── */
.cert-photo-frame {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(200,166,77,.06);
    border: 2px solid rgba(200,166,77,.25);
    border-radius: 16px;
    overflow: hidden;
    min-height: 0;
    aspect-ratio: 1 / 1; /* square frame — centre-crops any orientation */
}

.cert-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top; /* favour face area for portrait shots */
    display: block;
}

.cert-no-photo {
    text-align: center;
    padding: 24px;
    color: #999;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.8;
}

.cert-no-photo a { color: var(--bmc-gold-deep); }

/* top-left logo */
.cert-top-logo img {
    width: 100px;
    margin-bottom: 20px;
}

/* ==========================================================
   CERTIFICATE VARIATION 2 (Form 7629 — Recognition)
   ========================================================== */
.cert-variant-2 {
    background: linear-gradient(160deg, #fefcf8 0%, #f5ede0 100%);
    border-color: var(--bmc-brown);
    box-shadow:
        inset 0 0 0 10px rgba(123,79,24,.07),
        0 24px 70px rgba(0,0,0,.14);
}

.cert-variant-2::before          { border-color: rgba(123,79,24,.25); }
.cert-variant-2 .cert-rule       { background: linear-gradient(90deg, var(--bmc-brown), transparent); }
.cert-variant-2 .cert-subtitle   { color: var(--bmc-brown); }
.cert-variant-2 .cert-name       { color: var(--bmc-brown); }
.cert-variant-2 .cert-divider-thin { background: rgba(123,79,24,.35); }
.cert-variant-2 .cert-sig-rule   { background: var(--bmc-brown); }
.cert-variant-2 .cert-sig-name   { color: var(--bmc-brown); }
.cert-variant-2 .cert-sig-mtl    { color: #5a3008; }

.cert-variant-2 .cert-right {
    background: rgba(123,79,24,.04);
    border-left-color: rgba(123,79,24,.18);
}

.cert-sig-img {
    width: 70px;
    height: auto;
    display: block;
}

.cert-variant-2 .cert-logo-box {
    background: rgba(123,79,24,.08);
    border-color: rgba(123,79,24,.28);
}

.cert-variant-2 .cert-photo-frame { border-color: rgba(123,79,24,.28); }

.cert-variant-2 .cert-logo-line2,
.cert-variant-2 .cert-logo-line3  { color: var(--bmc-brown); }

/* ==========================================================
   PRINT
   ========================================================== */
@media print {
    body * { visibility: hidden !important; }

    #certificate-container,
    #certificate-container * { visibility: visible !important; }

    #certificate-container {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
    }

    .bmc-cert-actions-bar { display: none !important; }
    .cert-spacer { page-break-after: always; height: 0; }
}

/* ==========================================================
   RESPONSIVE — tablet
   ========================================================== */
@media (max-width: 820px) {
    .bmc-cert-card { aspect-ratio: unset; }

    .cert-inner {
        grid-template-columns: 1fr;
    }

    .cert-right {
        border-left: none;
        border-top: 1px solid rgba(200,166,77,.18);
        padding: 20px 16px 28px;
        flex-direction: row;
        gap: 14px;
    }

    .cert-logo-box   { width: auto; min-width: 120px; }

    .cert-photo-frame {
        min-height: 140px;
        max-height: 180px;
        flex: 1;
        aspect-ratio: 1 / 1;
    }

    .cert-left       { padding: 28px 18px 20px; }
    .cert-main-title { font-size: 32px; letter-spacing: 2px; }
    .cert-name       { font-size: 34px; }
    .cert-subtitle   { font-size: 18px; }
    .cert-footer     { flex-direction: column; gap: 16px; }
}
.cert-photo-frame img{
    height: 100% !important;
}

.cert-logo-box {
    overflow: visible;   /* was likely hidden — this clips line3 in html2canvas */
    min-height: 72px;
}
.bmc-cert-card {
    overflow: hidden !important;
    padding: 20px;
    box-sizing: border-box;
}

.cert-inner {
    overflow: hidden !important;
}

/* ==========================================================
   RESPONSIVE — tablet
   ========================================================== */
@media (max-width: 820px) {
    .bmc-cert-card { aspect-ratio: unset; }

    .cert-inner { grid-template-columns: 1fr; }

    .cert-right {
        border-left: none;
        border-top: 1px solid rgba(200,166,77,.18);
        padding: 16px;
        flex-direction: row;
        gap: 12px;
        align-items: center;
    }

    .cert-photo-frame {
        min-height: 100px;
        max-height: 160px;
        flex: 1;
        aspect-ratio: 1 / 1;
    }

    .cert-left        { padding: 24px 18px 16px; }
    .cert-main-title  { font-size: clamp(22px, 6vw, 36px); letter-spacing: 2px; }
    .cert-subtitle    { font-size: clamp(14px, 4vw, 22px); }
    .cert-name        { font-size: clamp(20px, 5.5vw, 30px); }
    .cert-certify     { font-size: 11px; letter-spacing: 2px; }
    .cert-body        { font-size: clamp(0.78rem, 2.5vw, 0.95rem) !important; margin-bottom: 6px !important; }
    .cert-body-small  { font-size: clamp(0.74rem, 2.3vw, 0.88rem) !important; }
    .cert-footer      { flex-direction: column; gap: 12px; }
    .cert-sig-img     { width: 54px; }
    .cert-top-logo img { width: 72px; margin-bottom: 12px; }
}

/* ==========================================================
   RESPONSIVE — mobile
   ========================================================== */
@media (max-width: 560px) {
    .bmc-wrap {
        margin: 24px 12px;
        padding: 28px 18px;
        border-radius: 18px;
    }
    .bmc-wrap h2   { font-size: 26px; }
    .bmc-subtext   { font-size: 13.5px; }

    .cert-right    { flex-direction: column; }
    .cert-logo-box { width: 100%; box-sizing: border-box; }

    .cert-main-title  { font-size: clamp(18px, 7vw, 26px); letter-spacing: 1px; }
    .cert-subtitle    { font-size: clamp(12px, 3.8vw, 16px); }
    .cert-name        { font-size: clamp(17px, 5vw, 22px); }
    .cert-body        { font-size: clamp(0.70rem, 3vw, 0.82rem) !important; line-height: 1.55 !important; }
    .cert-body-small  { font-size: clamp(0.67rem, 2.8vw, 0.78rem) !important; }

    .cert-photo-frame {
        width: 100%;
        max-height: 200px;
        aspect-ratio: 1 / 1;
    }

    .bmc-cert-actions-bar { flex-direction: column; align-items: stretch; }
    .cert-bar-label       { margin-right: 0; }
    .cert-bar-btn         { width: 100%; justify-content: center; }
}