/*
 * Course Lists: course table, toolbar and term header.
 * Self-contained: used inside the PUC site shell (CourseList.aspx, alongside Styles/puc/app.css)
 * and on its own (CourseSchedule.aspx, the page the PUC Mobile App opens).
 * PUC palette: green #1E5732, gold #AA9E7B, cream #F0EDE3, text #3A3325, muted #7A7060.
 */
.cl-scope {
    --cl-green: #1E5732;
    --cl-green-dark: #143D23;
    --cl-gold: #AA9E7B;
    --cl-gold-pale: #DDD7C6;
    --cl-cream: #F0EDE3;
    --cl-cream-light: #F8F6F0;
    --cl-text: #3A3325;
    --cl-muted: #6B6253;
    --cl-border: #D9D3C3;
    color: var(--cl-text);
    font-family: "Fira Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.cl-scope *, .cl-scope *::before, .cl-scope *::after { box-sizing: border-box; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- Term header ---- */
.cl-term-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.cl-term-head h1 { margin: 0; font-size: 2rem; line-height: 1.15; font-weight: 600; color: var(--cl-green); }
.cl-term-head .cl-eyebrow { margin: 0 0 4px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--cl-muted); font-weight: 600; }
.cl-term-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--cl-muted); font-size: .9rem; }
.cl-term-meta li { margin: 0; }
.cl-term-meta strong { color: var(--cl-text); font-weight: 600; }
.cl-term-links { display: flex; flex-wrap: wrap; gap: 8px; }
.cl-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--cl-gold);
    border-radius: 6px; background: #fff; color: var(--cl-green); font: inherit; font-size: .9rem; font-weight: 500;
    text-decoration: none; cursor: pointer; line-height: 1.3;
}
.cl-btn:hover, .cl-btn:focus { background: #F5F2EA; color: var(--cl-green-dark); }
.cl-btn.is-primary { background: var(--cl-green); border-color: var(--cl-green); color: #fff; }
.cl-btn.is-primary:hover, .cl-btn.is-primary:focus { background: var(--cl-green-dark); color: #fff; }

/* ---- Toolbar ---- */
.ct-toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 14px 16px;
    background: var(--cl-cream); border: 1px solid var(--cl-border); border-radius: 8px;
}
.ct-toolbar[hidden] { display: none; }
.ct-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ct-field > label { font-size: .78rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--cl-muted); }
.ct-search { flex: 1 1 280px; }
.ct-field input[type=search], .ct-field select {
    height: 38px; padding: 0 10px; border: 1px solid var(--cl-border); border-radius: 6px; background: #fff;
    color: var(--cl-text); font: inherit; font-size: .95rem; max-width: 100%;
}
.ct-field input[type=search]:focus, .ct-field select:focus { outline: 2px solid var(--cl-gold); outline-offset: 1px; border-color: var(--cl-gold); }
.ct-check { justify-content: flex-end; height: 38px; }
.ct-check label { display: flex; align-items: center; gap: 6px; font-size: .95rem; cursor: pointer; text-transform: none; letter-spacing: 0; color: var(--cl-text); font-weight: 400; }
.ct-check input { width: 16px; height: 16px; accent-color: var(--cl-green); }
.ct-reset { height: 38px; padding: 0 12px; border: 1px solid transparent; background: none; color: var(--cl-green); font: inherit; font-size: .9rem; text-decoration: underline; cursor: pointer; }
.ct-count { margin: 12px 2px 8px; font-size: .9rem; color: var(--cl-muted); }
.ct-none, .ct-empty { margin: 16px 0; padding: 16px; border: 1px dashed var(--cl-border); border-radius: 8px; text-align: center; color: var(--cl-muted); }
.ct-none[hidden] { display: none; }

/* ---- Table ---- */
.ct-wrap { overflow-x: auto; border: 1px solid var(--cl-border); border-radius: 8px; background: #fff; }
.course-table { width: 100%; table-layout: auto; border-collapse: collapse; font-size: .9rem; line-height: 1.35; background: #fff; border: 0; margin: 0; }
.course-table th, .course-table td { width: auto; padding: 9px 10px; border: 0; border-bottom: 1px solid #ECE8DC; text-align: left; vertical-align: top; }
.course-table thead th {
    position: sticky; top: 0; z-index: 1; background: var(--cl-green); color: #fff; font-weight: 600;
    font-size: .8rem; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; padding: 10px;
}
.course-table thead th.is-sortable { padding: 0; }
.course-table tbody tr:nth-child(even) { background: var(--cl-cream-light); }
.course-table tbody tr:hover { background: #EFEBDD; }
.course-table tr[hidden] { display: none; }

.ct-sort {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px; border: 0; background: none;
    color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: left; cursor: pointer;
}
.ct-sort:hover, .ct-sort:focus-visible { background: var(--cl-green-dark); outline: none; }
.ct-arrow { width: 0; height: 0; border: 4px solid transparent; opacity: .35; border-top-color: #fff; margin-top: 4px; }
th[aria-sort=ascending] .ct-arrow { opacity: 1; border-top-color: transparent; border-bottom-color: #fff; margin-top: -4px; }
th[aria-sort=descending] .ct-arrow { opacity: 1; }

.course-table .col-course { min-width: 230px; }
.course-code { display: block; font-weight: 600; color: var(--cl-green); white-space: nowrap; }
.course-title { display: block; }
.course-desc summary { cursor: pointer; color: var(--cl-text); list-style-position: inside; }
.course-desc summary:hover { color: var(--cl-green); text-decoration: underline; }
.course-desc[open] summary { font-weight: 600; }
.course-desc p { margin: 6px 0 2px; padding: 8px 10px; max-width: 46em; background: var(--cl-cream); border-left: 3px solid var(--cl-gold); border-radius: 0 4px 4px 0; color: var(--cl-text); font-size: .88rem; line-height: 1.45; }
.course-table .col-times, .course-table .col-dates, .course-table .col-days { white-space: nowrap; }
.course-table .col-num, .course-table .col-seats { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.course-table th.col-num .ct-sort, .course-table th.col-seats .ct-sort { justify-content: flex-end; }
.col-seats .of { color: var(--cl-muted); }
.course-table .col-faculty { min-width: 130px; }
.course-table .col-loc { white-space: nowrap; }

.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status.is-open { background: #E1EFE5; color: var(--cl-green); }
.status.is-closed { background: #ECE8E1; color: #6B5F4A; }
.status.is-other { background: #F3ECD6; color: #6A5A22; }

/* ---- Small screens: one card per section ---- */
@media (max-width: 760px) {
    .cl-term-head h1 { font-size: 1.6rem; }
    .ct-toolbar { padding: 12px; }
    .ct-toolbar .ct-field { flex: 1 1 100%; }
    .ct-toolbar .ct-field select, .ct-toolbar .ct-field input[type=search] { width: 100%; }
    .ct-check { height: auto; }
    .ct-wrap { border: 0; background: none; overflow: visible; }
    .course-table, .course-table tbody, .course-table tr, .course-table td { display: block; width: 100%; }
    .course-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .course-table tbody tr, .course-table tbody tr:nth-child(even) {
        margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--cl-border); border-radius: 8px; background: #fff;
    }
    .course-table td { display: flex; gap: 12px; padding: 4px 0; border: 0; text-align: left; white-space: normal; }
    .course-table td::before { content: attr(data-label); flex: 0 0 82px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--cl-muted); padding-top: 2px; }
    .course-table td.col-course { display: block; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid #ECE8DC; }
    .course-table td.col-course::before { content: none; }
    .course-table td:empty { display: none; }
    .course-table .col-num, .course-table .col-seats, .course-table .col-loc { text-align: left; white-space: normal; }
}

@media print {
    .ct-toolbar, .cl-term-links, .ct-count { display: none !important; }
    .ct-wrap { border: 0; overflow: visible; }
    .course-table { font-size: 9pt; }
    .course-table thead th { position: static; background: #eee !important; color: #000; }
    .ct-arrow { display: none; }
    .course-desc summary::marker { content: ""; }
}
