/*
| The training certificate (design `52` Ekran 2, EGT-225).
|
| ⚠ Its own file rather than utilities, for the invoice's reason: the sheet is
| drawn at paper sizes — a 38px name on a 1123px A4 — and the panels' type
| scale has no such steps.
|
| ⚠ Positions are percentages of the sheet, measured off the design's 1123 ×
| 794 drawing, so the same rules hold on screen and on paper: a CSS pixel is a
| ninety-sixth of an inch, and A4 landscape is 1123 of them.
|
| ⛔ Ink and grey only (design `52` «Renk»), and the invalid state is a
| bordered box, a word and a stamp — it survives a mono printer on its own.
*/

.certificate-stage {
    overflow-x: auto;
    padding: 24px 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.certificate {
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--color-print-paper);
    border: 1px solid var(--color-ink-100);
    color: var(--color-ink-950);
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
}

.certificate--landscape {
    width: 1123px;
    height: 794px;
}

.certificate--portrait {
    width: 794px;
    height: 1123px;
}

.certificate-template {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.certificate-mono {
    font-family: var(--font-mono);
}

.certificate-strong {
    font-weight: 700;
    color: var(--color-ink-950);
}

/* The print area — 70% of the width, 40% of the height, centred. */
.certificate-block {
    position: absolute;
    top: 26.7%;
    left: 14.4%;
    right: 14.4%;
    height: 41.6%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.certificate--portrait .certificate-block {
    top: 30%;
    left: 10%;
    right: 10%;
    height: 38%;
}

.certificate-dear {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--color-ink-600);
}

/* ⛔ One line, always: a long name steps down rather than breaking. */
.certificate-name {
    max-width: 100%;
    margin-top: 6px;
    overflow: hidden;
    white-space: nowrap;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.15;
}

.certificate-name--large {
    font-size: 38px;
}

.certificate-name--medium {
    font-size: 32px;
}

.certificate-name--small {
    font-size: 26px;
}

.certificate-identity {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--color-ink-800);
}

.certificate-rule {
    width: 72px;
    height: 2px;
    margin: 20px 0 18px;
    background: var(--color-ink-950);
}

/* ⚠ Two lines at most. */
.certificate-training {
    max-width: 700px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.3;
}

.certificate-facts {
    margin-top: 9px;
    font-size: 13.5px;
    color: var(--color-ink-800);
}

.certificate-parties {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 28px;
    margin-top: 18px;
    font-size: 11.5px;
    color: var(--color-ink-600);
}

.certificate-parties strong {
    color: var(--color-ink-950);
}

.certificate-divider {
    width: 1px;
    background: var(--color-ink-100);
}

/* The imprint strip — inside the template's frame, bottom by default. */
.certificate-imprint {
    position: absolute;
    left: 5.2%;
    right: 5.2%;
    bottom: 6.3%;
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.certificate--imprint-top .certificate-imprint {
    top: 6.3%;
    bottom: auto;
    align-items: flex-start;
}

.certificate-imprint-table {
    border-collapse: collapse;
    font-size: 10px;
}

.certificate-imprint-table td {
    padding: 2px 0;
}

.certificate-imprint-table td:first-child {
    padding-right: 12px;
    color: var(--color-ink-600);
}

.certificate-number {
    font-weight: 800;
}

.certificate-verify {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.certificate-verify-text {
    font-size: 9px;
    line-height: 1.5;
    text-align: right;
    color: var(--color-ink-600);
}

.certificate-qr {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

/* The invalid state: the box on top and the stamp under the block. */
.certificate-void {
    position: absolute;
    top: 6.5%;
    left: 6.5%;
    right: 6.5%;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 11px;
    border: 2px solid var(--color-ink-950);
    background: repeating-linear-gradient(135deg, var(--color-print-paper) 0 6px, var(--color-bg) 6px 8px);
}

.certificate--imprint-top .certificate-void {
    top: auto;
    bottom: 6.5%;
}

.certificate-void-word {
    flex-shrink: 0;
    padding: 2px 7px;
    border: 1.5px solid var(--color-ink-950);
    background: var(--color-print-paper);
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 2px;
}

.certificate-void-facts {
    padding: 1px 5px;
    background: var(--color-print-paper);
    font-size: 11px;
    line-height: 1.5;
}

.certificate-stamp {
    position: absolute;
    top: 67%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-10deg);
    padding: 4px 32px;
    border: 8px double color-mix(in oklab, var(--color-critical-fg) 55%, transparent);
    color: color-mix(in oklab, var(--color-critical-fg) 50%, transparent);
    font-size: 80px;
    font-weight: 900;
    letter-spacing: 12px;
    white-space: nowrap;
    pointer-events: none;
}

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

@page certificate-portrait {
    size: A4 portrait;
    margin: 0;
}

@media print {
    .certificate-stage {
        display: block;
        overflow: visible;
        padding: 0;
        min-height: 0;
    }

    .certificate {
        border: 0;
        break-after: page;
        break-inside: avoid;
    }

    .certificate:last-child {
        break-after: auto;
    }

    .certificate--landscape {
        page: certificate-landscape;
        width: 297mm;
        height: 210mm;
    }

    .certificate--portrait {
        page: certificate-portrait;
        width: 210mm;
        height: 297mm;
    }
}
