/* ===========================
   Printable training certificate
   =========================== */

body.bare.print-cert {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem 3rem;
    background: var(--color-bg-secondary);
    font-family: 'Inter', sans-serif;
    color: var(--color-text-primary);
}

/* Toolbar */
.print-actions {
    width: 100%;
    max-width: 50rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.print-btn,
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.75rem;
    border: none;
    border-radius: 9999px;
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.print-btn {
    background: linear-gradient(to right, var(--color-accent), var(--color-accent-light));
    color: var(--color-accent-contrast);
}

.back-btn {
    background: var(--color-surface);
    color: var(--color-text-primary);
}

.print-btn:hover,
.back-btn:hover {
    transform: scale(1.03);
}

/* Sheet: A-series proportions on screen, page-sized in print */
.certificate-container {
    position: relative;
    width: 100%;
    max-width: 50rem;
    aspect-ratio: 1 / 1.414;
    padding: 1rem;
    border-radius: 1rem;
    background-color: var(--color-surface);
    box-shadow: 0 20px 60px rgba(from var(--color-primary) r g b / 0.12);
}

.certificate-border {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 3.5rem 3rem 2.5rem;
    text-align: center;
    box-shadow: inset 0 0 0 1px rgba(from var(--color-text-tertiary) r g b / 0.15);
}

.corner-accent {
    position: absolute;
    width: 2rem;
    height: 2rem;
    border-color: var(--color-primary-vivid);
    border-style: solid;
    border-width: 0;
}

.corner-tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.corner-tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.corner-bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.corner-br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }

/* Header */
.cert-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.cert-org-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.cert-org-logo {
    height: 2.25rem;
    width: auto;
}

.cert-org-name {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.025em;
    text-transform: uppercase;
    color: var(--color-text-primary);
}

.cert-type-label {
    font-family: 'Manrope', sans-serif;
    font-size: 0.875rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--color-text-secondary);
}

.cert-module-name {
    font-family: 'Manrope', sans-serif;
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--color-text-primary);
}

/* Body */
.cert-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    width: 100%;
}

.cert-body-statement {
    max-width: 28rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.cert-recipient {
    width: 75%;
    padding: 1.5rem 0;
    border-top: 1px solid rgba(from var(--color-text-tertiary) r g b / 0.2);
    border-bottom: 1px solid rgba(from var(--color-text-tertiary) r g b / 0.2);
}

.cert-recipient-label {
    margin-bottom: 0.5rem;
    font-family: 'Manrope', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-tertiary);
}

.cert-recipient-name {
    font-family: 'Manrope', sans-serif;
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--color-text-primary);
}

.cert-metrics {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.cert-metric {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    background-color: var(--color-bg-secondary);
    text-align: left;
}

.cert-metric-icon {
    font-size: 1.5rem;
    color: var(--color-text-primary);
}

.metric-icon-accent {
    color: var(--color-accent);
}

.cert-metric-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-tertiary);
}

.cert-metric-value {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text-primary);
}

/* Footer */
.cert-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.cert-qr-code {
    color: var(--color-text-primary); /* the QR code is drawn in currentColor */
    width: 6rem;
    height: 6rem;
}

.cert-qr-code svg {
    width: 100%;
    height: 100%;
}

.cert-footer-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-tertiary);
}

.cert-footer-label-gap {
    margin-top: 0.5rem;
}

.cert-footer-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

@media (max-width: 600px) {
    .certificate-container {
        aspect-ratio: auto;
    }

    .certificate-border {
        padding: 2.5rem 1.25rem 2rem;
    }

    .cert-recipient {
        width: 100%;
    }
}

/* Print: one portrait page, A4 or Letter. The sheet is sized to the area both
   papers share inside 10mm margins (190mm x 257mm), so nothing needs scaling. */
@page {
    size: portrait;
    margin: 10mm;
}

@media print {
    body.bare.print-cert {
        display: block;
        min-height: 0;
        padding: 0;
        background: var(--color-surface);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .no-print {
        display: none !important;
    }

    .certificate-container {
        width: 190mm;
        max-width: none;
        height: 257mm;
        aspect-ratio: auto;
        margin: 0 auto;
        padding: 4mm;
        border-radius: 0;
        box-shadow: none;
        break-inside: avoid;
        overflow: hidden;
    }

    .certificate-border {
        padding: 16mm 12mm 10mm;
    }

    .cert-module-name,
    .cert-recipient-name {
        font-size: 30pt;
    }
}
