/* Shared layout fixes for all KCPEE pages.
   Loaded after each page's own <style> block so these rules take priority. */

img {
    max-width: 100%;
}

/* Centre section headings and intro text (homepage and programme pages) */
body:has(.section-intro) section .container > h2 {
    text-align: center;
}

.section-intro {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* Grids never force cards wider than the screen */
.career-stages,
.programs-grid,
.solutions-grid,
.benefits-grid,
.footer-grid,
.pathway-grid,
.assessment-flow,
.cert-types,
.highlights,
.module-list,
.audience-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 260px), 100%), 1fr));
}

.programs-grid { --grid-min: 320px; }
.solutions-grid,
.benefits-grid,
.cert-types { --grid-min: 300px; }
.assessment-flow,
.module-list,
.audience-grid { --grid-min: 280px; }
.career-stages,
.highlights { --grid-min: 240px; }
.footer-grid { --grid-min: 250px; }

/* Wide comparison tables scroll sideways instead of stretching the page */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile menu button (hidden on desktop) */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    margin: 5px 0;
    background: var(--navy);
    transition: transform 0.3s, opacity 0.3s;
}

nav.open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
nav.open .nav-toggle span:nth-child(2) { opacity: 0; }
nav.open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 768px) {
    nav .container {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0;
    }

    nav .container:has(.nav-toggle) {
        padding: 0.75rem 1rem;
    }

    .nav-toggle {
        display: block;
    }

    nav:has(.nav-toggle) ul {
        display: none;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        width: 100%;
        padding: 1rem 0 0.5rem;
    }

    nav.open ul {
        display: flex;
    }

    .hero h1 {
        font-size: clamp(1.8rem, 7vw, 2.5rem);
    }

    .rule-item {
        display: block;
        min-width: 0;
        margin: 0.5rem 0;
    }
}

/* Enquiry modals: always fit the viewport and scroll inside, with the close
   button kept in view. dvh follows mobile browser toolbars; vh is the fallback. */
.modal-content {
    margin: 5vh auto;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.close-modal {
    position: sticky;
    top: 0;
    z-index: 1;
    float: none;
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-bottom: -2rem;
    line-height: 1;
    background: var(--white);
    border-radius: 50%;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 2.5vh auto;
        max-height: 95vh;
        max-height: 95dvh;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.25rem;
    }
}

/* Contact form error message (shown if an enquiry fails to send) */
.error-message {
    display: none;
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.error-message a {
    color: inherit;
    font-weight: 600;
}

button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: wait;
}
