/* Variables */
:root {
  --bg: #fcfaf7;
  --ink: #1f2c46;
  --muted: #4b5563;
  --accent: #b97c2f;
  --gold: #d9a45e;
  --soft: #f3ecdf;
  --card: rgba(31, 44, 70, 0.06);
  --blue: #224993;
  --green: #2f7d4f;
  --code-bg: #f6f8fa;   /* neutral gray-blue, not the site cream: code reads as code */
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

a {
  color: var(--ink);
  text-decoration-color: rgba(31, 44, 70, 0.35);
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Header */
.site-header {
  background-color: var(--ink);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header::after {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, rgba(217, 164, 94, 0.35) 55%, rgba(217, 164, 94, 0) 100%);
}

.navbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.9rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  flex-shrink: 0;
}

.brand-name {
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-sep {
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 1.5rem;
}

.nav-link {
  position: relative;
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  padding: 0.3rem 0;
  transition: color 0.2s;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.nav-link:hover {
  color: #fff;
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

.nav-link.active {
  color: #fff;
}

.nav-link-ext {
  color: rgba(255, 255, 255, 0.5);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.85rem;
  font-weight: 500;
}

.nav-link-ext::after {
  display: none;
}

/* Hamburger Menu Button (mobile only) */
.menu-toggle {
  display: none;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: rgba(255, 255, 255, 0.8);
}

.menu-toggle:hover {
  color: #fff;
}

/* Course hero (homepage) */
.course-hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem 3rem;
}

.course-code {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 0.5rem;
}

.course-title {
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.course-tagline {
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 720px;
}

.course-people {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  margin-top: 2rem;
}

.person {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.person-role {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.person-name {
  font-weight: 600;
}

.person-mail {
  font-size: 0.9rem;
  color: var(--blue);
}

/* Sections */
.section-divider {
  max-width: 1100px;
  margin: 0 auto 2rem;
  border: none;
  border-top: 1px solid rgba(31, 44, 70, 0.12);
}

.home-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 1rem 0;
  scroll-margin-top: 80px;
}

.home-intro {
  max-width: 760px;
  color: var(--muted);
}

.home-intro p {
  margin-bottom: 0.9rem;
}

.home-intro strong {
  color: var(--ink);
}

.home-intro ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 0.9rem;
}

.home-intro li {
  margin-bottom: 0.4rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-week {
  background: rgba(35, 74, 140, 0.1);
  color: var(--blue);
  border: 1px solid rgba(35, 74, 140, 0.18);
}

.badge-due {
  background: rgba(185, 124, 47, 0.1);
  color: var(--accent);
  border: 1px solid rgba(185, 124, 47, 0.22);
}

/* Schedule table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid rgba(31, 44, 70, 0.08);
  border-radius: 10px;
  overflow: hidden;
}

.schedule-table th,
.schedule-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(31, 44, 70, 0.08);
  text-align: left;
  vertical-align: top;
}

.schedule-table th {
  background: rgba(35, 74, 140, 0.1);
  color: #234a8c;
  font-weight: 600;
}

.schedule-table tr:last-child td {
  border-bottom: none;
}

.schedule-link {
  display: block;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
}

.schedule-link:hover {
  color: var(--accent);
}

.schedule-none {
  color: rgba(75, 85, 99, 0.4);
}

.schedule-note {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}

/* Page content */
.page-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--ink);
}

.page-badges {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.page-summary {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 1.5rem;
  max-width: 720px;
}

.back-link {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 1.25rem;
}

.back-link:hover {
  color: var(--accent);
}

/* Card grid (teaching / labs lists) */
.list-intro {
  max-width: 760px;
  color: var(--muted);
  margin-bottom: 2rem;
}

.list-intro p {
  margin-bottom: 0.9rem;
}

.list-intro ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 0.9rem;
}

.card-grid {
  display: grid;
  gap: 1.5rem;
}

.card {
  display: grid;
  gap: 0.6rem;
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid rgba(31, 44, 70, 0.12);
  border-radius: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.card:hover {
  border-color: rgba(185, 124, 47, 0.4);
  box-shadow: 0 10px 30px rgba(31, 44, 70, 0.08);
  transform: translateY(-2px);
}

.card-badges {
  display: flex;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
}

.card-summary {
  color: var(--muted);
  margin: 0;
}

.card-cta {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

/* Lab hero */
.lab-hero {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(31, 44, 70, 0.12);
  margin-bottom: 2rem;
}

/* Download buttons */
.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: var(--ink);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-download:hover {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(185, 124, 47, 0.25);
  transform: translateY(-2px);
}

.btn-kind {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

/* "What you'll build" figure strip (homepage) */
.build-intro {
  color: var(--muted);
  margin: -0.5rem 0 1.5rem;
}

.build-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.build-card {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.build-card img {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
  border: 1px solid rgba(31, 44, 70, 0.12);
  border-radius: 12px;
  padding: 0.4rem;
  transition: all 0.2s ease;
}

.build-card a:hover img {
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(31, 44, 70, 0.1);
  transform: translateY(-2px);
}

.build-card figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.build-card figcaption a {
  font-weight: 600;
  color: var(--blue);
}

.build-card figcaption a:hover {
  color: var(--accent);
}

@media (max-width: 768px) {
  .build-grid {
    grid-template-columns: 1fr;
  }
}

/* Per-page materials box */
.resource-block {
  margin: 1.5rem 0 2rem;
  padding: 1.1rem 1.25rem 0.6rem;
  background: var(--soft);
  border: 1px solid rgba(31, 44, 70, 0.1);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
}

.resource-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.resource-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0;
}

.resource-row + .resource-row {
  border-top: 1px dashed rgba(31, 44, 70, 0.12);
}

.resource-key {
  flex: 0 0 6.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.resource-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.resource-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--blue);
}

.resource-link:hover {
  color: var(--accent);
}

.resource-link-open {
  color: var(--green);
}

.resource-locked {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  .resource-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
}

/* Callouts (solution gate) */
.callout {
  margin-top: 2.5rem;
  padding: 1.5rem;
  border-radius: 14px;
}

.callout h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.callout p {
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.callout-locked {
  background: var(--soft);
  border: 1px dashed rgba(31, 44, 70, 0.25);
}

.callout-open {
  background: rgba(47, 125, 79, 0.07);
  border: 1px solid rgba(47, 125, 79, 0.25);
}

.callout-open h2 {
  color: var(--green);
}

.btn-solution {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  background: var(--green);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-solution:hover {
  background: var(--ink);
  color: #ffffff;
  transform: translateY(-2px);
}

/* Prose (markdown body) */
.prose {
  color: var(--ink);
}

.prose h2 {
  font-size: 1.5rem;
  margin: 2.25rem 0 0.75rem;
  scroll-margin-top: 80px;
}

.prose h3 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.5rem;
}

.prose p {
  margin-bottom: 0.9rem;
  line-height: 1.7;
}

.prose ul,
.prose ol {
  padding-left: 1.5rem;
  margin-bottom: 0.9rem;
}

.prose li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  background: var(--soft);
  padding: 0.9rem 1.2rem;
  border-radius: 0 10px 10px 0;
  margin: 1.25rem 0;
  color: var(--muted);
  font-style: italic;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose hr {
  border: none;
  border-top: 1px solid rgba(31, 44, 70, 0.12);
  margin: 2rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid rgba(31, 44, 70, 0.08);
  border-radius: 10px;
  overflow: hidden;
  margin: 1rem 0 1.5rem;
}

.prose th,
.prose td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid rgba(31, 44, 70, 0.08);
  text-align: left;
}

.prose th {
  background: rgba(35, 74, 140, 0.1);
  color: #234a8c;
  font-weight: 600;
}

.prose tr:last-child td {
  border-bottom: none;
}

/* Inline code + code blocks */
.prose code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid rgba(31, 44, 70, 0.08);
  border-radius: 5px;
  padding: 0.1em 0.35em;
}

.prose pre {
  background: var(--code-bg);
  border: 1px solid rgba(31, 44, 70, 0.1);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  line-height: 1.55;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

.prose .highlight pre {
  background: var(--code-bg) !important;
}

/* Notebook-specific (converted solution): the whole notebook renders as a
   white "sheet" on the cream site, so code and outputs sit on a neutral
   technical background rather than the site's warm tint. */
.notebook {
  background: #ffffff;
  border: 1px solid rgba(31, 44, 70, 0.1);
  border-radius: 14px;
  padding: 2rem 2.25rem;
  margin-top: 1.5rem;
  box-shadow: 0 10px 30px rgba(31, 44, 70, 0.05);
}

/* Code INPUT cells (Chroma-highlighted): neutral card with a navy accent */
.notebook .highlight pre {
  background: var(--code-bg) !important;
  border: 1px solid rgba(31, 44, 70, 0.1);
  border-left: 3px solid #1f4e79;
}

/* OUTPUT blocks (plain pre from nbconvert): white, gray left rule, so
   input and output are distinguishable at a glance */
.notebook > pre {
  background: #fbfcfd;
  border: none;
  border-left: 3px solid rgba(31, 44, 70, 0.18);
  border-radius: 0 8px 8px 0;
  color: #374151;
}

.notebook img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto 1.5rem;
  border: 1px solid rgba(31, 44, 70, 0.08);
  border-radius: 10px;
  background: #ffffff;
  padding: 0.5rem;
}

/* Notebook output tables, booktabs style: horizontal rules only — a heavy
   rule top and bottom, a light rule under the header, no vertical lines,
   no zebra striping; numbers right-aligned. */
.notebook table.dataframe {
  width: auto;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  font-size: 0.85rem;
  border: none;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  background: transparent;
  border-radius: 0;
}

.notebook table.dataframe thead th {
  background: transparent;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  font-weight: 600;
}

.notebook table.dataframe th,
.notebook table.dataframe td {
  padding: 0.4rem 0.8rem;
  white-space: nowrap;
  border-bottom: none;
  text-align: right;
}

.notebook table.dataframe tbody th {
  text-align: left;
  font-weight: 500;
}

.notebook table.dataframe td {
  font-variant-numeric: tabular-nums;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-sub {
  font-size: 0.8rem;
  color: rgba(75, 85, 99, 0.7);
  margin-top: 0.25rem;
}

/* Scroll to top button */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--muted);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 99;
}

.scroll-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-top:hover {
  background: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(185, 124, 47, 0.3);
}

/* Forum: pointer from a lecture / lab page */
.ask-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 2.5rem;
  padding: 0.85rem 1.1rem;
  background: var(--soft);
  border: 1px solid rgba(31, 44, 70, 0.1);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.ask-link svg {
  flex-shrink: 0;
  color: var(--accent);
}

.ask-link strong {
  color: var(--ink);
  font-weight: 600;
}

.ask-link:hover {
  border-left-color: var(--accent);
  color: var(--muted);
  transform: translateX(2px);
}

.ask-link:hover strong {
  color: var(--accent);
}

/* Forum: giscus thread */
.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(31, 44, 70, 0.12);
}

.comments-head h2 {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.comments-head p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
}

/* giscus injects its own iframe; keep it from inheriting prose widths */
.comments .giscus,
.comments .giscus-frame {
  width: 100%;
}

.comments-fallback {
  color: var(--muted);
  font-size: 0.92rem;
}

/* Responsive - Tablet (1024px) */
@media (max-width: 1024px) {
  .course-hero {
    padding: 3rem 1.5rem 2.5rem;
  }

  .course-title {
    font-size: 2.25rem;
  }

  .section-title {
    font-size: 1.75rem;
  }

  .page-content {
    padding: 2.5rem 1.5rem;
  }

  .home-section {
    padding: 0 1.5rem 2.5rem;
  }
}

/* Responsive - Mobile (768px) */
@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1.25rem;
  }

  .menu-toggle {
    display: flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 1.25rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--ink);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    min-width: 200px;
    overflow: hidden;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-menu li {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-menu li:first-child {
    border-top: none;
  }

  .nav-menu .nav-sep {
    border-left: none;
    padding-left: 0;
  }

  .nav-menu .nav-link {
    display: block;
    padding: 0.75rem 1.25rem;
  }

  .nav-menu .nav-link::after {
    display: none;
  }

  .nav-menu .nav-link.active {
    color: var(--gold);
  }

  .course-hero {
    padding: 2.5rem 1.25rem 2rem;
  }

  .course-title {
    font-size: 1.9rem;
  }

  .course-tagline {
    font-size: 1rem;
  }

  .course-people {
    gap: 1.5rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .page-title {
    font-size: 1.65rem;
  }

  .page-content {
    padding: 2rem 1.25rem;
  }

  .home-section {
    padding: 0 1.25rem 2rem;
  }

  .card {
    padding: 1.25rem;
  }

  .card-title {
    font-size: 1.2rem;
  }

  .schedule-table th,
  .schedule-table td {
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
  }

  .prose pre {
    padding: 0.85rem 1rem;
  }

  .scroll-top {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 44px;
    height: 44px;
  }
}

/* Responsive - Small Mobile (480px) */
@media (max-width: 480px) {
  .navbar {
    padding: 0.6rem 1rem;
  }

  .navbar-brand {
    gap: 8px;
  }

  .brand-name {
    font-size: 0.95rem;
  }

  .brand-code {
    font-size: 0.7rem;
  }

  .course-title {
    font-size: 1.6rem;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .page-content {
    padding: 1.5rem 1rem;
  }

  .home-section {
    padding: 0 1rem 1.75rem;
  }

  .badge {
    font-size: 0.72rem;
  }

  .btn-download {
    width: 100%;
    justify-content: center;
  }

  .site-footer {
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
  }

  .scroll-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}
