/* =========================================================
   Leland E. Farmer — personal site
   Layout: fixed left sidebar + scrollable main column
   Theme: UVA Jefferson Blue + Cavalier Orange
   To change schools, edit --accent-primary and --accent-secondary
   ========================================================= */

:root {
  /* Theme — change these two for a different school's palette */
  --accent-primary: #232D4B;     /* UVA Jefferson Blue */
  --accent-secondary: #E57200;   /* UVA Cavalier Orange */

  /* Derived */
  --accent-primary-soft: #f1f3f9;
  --accent-secondary-soft: #fdf1e3;

  /* Text & surfaces */
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #e4e4e6;
  --rule-soft: #efefef;
  --bg: #ffffff;
  --sidebar-bg: #fafaf7;
  --card-bg: #fbfaf6;
  --card-border: #eae6dc;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  --card-shadow-hover: 0 6px 18px rgba(35, 45, 75, 0.08);

  /* Layout */
  --sidebar-width: 290px;
  --sidebar-pad: 32px;
  --content-max: 680px;
  --content-pad: 56px;
}

/* =========================================================
   DARK THEME — invert surfaces, keep UVA accents warm
   ========================================================= */
html[data-theme="dark"] {
  --accent-primary: #8ea6d1;          /* lighter Jefferson Blue */
  --accent-secondary: #f59538;         /* brighter Cavalier Orange */
  --accent-primary-soft: #1d2636;
  --accent-secondary-soft: #2d2112;
  --text: #e5e1d8;
  --muted: #9aa0a8;
  --rule: #2a3340;
  --rule-soft: #1e252f;
  --bg: #0f1419;
  --sidebar-bg: #121820;
  --card-bg: #1a2028;
  --card-border: #2a3340;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  --card-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.45);
}
html[data-theme="dark"] .paper-meta em,
html[data-theme="dark"] .paper-status em { color: #d6ccbc; }
html[data-theme="dark"] .pill.published {
  background: var(--accent-primary);
  color: #0f1419;
}
html[data-theme="dark"] .pill.wp {
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
  border-color: #2d3a52;
}
html[data-theme="dark"] .pill.forthcoming {
  background: var(--accent-secondary-soft);
  color: #f7b478;
  border-color: #4a3620;
}
html[data-theme="dark"] .paper-title a { color: var(--text); border-bottom-color: rgba(142, 166, 209, 0.35); }
html[data-theme="dark"] .paper-note-block a { color: var(--accent-primary); border-bottom-color: rgba(142, 166, 209, 0.35); }
html[data-theme="dark"] .abstract { color: #d6d0c4; }
html[data-theme="dark"] .course-desc { color: #d0cabe; }
html[data-theme="dark"] #to-top { color: #0f1419; }
html[data-theme="dark"] #to-top:hover { color: #0f1419; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Charter", "Iowan Old Style", "Source Serif Pro", "Georgia", serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 140ms ease, color 140ms ease;
}
a:hover {
  border-bottom-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

/* =========================================================
   SIDEBAR (fixed left)
   ========================================================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  padding: var(--sidebar-pad);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar img.headshot {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 3px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.sidebar .name {
  font-family: "Charter", "Iowan Old Style", "Source Serif Pro", "Georgia", serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 6px;
}

.sidebar .title {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 4px;
}
.sidebar .title strong { color: var(--text); font-weight: 600; }

.sidebar .affil {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 18px;
}

.sidebar .contact {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.sidebar .contact a { color: var(--accent-primary); }

/* Sidebar nav */
.sidebar nav.pages {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar nav.pages a {
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0 4px 10px;
  border-left: 2px solid transparent;
  border-bottom: none;
  transition: color 120ms ease, border-color 120ms ease;
}
.sidebar nav.pages a:hover {
  color: var(--accent-primary);
  border-left-color: var(--accent-secondary);
}
.sidebar nav.pages a.active {
  color: var(--accent-primary);
  font-weight: 600;
  border-left-color: var(--accent-secondary);
}

/* Sub-section nav (within-page anchors) */
.sidebar nav.sections {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar nav.sections .sections-label {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  padding-left: 10px;
}
.sidebar nav.sections a {
  font-size: 13px;
  color: var(--muted);
  padding: 3px 0 3px 10px;
  border-left: 2px solid transparent;
  border-bottom: none;
  transition: color 120ms ease, border-color 120ms ease;
}
.sidebar nav.sections a:hover {
  color: var(--accent-primary);
  border-left-color: var(--accent-secondary);
}
.sidebar nav.sections a.active {
  color: var(--accent-primary);
  border-left-color: var(--accent-secondary);
}

/* External links group */
.sidebar .links {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  font-size: 13.5px;
}
.sidebar .links a { color: var(--accent-primary); }

/* Dark mode toggle */
.sidebar .theme-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  justify-content: flex-start;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 11px 5px 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.theme-toggle:hover {
  color: var(--accent-primary);
  border-color: var(--accent-secondary);
}
.theme-toggle .theme-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  flex-shrink: 0;
}
.theme-toggle .theme-icon--moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon--sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon--moon { display: inline-block; }

/* =========================================================
   MAIN CONTENT
   ========================================================= */
main {
  margin-left: var(--sidebar-width);
  padding: 64px var(--content-pad) 96px;
  max-width: calc(var(--sidebar-width) + var(--content-pad) * 2 + var(--content-max));
}

main > section {
  max-width: var(--content-max);
}

/* Headings */
h1, h2, h3 {
  font-family: "Charter", "Iowan Old Style", "Source Serif Pro", "Georgia", serif;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

/* Section heading with accent rule */
h2 {
  font-size: 22px;
  margin: 64px 0 22px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--accent-primary);
  position: relative;
  letter-spacing: -0.005em;
}
h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 36px;
  height: 4px;
  background: var(--accent-secondary);
  border-radius: 1px;
}

main > section:first-child h2 { margin-top: 0; }

/* In-page anchor offset (so headings don't get hidden if linked to) */
section[id] { scroll-margin-top: 24px; }

/* Bio */
.bio p { margin: 0 0 16px; }

/* Drop cap on first paragraph of bio */
.bio p.lead::first-letter {
  font-family: "Charter", "Iowan Old Style", "Georgia", serif;
  float: left;
  font-size: 56px;
  line-height: 0.95;
  font-weight: 600;
  color: var(--accent-primary);
  padding: 6px 12px 0 0;
  margin-top: 4px;
}

/* =========================================================
   PAPER LIST
   ========================================================= */
ul.papers {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.papers > li {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 14px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 180ms ease, transform 180ms ease, border-color 180ms ease;
}
ul.papers > li:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  border-color: var(--accent-secondary);
}

.paper-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}
.paper-title {
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
}
.paper-title a {
  color: var(--text);
  border-bottom: 1px solid rgba(35, 45, 75, 0.25);
}
.paper-title a:hover {
  color: var(--accent-secondary);
  border-bottom-color: var(--accent-secondary);
}
.paper-meta {
  color: var(--muted);
  font-size: 15px;
  margin-top: 3px;
  line-height: 1.5;
}
.paper-meta em { font-style: italic; color: #444; }
.paper-meta a { color: var(--accent-primary); }

.paper-status {
  font-size: 14.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.5;
}
.paper-status em { color: #444; font-style: italic; }

/* Status pills */
.pill {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: 2px;
  line-height: 1.4;
}
.pill.published {
  background: var(--accent-primary);
  color: #fff;
}
.pill.rr {
  background: var(--accent-secondary);
  color: #fff;
}
.pill.wp {
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
  border: 1px solid #d8def0;
}
.pill.wip {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--rule);
}
.pill.submitted {
  background: transparent;
  color: var(--accent-secondary);
  border: 1px solid #f0c896;
}
.pill.forthcoming {
  background: var(--accent-secondary-soft);
  color: #a04f00;
  border: 1px solid #f5d9b8;
}

/* Italic note shown next to a paper, e.g. "New draft coming soon" */
.paper-note {
  font-size: 13.5px;
  color: var(--accent-secondary);
  font-style: italic;
  margin-top: 4px;
  letter-spacing: 0.01em;
}

/* Multi-sentence prose note attached to a paper (e.g., a reply/erratum) */
.paper-note-block {
  font-size: 14.5px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.55;
}
.paper-note-block a {
  color: var(--accent-primary);
  border-bottom: 1px solid rgba(35, 45, 75, 0.25);
}
.paper-note-block a:hover {
  border-bottom-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

/* Abstract toggle */
.toggle-abstract {
  display: inline-block;
  margin-top: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--accent-primary);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  border-bottom: 1px dotted var(--accent-primary);
  transition: color 120ms ease, border-color 120ms ease;
}
.toggle-abstract:hover {
  color: var(--accent-secondary);
  border-bottom-color: var(--accent-secondary);
}

.abstract {
  display: none;
  margin-top: 12px;
  padding: 14px 18px;
  background: var(--accent-primary-soft);
  border-left: 3px solid var(--accent-secondary);
  border-radius: 0 4px 4px 0;
  font-size: 15.5px;
  line-height: 1.6;
  color: #2a2a2a;
}
.abstract.open { display: block; }

/* Paper extra links (PDF, slides, etc.) */
.paper-links {
  margin-top: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 13px;
}
.paper-links a {
  color: var(--accent-primary);
  margin-right: 14px;
}

/* =========================================================
   TEACHING (used on teaching.html)
   ========================================================= */
ul.teaching { list-style: none; padding: 0; margin: 0; }
ul.teaching li {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 14px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 180ms ease, transform 180ms ease, border-color 180ms ease;
}
ul.teaching li:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  border-color: var(--accent-secondary);
}
.course-code {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-secondary);
}
.course-title {
  font-weight: 600;
  font-size: 18px;
  margin-top: 4px;
  color: var(--text);
}
.course-meta { color: var(--muted); font-size: 15px; margin-top: 4px; }
.course-desc { font-size: 15.5px; margin-top: 8px; color: #333; line-height: 1.6; }

/* List of PhD students (inside a teaching card) */
ul.student-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
ul.student-list li {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0 0 14px 0;
  box-shadow: none;
  transition: none;
  font-size: 15.5px;
  line-height: 1.5;
  color: #333;
}
ul.student-list li:last-child { margin-bottom: 0; }
ul.student-list li:hover {
  transform: none;
  box-shadow: none;
  border-color: transparent;
}
ul.student-list .student-name { font-weight: 600; color: var(--text); }
ul.student-list .year {
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
ul.student-list .placement {
  display: block;
  color: var(--muted);
  font-size: 14.5px;
  margin: 2px 0 0;
}
.course-title .subtle {
  font-weight: 400;
  color: var(--muted);
}

/* Short intro paragraph under a section heading */
.section-intro {
  color: var(--muted);
  font-size: 15px;
  font-style: italic;
  margin: -4px 0 22px;
  max-width: var(--content-max);
}
html[data-theme="dark"] ul.student-list li { color: #d0cabe; }
html[data-theme="dark"] ul.student-list .student-name { color: var(--text); }

/* Contact section */
#contact p { color: var(--muted); }
#contact strong { color: var(--text); font-weight: 500; }

/* Footer */
footer.page-foot {
  margin-top: 80px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  letter-spacing: 0.02em;
}

/* =========================================================
   FLOATING "BACK TO TOP"
   ========================================================= */
#to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease, background 140ms ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  z-index: 20;
}
#to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#to-top:hover { background: var(--accent-secondary); }

/* =========================================================
   MOBILE — sidebar collapses to top
   ========================================================= */
@media (max-width: 900px) {
  :root { --sidebar-width: 100%; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    flex-direction: column;
    padding: 28px 22px;
  }
  .sidebar img.headshot {
    max-width: 200px;
    margin: 0 auto 18px;
  }
  .sidebar .name { text-align: center; }
  .sidebar .title, .sidebar .affil { text-align: center; }
  .sidebar .contact, .sidebar nav.pages, .sidebar nav.sections, .sidebar .links, .sidebar .theme-row {
    text-align: center;
    align-items: center;
  }
  .sidebar nav.pages { flex-direction: row; justify-content: center; gap: 18px; }
  .sidebar nav.pages a { padding: 4px 0; border-left: none; border-bottom: 2px solid transparent; }
  .sidebar nav.pages a.active { border-left: none; border-bottom-color: var(--accent-secondary); }
  .sidebar nav.sections { flex-direction: row; justify-content: center; flex-wrap: wrap; gap: 10px 18px; }
  .sidebar nav.sections .sections-label { display: none; }
  .sidebar nav.sections a { padding: 4px 0; border-left: none; border-bottom: 2px solid transparent; }
  .sidebar nav.sections a:hover, .sidebar nav.sections a.active {
    border-left: none;
    border-bottom-color: var(--accent-secondary);
  }
  .sidebar .links { justify-content: center; }
  .sidebar .theme-row { justify-content: center; }
  main {
    margin-left: 0;
    padding: 36px 22px 64px;
  }
  h2 { font-size: 20px; }
  #to-top { right: 16px; bottom: 16px; width: 36px; height: 36px; }
}

/* =========================================================
   PRINT — clean serif layout, hide sidebar / chrome
   ========================================================= */
@media print {
  :root { --bg: #fff; }
  body { font-size: 11pt; line-height: 1.45; color: #000; }
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    border: none;
    background: transparent;
    padding: 0 0 16pt;
    margin-bottom: 16pt;
    border-bottom: 1pt solid #999;
  }
  .sidebar img.headshot { display: none; }
  .sidebar .name { font-size: 18pt; }
  .sidebar nav.pages, .sidebar .links { display: none; }
  main { margin: 0; padding: 0; max-width: 100%; }
  h2 { font-size: 13pt; border-color: #000; page-break-after: avoid; }
  h2::after { display: none; }
  a { color: #000; border: none; text-decoration: underline; }
  .toggle-abstract { display: none; }
  .abstract {
    display: block !important;
    background: transparent;
    border-left: 2pt solid #000;
    padding: 4pt 8pt;
    color: #000;
  }
  .pill {
    background: transparent !important;
    color: #000 !important;
    border: 1pt solid #000 !important;
  }
  #to-top, footer.page-foot, .theme-toggle, .sidebar .theme-row { display: none; }
  ul.papers > li, ul.teaching li {
    page-break-inside: avoid;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0 0 12pt;
    margin: 0 0 12pt;
    border-bottom: 1pt solid #ccc;
    border-radius: 0;
  }
  ul.papers > li:hover, ul.teaching li:hover {
    transform: none;
    box-shadow: none;
    border-color: #ccc;
  }
}
