/* ============================================================
   11-811 course site — custom top-nav layout
   ============================================================ */

:root {
  --cmu-red: #c41230;
  --cmu-red-dark: #8c0d20;
  --ink: #1a1a2e;
  --text: #24242c;
  --muted: #5b5b66;
  --border: #e4e4ea;
  --bg: #ffffff;
  --bg-soft: #f7f7f9;
  --max: 1040px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--cmu-red); text-decoration: none; }
a:hover { color: var(--cmu-red-dark); text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  background: var(--ink);
  color: #fff;
  border-bottom: 4px solid var(--cmu-red);
  padding: 2rem 0 1.75rem;
}
.site-header .eyebrow {
  margin: 0 0 .5rem;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #b9b9c6;
}
.site-header .site-title {
  display: inline-block;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
}
.site-header .site-title:hover { color: #fff; text-decoration: none; }
.site-header .tagline { margin: .5rem 0 0; color: #c9c9d4; font-size: 1.05rem; }

/* ---------- Top nav ---------- */
.site-nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.nav-list {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-item { position: relative; }
.nav-item > a {
  display: block;
  padding: .85rem 1rem;
  color: var(--ink);
  font-weight: 500;
  border-bottom: 3px solid transparent;
}
.nav-item > a:hover { color: var(--cmu-red); text-decoration: none; }
.nav-item.active > a { color: var(--cmu-red); border-bottom-color: var(--cmu-red); }
.nav-item.external.first-external { margin-left: auto; }
.nav-item.external > a { color: var(--muted); font-weight: 400; }
.nav-item.external > a:hover { color: var(--cmu-red); }
.caret { font-size: .85em; }

/* ---------- Dropdown ---------- */
.dropdown-menu {
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  list-style: none;
  margin: 0;
  padding: .35rem 0;
  display: none;
  z-index: 30;
}
.has-dropdown.open .dropdown-menu { display: block; }
.dropdown-menu li { margin: 0; }
.dropdown-menu a { display: block; padding: .5rem 1rem; color: var(--ink); white-space: nowrap; }
.dropdown-menu a:hover { background: var(--bg-soft); color: var(--cmu-red); text-decoration: none; }
.dropdown-menu li.active a { color: var(--cmu-red); font-weight: 600; }
@media (hover: hover) {
  .has-dropdown:hover .dropdown-menu { display: block; }
}

/* ---------- Main content ---------- */
.site-main { padding: 2.25rem 0 3rem; }
.site-main h1 { font-size: 2rem; line-height: 1.2; margin: .1em 0 .5rem; }
.site-main h2 { font-size: 1.45rem; margin: 2rem 0 .75rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.site-main h3 { font-size: 1.18rem; margin: 1.6rem 0 .5rem; }
.site-main h4 { font-size: 1.02rem; margin: 1.2rem 0 .3rem; }
.site-main p, .site-main ul, .site-main ol { margin: 0 0 1rem; }
.site-main li { margin: .2rem 0; }
.site-main hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ---------- Tables ---------- */
.site-main table { border-collapse: collapse; width: 100%; margin: 0 0 1.25rem; font-size: .96rem; }
.site-main th, .site-main td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; vertical-align: top; }
.site-main thead th { background: var(--bg-soft); font-weight: 600; }
.site-main tbody tr:nth-child(even) { background: #fbfbfc; }

/* Schedule table */
.table-scroll { overflow-x: auto; margin: 0 0 1.25rem; }
.table-scroll table { margin-bottom: 0; }
.site-main .schedule { font-size: .9rem; }
.site-main .schedule th:first-child,
.site-main .schedule td:first-child { width: 2.2rem; text-align: center; color: #666; font-weight: 600; }
.site-main .schedule tr.week-start > td { border-top: 2px solid var(--border); }
.site-main .schedule tr.no-class td { color: #8a8a8a; }

/* Lecture-number badge */
.site-main .schedule .lec-no {
  display: inline-block; margin-right: .35em; padding: 0 .35em;
  border-radius: 3px; background: var(--bg-soft); border: 1px solid var(--border);
  font-size: .78em; font-weight: 600; color: #555; vertical-align: baseline;
}

/* Unit color rail (left edge of each row) + legend chips.
   Colors: 1 blue, 2 teal, 3 amber, 4 purple. */
.site-main .schedule tr.u1 td:first-child { border-left: 5px solid #3D6FB4; }
.site-main .schedule tr.u2 td:first-child { border-left: 5px solid #2E8B72; }
.site-main .schedule tr.u3 td:first-child { border-left: 5px solid #C98A1B; }
.site-main .schedule tr.u4 td:first-child { border-left: 5px solid #8E5AA6; }

.unit-legend { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .8rem; }
.unit-chip {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px;
  font-size: .82rem; text-decoration: none; color: #fff; border: 1px solid rgba(0,0,0,.08);
}
.unit-chip.u1 { background: #3D6FB4; }
.unit-chip.u2 { background: #2E8B72; }
.unit-chip.u3 { background: #C98A1B; }
.unit-chip.u4 { background: #8E5AA6; }
.unit-chip:hover { filter: brightness(1.08); }

/* Assignment type badges (lab / prj) in the schedule */
.site-main .schedule .atag {
  display: inline-block; padding: 0 .38em; border-radius: 3px;
  font-size: .72em; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; vertical-align: baseline;
}
.site-main .schedule .atag-lab { background: #E4EDF6; color: #2B4B72; border: 1px solid #C3D6E8; }
.site-main .schedule .atag-prj { background: #F1E8DB; color: #7A551A; border: 1px solid #E0CDAF; }

/* ---------- Assignment summary cards (home page) ---------- */
.assignment-summary {
  border: 1px solid var(--border);
  border-left: 4px solid var(--cmu-red);
  border-radius: 4px;
  padding: .6rem .9rem;
  margin: 0 0 .75rem;
  background: var(--bg-soft);
}
.assignment-summary h4 { margin: .1rem 0 .3rem; }
.assignment-summary p { margin: .2rem 0 0; }
.assignment-summary small { color: var(--muted); font-weight: 400; }

/* ---------- Lab detail meta ---------- */
.lab-meta {
  color: var(--muted);
  font-size: 1.02rem;
  margin: 0 0 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}

/* ---------- Code ---------- */
code { background: var(--bg-soft); padding: .1em .35em; border-radius: 3px; font-size: .9em; }
pre { background: var(--bg-soft); padding: 1rem; border-radius: 6px; overflow: auto; }
pre code { background: none; padding: 0; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: .9rem;
  padding: 1.5rem 0;
  margin-top: 2rem;
}
.site-footer p { margin: 0 0 .25rem; }
.site-footer .source-link a { color: var(--muted); }
.site-footer .source-link a:hover { color: var(--cmu-red); }

/* ---------- Expandable topic + FAQ blocks ---------- */
details.topic, details.faq {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  margin: 0 0 .6rem;
  padding: 0 .9rem;
}
details.topic > summary, details.faq > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  padding: .7rem 0;
}
details.faq > summary { font-size: .98rem; }
details.topic > summary:hover, details.faq > summary:hover { color: var(--cmu-red); }
details.topic[open], details.faq[open] { padding-bottom: .8rem; }
details.topic[open] > summary, details.faq[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: .7rem; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-header .site-title { font-size: 1.6rem; }
  .nav-item.external.first-external { margin-left: 0; }
  .nav-list { font-size: .95rem; }
}
