/* ==========================================================================
   Course web pages (index.php/courses/<Term>/<Code>), rendered from Markdown.
   A stand-alone, documentation-style layout: header band, info cards,
   sticky section menu, readable content column.
   ========================================================================== */

:root {
    --c-ink: #0f172a;
    --c-ink-2: #334155;
    --c-ink-3: #64748b;
    --c-line: #e2e8f0;
    --c-soft: #f8fafc;
    --c-accent: #4338ca;        /* indigo */
    --c-accent-soft: #eef2ff;
    --c-hero: #111827;
    --c-bg: #ffffff;
    --c-surface: #ffffff;
    --c-top-bg: rgba(255, 255, 255, .92);
    --c-card-shadow: 0 10px 30px rgba(15, 23, 42, .10);
    --c-dot: #cbd5e1;
    --c-row-hover: #fbfcfe;
    color-scheme: light;
    --c-radius: 12px;
    --c-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --c-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { margin: 0; font-family: var(--c-sans); font-size: 16px; line-height: 1.65; color: var(--c-ink); background: var(--c-bg); }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; border-radius: 3px; }
code { font-family: var(--c-mono); font-size: .88em; background: var(--c-accent-soft); color: var(--c-accent); padding: 1px 6px; border-radius: 5px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; background: var(--c-surface); padding: 8px 12px; z-index: 10; }

/* ---------- Top bar ---------- */
.c-top { position: sticky; top: 0; z-index: 20; background: var(--c-top-bg); backdrop-filter: saturate(160%) blur(8px); border-bottom: 1px solid var(--c-line); }
.c-top-inner { max-width: 1200px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; }
.c-brand img { display: block; height: 32px; width: auto; }
.c-top-links a { color: var(--c-ink-2); font-weight: 500; font-size: .95rem; }
.c-top-links a:hover { color: var(--c-accent); text-decoration: none; }

/* ---------- Hero ---------- */
.c-hero {
    background:
        radial-gradient(1200px 300px at 85% -40%, rgba(99, 102, 241, .45), transparent 60%),
        radial-gradient(800px 260px at 0% 120%, rgba(14, 165, 233, .25), transparent 60%),
        var(--c-hero);
    color: #fff;
    padding: 56px 24px 0;
}
.c-hero-inner { max-width: 1200px; margin: 0 auto; }
.c-kicker { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 14px; }
.c-code { font-weight: 700; font-size: .85rem; letter-spacing: .06em; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); padding: 4px 10px; border-radius: 999px; }
.c-term { font-size: .92rem; color: #c7d2fe; }
.c-hero h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); line-height: 1.12; letter-spacing: -.02em; margin: 0 0 10px; font-weight: 700; }
.c-dept { margin: 0; color: #cbd5e1; font-size: .98rem; }
.c-facts {
    max-width: 1200px; margin: 36px auto 0; position: relative; top: 32px;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px;
}
.c-fact { background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-line); border-radius: var(--c-radius); padding: 16px 18px; box-shadow: var(--c-card-shadow); }
.c-fact-label { margin: 0 0 6px; font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-ink-3); }
.c-fact-label i { color: var(--c-accent); margin-right: 4px; }
.c-fact-value { margin: 0; font-size: .95rem; line-height: 1.5; color: var(--c-ink-2); }
.c-fact-value + .c-fact-value { margin-top: 2px; }

/* ---------- Layout ---------- */
.c-layout { max-width: 1200px; margin: 0 auto; padding: 72px 24px 64px; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 56px; }
.c-hero:not(:has(.c-facts)) + .c-layout { padding-top: 48px; }
.c-side { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow: auto; }
.c-side-title { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c-ink-3); margin: 0 0 10px; }
.c-side ul { list-style: none; margin: 0 0 28px; padding: 0; border-left: 2px solid var(--c-line); }
.c-side li a { display: block; padding: 6px 0 6px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--c-ink-2); font-size: .93rem; line-height: 1.35; }
.c-side li a:hover { color: var(--c-accent); text-decoration: none; }
.c-side li a.active { color: var(--c-accent); border-left-color: var(--c-accent); font-weight: 600; }

/* ---------- Content ---------- */
.c-content { max-width: 800px; min-width: 0; }
.c-content > :first-child { margin-top: 0; }
.c-content h2 {
    font-size: 1.55rem; letter-spacing: -.01em; line-height: 1.25; font-weight: 700;
    margin: 2.6em 0 .8em; padding-top: .2em; scroll-margin-top: 84px;
}
.c-content h2:first-child { margin-top: 0; }
.c-content h3 { font-size: 1.15rem; margin: 1.8em 0 .6em; scroll-margin-top: 84px; }
.c-content p, .c-content ul, .c-content ol { margin: 0 0 1em; color: var(--c-ink-2); }
.c-content ul, .c-content ol { padding-left: 1.3em; }
.c-content li { margin: .35em 0; }
.c-content li::marker { color: var(--c-accent); }
.c-content strong { color: var(--c-ink); }
.c-content hr { border: 0; border-top: 1px solid var(--c-line); margin: 2.4em 0; }
.c-content blockquote { margin: 1.4em 0; padding: 12px 18px; background: var(--c-accent-soft); border-left: 3px solid var(--c-accent); border-radius: 0 8px 8px 0; color: var(--c-ink-2); }

/* Announcements: the first list after an "Announcements" heading gets a card look */
.c-content h2[id^="announcements"] + ul { list-style: none; padding: 0; border: 1px solid var(--c-line); border-radius: var(--c-radius); overflow: hidden; }
.c-content h2[id^="announcements"] + ul li { margin: 0; padding: 12px 16px 12px 40px; position: relative; border-top: 1px solid var(--c-line); background: var(--c-surface); }
.c-content h2[id^="announcements"] + ul li:first-child { border-top: 0; background: var(--c-accent-soft); }
.c-content h2[id^="announcements"] + ul li::before { content: ''; position: absolute; left: 18px; top: 22px; width: 8px; height: 8px; border-radius: 50%; background: var(--c-dot); }
.c-content h2[id^="announcements"] + ul li:first-child::before { background: var(--c-accent); }

/* Tables */
.c-content .table-wrap { overflow-x: auto; margin: 0 0 1.4em; border: 1px solid var(--c-line); border-radius: var(--c-radius); }
.c-content table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.c-content th { text-align: left; font-weight: 600; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--c-ink-3); background: var(--c-soft); padding: 10px 14px; border-bottom: 1px solid var(--c-line); white-space: nowrap; }
.c-content td { padding: 10px 14px; border-top: 1px solid var(--c-line); vertical-align: top; color: var(--c-ink-2); }
.c-content tbody tr:first-child td { border-top: 0; }
.c-content tbody tr:hover td { background: var(--c-row-hover); }
.c-content td:first-child { color: var(--c-ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */
.c-foot { border-top: 1px solid var(--c-line); background: var(--c-soft); }
.c-foot-inner { max-width: 1200px; margin: 0 auto; padding: 22px 24px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: .88rem; color: var(--c-ink-3); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .c-layout { grid-template-columns: 1fr; gap: 0; padding-top: 64px; }
    .c-side { position: static; max-height: none; margin-bottom: 8px; }
    .c-side ul { display: flex; flex-wrap: wrap; gap: 8px; border-left: 0; margin-bottom: 18px; }
    .c-side li a { border: 1px solid var(--c-line); border-radius: 999px; padding: 5px 12px; margin: 0; font-size: .88rem; }
    .c-side li a.active { border-color: var(--c-accent); }
}
@media (max-width: 560px) {
    .c-hero { padding-top: 40px; }
    .c-facts { grid-template-columns: 1fr; }
}
@media print {
    .c-top, .c-side, .c-foot { display: none; }
    .c-hero { background: none; color: var(--c-ink); padding: 0; }
    .c-hero .c-term, .c-dept { color: var(--c-ink-3); }
    .c-facts { top: 0; }
    .c-layout { display: block; padding-top: 24px; }
}

/* Top bar without a logo: "All courses" on the left, course name on the right */
.c-top-inner { min-height: 52px; }
.c-top-code { font-size: .9rem; font-weight: 600; color: var(--c-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(60vw, 520px); }
@media (max-width: 560px) { .c-top-code { display: none; } }

/* Justified body text with hyphenation (same rule as the main site); tables and
   the announcement list stay left-aligned. */
.c-content p, .c-content li, .c-content blockquote {
    text-align: justify; text-justify: inter-word;
    -webkit-hyphens: auto; hyphens: auto; hyphenate-limit-chars: 7 3 3;
}
.c-content td, .c-content th, .c-content td p { text-align: left; -webkit-hyphens: manual; hyphens: manual; }
.c-content a { overflow-wrap: anywhere; }
@media (max-width: 640px) { .c-content p, .c-content li, .c-content blockquote { text-align: left; } }


/* ---------- Dark theme (same switch as the main site: system setting, or
   <html data-theme> set by the toggle; see static/js/theme.js) ---------- */
:root[data-theme="dark"] {
    --c-ink: #e3e7ec;
    --c-ink-2: #b6bfcb;
    --c-ink-3: #8c96a4;
    --c-line: #2a333f;
    --c-soft: #161c24;
    --c-accent: #a5b4fc;
    --c-accent-soft: #232846;
    --c-hero: #0b0f14;
    --c-bg: #12171e;
    --c-surface: #1a212b;
    --c-top-bg: rgba(18, 23, 30, .92);
    --c-card-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --c-dot: #4a5462;
    --c-row-hover: #19202a;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --c-ink: #e3e7ec;
        --c-ink-2: #b6bfcb;
        --c-ink-3: #8c96a4;
        --c-line: #2a333f;
        --c-soft: #161c24;
        --c-accent: #a5b4fc;
        --c-accent-soft: #232846;
        --c-hero: #0b0f14;
        --c-bg: #12171e;
        --c-surface: #1a212b;
        --c-top-bg: rgba(18, 23, 30, .92);
        --c-card-shadow: 0 10px 30px rgba(0, 0, 0, .45);
        --c-dot: #4a5462;
        --c-row-hover: #19202a;
        color-scheme: dark;
    }
}
.c-top-inner { gap: 16px; }
.c-top-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 34px; height: 34px; border-radius: 50%;
    background: none; border: 1px solid var(--c-line); color: var(--c-ink-2); cursor: pointer;
}
.theme-toggle:hover { color: var(--c-ink); border-color: var(--c-ink-3); }
.theme-toggle:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
/* Half-filled "contrast" circle; it turns half a turn when the theme switches */
.theme-icon { display: block; transition: transform .45s cubic-bezier(.4, 0, .2, 1); }
:root[data-theme="dark"] .theme-icon { transform: rotate(180deg); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon { transform: rotate(180deg); }
}
