/*
 * Academic portfolio styles
 *
 * Layout overview (top to bottom):
 *   1. Bio (#bio-section)
 *   2. Research projects (#research-section)
 *   3. Fortune cookie image + caption (#cookie-section)
 *      Each project: text + papers (left), stacked figures (right, sticky on desktop)
 *
 * Key variables below control page width, colors, and fonts.
 * Mobile breakpoint: 640px — figures shrink and center instead of full width.
 */
:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5c5c5c;
  --accent: #2c5282;
  --accent-hover: #1a365d;
  --border: #e2ddd4;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --font-serif: "Crimson Pro", Georgia, "Times New Roman", serif;
  --font-sans: "Source Sans 3", system-ui, sans-serif;
  --max-width: 960px; /* page content width; increase to widen everything */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 3.5rem 0;
}

.page-intro {
  background: var(--surface);
}

/* --- Intro: bio, cookie image, research heading --- */
#bio-section {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

#research-section {
  margin-top: 1.5rem;
}

#cookie-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.bio-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 5vw, 3rem);
  font-weight: 600;
  line-height: 1.15;
}

.bio p {
  margin: 0 0 1rem;
}

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

.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-shrink: 0;
}

.contact-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.contact-links a:hover {
  border-bottom-color: var(--accent);
}

.bio a,
.paper-venue a,
.abstract-panel a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.bio a:hover,
.paper-venue a:hover,
.abstract-panel a:hover {
  border-bottom-color: var(--accent);
}

.research-heading {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.cookie-figure {
  margin: 0;
  width: 100%;
  text-align: center;
}

.cookie-figure img {
  display: block;
  width: 100%;
  max-height: 3.25rem;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
  border-radius: 4px;
}

.cookie-caption {
  margin: 0.6rem auto 0;
  max-width: 40rem;
  font-size: 0.85rem;
  line-height: 1.55;
  text-align: center;
  color: var(--text-muted);
}

#research-section .project-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.project-item {
  border-top: 1px solid var(--border);
}

.project-item:first-child {
  border-top: none;
}

.project-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 1.25rem 0;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  transition: color 0.15s ease;
}

.project-toggle:hover {
  color: var(--accent);
}

.project-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.project-toggle[aria-expanded="true"] {
  color: var(--accent);
}

.project-toggle-title {
  flex: 1;
}

.project-panel {
  padding: 0 0 2rem 0;
}

.project-panel[hidden] {
  display: none;
}

/* --- Projects: two-column layout (text | figures) --- */
.project-layout {
  display: grid;
  grid-template-columns: 1fr 300px; /* right column = figure width; increase for larger diagrams */
  gap: 2rem;
  align-items: start;
}

.project-main {
  min-width: 0;
}

.project-abstract {
  margin-bottom: 1.5rem;
}

.project-abstract p {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.65;
}

.project-abstract p:last-child {
  margin-bottom: 0;
}

/* Figures stack in the right column; sticky while scrolling project text */
.project-figures {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 1.5rem;
}

.project-figure {
  margin: 0;
}

.project-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.caption {
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Papers: collapsible abstracts only --- */
.paper-list {
  margin-top: 0.5rem;
}

.paper-item {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.paper-item:first-of-type {
  border-top: none;
  padding-top: 0;
}

.paper-link {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.paper-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.paper-title-text {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.paper-venue {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.abstract-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.25rem;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.abstract-toggle:hover {
  color: var(--accent);
}

.abstract-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.toggle-icon {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-top: -0.1rem;
}

.project-toggle .toggle-icon {
  width: 0.55rem;
  height: 0.55rem;
  margin-top: -0.15rem;
}

.abstract-toggle[aria-expanded="true"] .toggle-icon,
.project-toggle[aria-expanded="true"] .toggle-icon {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
}

.abstract-panel {
  margin-top: 0.5rem;
  padding: 0.15rem 0 0.15rem 1.15rem;
  border-left: 3px solid var(--accent);
  background: none;
  border-radius: 0;
  box-shadow: none;
}

.abstract-panel[hidden] {
  display: none;
}

.paper-expandable[hidden] {
  display: none;
}

.paper-expandable {
  margin-top: 0.5rem;
}

.paper-expandable .abstract-panel {
  margin-top: 0;
}

.abstract-panel p {
  margin: 0 0 0.75rem;
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text);
}

.abstract-panel p:last-of-type {
  margin-bottom: 0;
}

.site-footer {
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .section {
    padding: 2.5rem 0;
  }

  .bio-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .contact-links {
    justify-content: flex-start;
  }

  #research-section,
  #cookie-section {
    margin-top: 1rem;
  }

  .cookie-figure img {
    max-height: 2.75rem;
  }

  .project-toggle {
    font-size: 1.1rem;
    padding: 1rem 0;
  }

  .project-figures {
    position: static;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
  }

  .project-layout {
    grid-template-columns: 1fr;
  }
}
