/* ============================================================
   ACADEMIC WEBSITE — STYLE SYSTEM
   Aesthetic: International Style × Dark Academia
   Palette: Charcoal / Forest Green / Warm Amber
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* --- Design Tokens ----------------------------------------- */
:root {
  /* Backgrounds */
  --bg-page:         #2A4235; /* A slightly lighter, breathable version of #23342B */
  --bg-primary:      #1A1A1E; /* Reverted to the deep slate center block */
  --bg-surface:      #212126; /* Lighter slate for inner cards */
  --bg-elevated:     #2A2A32; /* Elevated hover states */

  /* Accents */
  --accent-green:       #5E8B7E; /* Soft, refined sage green */
  --accent-green-muted: #4A7065;
  --accent-green-faint: rgba(94, 139, 126, 0.15);
  --accent-amber:       #E2B054; /* Clean, professional gold/amber */
  --accent-amber-muted: #B88E40;
  --accent-amber-faint: rgba(226, 176, 84, 0.12);

  /* Text */
  --text-primary:   #F8FAFC; /* Bright crisp white */
  --text-secondary: #CBD5E1; /* Clear, legible secondary gray */
  --text-tertiary:  #94A3B8; /* Muted tertiary text */

  /* Borders */
  --border:        rgba(255, 255, 255, 0.1);
  --border-accent: rgba(255, 255, 255, 0.2);

  /* Typography */
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Cormorant Garamond', 'Georgia', serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Fluid type scale */
  --fs-xs:   clamp(0.7rem, 0.65rem + 0.25vw, 0.8rem);
  --fs-sm:   clamp(0.85rem, 0.8rem + 0.25vw, 0.95rem);
  --fs-base: clamp(1rem, 0.95rem + 0.25vw, 1.1rem);
  --fs-md:   clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem);
  --fs-lg:   clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --fs-xl:   clamp(2rem, 1.8rem + 1.5vw, 2.8rem);
  --fs-2xl:  clamp(2.5rem, 2.2rem + 2vw, 3.5rem);
  --fs-3xl:  clamp(3rem, 2.5rem + 3vw, 4.5rem);

  /* Spacing */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.5rem;
  --space-lg:  2.5rem;
  --space-xl:  4rem;
  --space-2xl: clamp(5rem, 4rem + 5vw, 8rem);
  --space-section: clamp(5rem, 4rem + 6vw, 9rem);

  /* Layout */
  --max-width: 1080px; /* Expanded to give 3-column layout more room */
  --nav-height: 4rem;

  /* Animation */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --duration-fast: 200ms;
  --duration-normal: 400ms;
  --duration-slow: 800ms;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-page);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* The central text block */
.site-wrapper {
  width: 100%;
  max-width: 1080px;
  background-color: var(--bg-primary);
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
  position: relative;
  min-height: 100vh;
}

/* --- Cursor Trail Canvas ----------------------------------- */
#cursor-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.6;
}

/* --- Navigation -------------------------------------------- */
.nav {
  position: absolute; /* Changed from fixed so it stays in the wrapper context initially */
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.5rem, 3vw, 3rem);
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-normal) ease,
              background var(--duration-normal) ease;
}

.nav.scrolled {
  position: fixed;
  max-width: 1080px; /* Match wrapper width */
  margin: 0 auto;
  border-bottom-color: var(--border);
  background: rgba(26, 26, 30, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav__logo {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: 0.08em;
  transition: color var(--duration-fast) ease;
}

.nav__logo:hover {
  color: var(--accent-amber);
}

.nav__links {
  display: flex;
  gap: clamp(1.2rem, 2.5vw, 2.5rem);
  list-style: none;
}

.nav__link {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  position: relative;
  padding-bottom: 2px;
  transition: color var(--duration-fast) ease;
}

.nav__link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent-amber);
  transition: width var(--duration-normal) var(--ease-out-expo);
}

.nav__link:hover,
.nav__link.active {
  color: var(--text-primary);
}

.nav__link.active::after,
.nav__link:hover::after {
  width: 100%;
}

/* Mobile nav toggle */
.nav__toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  position: relative;
  width: 28px;
  height: 20px;
}

.nav__toggle span {
  display: block;
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--text-primary);
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.nav__toggle span:nth-child(1) { top: 0; }
.nav__toggle span:nth-child(2) { top: 50%; transform: translateY(-50%); }
.nav__toggle span:nth-child(3) { bottom: 0; }

.nav__toggle.open span:nth-child(1) {
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}
.nav__toggle.open span:nth-child(2) { opacity: 0; }
.nav__toggle.open span:nth-child(3) {
  bottom: 50%;
  transform: translateY(50%) rotate(-45deg);
}

/* --- Layout Containers ------------------------------------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(1.5rem, 3vw, 3rem);
}

.section {
  padding: var(--space-xl) 0; /* Reduced from var(--space-section) */
  position: relative;
}

.section + .section,
.about + .section {
  border-top: 1px solid var(--border);
}

/* --- Scroll Reveal ----------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 100ms; }
.reveal-delay-2 { transition-delay: 200ms; }
.reveal-delay-3 { transition-delay: 300ms; }
.reveal-delay-4 { transition-delay: 400ms; }

/* --- About / Hero Section ---------------------------------- */
.about {
  padding-top: calc(var(--nav-height) + var(--space-2xl)); /* Moved slightly lower */
  padding-bottom: var(--space-xl); /* Reduced padding below about */
  min-height: 90vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Mondrian geometric background — Refined for more impact */
.mondrian {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(12, 1fr);
}

.mondrian__block {
  position: absolute;
  border: 1px solid rgba(42, 42, 50, 0.4);
  transition: opacity var(--duration-slow) ease;
}

.mondrian__block--1 {
  grid-column: 8 / 11;
  grid-row: 2 / 5;
  width: 100%;
  height: 100%;
  background: var(--accent-green-faint);
  border-color: rgba(58, 107, 82, 0.15);
  top: 10%; right: 10%; width: 200px; height: 160px;
}

.mondrian__block--2 {
  top: 15%; right: calc(10% + 201px);
  width: 80px; height: 80px;
  background: var(--accent-amber-faint);
  border-color: rgba(212, 168, 67, 0.12);
}

.mondrian__block--3 {
  top: 0; right: 28%; /* Pull the background line slightly further left so the timeline sits completely to the right of it */
  width: 1px; height: 100%;
  background: var(--border);
  border: none;
}

.mondrian__block--4 {
  display: none;
}

.mondrian__block--5 {
  bottom: 10%; left: 5%;
  width: 120px; height: 120px;
  background: rgba(58, 107, 82, 0.05);
  border-color: var(--accent-green-muted);
  opacity: 0.3;
}

.about__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  width: 100%;
}

.about__intro {
  max-width: 800px;
}

.about__name {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 0.95;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}

.about__title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  color: var(--text-primary);
  font-style: italic;
  margin-bottom: var(--space-xs);
}

.about__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-lg);
  position: relative;
  padding-bottom: var(--space-lg);
}

.about__header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -50vw;
  right: -50vw;
  height: 1px;
  background: var(--border);
}

.about__affiliation {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--accent-amber);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  margin-top: var(--space-md);
}

.about__affiliation a {
  color: var(--accent-amber);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--duration-fast) ease;
}

.about__affiliation a:hover {
  text-decoration: underline;
}

.about__affiliation svg {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.about__affiliation a:hover svg {
  color: var(--text-tertiary); /* Keep icon gray on hover */
}

.about__grid {
  display: grid;
  grid-template-columns: 1fr 220px; /* Photo moved to header, bio takes full left space */
  gap: clamp(2rem, 4vw, 4rem);
  column-gap: clamp(3rem, 7vw, 7rem); /* Extra gap to push the 3rd column right */
  align-items: start;
}

.about__photo {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0;
  border: 1px solid var(--border-accent);
}

.timeline {
  position: relative;
  padding-left: 1.2rem;
  border-left: 1px solid var(--border);
  margin-left: auto; /* ensure it anchors right */
}

.timeline__item {
  position: relative;
  margin-bottom: var(--space-md);
}

.timeline__item h4 {
  font-size: var(--fs-sm); /* Smaller text */
}

.timeline__item p {
  font-size: 0.8rem !important; /* Force smaller tertiary text */
}

.timeline__item::before {
  content: '';
  position: absolute;
  left: calc(-1.2rem - 3.5px); /* Adjusted for new padding */
  top: 0.35rem;
  width: 6px; /* Smaller dot */
  height: 6px;
  border-radius: 50%;
  background: var(--accent-amber);
}

.cv__download {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs); /* Smaller font */
  color: var(--accent-amber);
  background: transparent;
  border: 1px solid var(--border-accent);
  padding: 0.5rem 1rem; /* Smaller padding */
  border-radius: 2px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all var(--duration-fast) ease;
}

.cv__download:hover {
  background: var(--accent-amber);
  color: var(--bg-primary); /* Dark slate / essentially black against amber */
  border-color: var(--accent-amber);
}

.cv__download svg {
  width: 14px; /* Smaller icon */
  height: 14px;
}

.about__bio {
  color: var(--text-primary);
  line-height: 1.8;
}

.about__bio p + p {
  margin-top: var(--space-sm);
}

/* --- Section Headers --------------------------------------- */
.section__header {
  margin-bottom: var(--space-lg); /* Reduced from space-xl */
}

.section__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: var(--space-xs);
}

.section__title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.2;
}

/* --- Research Section -------------------------------------- */
.research__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.research-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  transition: all var(--duration-normal) var(--ease-out-expo);
  min-height: 240px;
}

.research-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-4px);
  background: var(--bg-elevated);
}

.research-card--theme {
  background: var(--accent-green-faint);
  border-color: rgba(58, 107, 82, 0.2);
}

.research-card--theme:hover {
  background: rgba(58, 107, 82, 0.15);
  border-color: var(--accent-green-muted);
}

.research-card__title {
  font-family: var(--font-heading);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.research-card__desc {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  line-height: 1.7;
  flex: 1;
}

.research-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: var(--space-md);
}

.research-card__tag {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  background: rgba(20, 20, 24, 0.4);
  padding: 0.2em 0.6em;
  border-radius: 2px;
  border: 1px solid var(--border);
}

.research-card__footer {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

.research-card__link {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent-amber);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Publications Section ---------------------------------- */
.publications__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.pub-category {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.pub-category__title {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  color: var(--text-secondary); /* Darker/secondary text color */
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  position: sticky;
  top: calc(var(--nav-height) + var(--space-md));
}

.pub-entries {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.pub-entry {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  padding: 0;
  border-left: none;
  padding-left: 0;
}

.pub-entry:hover {
  border-left-color: transparent;
}

.pub-entry__year {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent-amber-muted);
  margin-bottom: 0.25rem;
}

.pub-entry__content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pub-entry__title {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.4;
}

.pub-entry__title a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all var(--duration-fast) ease;
}

.pub-entry__title a:hover {
  color: var(--accent-amber);
  border-bottom-color: var(--accent-amber-faint);
}

.pub-entry__authors {
  font-size: var(--fs-sm);
  color: var(--text-primary);
}

.pub-entry__venue {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  font-style: italic;
}

.pub-entry__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent-amber-muted);
  text-decoration: none;
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color var(--duration-fast) ease;
}

.pub-entry__link:hover {
  color: var(--accent-amber);
}

.pub-entry__link svg {
  width: 12px;
  height: 12px;
}

/* --- Footer ------------------------------------------------ */
.footer {
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--border);
}

.footer__content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer__text {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}

.footer__text a {
  color: var(--accent-amber-muted);
  text-decoration: none;
  transition: all var(--duration-fast) ease;
}

.footer__text a:hover {
  color: var(--accent-amber);
  text-decoration: underline;
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 768px) {
  .nav__links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(20, 20, 24, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) ease,
                visibility var(--duration-normal) ease;
  }

  .nav__links.open {
    opacity: 1;
    visibility: visible;
  }

  .nav__link {
    font-size: var(--fs-sm);
  }

  .nav__toggle {
    display: block;
  }

  .about__grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .about__photo {
    width: 120px;
    height: 150px;
  }

  .research__grid {
    grid-template-columns: 1fr;
  }

  .pub-entry {
    grid-template-columns: 1fr;
  }

  .pub-entry__year {
    font-size: var(--fs-xs);
  }

  .footer__content {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
  }

  .mondrian__block--1,
  .mondrian__block--2,
  .mondrian__block--5 {
    opacity: 0.4;
  }
}

@media (max-width: 480px) {
  :root {
    --nav-height: 3rem;
  }

  .about__name {
    font-size: var(--fs-xl);
  }

  .mondrian {
    display: none;
  }
}

/* --- Print Styles ------------------------------------------ */
@media print {
  .nav,
  #cursor-canvas,
  .mondrian {
    display: none !important;
  }

  body {
    background: white;
    color: #222;
    font-size: 11pt;
  }

  .section {
    padding: 1.5rem 0;
    page-break-inside: avoid;
  }

  a {
    color: #222;
  }

  .about {
    min-height: auto;
    padding-top: 0;
  }
}

/* --- Selection -------------------------------------------- */
::selection {
  background: rgba(212, 168, 67, 0.25);
  color: var(--text-primary);
}

/* --- Scrollbar -------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-accent);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--border-accent) var(--bg-primary);
}