/* ══════════════════════════════════════════════════════════════════════════════
   CS 394E — course site stylesheet
   Hand-written, no framework, no build step. Tokens first, then components.
   Color tokens are defined three times on purpose: once for light, once for
   system-dark, once for the explicit dark toggle, so both directions win.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────────────────── */
:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-serif: ui-serif, Charter, "Iowan Old Style", Georgia, Cambria, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg:          #ffffff;
  --bg-alt:      #f5f8f7;
  --surface:     #ffffff;
  --surface-2:   #fafcfb;
  --line:        #e2e8e7;
  --line-2:      #ccd6d4;
  --ink:         #0e1a19;
  --ink-2:       #475957;
  --ink-3:       #6d807d;
  --accent:      #0a6f68;
  --accent-2:    #0c8a81;
  --accent-wash: #e8f3f1;
  --accent-line: #b6dbd6;
  --accent-ink:  #ffffff;
  --warn:        #9a4a12;
  --warn-wash:   #fdf3e8;

  --shadow-sm: 0 1px 2px rgba(14, 26, 25, .05), 0 1px 3px rgba(14, 26, 25, .04);
  --shadow-md: 0 2px 4px rgba(14, 26, 25, .04), 0 8px 24px rgba(14, 26, 25, .07);

  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --wrap: 1080px;
  --wrap-wide: 1200px;

  --step-fluid: clamp(1rem, 0.6rem + 1.2vw, 1.0625rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0a1110;
    --bg-alt:      #0e1716;
    --surface:     #121d1c;
    --surface-2:   #16211f;
    --line:        #22302e;
    --line-2:      #334340;
    --ink:         #e9efee;
    --ink-2:       #a5b6b3;
    --ink-3:       #7e908d;
    --accent:      #48c9c0;
    --accent-2:    #6cdbd2;
    --accent-wash: #102f2c;
    --accent-line: #24504b;
    --accent-ink:  #05201e;
    --warn:        #e9a866;
    --warn-wash:   #2a1f11;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg:          #0a1110;
  --bg-alt:      #0e1716;
  --surface:     #121d1c;
  --surface-2:   #16211f;
  --line:        #22302e;
  --line-2:      #334340;
  --ink:         #e9efee;
  --ink-2:       #a5b6b3;
  --ink-3:       #7e908d;
  --accent:      #48c9c0;
  --accent-2:    #6cdbd2;
  --accent-wash: #102f2c;
  --accent-line: #24504b;
  --accent-ink:  #05201e;
  --warn:        #e9a866;
  --warn-wash:   #2a1f11;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

/* Per-module accent, derived from the hue set in data/course.yaml. */
[style*="--h"] {
  --mod-fg:   hsl(var(--h) 45% 32%);
  --mod-bg:   hsl(var(--h) 52% 96%);
  --mod-line: hsl(var(--h) 34% 86%);
  --mod-dot:  hsl(var(--h) 52% 42%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [style*="--h"] {
    --mod-fg:   hsl(var(--h) 52% 70%);
    --mod-bg:   hsl(var(--h) 30% 13%);
    --mod-line: hsl(var(--h) 24% 26%);
    --mod-dot:  hsl(var(--h) 50% 58%);
  }
}
:root[data-theme="dark"] [style*="--h"] {
  --mod-fg:   hsl(var(--h) 52% 70%);
  --mod-bg:   hsl(var(--h) 30% 13%);
  --mod-line: hsl(var(--h) 24% 26%);
  --mod-dot:  hsl(var(--h) 50% 58%);
}

/* ── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-fluid);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  line-height: 1.18;
  letter-spacing: -0.018em;
  font-weight: 650;
  margin: 0 0 .5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3rem); }
h2 { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.75rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: .18em; }
a:hover { color: var(--accent-2); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

code, kbd, pre { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--bg-alt); border: 1px solid var(--line); border-radius: 4px; padding: .1em .34em; }
pre { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; overflow-x: auto; }
pre code { background: none; border: 0; padding: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

time, .grade-weight, .week-num, .meeting-date, .date-when { font-variant-numeric: tabular-nums; }

.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.tba { color: var(--ink-3); font-style: italic; }
.warn {
  background: var(--warn-wash); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--radius-sm); padding: .6rem .85rem; font-size: .9rem;
}

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: clamp(1.1rem, 4vw, 2rem); }
.section { padding-block: clamp(2.5rem, 5vw, 4rem); }
.section-title { margin-bottom: 1.5rem; }
.eyebrow {
  font-size: .74rem; font-weight: 620; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: .9rem;
}
.lede { font-size: 1.13rem; color: var(--ink-2); max-width: 62ch; text-wrap: pretty; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .7rem 1.1rem; border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: 1rem;
  min-height: 4rem; max-width: var(--wrap-wide);
}
.brand {
  display: flex; align-items: baseline; gap: .55rem;
  text-decoration: none; color: var(--ink); margin-right: auto; min-width: 0;
}
.brand-code {
  font-weight: 700; letter-spacing: -.02em; font-size: 1.02rem;
  background: var(--accent-wash); color: var(--accent);
  border: 1px solid var(--accent-line);
  padding: .12rem .45rem; border-radius: var(--radius-sm); white-space: nowrap;
}
.brand-title {
  font-size: .95rem; color: var(--ink-2); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 560px) { .brand-title { display: none; } }

.site-nav { display: flex; align-items: center; gap: .35rem; }
.site-nav ul { display: flex; gap: .15rem; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: .45rem .7rem; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: .93rem; font-weight: 520;
  white-space: nowrap;
}
.site-nav a:hover { background: var(--bg-alt); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-wash); }

.theme-toggle, .nav-toggle {
  display: grid; place-items: center;
  width: 2.2rem; height: 2.2rem; margin-left: .3rem;
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink-2); cursor: pointer;
}
.theme-toggle:hover, .nav-toggle:hover { background: var(--bg-alt); color: var(--ink); border-color: var(--line-2); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

.nav-toggle { display: none; }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  content: ""; display: block; width: 1.05rem; height: 1.5px;
  background: currentColor; border-radius: 2px; transition: transform .18s ease, opacity .18s ease;
}
.nav-toggle-bars::before { transform: translateY(-5px); }
.nav-toggle-bars::after  { transform: translateY(3.5px); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: rotate(45deg) translateY(0); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after  { transform: rotate(-45deg) translateY(-1.5px); }

@media (max-width: 800px) {
  .nav-toggle { display: grid; order: 3; }
  .site-nav {
    order: 4; flex-basis: 100%; display: none;
    flex-direction: column; align-items: stretch;
    padding-bottom: .9rem; gap: .5rem;
  }
  .site-nav.is-open { display: flex; }
  .site-nav ul { flex-direction: column; gap: .1rem; }
  .site-nav a { padding: .6rem .8rem; font-size: 1rem; }
  .header-inner { flex-wrap: wrap; }
  .theme-toggle { margin-left: .8rem; }
}

/* ── Hero ───────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(60rem 26rem at 12% -12%, var(--accent-wash), transparent 65%),
    linear-gradient(var(--bg), var(--bg-alt));
}
.hero-grid { display: grid; gap: clamp(1.75rem, 4vw, 3.5rem); align-items: center; }
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr) clamp(15rem, 26vw, 20rem); }
}
.hero-copy { min-width: 0; }

.hero-art { margin: 0; order: -1; }
@media (min-width: 900px) { .hero-art { order: 0; } }
.hero-art img {
  display: block; width: 100%; height: auto;
  max-width: 20rem; margin-inline: auto;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  box-shadow: var(--shadow-md), 0 0 0 6px color-mix(in srgb, var(--accent) 7%, transparent);
}
@media (min-width: 900px) { .hero-art img { max-width: none; } }

.hero-title { max-width: 30ch; display: flex; flex-wrap: wrap; align-items: baseline; gap: .18em .55em; }
.hero-code {
  font-family: var(--font-mono); font-size: .38em; font-weight: 600;
  letter-spacing: .06em; color: var(--accent);
  background: var(--surface); border: 1px solid var(--accent-line);
  padding: .38em .6em; border-radius: var(--radius-sm);
  transform: translateY(-.25em);
}
.hero-tagline { font-size: 1.15rem; color: var(--ink-2); max-width: 60ch; text-wrap: pretty; }

.facts {
  display: grid; gap: 1px; margin: clamp(1.75rem, 4vw, 2.75rem) 0 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.fact { background: var(--surface); padding: 1rem 1.1rem; }
.fact dt {
  font-size: .7rem; font-weight: 620; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: .4rem;
}
.fact dd { margin: 0; font-size: .95rem; line-height: 1.5; }

.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.75rem; }
.hero-copy .hero-actions { margin-bottom: 0; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.05rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: .93rem; font-weight: 560; text-decoration: none; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.btn:hover { background: var(--bg-alt); border-color: var(--ink-3); color: var(--ink); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.btn-small { padding: .35rem .7rem; font-size: .84rem; }

/* ── Up next ────────────────────────────────────────────────────────────────── */
.up-next {
  margin-top: clamp(1.5rem, 3vw, 2.25rem); margin-bottom: 0; position: relative;
  background: var(--surface); border: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow-md);
}
.up-next-label {
  font-size: .7rem; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .3rem;
}
.up-next-when { font-size: .9rem; color: var(--ink-2); margin-bottom: .25rem; font-variant-numeric: tabular-nums; }
.up-next-title { font-size: 1.15rem; margin-bottom: .35rem; }
.up-next-meta { font-size: .9rem; color: var(--ink-2); margin-bottom: .5rem; }
.up-next-link { font-size: .89rem; font-weight: 560; }

/* ── Grade breakdown ────────────────────────────────────────────────────────── */
.grade-bar {
  display: flex; gap: 3px; height: 2.6rem; margin-bottom: 1.5rem;
  border-radius: var(--radius-sm); overflow: hidden;
}
.grade-seg {
  display: grid; place-items: center; min-width: 0;
  background: var(--seg); color: #fff; font-size: .82rem; font-weight: 620;
  border-radius: 3px;
}
.grade-seg-pct { text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.grade-seg:nth-child(1), .grade-list li:nth-child(1) { --seg: hsl(188 52% 34%); }
.grade-seg:nth-child(2), .grade-list li:nth-child(2) { --seg: hsl(262 40% 50%); }
.grade-seg:nth-child(3), .grade-list li:nth-child(3) { --seg: hsl(348 48% 47%); }
.grade-seg:nth-child(4), .grade-list li:nth-child(4) { --seg: hsl(152 44% 33%); }
.grade-seg:nth-child(5), .grade-list li:nth-child(5) { --seg: hsl(28 60% 44%); }
.grade-seg:nth-child(6), .grade-list li:nth-child(6) { --seg: hsl(210 42% 42%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .grade-seg:nth-child(1), :root:not([data-theme="light"]) .grade-list li:nth-child(1) { --seg: hsl(188 48% 46%); }
  :root:not([data-theme="light"]) .grade-seg:nth-child(2), :root:not([data-theme="light"]) .grade-list li:nth-child(2) { --seg: hsl(262 45% 62%); }
  :root:not([data-theme="light"]) .grade-seg:nth-child(3), :root:not([data-theme="light"]) .grade-list li:nth-child(3) { --seg: hsl(348 52% 58%); }
  :root:not([data-theme="light"]) .grade-seg:nth-child(4), :root:not([data-theme="light"]) .grade-list li:nth-child(4) { --seg: hsl(152 40% 44%); }
  :root:not([data-theme="light"]) .grade-seg:nth-child(5), :root:not([data-theme="light"]) .grade-list li:nth-child(5) { --seg: hsl(28 58% 55%); }
  :root:not([data-theme="light"]) .grade-seg:nth-child(6), :root:not([data-theme="light"]) .grade-list li:nth-child(6) { --seg: hsl(210 45% 56%); }
}
:root[data-theme="dark"] .grade-seg:nth-child(1), :root[data-theme="dark"] .grade-list li:nth-child(1) { --seg: hsl(188 48% 46%); }
:root[data-theme="dark"] .grade-seg:nth-child(2), :root[data-theme="dark"] .grade-list li:nth-child(2) { --seg: hsl(262 45% 62%); }
:root[data-theme="dark"] .grade-seg:nth-child(3), :root[data-theme="dark"] .grade-list li:nth-child(3) { --seg: hsl(348 52% 58%); }
:root[data-theme="dark"] .grade-seg:nth-child(4), :root[data-theme="dark"] .grade-list li:nth-child(4) { --seg: hsl(152 40% 44%); }
:root[data-theme="dark"] .grade-seg:nth-child(5), :root[data-theme="dark"] .grade-list li:nth-child(5) { --seg: hsl(28 58% 55%); }
:root[data-theme="dark"] .grade-seg:nth-child(6), :root[data-theme="dark"] .grade-list li:nth-child(6) { --seg: hsl(210 45% 56%); }

.grade-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.grade-list li {
  display: grid; align-items: baseline; gap: .2rem .75rem;
  grid-template-columns: auto 3.1rem minmax(0, 1fr);
  padding: .6rem 0; border-top: 1px solid var(--line);
}
.grade-list li:last-child { border-bottom: 1px solid var(--line); }
.grade-swatch { width: .6rem; height: .6rem; border-radius: 2px; background: var(--seg); transform: translateY(-1px); }
.grade-weight { font-weight: 650; font-size: 1rem; }
.grade-name { font-weight: 545; }
.grade-note { grid-column: 3; font-size: .875rem; }
@media (max-width: 560px) {
  .grade-list li { grid-template-columns: auto 3rem 1fr; }
  .grade-note { grid-column: 2 / -1; }
}

/* ── Module cards ───────────────────────────────────────────────────────────── */
.module-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15.5rem), 1fr));
}
.module-card {
  background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid var(--mod-dot);
  border-radius: var(--radius); padding: 1.15rem 1.2rem 1.05rem;
  display: flex; flex-direction: column; gap: .3rem;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.module-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.module-num {
  font-size: .7rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
  color: var(--mod-fg); margin: 0;
}
.module-card h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.module-card p.muted { font-size: .89rem; flex: 1; }
.module-link { font-size: .85rem; font-weight: 560; margin-top: .5rem; text-decoration: none; color: var(--mod-fg); }
.module-link:hover { color: var(--mod-fg); text-decoration: underline; }

.module-tag {
  display: inline-flex; align-items: flex-start; gap: .4rem;
  font-size: .74rem; font-weight: 600; line-height: 1.35;
  color: var(--mod-fg); background: var(--mod-bg);
  border: 1px solid var(--mod-line); border-radius: 100px;
  padding: .2rem .6rem .2rem .5rem;
  /* Must wrap: the week rail is 11rem and a chip that refuses to break spills
     right, where the meeting boxes paint over it. */
  white-space: normal; max-width: 100%;
}
.module-tag .module-dot { margin-top: .38em; }
.module-dot { width: .45rem; height: .45rem; border-radius: 50%; background: var(--mod-dot); flex: none; }

/* ── Key dates ──────────────────────────────────────────────────────────────── */
.dates { list-style: none; margin: 0 0 1rem; padding: 0; }
.date-item {
  display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: .3rem 1rem;
  padding: .8rem 0; border-top: 1px solid var(--line);
}
.date-item:last-of-type { border-bottom: 1px solid var(--line); }
.date-when { font-weight: 620; font-size: .92rem; color: var(--ink); }
.date-item.is-past { opacity: .5; }
.date-what { font-weight: 545; }
.date-blurb { display: block; font-weight: 400; font-size: .875rem; margin-top: .15rem; }
.date-project  .date-when { color: hsl(262 42% 48%); }
.date-assignment .date-when { color: hsl(152 44% 33%); }
.date-admin    .date-when { color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .date-project  .date-when { color: hsl(262 48% 68%); }
  :root:not([data-theme="light"]) .date-assignment .date-when { color: hsl(152 42% 52%); }
}
:root[data-theme="dark"] .date-project  .date-when { color: hsl(262 48% 68%); }
:root[data-theme="dark"] .date-assignment .date-when { color: hsl(152 42% 52%); }
@media (max-width: 480px) { .date-item { grid-template-columns: 1fr; } }

/* ── Outcomes ───────────────────────────────────────────────────────────────── */
.outcomes { counter-reset: o; list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.outcomes li {
  counter-increment: o; position: relative; padding-left: 2.6rem;
  color: var(--ink-2); font-size: .96rem; max-width: 78ch;
}
.outcomes li::before {
  content: counter(o); position: absolute; left: 0; top: .1rem;
  display: grid; place-items: center; width: 1.7rem; height: 1.7rem;
  font-size: .8rem; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--accent); background: var(--accent-wash);
  border: 1px solid var(--accent-line); border-radius: 50%;
}

/* ── Interior pages ─────────────────────────────────────────────────────────── */
.page-head {
  padding-block: clamp(2rem, 4.5vw, 3.25rem) clamp(1.25rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--bg-alt), var(--bg));
}
.page-head h1 { margin-bottom: .6rem; }
.page-layout { padding-block: clamp(2rem, 4vw, 3rem); }
.page-layout.has-toc { display: grid; gap: clamp(1.5rem, 4vw, 3rem); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .page-layout.has-toc { grid-template-columns: 15rem minmax(0, 1fr); }
  .toc { position: sticky; top: 5.5rem; align-self: start; max-height: calc(100vh - 7rem); overflow-y: auto; }
}
.toc-label {
  font-size: .7rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: .6rem;
}
.toc nav ul, .toc > ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li { margin: 0; }
.toc a {
  display: block; padding: .28rem 0 .28rem .85rem; margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: .875rem; color: var(--ink-2); text-decoration: none; line-height: 1.45;
}
.toc a:hover { color: var(--ink); border-left-color: var(--line-2); }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 560; }
.toc ul ul a { padding-left: 1.6rem; font-size: .84rem; }
@media (max-width: 959px) {
  .toc { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
}

/* ── Prose ──────────────────────────────────────────────────────────────────── */
.prose { max-width: 72ch; }
.prose > :first-child { margin-top: 0; }
.prose h2 {
  margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
  scroll-margin-top: 5.5rem;
}
.prose > h2:first-of-type { margin-top: 1rem; padding-top: 0; border-top: 0; }
.prose h3 { margin-top: 1.9rem; scroll-margin-top: 5.5rem; }
.prose h4 { margin-top: 1.5rem; font-size: 1rem; color: var(--ink-2); scroll-margin-top: 5.5rem; }
.prose ul, .prose ol { padding-left: 1.35rem; margin: 0 0 1.1rem; }
.prose li { margin-bottom: .45rem; }
.prose li > ul, .prose li > ol { margin-top: .45rem; }
.prose strong { font-weight: 640; color: var(--ink); }
.prose blockquote {
  margin: 1.5rem 0; padding: .3rem 0 .3rem 1.1rem;
  border-left: 3px solid var(--accent-line); color: var(--ink-2); font-style: italic;
}
.prose-tight { max-width: 66ch; font-size: 1rem; color: var(--ink-2); }
.prose-tight p:last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 1.25rem 0 1.75rem; }
.prose table { width: 100%; border-collapse: collapse; margin: 0; font-size: .93rem; }
.prose :is(th, td) { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose thead th { font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--line-2); }
.prose tbody tr:hover { background: var(--surface-2); }
.prose td:first-child { white-space: nowrap; }
/* On a phone, let the first column wrap so the table fits instead of scrolling. */
@media (max-width: 720px) {
  .prose td:first-child { white-space: normal; }
  .prose :is(th, td) { padding: .55rem .5rem; }
}

/* ── Schedule ───────────────────────────────────────────────────────────────── */
.schedule-controls {
  position: sticky; top: 4rem; z-index: 40;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.controls-inner {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  padding-block: .7rem; max-width: var(--wrap-wide);
}
.filters { display: flex; flex-wrap: wrap; gap: .35rem; }
.controls-right { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.chip-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .7rem; border-radius: 100px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: .8rem; font-weight: 560; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.chip-btn:hover { border-color: var(--line-2); color: var(--ink); }
.chip-btn.is-on { background: var(--mod-bg, var(--accent-wash)); color: var(--mod-fg, var(--accent)); border-color: var(--mod-line, var(--accent-line)); }
.chip-btn[data-filter="all"].is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.switch { display: inline-flex; align-items: center; gap: .45rem; font-size: .84rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { accent-color: var(--accent); width: 1rem; height: 1rem; cursor: pointer; }

.filter-empty { padding: 3rem 0; text-align: center; color: var(--ink-3); }

.weeks { margin-block: clamp(1rem, 3vw, 2rem) 0; }
.module-anchor { display: block; height: 0; scroll-margin-top: 8.5rem; }

.week {
  display: grid; gap: .9rem 2rem;
  grid-template-columns: 11rem minmax(0, 1fr);
  padding-block: 1.6rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 8.5rem;
}
.week:last-child { border-bottom: 1px solid var(--line); }
.week[hidden] { display: none; }
.week.is-past { opacity: .68; }
.week.is-past:hover, .week.is-past:focus-within { opacity: 1; }
.week.is-current {
  background: linear-gradient(90deg, var(--accent-wash), transparent 55%);
  border-radius: var(--radius);
  padding-inline: 1rem; margin-inline: -1rem;
  box-shadow: inset 3px 0 0 var(--accent);
}
.week.is-current .week-num[data-current-label]::after {
  content: attr(data-current-label); display: block;
  font-size: .66rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); margin-top: .2rem;
}

.week-rail { display: flex; flex-direction: column; align-items: flex-start; gap: .55rem; }
.week-num { font-size: 1.6rem; font-weight: 680; line-height: 1; letter-spacing: -.03em; color: var(--ink); }
.week-num-label {
  display: block; font-size: .68rem; font-weight: 620; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: .25rem;
}
.week-title { margin: 0 0 .2rem; font-size: 1.13rem; }
.week-note {
  font-size: .85rem; color: var(--warn); background: var(--warn-wash);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius-sm); padding: .45rem .7rem; margin: .5rem 0 .75rem;
}

.meetings { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .55rem; }
.meeting {
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: .9rem;
  padding: .55rem .8rem .55rem .7rem;
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 2px solid var(--mod-dot, var(--line-2));
  border-radius: var(--radius-sm);
}
.meeting.is-canceled { opacity: .6; }
.meeting.is-canceled .meeting-date { text-decoration: line-through; text-decoration-color: var(--line-2); }
.meeting.is-next { border-color: var(--accent-line); background: var(--accent-wash); border-left-color: var(--accent); }
.meeting-date { display: flex; flex-direction: column; line-height: 1.25; }
.meeting-date .dow { font-size: .7rem; font-weight: 620; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.meeting-date .dmy { font-size: .95rem; font-weight: 600; }
.meeting-body { min-width: 0; font-size: .9rem; }
.meeting-body > :last-child { margin-bottom: 0; }
.meeting-label, .meeting-lecture { font-weight: 580; margin: 0 0 .2rem; }
.meeting-tba { color: var(--ink-3); font-size: .85rem; font-style: italic; margin: 0; }

.tiny-label {
  display: inline-block; font-size: .64rem; font-weight: 650; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3); margin-right: .4rem;
  vertical-align: .08em;
}
.reading { margin: 0 0 .3rem; }
/* Optional readings sit a shade back from required ones. */
.reading:has(.tiny-label.is-optional) { color: var(--ink-2); }
.tiny-label.is-optional { color: var(--ink-3); font-weight: 600; }
.reading .authors::before { content: " — "; }
.reading .chip { margin-left: .4rem; vertical-align: .05em; }
.reading-note { display: block; font-size: .78rem; margin-top: .1rem; }
/* A `reading:` id in schedule.yaml with no folder in F26/readings/ — loud on
   purpose, so a typo cannot quietly drop a reading from the schedule. */
.reading.is-missing { color: var(--warn); font-weight: 600; }
.venue {
  display: inline-block; margin-left: .4rem; font-size: .74rem; font-weight: 560;
  color: var(--ink-2); background: var(--bg-alt); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 .35rem;
}
.meeting-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin: .35rem 0 0; }
.meeting-meta:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .76rem; font-weight: 560; border-radius: 100px;
  padding: .15rem .55rem; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.chip-presenter::before { content: "◆"; font-size: .6rem; color: var(--accent); }
.chip-slides { color: var(--accent); border-color: var(--accent-line); background: var(--accent-wash); }
.chip-slides:hover { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.topics { margin-top: .8rem; font-size: .9rem; }
.topics summary {
  cursor: pointer; color: var(--ink-2); font-size: .82rem; font-weight: 560;
  list-style: none; display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem 0; width: fit-content;
}
.topics summary::-webkit-details-marker { display: none; }
.topics summary::before {
  content: ""; display: inline-block; flex: none;
  width: 0; height: 0;
  border-left: 4.5px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform .15s ease;
}
.topics[open] summary::before { transform: rotate(90deg); }
.topics summary:hover { color: var(--accent); }
.topics ul { margin: .6rem 0 0; padding-left: 1.15rem; color: var(--ink-2); }
.topics li { margin-bottom: .3rem; }

@media (max-width: 720px) {
  .week { grid-template-columns: 1fr; gap: .6rem; padding-block: 1.4rem; }
  /* Module names are long enough to force the page wider than a phone if the
     chips refuse to wrap. Let them break instead. */
  .chip-btn { white-space: normal; }
  .week-rail { flex-direction: row; align-items: flex-start; flex-wrap: wrap; gap: .5rem .8rem; }
  .week-num { font-size: 1.15rem; display: flex; align-items: baseline; gap: .35rem; }
  .week-num-label { display: inline; margin: 0; }
  .week.is-current .week-num::after { display: inline-block; margin: 0 0 0 .5rem; }
  .schedule-controls { position: static; }
  .controls-right { margin-left: 0; }
}

/* ── Note box ───────────────────────────────────────────────────────────────── */
.note-box {
  margin-block: clamp(2rem, 4vw, 3rem) clamp(2rem, 5vw, 4rem);
  background: var(--bg-alt); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.3rem 1.4rem;
}
.note-box h2 { font-size: 1rem; margin-bottom: .8rem; }
.ack-box p { font-size: .93rem; color: var(--ink-2); max-width: 74ch; }
.ack-box p:last-child { margin-bottom: 0; }
.note-box ul { margin: 0; padding-left: 1.15rem; font-size: .9rem; color: var(--ink-2); }
.note-box li { margin-bottom: .5rem; }
.note-box li:last-child { margin-bottom: 0; }

.notfound { text-align: center; padding-block: clamp(4rem, 12vw, 8rem); }
.notfound .hero-actions { justify-content: center; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer { margin-top: clamp(3rem, 6vw, 5rem); border-top: 1px solid var(--line); background: var(--bg-alt); }
.footer-grid {
  display: grid; gap: 1.5rem; padding-block: 2.25rem 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  font-size: .9rem;
}
.footer-grid p { margin: 0 0 .25rem; }
.footer-course { font-size: 1rem; margin-bottom: .35rem !important; }
.footer-label {
  font-size: .7rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: .45rem !important;
}
.footer-bar { padding-bottom: 2rem; border-top: 1px solid var(--line); padding-top: 1rem; }

/* ── Print (the syllabus gets printed) ──────────────────────────────────────── */
@media print {
  :root { --bg: #fff; --surface: #fff; --bg-alt: #fff; --ink: #000; --ink-2: #333; --line: #ccc; }
  .site-header, .site-footer, .schedule-controls, .theme-toggle, .nav-toggle,
  .hero-actions, .up-next, .toc, .skip-link { display: none !important; }
  body { font-size: 10.5pt; }
  .hero { background: none; border-bottom: 1px solid #999; }
  .week, .prose h2, .module-card { break-inside: avoid; }
  .topics { display: block; }
  .topics[open] summary::before, .topics summary::before { display: none; }
  a { color: #000; text-decoration: underline; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; word-break: break-all; }
}
