:root {
  --nav-bg: #777E49;
  --nav-fg: #ffffff;
  --text: #222222;
  --bg: #ffffff;
  --link: #5a6038;
  --font-body: Arial, Helvetica, sans-serif;
  --column-width: 42rem;
  --home-width: 58rem;
  --nav-pad-x: 2rem;
  --muted: #666666;
  --rule: #dddddd;
  --card-bg: #f6ecda;
  --card-border: #e6d9bd;
  --btn-active: #5B3000;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

nav {
  background: var(--nav-bg);
  padding: 1.15rem var(--nav-pad-x);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

nav a {
  color: var(--nav-fg);
  text-decoration: none;
}

nav .brand {
  font-weight: bold;
  margin-right: auto;
}

nav .brand:hover {
  text-decoration: underline;
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

nav li {
  text-transform: lowercase;
}

nav ul a {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border: 2px solid transparent;
  border-radius: 999px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

nav ul a:hover {
  border-color: rgba(255, 255, 255, 0.6);
}

nav ul a[aria-current="page"] {
  border-color: var(--nav-fg);
  background: rgba(255, 255, 255, 0.15);
}

/* Mobile hamburger menu — pure CSS, toggled by the hidden checkbox */
.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.nav-toggle-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.5rem;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 4px;
}

.nav-toggle-btn span {
  display: block;
  height: 2px;
  background: var(--nav-fg);
  border-radius: 2px;
}

.nav-toggle:focus-visible ~ .nav-toggle-btn {
  border-color: var(--nav-fg);
}

@media (max-width: 40rem) {
  /* Brand stays centered across the whole bar; the toggle button floats
     over the right edge and doesn't shift it. */
  nav {
    position: relative;
    justify-content: center;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  nav .brand {
    margin: 0;
    text-align: center;
  }

  .nav-toggle-btn {
    display: flex;
    position: absolute;
    top: 0.75rem;
    right: 1rem;
  }

  nav ul {
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
  }

  .nav-toggle:checked ~ ul {
    display: flex;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    margin-top: 0.15rem;
    padding-top: 0.7rem;
  }

  nav ul a {
    display: block;
  }
}

main {
  max-width: var(--column-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

a {
  color: var(--link);
}

footer {
  flex-shrink: 0;
  padding: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.intro {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.intro-left {
  flex-shrink: 0;
  width: 280px;
  margin-left: -2.5rem;
  margin-top: 2rem;
}

.intro-pic {
  display: block;
  width: 100%;
  border-radius: 4px;
}

.intro-text {
  margin-top: 2rem;
}

.intro-text h1 {
  margin-top: 0;
  font-size: 1.4rem;
}

.intro-interests {
  margin-top: 1.5rem;
}

.intro-interests-label {
  font-weight: bold;
  margin: 0 0 0.5rem;
}

.intro-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1rem;
}

.intro-contact-label {
  font-weight: bold;
  margin-right: 0.25rem;
}

.btn-slim {
  padding: 0.1rem 0.7rem;
  font-size: 0.8rem;
}

@media (max-width: 40rem) {
  .intro {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  /* Unwrap .intro-left so the photo and contact block become direct
     flex items of .intro and can be reordered independently. */
  .intro-left {
    display: contents;
  }

  .intro-pic {
    order: 1;
    width: 100%;
    max-width: 240px;
    margin-top: 0;
  }

  .intro-text {
    order: 2;
    margin-top: 0;
  }

  /* Contact drops to the very end of the page on mobile. */
  .intro-contact {
    order: 3;
    margin-top: 0;
    justify-content: center;
  }
}

main.home {
  max-width: var(--home-width);
}

/* CV page */
main.cv {
  max-width: var(--home-width);
}

.cv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1.4rem;
  margin-bottom: 0.75rem;
}

.cv-header h1 {
  margin: 0;
}

.cv-header .btn {
  flex-shrink: 0;
}

.cv section {
  margin-top: 2.5rem;
}

.cv section:first-of-type {
  margin-top: 0;
}

.cv h2 {
  color: var(--nav-bg);
  border-bottom: 2px solid var(--nav-bg);
  padding-bottom: 0.2rem;
  margin-bottom: 1.25rem;
}

.cv h3 {
  margin: 1.5rem 0 0.85rem;
  font-size: 1rem;
  color: var(--text);
}

.cv-h3-note {
  font-weight: normal;
}

.cv-tl-track .cv-ay {
  position: relative;
  margin-bottom: 1.7rem;
}

.cv-tl-track .cv-ay:last-child {
  margin-bottom: 0;
}

.cv-tl-track .cv-ay .cv-entry {
  margin-bottom: 0.15rem;
}

.cv-tl-track .cv-ay .cv-entry:last-child {
  margin-bottom: 0;
}

.cv-ay-label {
  position: absolute;
  right: calc(100% + 7.5rem);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  text-align: right;
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--muted);
}

.cv-tl-track .cv-role-pos {
  font-weight: normal;
  color: var(--text);
}

.cv-entry {
  margin-bottom: 1.25rem;
}

.cv-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.cv-role {
  font-weight: bold;
}

.cv-date {
  color: var(--muted);
  white-space: nowrap;
}

.cv-place {
  color: var(--muted);
  font-style: italic;
}

.cv-entry ul,
.cv-pubs {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

.cv-entry > p {
  margin: 0.3rem 0 0;
}

.cv-pubs li {
  margin-bottom: 0.7rem;
}

.cv-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cv-tags li {
  background: var(--nav-bg);
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.7rem;
  font-size: 0.85rem;
}

.cv-langs li {
  padding: 0;
  background: none;
  display: flex;
  overflow: hidden;
}

.cv-langs .lang {
  background: var(--nav-bg);
  color: #fff;
  padding: 0.05rem 0.7rem;
}

.cv-langs .level {
  background: var(--card-bg);
  color: var(--text);
  padding: 0.05rem 0.7rem;
}

/* CV timeline (Education, Professional Experience, Teaching, Presentations) */
.cv-tl-track {
  position: relative;
  margin-left: 14rem;
  padding-left: 1.75rem;
  border-left: 2px solid var(--nav-bg);
}

.cv-tl-track .cv-entry {
  position: relative;
  margin-bottom: 1.4rem;
}

.cv-tl-track .cv-entry:last-child {
  margin-bottom: 0;
}

.cv-tl-track .cv-entry::before {
  content: "";
  position: absolute;
  left: calc(-1.75rem - 1px);
  top: 0.5rem;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--nav-bg);
  border: 2px solid var(--bg);
  transform: translateX(-50%);
}

.cv-tl-track .cv-entry-head {
  display: block;
}

.cv-tl-track .cv-role {
  color: var(--nav-bg);
}

.cv-tl-track .cv-date {
  position: absolute;
  right: calc(100% + 3rem);
  top: 0.2rem;
  white-space: nowrap;
  text-align: right;
}

.cv-tl-confs .cv-tl-track .cv-date {
  font-weight: bold;
  color: var(--text);
}

@media (max-width: 40rem) {
  .cv-entry-head {
    flex-direction: column;
    gap: 0;
  }

  /* Keep the desktop timeline on mobile: line, dots and a left-hand date
     column. Just narrow that column and let the dates wrap so they fit. */
  .cv-tl-track {
    margin-left: 6.25rem;
    padding-left: 1.1rem;
  }

  .cv-tl-track .cv-date {
    right: calc(100% + 1.3rem);
    width: 5.5rem;
    font-size: 0.9rem;
    white-space: normal;
    hyphens: none;
  }

  /* Month-year ranges wrap onto two lines, so left-align them; the
     shorter single-token dates elsewhere stay right-aligned to the rail. */
  .cv-tl-ranges .cv-tl-track .cv-date {
    text-align: left;
  }

  /* Honors, Presentations and Teaching: shorter dates, narrower box. */
  .cv-tl:not(.cv-tl-ranges) .cv-tl-track .cv-date {
    width: 4.5rem;
    right: calc(100% + 1.7rem);
  }

  /* Honors and Teaching dates are single tokens — never wrap them. */
  .cv-tl:not(.cv-tl-ranges):not(.cv-tl-confs) .cv-tl-track .cv-date {
    white-space: nowrap;
  }

  .cv-tl-track .cv-entry::before {
    left: calc(-1.1rem - 1px);
  }

  .cv-ay-label {
    position: static;
    transform: none;
    width: auto;
    text-align: left;
    display: block;
    margin-bottom: 0.5rem;
  }
}

/* Publications page */
main.pubs {
  max-width: var(--home-width);
}

.pubs h1 {
  margin: 1.4rem 0 0.75rem;
}

.pubs section {
  margin-top: 2.5rem;
}

.pubs section:first-of-type {
  margin-top: 0;
}

.pubs h2 {
  color: var(--nav-bg);
  border-bottom: 2px solid var(--nav-bg);
  padding-bottom: 0.2rem;
  margin-bottom: 1.25rem;
}

.pub {
  background: transparent;
  border: 2px solid var(--nav-bg);
  border-radius: 10px;
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}

.pub-row {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.pub-main {
  flex: 1;
  min-width: 0;
}

.pub-main > :last-child {
  margin-bottom: 0;
}

.pub-title {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  color: var(--link);
}

.pub-authors {
  margin: 0 0 0.15rem;
}

.pub-venue {
  margin: 0 0 0.9rem;
  font-style: italic;
  color: var(--muted);
}

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

.pub-abstract {
  display: contents;
}

.pub-abstract summary {
  list-style: none;
  cursor: pointer;
}

.pub-abstract summary::-webkit-details-marker {
  display: none;
}

.pub-abstract-body {
  display: none;
  margin-top: 0.9rem;
}

.pub-row:has(.pub-abstract[open]) + .pub-abstract-body {
  display: block;
}

.pub-abstract-body p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.pub-abstract-body p + p {
  margin-top: 0.6rem;
}

.pub-abstract-body strong {
  color: var(--text);
}

.pub-fig-link {
  width: 240px;
  flex-shrink: 0;
  display: block;
  background: #fff;
  padding: 0.6rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.pub-fig {
  display: block;
  width: 100%;
  border-radius: 4px;
}

.btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover,
.btn:active {
  background: var(--btn-active);
  color: #fff;
}

.pub-abstract[open] summary.btn {
  background: var(--btn-active);
  color: #fff;
}

@media (max-width: 40rem) {
  .pub-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pub-fig-link {
    width: 100%;
    order: -1;
  }
}
