/*
  Stylesheet map
  1. Design tokens and global defaults
  2. Header and profile
  3. Research and projects
  4. Footer
  5. Responsive, reduced-motion, and print rules

  For simple visual changes, start with these custom properties. Rules later in
  the file use them consistently across the page.
*/
:root {
  --ink: #17202b;
  --muted: #5e6874;
  --paper: #f7f5f0;
  --surface: #ffffff;
  --accent: #9b2f36;
  --accent-dark: #712127;
  --line: #dcd8d0;
  --shadow: 0 20px 55px rgba(31, 39, 48, 0.09);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Global defaults and link behavior. */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

a:focus-visible {
  outline: 3px solid rgba(155, 47, 54, 0.3);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Keyboard-only shortcut that becomes visible when focused. */
.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  transform: translateY(-150%);
  padding: 0.7rem 1rem;
  color: white;
  background: var(--ink);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Sticky header and primary navigation. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid rgba(220, 216, 208, 0.9);
  background: rgba(247, 245, 240, 0.94);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 3rem));
  min-height: 4.5rem;
  margin: 0 auto;
  gap: 2rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 700;
  text-decoration: none;
}

.wordmark-mark {
  display: grid;
  width: 2.1rem;
  height: 2.1rem;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-dark);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

nav a {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

main,
footer {
  width: min(1120px, calc(100% - 3rem));
  margin-inline: auto;
}

/* Profile hero: biography on the left and portrait on the right. */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.75fr);
  align-items: center;
  gap: clamp(3rem, 7vw, 6.5rem);
  min-height: calc(100vh - 4.75rem);
  padding: clamp(5rem, 10vw, 8rem) 0;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--accent-dark);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.4;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  font-family: var(--serif);
}

h1 {
  max-width: 13ch;
  margin: 0;
  font-size: clamp(1.5rem, 3.25vw, 2.85rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.97;
}

.role {
  margin: 1.6rem 0 0.2rem;
  color: var(--accent-dark);
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
}

.fields {
  margin: 0 0 2.25rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: 0.015em;
}

.fields span {
  margin: 0 0.45em;
  color: var(--accent);
}

.introduction {
  max-width: 66ch;
  margin: 0 0 0.9rem;
  font-size: 1.05rem;
}

.introduction.secondary {
  color: var(--muted);
}

.primary-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: 0.62rem 1rem;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
}

.button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--surface);
}

.button.primary {
  border-color: var(--accent-dark);
  color: white;
  background: var(--accent-dark);
}

.button.primary:hover {
  border-color: var(--accent);
  background: var(--accent);
}

.text-link {
  font-size: 0.9rem;
  font-weight: 650;
}

.profile-details {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 3rem;
  margin: 2.2rem 0 0;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
}

.profile-details div {
  display: grid;
  gap: 0.15rem;
}

.profile-details dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.profile-details dd {
  margin: 0;
  font-size: 0.88rem;
}

.portrait-wrap {
  position: relative;
  margin: 0;
}

.portrait-wrap::before {
  content: "";
  position: absolute;
  inset: 1.2rem -1.2rem -1.2rem 1.2rem;
  border: 1px solid var(--accent);
}

.portrait {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  filter: saturate(0.88) contrast(1.02);
  box-shadow: var(--shadow);
}

/* Working papers and the research-section heading. */
.research-section {
  padding: clamp(5rem, 8vw, 8rem) 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  column-gap: 3rem;
  margin-bottom: 3.2rem;
}

.section-heading .eyebrow {
  grid-column: 1;
}

.section-heading h2 {
  grid-column: 1;
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 2.25rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

#research-heading {
  white-space: nowrap;
}

/* The optional summary paragraph must be the final element inside .section-heading. */
.section-heading > p:last-child {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: end;
  max-width: 55ch;
  margin: 0;
  color: var(--muted);
}

.papers {
  display: grid;
  gap: 1rem;
}

.paper {
  position: relative;
  padding: clamp(1.7rem, 4vw, 2.7rem);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

/* Add class="paper featured" in the HTML to highlight one primary paper. */
.paper.featured {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.paper h3 {
  max-width: 40ch;
  margin: 0.5rem 0 0.7rem;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.paper-year,
.paper-status {
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.featured .paper-status {
  color: var(--accent-dark);
}

.coauthors {
  margin: 0;
  color: var(--muted);
  font-size: 0.91rem;
}

.abstract-label {
  margin: 1.55rem 0 0.28rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.abstract-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1.55rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(23, 32, 43, 0.12);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.88);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.abstract-toggle::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-0.08rem);
  transition: transform 220ms ease;
}

.abstract-toggle:hover {
  border-color: rgba(113, 33, 39, 0.3);
  color: var(--accent);
  background: var(--surface);
  transform: translateY(-1px);
}

.abstract-toggle:focus-visible {
  outline: 3px solid rgba(155, 47, 54, 0.22);
  outline-offset: 4px;
}

.paper.is-open .abstract-toggle::after {
  transform: rotate(-135deg) translateX(-0.04rem);
}

.abstract-panel {
  display: grid;
  grid-template-rows: 0fr;
  margin-top: 0;
  opacity: 0;
  transition:
    grid-template-rows 260ms ease,
    margin-top 260ms ease,
    opacity 220ms ease;
}

.paper.is-open .abstract-panel {
  grid-template-rows: 1fr;
  margin-top: 0.95rem;
  opacity: 1;
}

.abstract-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.abstract {
  max-width: 78ch;
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(23, 32, 43, 0.08);
  color: #3d4650;
}

.featured .abstract-label {
  color: var(--muted);
}

.featured .abstract {
  color: #3d4650;
}

.paper-links {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.paper-links a {
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Work-in-progress project list. */
.work-in-progress {
  margin-top: clamp(5rem, 9vw, 8rem);
}

.section-heading.compact {
  display: block;
  margin-bottom: 2rem;
}

.section-heading.compact h2 {
  font-size: clamp(1.15rem, 2vw, 1.75rem);
}

.project {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(250px, 0.7fr);
  gap: 2rem;
  padding: 1.6rem 0;
  border-top: 1px solid var(--line);
}

.project:last-child {
  border-bottom: 1px solid var(--line);
}

.project h3,
.project p {
  margin: 0;
}

.project h3 {
  font-size: 1.3rem;
  line-height: 1.35;
}

.project p {
  color: var(--muted);
  font-size: 0.91rem;
}

/* Contact footer. */
footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.5rem 0 3.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

footer p {
  margin: 0;
}

.footer-name {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
}

.footer-contact {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Stack multi-column sections and simplify navigation on narrower screens. */
@media (max-width: 780px) {
  .header-inner,
  main,
  footer {
    width: min(100% - 2rem, 1120px);
  }

  .wordmark > span:last-child {
    display: none;
  }

  nav {
    gap: 1rem;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 4rem;
  }

  .portrait-wrap {
    grid-row: 1;
    width: min(76vw, 360px);
  }

  h1 {
    font-size: clamp(1.6rem, 7vw, 2.5rem);
  }

  .section-heading,
  .project {
    grid-template-columns: 1fr;
  }

  .section-heading > p:last-child {
    grid-column: 1;
    grid-row: auto;
    margin-top: 1.25rem;
  }

  .project {
    gap: 0.55rem;
  }
}

/* Additional controls for phone-sized screens. */
@media (max-width: 520px) {
  nav a:nth-child(3) {
    display: none;
  }

  .primary-links {
    align-items: stretch;
  }

  .button {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .text-link {
    margin-top: 0.45rem;
  }

  footer {
    flex-direction: column;
  }

  .footer-contact {
    align-items: flex-start;
  }
}

/* Respect operating-system accessibility preferences. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Remove navigation and decorative treatments from printed pages. */
@media print {
  body {
    background: white;
  }

  .site-header,
  .primary-links,
  .paper-links {
    display: none;
  }

  .hero {
    min-height: auto;
    padding: 2rem 0;
  }

  .research-section {
    padding-top: 2rem;
  }

  .paper,
  .paper.featured {
    break-inside: avoid;
    border: 1px solid #aaa;
    color: black;
    background: white;
    box-shadow: none;
  }

  .featured .paper-status,
  .featured .abstract-label,
  .featured .abstract {
    color: black;
  }
}
