html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    font-family: Arial, Helvetica, sans-serif;
}

/* =========================
   HEADER
   ========================= */

.header-container {
    text-align: center;
    width: 100%;
    min-width: 900px;
    margin: 0 auto;
    background-color: #fff;
}

.header-container h1 {
    margin: 0;
    padding: 20px 0;
}

.header-container p {
    margin: 0;
    padding: 10px 0;
}

.header-container a {
    text-decoration: none;
    color: #004a8e;
}

.header-container .print {
    margin: 10px;
    padding: 10px 20px;
    background-color: #07725b;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.header-container .print:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* =========================
   PAGE CONTAINER
   ========================= */

.page-container {
    width: 100%;
    margin: 0 auto;
}

/* =========================
   CERTIFICATE CONTAINER
   ========================= */

.certificate-container {
    container-type: inline-size;
    position: relative;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;

    /* maintains exact portrait certificate aspect ratio */
     aspect-ratio: 1920 / 2773;
}

/* Background image */

.background-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* =========================
   CERTIFICATE CONTENT
   ========================= */

.certificate-content {
    position: absolute;

    top: 10%;
    left: 11%;
    width: 78%;
    height: 80%;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    text-align: center;
    min-width: 0;

    box-sizing: border-box;
}

/* =========================
   LOGO ROW — ROBUST FIX
   ========================= */

.logo-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 2%;
    width: 100%;
}

/* ALL logos scale proportionally */

.logo-row img {
    height: 20vh;
    max-height: 300px;
    min-height: 30px;
    width: auto;
}

/* Optional special sizing */

.logo {
    height: 20vh;
    max-height: 300px;
}

/* =========================
   TEXT SCALING
   ========================= */
.certificate-content h1 {
    font-size: clamp(28px, 3.2cqw, 58px);
    line-height: 1.15;
    max-width: 100%;
    box-sizing: border-box;
    margin: 10px 0;
    overflow-wrap: normal;
    text-wrap: balance;
}

.certificate-content h3 {
    font-size: clamp(20px, 2.1cqw, 38px);
    line-height: 1.2;
    max-width: 100%;
    overflow-wrap: anywhere;
    margin: 0;
}

.certificate-content .course-name {
    font-size: clamp(18px, 1.8cqw, 32px);
    color: #004a8e;
    margin: 0 5%;
    max-width: 100%;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}

.certificate-content .course-description {
    font-size: clamp(14px, 1.1cqw, 20px);
    max-width: 90%;
    margin: 2% auto;
    white-space: normal;
    overflow-wrap: anywhere;
    box-sizing: border-box;

}
/* =========================
   SIGNATURES
   ========================= */

.signature {
    height: 5vh;
    max-height: 60px;
}

.signature-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    align-items: flex-start;
    gap: 1%;
    width: 100%;
}

.instructor {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.instructor-name {
    text-transform: uppercase;
    font-weight: bold;
    overflow-wrap: anywhere;
}

.role,
.instructor > div:last-child {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.role {
    padding: 4px;
}


/* =========================
   LARGE SCREEN IMPROVEMENTS
   ========================= */

@media (min-width: 1800px) {

    .certificate-container {
        max-width: 1800px;
    }

    .logo-row img {
        max-height: 100px;
    }
}

/* =========================
   SMALL SCREEN FIX
   ========================= */

@media (max-width: 1200px) {

    .certificate-container {
        width: 100%;
    }

    .certificate-content {
        top: 8%;
        width: 84%;
        left: 8%;
    }

}

/* =========================
   PRINT STYLES
   ========================= */

@media print {

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

    html,
    body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }

    /* Hide the Open edX page header and footer */
    .header-container {
        display: none !important;
    }

    /* Only the certificate should occupy the printed page */
    .page-container {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
    }

    .certificate-container {
        position: relative;
        width: 100%;
        height: 100%;
        max-width: none;
        margin: 0;
    }

    .background-svg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: fill;
    }

    .certificate-content {
        position: absolute;
        top: 6%;
        left: 11%;
        width: 78%;
        height: 80%;
 	box-sizing: border-box;
    }

    /* Print sizes */
    .logo-row img {
        height: 30mm;
        max-height: none;
        min-height: unset;
        width: auto;
    }

    .logo {
        height: 25mm;
    }
   /* -------------------------
       SIGNATURES
       Always keep on one row
       ------------------------- */

	.signature-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    align-items: flex-start;
    gap: 2mm;
    width: 100%;
}

    .instructor {
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
    }    
.signature {
        height: 8mm;
        max-height: none;
        width: auto;
    }
 .instructor-name {
        font-size: 7pt;
        line-height: 1.1;
        white-space: normal;
    }

    .role {
        font-size: 6.5pt;
        line-height: 1.1;
        padding: 2px;
    }

 /* -------------------------
       CERTIFICATE TEXT
       ------------------------- */

    h1 {
        font-size: 20pt;
        margin: 4pt 0;
    }

    h3 {
        font-size: 16pt;
        margin: 3pt 0;
    }

    .course-name {
        font-size: 12pt;
        margin: 3pt 5%;
    }

    .course-description {
        font-size: 9pt;
        margin: 4pt 5%;
    }
}