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 {
    position: relative;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;

    /* maintains exact certificate aspect ratio */
    aspect-ratio: 2048 / 1153;
}

/* 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;

    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: 6vh;
    max-height: 80px;
    min-height: 30px;
    width: auto;
}

/* Optional special sizing */

.logo {
    height: 10vh;
    max-height: 140px;
}

/* =========================
   TEXT SCALING
   ========================= */

h1 {
    font-size: clamp(1.8rem, 3vw, 3.8rem);
    margin: 10px 0;
}

h3 {
    font-size: clamp(1.2rem, 2vw, 2.1rem);
    margin: 0;
}

.course-name {
    font-size: clamp(1.1rem, 1.6vw, 1.8rem);
    color: #004a8e;
    margin: 0 5%;
}

.course-description {
    font-size: clamp(0.8rem, 1vw, 1rem);
    margin: 2% 5%;
}

/* =========================
   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 landscape;
        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: 16mm;
        max-height: none;
        min-height: unset;
        width: auto;
    }

    .logo {
        height: 20mm;
    }
   /* -------------------------
       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%;
    }
}