/* ═══════════════════════════════════════════════════════════════
   CS7 — Course Site Stylesheet
   Design system: Poseidon sibling (mint / terracotta / cream)
   Fonts: Fraunces (display) · Inter (body) · JetBrains Mono (code)
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens ───────────────────────────────────────────────────── */
:root {
  --font-display: 'Fraunces', Georgia, serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'Courier New', monospace;

  --bg:       #fbf8f1;
  --bg-2:     #f5f1e8;
  --surface:  #ffffff;
  --ink:      #13141a;
  --ink-2:    #3d4148;
  --ink-3:    #6b6f78;
  --ink-4:    #9aa0a8;
  --border:   #e8e2d3;
  --border-2: #d4ccba;

  --brand:        #4dbba0;
  --brand-deep:   #2e8a73;
  --brand-fg:     #0c5a4a;
  --brand-bg:     #e8f5f0;
  --brand-border: #b8e0d2;

  --accent:    #c9683a;
  --accent-fg: #7a3e1f;
  --accent-bg: #f5e6dc;

  --amber:     #e8a838;
  --amber-fg:  #7a5010;
  --amber-bg:  #fdf3d8;

  --radius: 6px;
  --max-w:  1100px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content, .asgn-layout { flex: 1; }

a { color: var(--brand-fg); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: #d8d3c5;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 52px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}

/* nav is a direct flex child of topbar — margin-left: auto pushes it right */
.topbar nav {
  margin-left: auto;
  min-width: 0;
}

.topbar-cs { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; color: var(--brand); font-variation-settings: 'opsz' 36, 'SOFT' 40; }
.topbar-title { font-size: 0.8125rem; color: #8b8780; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  flex-wrap: wrap;
}

.topbar-nav a {
  color: #b8b3aa;
  font-size: 0.8125rem;
  padding: 0.3rem 0.625rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.topbar-nav a:hover { color: #fff; background: rgba(255,255,255,0.08); text-decoration: none; }
.topbar-nav a.nav-cta {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
}
.topbar-nav a.nav-cta:hover { background: var(--brand-deep); }

/* ── Page header ──────────────────────────────────────────────── */
.page-header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1.5rem 1.75rem;
}

.page-header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.page-header-logo {
  height: 64px;
  width: auto;
  flex-shrink: 0;
  opacity: 0.92;
}

.course-label {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 400;
  color: var(--brand-fg);
  font-variation-settings: 'opsz' 72, 'SOFT' 30;
  line-height: 1;
}

.course-subtitle {
  font-size: 1rem;
  color: var(--ink-3);
  margin-top: 0.25rem;
}

.course-meta {
  font-size: 0.8125rem;
  color: var(--ink-4);
  margin-top: 0.5rem;
}

/* ── Content wrapper ──────────────────────────────────────────── */
.content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ── Section headings ─────────────────────────────────────────── */
.section-heading {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 400;
  color: var(--brand-fg);
  font-variation-settings: 'opsz' 36, 'SOFT' 30;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--brand-bg);
}

.section-heading:first-child { margin-top: 0; }

/* ── Announcements ────────────────────────────────────────────── */
.ann-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.ann-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
}

.ann-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-fg);
  background: var(--brand-bg);
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 4.5rem;
  text-align: center;
}

.ann-date--empty {
  background: transparent;
  border-color: transparent;
  min-width: 4.5rem;
}

.ann-text { font-size: 0.9rem; color: var(--ink-2); line-height: 1.5; }
.ann-text a { color: var(--brand-fg); }
.ann-text a:hover { text-decoration: underline; }

/* ── Schedule table ───────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -0.25rem; }

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 780px;
}

.schedule-table thead th {
  background: var(--ink);
  color: #c8c3bb;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.625rem 0.75rem;
  text-align: left;
  border: none;
}

.schedule-table thead th:first-child { text-align: center; width: 3.5rem; }

.schedule-table tbody td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  vertical-align: top;
  background: var(--surface);
  line-height: 1.45;
}

/* Alternating week backgrounds */
.schedule-table tbody tr:nth-child(odd) td { background: var(--bg); }
.schedule-table tbody tr:nth-child(even) td { background: var(--surface); }
/* Override: weeknum cell always same within a group */
.schedule-table td.weeknum {
  background: var(--bg-2) !important;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 400;
  color: var(--brand-fg);
  font-variation-settings: 'opsz' 36, 'SOFT' 40;
  vertical-align: middle;
  border-right: 2px solid var(--brand-border);
}

.schedule-table td.col-date {
  white-space: nowrap;
  color: var(--ink-3);
  font-size: 0.8rem;
  width: 7.5rem;
}

.schedule-table td.col-topic {
  font-weight: 500;
  color: var(--ink);
  min-width: 220px;
}

.schedule-table td.col-reading { width: 5rem; text-align: center; }

.schedule-table td.col-lab,
.schedule-table td.col-hw,
.schedule-table td.col-proj { min-width: 160px; }

/* ── Resource links (Video / Slides / Code / Notes) ───────────── */
.res-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.res {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  text-decoration: none !important;
  border: 1px solid transparent;
  transition: opacity 0.15s;
}
.res:hover { opacity: 0.75; }

.res-video  { background: #e8f0fb; color: #2d5cb8; border-color: #c0d0f0; }
.res-slides { background: var(--amber-bg); color: var(--amber-fg); border-color: #f0d898; }
.res-code   { background: #f0f0f8; color: #4a3e8a; border-color: #d0ccf0; font-family: var(--font-mono); }
.res-notes  { background: var(--accent-bg); color: var(--accent-fg); border-color: #e8c5ad; }
.res        { background: var(--bg-2); color: var(--ink-3); border-color: var(--border); }

/* ── Reading links ────────────────────────────────────────────── */
.reading-link {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-fg);
  background: var(--brand-bg);
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  margin: 0.1rem 0;
  text-decoration: none !important;
}
.reading-link:hover { background: var(--brand-border); }

/* ── Assignment cells ─────────────────────────────────────────── */
.asgn { display: flex; flex-direction: column; gap: 0.25rem; }
.asgn a { color: var(--ink); font-weight: 500; font-size: 0.8rem; }
.asgn a:hover { color: var(--brand-fg); }

.due {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  border: 1px solid transparent;
  width: fit-content;
}

.badge-lab  { background: var(--brand-bg);  color: var(--brand-fg);  border-color: var(--brand-border); }
.badge-hw   { background: var(--amber-bg);  color: var(--amber-fg);  border-color: #f0d898; }
.badge-proj { background: var(--accent-bg); color: var(--accent-fg); border-color: #e8c5ad; }

/* ── Resources section ────────────────────────────────────────── */
.resources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.resources-list li::before { content: "→ "; color: var(--brand); font-weight: 700; }
.resources-list a { color: var(--brand-fg); }
.resources-list a:hover { text-decoration: underline; }

/* ── About page ───────────────────────────────────────────────── */
.about-section { margin-bottom: 2rem; }
.about-section h2 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 400;
  color: var(--brand-fg);
  font-variation-settings: 'opsz' 24, 'SOFT' 30;
  margin: 2rem 0 0.625rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
}

.about-section p { color: var(--ink-2); margin-bottom: 0.875rem; }
.about-section a { color: var(--brand-fg); }
.about-section ul,
.about-section ol {
  color: var(--ink-2);
  margin: 0.375rem 0 0.875rem 1.5rem;
  line-height: 1.7;
}
.about-section li { margin-bottom: 0.3rem; }

pre.grading-grid {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  color: var(--ink-2);
  margin: 0.75rem 0;
}

/* ── Staff page ───────────────────────────────────────────────── */
.staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem;
  margin: 1rem 0;
}

.staff-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.staff-card img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--brand-border);
}

.staff-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.staff-card-role {
  font-size: 0.78rem;
  color: var(--ink-3);
}

.staff-card a { color: var(--brand-fg); }

.staff-section-heading {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--ink-3);
  font-variation-settings: 'opsz' 24, 'SOFT' 40;
  margin: 1.75rem 0 0.75rem;
}

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer {
  background: var(--ink);
  color: #8b8780;
  text-align: center;
  font-size: 0.8rem;
  padding: 1.25rem;
  margin-top: 4rem;
}

.site-footer a { color: #b8b3aa; }
.site-footer a:hover { color: #fff; }
.site-footer .sep { margin: 0 0.5rem; }

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 720px) {
  /* Topbar: hide subtitle; nav fills remaining width, items scroll inside it */
  .topbar { padding: 0 1rem; gap: 0.75rem; }
  .topbar-title { display: none; }
  .topbar nav { margin-left: 0; flex: 1; overflow: hidden; }
  .topbar-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav a { font-size: 0.75rem; padding: 0.25rem 0.5rem; white-space: nowrap; }

  /* Page header: hide logo (illegible at small size), reset flex */
  .page-header { padding: 1.25rem 1rem 1rem; }
  .page-header-inner { display: block; }
  .course-label { font-size: 1.875rem; }
  .page-header-logo { display: none; }

  .content { padding: 1.25rem 1rem 3rem; }

  .ann-item { flex-direction: column; gap: 0.375rem; }
  .ann-date { align-self: flex-start; }

  /* ── Schedule table → card layout ── */
  .table-scroll { overflow-x: visible; margin: 0; }

  .schedule-table { min-width: unset; width: 100%; }
  .schedule-table thead { display: none; }

  .schedule-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
  }

  /* Reset alternating row backgrounds — card handles its own surface */
  .schedule-table tbody tr:nth-child(odd) td,
  .schedule-table tbody tr:nth-child(even) td { background: var(--surface) !important; }

  .schedule-table tbody td {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: none;
    border-bottom: 1px solid var(--border);
    /* Reset desktop sizing */
    width: auto;
    min-width: unset;
    white-space: normal;
    text-align: left;
    font-size: 0.875rem;
  }

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

  /* Column label prefix from data-label attribute */
  .schedule-table tbody td::before {
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-4);
    min-width: 4.25rem;
    flex-shrink: 0;
    padding-top: 0.2rem;
    line-height: 1.4;
  }

  /* Week cell: full-width mint header, no label prefix needed */
  .schedule-table td.weeknum {
    background: var(--brand-bg) !important;
    color: var(--brand-fg);
    border-bottom: 2px solid var(--brand-border) !important;
    border-right: none;
    font-size: 0.8125rem;
    font-weight: 600;
    vertical-align: middle;
    font-variation-settings: 'opsz' 24, 'SOFT' 40;
  }
  .schedule-table td.weeknum::before { content: "Week "; }

  /* Hide empty cells (no reading, no assignment) */
  .schedule-table td.col-reading:empty,
  .schedule-table td.col-lab:empty,
  .schedule-table td.col-hw:empty,
  .schedule-table td.col-proj:empty { display: none; }

  .staff-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1rem; }
}
