/*
    ============================================================
    GENERAL PAGE STYLES
    ============================================================
*/

:root {
    --page-background: #f5f6f8;
    --content-background: #ffffff;
    --header-background: #243447;
    --header-text: #ffffff;
    --heading-text: #1f2933;
    --body-text: #303943;
    --muted-text: #5d6975;
    --border-color: #d7dde3;
    --table-header: #e9edf2;
    --special-week: #fff4d6;
    --link-color: #145da0;

    font-family:
            system-ui,
            -apple-system,
            BlinkMacSystemFont,
            "Segoe UI",
            sans-serif;

    color: var(--body-text);
    background: var(--page-background);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    line-height: 1.5;
}

.container {
    width: min(1100px, calc(100% - 2rem));
    margin-inline: auto;
}

.course-header {
    padding: 2rem 0;
    color: var(--header-text);
    background: var(--header-background);
}

.course-header h1 {
    margin: 0;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
}

.course-header p {
    margin: 0.4rem 0 0;
    font-size: 1.1rem;
}

main {
    padding-block: 2rem 4rem;
}

section {
    margin-bottom: 2.5rem;
}

h2 {
    color: var(--heading-text);
}

.schedule-note,
.updated-date {
    color: var(--muted-text);
}

.updated-date {
    margin-top: 1rem;
    font-size: 0.9rem;
}


/*
    ============================================================
    COURSE INFORMATION
    ============================================================
*/

.course-information {
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    background: var(--content-background);
}

.course-information h2 {
    margin-top: 0;
}

.course-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 0;
}

.course-details div {
    min-width: 0;
}

.course-details dt {
    font-weight: 700;
}

.course-details dd {
    margin: 0.2rem 0 0;
}


/*
    ============================================================
    DESKTOP TABLE
    ============================================================
*/

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    background: var(--content-background);
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
}

.schedule-table th,
.schedule-table td {
    padding: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}

.schedule-table th {
    background: var(--table-header);
    color: var(--heading-text);
}

.schedule-table tbody tr:last-child td {
    border-bottom: 0;
}

.schedule-table tbody tr:hover {
    background: #f8fafc;
}

.schedule-table .special-week {
    background: var(--special-week);
}

.schedule-table .special-week:hover {
    background: var(--special-week);
}

.schedule-table .exam-day {
    background: #e8f1ff;
    font-weight: 600;
}

.schedule-table .exam-day:hover {
    background: #e8f1ff;
}

.schedule-table th:first-child,
.schedule-table td:first-child {
    width: 8rem;
    white-space: nowrap;
}


/*
    ============================================================
    MOBILE LAYOUT

    On smaller screens, each table row becomes a separate card.
    ============================================================
*/

@media screen and (max-width: 700px) {
    .container {
        width: min(100% - 1rem, 1100px);
    }

    .course-header {
        padding: 1.5rem 0;
    }

    main {
        padding-top: 1.25rem;
    }

    .course-details {
        grid-template-columns: 1fr;
    }

    .table-wrapper {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .schedule-table,
    .schedule-table tbody,
    .schedule-table tr,
    .schedule-table td {
        display: block;
        width: 100%;
    }

    .schedule-table thead {
        /*
            Hide the table headings visually while keeping the
            cell-specific labels below.
        */
        display: none;
    }

    .schedule-table tbody {
        display: grid;
        gap: 1rem;
    }

    .schedule-table tr {
        overflow: hidden;
        border: 1px solid var(--border-color);
        border-radius: 0.6rem;
        background: var(--content-background);
    }

    .schedule-table td {
        display: grid;
        grid-template-columns: minmax(7.5rem, 38%) 1fr;
        gap: 0.75rem;
        padding: 0.7rem 0.85rem;
        border-bottom: 1px solid var(--border-color);
    }

    .schedule-table td:last-child {
        border-bottom: 0;
    }

    .schedule-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--heading-text);
    }

    .schedule-table tbody tr:hover {
        background: var(--content-background);
    }

    .schedule-table .special-week,
    .schedule-table .special-week:hover {
        background: var(--special-week);
    }
}


/*
    Very narrow phones: place the label above the value.
*/

@media screen and (max-width: 400px) {
    .schedule-table td {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }
}

/*
    ============================================================
    PRINT STYLES
    ============================================================
*/

@media print {

    @page {
        margin: 0.75in;
    }

    html,
    body {
        background: white;
        color: black;
        font-size: 11pt;
    }

    .container {
        width: 100%;
        margin: 0;
    }

    .course-header {
        background: white;
        color: black;
        padding: 0 0 0.25in 0;
        border-bottom: 2px solid black;
    }

    .course-header h1 {
        font-size: 22pt;
    }

    .course-header p {
        font-size: 12pt;
    }

    section {
        margin-bottom: 0.25in;
    }

    .course-information {
        border: 1px solid black;
        background: white;
        break-inside: avoid;
    }

    .table-wrapper {
        overflow: visible;
        border: none;
    }

    .schedule-table {
        width: 100%;
        border-collapse: collapse;
    }

    .schedule-table th,
    .schedule-table td {
        border: none;
        border-bottom: 1px solid black;
    }

    .schedule-table th {
        border-top: 1px solid black;
        font-weight: bold;
    }

    /*
        Prevent rows from being split
        across two printed pages.
    */
    .schedule-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /*
        Remove hover effects.
    */

    .schedule-table tbody tr:hover {
        background: white;
    }

    /*
        Don't print the course information and exam summary sections.
     */
    .course-information {
        display: none;
    }

    .exam-summary {
        display: none;
    }

    /*
        Don't underline hyperlinks.
    */

    a {
        color: black;
        text-decoration: none;
    }

    /*
        Don't print URLs after links.
    */

    a[href]::after {
        content: "";
    }

}

.exam-summary {
    margin-bottom: 1.5rem;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}

.exam-summary summary {
    font-weight: 600;
    cursor: pointer;
}

.exam-summary ul {
    margin: 0.75rem 0 0;
    padding-left: 1.5rem;
}

.exam-summary li {
    margin: 0.3rem 0;
}

/*
    ============================================================
    COURSE LIST
    ============================================================
*/

.course-list {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.course-link {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;

    padding: 1.25rem;

    border: 1px solid var(--border-color);
    border-radius: 0.6rem;

    background: var(--content-background);
    color: var(--body-text);
    text-decoration: none;
}

.course-link strong {
    color: var(--heading-text);
    font-size: 1.1rem;
}

.course-link span {
    color: var(--muted-text);
}

.course-link:hover,
.course-link:focus-visible {
    background: #f8fafc;
    border-color: var(--link-color);
}

.course-link:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}