/* ============================================
   Sara Hormozinejad — Academic Portfolio
   Best-in-class UI/UX — v5 (Dark Mode Toggle)
   ============================================ */

/* --- Design Tokens --- */
:root {
  /* Core palette — deep slate, warm blush, ivory, soft charcoal */
  --slate: #1e293b;
  --slate-deep: #0f172a;
  --slate-mid: #334155;
  --slate-light: #475569;
  --blush: #d46a6a;
  --blush-light: #e88a8a;
  --blush-muted: rgba(212, 106, 106, 0.08);
  --blush-ghost: rgba(212, 106, 106, 0.04);
  --blush-glow: rgba(212, 106, 106, 0.15);
  --ivory: #f8f5f0;
  --ivory-light: #fcfaf7;
  --ivory-dark: #efeae2;
  --warm-gray: #e2dcd4;
  --warm-gray-light: #ede8e2;
  --charcoal: #1c1917;
  --charcoal-soft: #3a3530;
  --charcoal-muted: #7a7268;
  --charcoal-faint: #a0988e;
  --rule: #d6cec4;
  --rule-light: #e4ddd4;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  --card-shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.06), 0 16px 40px rgba(15, 23, 42, 0.08);
  --nav-bg: rgba(248, 245, 240, 0.85);
  --nav-shadow: 0 1px 0 var(--rule-light);
  --radius: 6px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --measure: 68ch;
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 3.5rem;
  --space-xl: 6rem;
  --space-2xl: 8rem;
  --font-serif: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.44, 0, 0.56, 1);
  --ease-smooth: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dark mode — applied via class on html element (toggle) */
html.dark {
  --slate: #475569;
  --slate-deep: #e2e8f0;
  --slate-mid: #64748b;
  --slate-light: #94a3b8;
  --blush: #e88a8a;
  --blush-light: #f0a0a0;
  --blush-muted: rgba(232, 138, 138, 0.12);
  --blush-ghost: rgba(232, 138, 138, 0.06);
  --blush-glow: rgba(232, 138, 138, 0.18);
  --ivory: #0f0e0c;
  --ivory-light: #161412;
  --ivory-dark: #1c1917;
  --warm-gray: #2a2622;
  --warm-gray-light: #211e1b;
  --charcoal: #f0ebe4;
  --charcoal-soft: #d4ccc2;
  --charcoal-muted: #8a8278;
  --charcoal-faint: #6a625a;
  --rule: #2a2622;
  --rule-light: #211e1b;
  --card-bg: #1a1714;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4), 0 16px 40px rgba(0,0,0,0.5);
  --nav-bg: rgba(15, 14, 12, 0.88);
  --nav-shadow: 0 1px 0 var(--rule);
}

/* Dark mode — system preference fallback (before JS runs) */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --slate: #475569;
    --slate-deep: #e2e8f0;
    --slate-mid: #64748b;
    --slate-light: #94a3b8;
    --blush: #e88a8a;
    --blush-light: #f0a0a0;
    --blush-muted: rgba(232, 138, 138, 0.12);
    --blush-ghost: rgba(232, 138, 138, 0.06);
    --blush-glow: rgba(232, 138, 138, 0.18);
    --ivory: #0f0e0c;
    --ivory-light: #161412;
    --ivory-dark: #1c1917;
    --warm-gray: #2a2622;
    --warm-gray-light: #211e1b;
    --charcoal: #f0ebe4;
    --charcoal-soft: #d4ccc2;
    --charcoal-muted: #8a8278;
    --charcoal-faint: #6a625a;
    --rule: #2a2622;
    --rule-light: #211e1b;
    --card-bg: #1a1714;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.3);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4), 0 16px 40px rgba(0,0,0,0.5);
    --nav-bg: rgba(15, 14, 12, 0.88);
    --nav-shadow: 0 1px 0 var(--rule);
  }
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--charcoal-soft);
  background: var(--ivory);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--blush); text-decoration: none; transition: color 0.2s var(--ease-out); }
a:hover, a:focus { color: var(--blush-light); }
a:focus-visible { outline: 2px solid var(--blush); outline-offset: 2px; border-radius: 2px; }

::selection { background: var(--blush); color: white; }

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.15;
  color: var(--slate-deep);
  margin-top: 0;
  transition: color 0.4s var(--ease-out);
}

h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); letter-spacing: -0.02em; }
h3 { font-size: clamp(1.15rem, 1.8vw, 1.35rem); letter-spacing: -0.01em; }
h4 { font-size: 1rem; font-weight: 600; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--charcoal-muted); }

p { margin: 0 0 1em; max-width: var(--measure); }
.muted { color: var(--charcoal-muted); }
.small { font-size: 0.9rem; }

/* --- Layout --- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.section {
  padding: var(--space-2xl) 0;
  position: relative;
}

.section-alt {
  background: var(--ivory-light);
  border-top: 1px solid var(--rule-light);
  border-bottom: 1px solid var(--rule-light);
  transition: background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.section-number {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--blush);
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.6;
}

.section-title {
  margin: 0;
}

.section-intro {
  font-size: 1.1rem;
  color: var(--charcoal-soft);
  max-width: var(--measure);
  margin-bottom: var(--space-lg);
  line-height: 1.65;
  transition: color 0.4s var(--ease-out);
}

/* --- Navigation --- */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: transparent;
  transition: background 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), backdrop-filter 0.4s var(--ease-out);
}

nav.scrolled {
  background: var(--nav-bg);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  box-shadow: var(--nav-shadow);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  height: 60px;
}

.nav-logo {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--slate-deep);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: opacity 0.2s var(--ease-out), color 0.4s var(--ease-out);
}

.nav-logo:hover { opacity: 0.7; }

.nav-links {
  display: flex;
  gap: 0.05rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav-links a {
  display: block;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  color: var(--charcoal-muted);
  border-radius: 4px;
  transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out);
  letter-spacing: 0.02em;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 50%;
  height: 1.5px;
  background: var(--blush);
  transition: transform 0.25s var(--ease-out);
  border-radius: 1px;
}

.nav-links a:hover {
  color: var(--blush);
  background: var(--blush-ghost);
}

.nav-links a.active {
  color: var(--blush);
}

.nav-links a.active::after {
  transform: translateX(-50%) scaleX(1);
}

/* --- Dark Mode Toggle Button --- */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  background: transparent;
  color: var(--charcoal-muted);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  margin-left: 0.4rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  border-color: var(--blush);
  color: var(--blush);
  background: var(--blush-muted);
  transform: rotate(15deg);
}

.theme-toggle:active {
  transform: rotate(15deg) scale(0.9);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--blush);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.4s var(--ease-spring), opacity 0.3s var(--ease-out);
}

.theme-toggle .sun-icon {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

html.dark .theme-toggle .sun-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

html.dark .theme-toggle .moon-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.theme-toggle .moon-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* --- Mobile Nav Toggle --- */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--slate-deep);
  transition: opacity 0.2s var(--ease-out), color 0.4s var(--ease-out);
}

.nav-toggle:hover { opacity: 0.7; }
.nav-toggle svg { display: block; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--ivory-light);
    border-bottom: 1px solid var(--rule);
    flex-direction: column;
    padding: var(--space-sm);
    gap: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    transition: background 0.4s var(--ease-out);
  }
  nav.scrolled .nav-links { background: var(--ivory-light); }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.7rem 1rem; border-bottom: 1px solid var(--rule-light); }
  .nav-links a:last-child { border-bottom: none; }
  .nav-links a::after { display: none; }

  .theme-toggle {
    margin-left: auto;
    margin-right: 0.4rem;
  }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  text-decoration: none;
  line-height: 1.3;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent);
  opacity: 0;
  transition: opacity 0.25s var(--ease-out);
  pointer-events: none;
}

.btn:hover::after { opacity: 1; }

.btn-primary {
  background: var(--slate-deep);
  color: var(--ivory-light);
  transition: background 0.25s var(--ease-out), color 0.25s var(--ease-out), transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.btn-primary:hover {
  background: var(--slate-mid);
  color: var(--ivory-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.2);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.btn-outline {
  background: transparent;
  color: var(--slate-deep);
  border: 1.5px solid var(--rule);
  transition: border-color 0.25s var(--ease-out), color 0.25s var(--ease-out), transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.btn-outline:hover {
  border-color: var(--blush);
  color: var(--blush);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 106, 106, 0.08);
}

.btn-outline:active {
  transform: translateY(0);
}

/* ==================== HERO ==================== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: 60px;
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  color: var(--slate-deep);
  pointer-events: none;
  opacity: 0.25;
  animation: heroWaveDrift 20s ease-in-out infinite alternate;
  transition: color 0.4s var(--ease-out), opacity 0.4s var(--ease-out);
}

@keyframes heroWaveDrift {
  0% { transform: scale(1) translateX(0); opacity: 0.25; }
  50% { transform: scale(1.03) translateX(-10px); opacity: 0.3; }
  100% { transform: scale(1) translateX(0); opacity: 0.25; }
}

.hero-bg svg {
  width: 100%;
  height: 100%;
}

.hero-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-xl);
  align-items: center;
  position: relative;
  z-index: 2;
}

.hero-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--blush);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.hero-label-line {
  display: inline-block;
  width: 1.5rem;
  height: 1.5px;
  background: var(--blush);
  animation: labelLineGrow 1s var(--ease-out) forwards;
  transform-origin: left;
  transform: scaleX(0);
}

@keyframes labelLineGrow {
  to { transform: scaleX(1); }
}

.hero-title {
  margin-bottom: var(--space-sm);
}

.hero-text {
  font-size: 1.05rem;
  color: var(--charcoal-soft);
  max-width: 58ch;
  margin-bottom: var(--space-md);
  line-height: 1.65;
  transition: color 0.4s var(--ease-out);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.hero-affiliations {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--charcoal-muted);
  letter-spacing: 0.02em;
}

.hero-affil-dot {
  color: var(--charcoal-faint);
  padding: 0 0.2rem;
}

.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.portrait-frame {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ivory-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--rule);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  transition: box-shadow 0.4s var(--ease-out), transform 0.4s var(--ease-out), border-color 0.4s var(--ease-out), background 0.4s var(--ease-out);
  position: relative;
}

.portrait-frame::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  background: linear-gradient(135deg, var(--blush), var(--blush-light), var(--blush)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
}

.portrait-frame:hover::after {
  opacity: 1;
}

.portrait-frame:hover {
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1);
  transform: scale(1.02);
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease-out);
}

.portrait-frame:hover .portrait-img {
  transform: scale(1.05);
}

.hero-scroll {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  color: var(--charcoal-faint);
  opacity: 0.4;
  animation: scrollPulse 2.5s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.25; transform: translateX(-50%) translateY(0); }
  50% { opacity: 0.6; transform: translateX(-50%) translateY(4px); }
}

/* ==================== ABOUT ==================== */
.about-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--space-xl);
  align-items: start;
}

.about-text p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--charcoal-soft);
  transition: color 0.4s var(--ease-out);
}

.about-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.about-card {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  padding: var(--space-md);
  border: 1px solid var(--rule-light);
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.4s var(--ease-out), transform 0.4s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.about-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blush), var(--blush-light));
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}

.about-card:hover::before {
  opacity: 1;
}

.about-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-3px);
}

.about-card h3 {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blush);
  margin-bottom: var(--space-sm);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule-light);
  transition: border-color 0.4s var(--ease-out);
}

.about-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.about-list li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--rule-light);
  font-size: 0.85rem;
  color: var(--charcoal-soft);
  display: flex;
  gap: var(--space-sm);
  align-items: baseline;
  line-height: 1.4;
  transition: padding-left 0.2s var(--ease-out), border-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

.about-list li:last-child { border-bottom: none; }

.about-card:hover .about-list li {
  padding-left: 3px;
}

.about-tag {
  font-weight: 600;
  color: var(--slate-deep);
  min-width: 6.5rem;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  transition: color 0.4s var(--ease-out);
}

/* ==================== RESEARCH ==================== */
.research-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.research-card {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  padding: var(--space-md);
  border: 1px solid var(--rule-light);
  position: relative;
  overflow: hidden;
  transition: all 0.4s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
  box-shadow: var(--card-shadow);
}

.research-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blush), var(--blush-light));
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}

.research-card:hover::before {
  opacity: 1;
}

.research-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--rule);
}

.research-card-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--blush);
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-xs);
  opacity: 0.5;
  transition: opacity 0.3s var(--ease-out);
}

.research-card:hover .research-card-num {
  opacity: 0.8;
}

.research-card h3 {
  margin-bottom: 0.5rem;
  color: var(--slate-deep);
  transition: color 0.3s var(--ease-out);
}

.research-card:hover h3 {
  color: var(--blush);
}

.research-card p {
  font-size: 0.9rem;
  color: var(--charcoal-soft);
  margin: 0;
  line-height: 1.6;
  transition: color 0.4s var(--ease-out);
}

/* ==================== PUBLICATIONS ==================== */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.pub-card {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  padding: var(--space-md);
  border: 1px solid var(--rule-light);
  transition: all 0.4s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.pub-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--blush), var(--blush-light));
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
  border-radius: 0 1px 1px 0;
}

.pub-card:hover::before {
  opacity: 1;
}

.pub-card:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: var(--rule);
  transform: translateY(-3px);
}

.pub-badge-row {
  margin-bottom: var(--space-sm);
}

.pub-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  background: var(--blush-muted);
  color: var(--blush);
  border: 1px solid rgba(212, 106, 106, 0.15);
  animation: badgeGlow 3s ease-in-out infinite;
}

@keyframes badgeGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 106, 106, 0); }
  50% { box-shadow: 0 0 8px 2px rgba(212, 106, 106, 0.1); }
}

.pub-title {
  font-size: 1.15rem;
  color: var(--slate-deep);
  margin-bottom: 0.2rem;
  line-height: 1.3;
  transition: color 0.3s var(--ease-out);
}

.pub-card:hover .pub-title {
  color: var(--blush);
}

.pub-venue {
  font-size: 0.85rem;
  color: var(--blush);
  margin-bottom: 0.3rem;
  font-style: italic;
}

.pub-doi {
  font-size: 0.78rem;
  color: var(--charcoal-muted);
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  transition: color 0.4s var(--ease-out);
}

.pub-doi a {
  color: var(--charcoal-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--rule);
  transition: color 0.2s var(--ease-out), text-decoration-color 0.2s var(--ease-out);
}

.pub-doi a:hover {
  color: var(--blush);
  text-decoration-color: var(--blush);
}

.pub-abstract {
  font-size: 0.9rem;
  color: var(--charcoal-soft);
  margin-bottom: var(--space-sm);
  line-height: 1.6;
  transition: color 0.4s var(--ease-out);
}

.pub-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--slate-deep);
  transition: color 0.2s var(--ease-out), gap 0.2s var(--ease-out);
}

.pub-link span {
  transition: transform 0.2s var(--ease-out);
}

.pub-link:hover {
  color: var(--blush);
}

.pub-link:hover span {
  transform: translateX(4px);
}

/* Expandable */
.expandable {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--rule-light);
  margin-top: var(--space-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.3s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}

.expandable:hover {
  box-shadow: var(--card-shadow-hover);
}

.expandable-toggle {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--slate-deep);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out);
  user-select: none;
}

.expandable-toggle::-webkit-details-marker { display: none; }

.expandable-toggle::before {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--blush);
  transition: transform 0.3s var(--ease-spring);
  line-height: 1;
}

details[open] .expandable-toggle::before {
  content: '−';
  transform: rotate(180deg);
}

.expandable-toggle:hover {
  color: var(--blush);
  background: var(--blush-muted);
}

.expandable-content {
  padding: 0 var(--space-md) var(--space-sm);
  animation: expandFade 0.3s var(--ease-out);
}

@keyframes expandFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.expandable-content p {
  font-size: 0.88rem;
  color: var(--charcoal-soft);
  margin: 0;
  transition: color 0.4s var(--ease-out);
}

/* ==================== PROJECTS ==================== */
.project-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.project-card {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  padding: var(--space-md);
  border: 1px solid var(--rule-light);
  transition: all 0.4s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blush), var(--blush-light));
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}

.project-card:hover::before {
  opacity: 1;
}

.project-card:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: var(--rule);
  transform: translateY(-4px);
}

.project-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.project-tag {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--blush-muted);
  color: var(--blush);
  transition: transform 0.2s var(--ease-out);
}

.project-card:hover .project-tag {
  transform: scale(1.05);
}

.project-tag.fellowship {
  background: rgba(212, 106, 106, 0.06);
  color: var(--blush);
  border: 1px solid rgba(212, 106, 106, 0.1);
}

.project-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--charcoal-muted);
}

.project-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.15rem;
  transition: color 0.3s var(--ease-out);
}

.project-card:hover h3 {
  color: var(--blush);
}

.project-role {
  font-size: 0.8rem;
  color: var(--blush);
  margin-bottom: 0.5rem;
  font-style: italic;
}

.project-card p {
  font-size: 0.88rem;
  color: var(--charcoal-soft);
  margin: 0;
  line-height: 1.6;
  transition: color 0.4s var(--ease-out);
}

/* ==================== TEACHING ==================== */
.teaching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.teaching-col-title {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blush);
  margin-bottom: var(--space-sm);
  padding-bottom: 0.5rem;
  border-bottom: 1.5px solid var(--blush);
  display: inline-block;
  position: relative;
}

.teaching-col-title::after {
  content: '';
  position: absolute;
  bottom: -1.5px;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--blush-light);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease-out);
}

.teaching-col:hover .teaching-col-title::after {
  transform: scaleX(1);
}

.teaching-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.teaching-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule-light);
  font-size: 0.9rem;
  color: var(--charcoal-soft);
  display: flex;
  gap: var(--space-sm);
  align-items: baseline;
  line-height: 1.4;
  transition: padding-left 0.2s var(--ease-out), border-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

.teaching-list li:last-child { border-bottom: none; }

.teaching-col:hover .teaching-list li {
  padding-left: 4px;
}

.teaching-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--charcoal-muted);
  white-space: nowrap;
  min-width: 5.5rem;
  flex-shrink: 0;
}

.teaching-philosophy {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  padding: var(--space-md);
  border: 1px solid var(--rule-light);
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.4s var(--ease-out), transform 0.4s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}

.teaching-philosophy:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.teaching-philosophy h3 {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blush);
  margin-bottom: var(--space-sm);
}

.teaching-philosophy p {
  font-size: 0.92rem;
  color: var(--charcoal-soft);
  line-height: 1.65;
  transition: color 0.4s var(--ease-out);
}

/* ==================== CV ==================== */
.cv-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1.5px solid var(--rule);
  transition: border-color 0.4s var(--ease-out);
}

.cv-intro p {
  margin: 0;
  color: var(--charcoal-soft);
  font-size: 0.95rem;
  transition: color 0.4s var(--ease-out);
}

/* --- CV Carousel --- */
.cv-carousel {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--rule-light);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  padding: var(--space-md);
  max-width: 600px;
  margin: 0 auto;
  transition: box-shadow 0.4s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}

.cv-carousel:hover {
  box-shadow: var(--card-shadow-hover);
}

.carousel-viewport {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--ivory-dark);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  aspect-ratio: 8.5 / 11;
  max-height: 80vh;
  transition: background 0.4s var(--ease-out);
}

.carousel-track {
  display: flex;
  transition: transform 0.5s var(--ease-out);
  height: 100%;
}

.carousel-slide {
  min-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.carousel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  background: var(--card-bg);
  color: var(--charcoal-soft);
  cursor: pointer;
  transition: all 0.25s var(--ease-out), background 0.4s var(--ease-out), border-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

.carousel-btn:hover {
  border-color: var(--blush);
  color: var(--blush);
  background: var(--blush-muted);
  transform: scale(1.08);
}

.carousel-btn:active {
  transform: scale(0.95);
}

.carousel-btn:focus-visible {
  outline: 2px solid var(--blush);
  outline-offset: 2px;
}

.carousel-dots {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--rule);
  cursor: pointer;
  transition: all 0.35s var(--ease-spring), background 0.4s var(--ease-out);
  padding: 0;
}

.carousel-dot.active {
  background: var(--blush);
  width: 24px;
  border-radius: 4px;
}

.carousel-dot:hover {
  background: var(--blush-light);
  transform: scale(1.2);
}

.carousel-counter {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--charcoal-muted);
  margin-top: 0.4rem;
  transition: color 0.4s var(--ease-out);
}

/* ==================== CONTACT ==================== */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.contact-intro {
  font-size: 1.02rem;
  color: var(--charcoal-soft);
  line-height: 1.65;
  margin-bottom: var(--space-md);
  transition: color 0.4s var(--ease-out);
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--charcoal-soft);
  padding: 0.35rem 0;
  transition: color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.contact-link:hover {
  color: var(--blush);
  transform: translateX(5px);
}

.contact-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.contact-link:hover svg {
  opacity: 0.7;
  transform: scale(1.1);
}

.contact-form label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate-deep);
  margin-bottom: 0.2rem;
  letter-spacing: 0.02em;
  transition: color 0.4s var(--ease-out);
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--charcoal);
  transition: border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), transform 0.25s var(--ease-out), background 0.4s var(--ease-out), color 0.4s var(--ease-out);
  margin-bottom: var(--space-sm);
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--blush);
  box-shadow: 0 0 0 3px var(--blush-muted);
  transform: translateY(-1px);
}

.contact-form textarea {
  min-height: 110px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.form-status {
  font-size: 0.85rem;
  margin-top: var(--space-xs);
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  animation: statusSlide 0.3s var(--ease-out);
}

@keyframes statusSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-status.success { color: #2e7d32; background: rgba(46, 125, 50, 0.06); }
.form-status.error { color: #c62828; background: rgba(198, 40, 40, 0.06); }

/* ==================== FOOTER ==================== */
.footer {
  border-top: 1px solid var(--rule);
  padding: var(--space-lg) 0 var(--space-md);
  background: var(--ivory-light);
  text-align: center;
  position: relative;
  transition: background 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}

.footer::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--blush), transparent);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.footer-name {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  color: var(--slate-deep);
  transition: color 0.4s var(--ease-out);
}

.footer-links {
  display: flex;
  gap: var(--space-sm);
  list-style: none;
  padding: 0;
  margin: 0;
  justify-content: center;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--charcoal-muted);
  transition: color 0.2s var(--ease-out);
  position: relative;
}

.footer-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--blush);
  transform: scaleX(0);
  transition: transform 0.2s var(--ease-out);
}

.footer-links a:hover::after {
  transform: scaleX(1);
}

.footer-links a:hover { color: var(--blush); }

.footer-divider {
  width: 2rem;
  height: 1px;
  background: var(--rule);
  margin: 0 auto var(--space-sm);
}

.footer-copy {
  text-align: center;
  font-size: 0.72rem;
  color: var(--charcoal-faint);
  margin-bottom: 0.15rem;
  max-width: none;
}

.footer-attribution {
  text-align: center;
  font-size: 0.72rem;
  color: var(--charcoal-faint);
  max-width: none;
}

.footer-attribution a {
  color: var(--charcoal-faint);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--rule);
  transition: color 0.2s var(--ease-out), text-decoration-color 0.2s var(--ease-out);
}

.footer-attribution a:hover {
  color: var(--blush);
  text-decoration-color: var(--blush);
}

/* ==================== SCROLL REVEAL ANIMATIONS ==================== */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

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

/* Stagger delays via nth-child */
.research-card:nth-child(1).revealed { transition-delay: 0.05s; }
.research-card:nth-child(2).revealed { transition-delay: 0.1s; }
.research-card:nth-child(3).revealed { transition-delay: 0.15s; }
.research-card:nth-child(4).revealed { transition-delay: 0.2s; }

.pub-card:nth-child(1).revealed { transition-delay: 0.05s; }
.pub-card:nth-child(2).revealed { transition-delay: 0.1s; }
.pub-card:nth-child(3).revealed { transition-delay: 0.15s; }
.pub-card:nth-child(4).revealed { transition-delay: 0.2s; }

.project-card:nth-child(1).revealed { transition-delay: 0.03s; }
.project-card:nth-child(2).revealed { transition-delay: 0.06s; }
.project-card:nth-child(3).revealed { transition-delay: 0.09s; }
.project-card:nth-child(4).revealed { transition-delay: 0.12s; }
.project-card:nth-child(5).revealed { transition-delay: 0.15s; }
.project-card:nth-child(6).revealed { transition-delay: 0.18s; }
.project-card:nth-child(7).revealed { transition-delay: 0.21s; }

.about-card:nth-child(1).revealed { transition-delay: 0.1s; }
.about-card:nth-child(2).revealed { transition-delay: 0.2s; }

.about-text p:nth-child(1).revealed { transition-delay: 0.05s; }
.about-text p:nth-child(2).revealed { transition-delay: 0.1s; }
.about-text p:nth-child(3).revealed { transition-delay: 0.15s; }
.about-text p:nth-child(4).revealed { transition-delay: 0.2s; }

.teaching-col:nth-child(1).revealed { transition-delay: 0.05s; }
.teaching-col:nth-child(2).revealed { transition-delay: 0.1s; }

/* Hero reveal — handled by JS */
.reveal-hero {
  opacity: 0;
  transform: translateY(25px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.reveal-hero.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 960px) {
  .about-layout { grid-template-columns: 1fr; }
  .about-sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
}

@media (max-width: 820px) {
  .hero-layout {
    grid-template-columns: 1fr;
    text-align: center;
    gap: var(--space-lg);
  }
  .hero-visual { order: -1; }
  .hero-actions { justify-content: center; }
  .hero-text { margin-left: auto; margin-right: auto; }
  .hero-label { justify-content: center; }
  .hero-affiliations { justify-content: center; }
  .research-grid { grid-template-columns: 1fr; }
  .project-list { grid-template-columns: 1fr; }
  .teaching-grid { grid-template-columns: 1fr; }
  .contact-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .about-sidebar { grid-template-columns: 1fr; }
  .about-list li { flex-direction: column; gap: 0.1rem; }
  .about-tag { min-width: auto; }
  .teaching-list li { flex-direction: column; gap: 0.1rem; }
  .teaching-date { min-width: auto; }
  .cv-intro { flex-direction: column; align-items: flex-start; }

  .carousel-viewport { max-height: 60vh; }
  .cv-carousel { max-width: 100%; }
}

@media (max-width: 600px) {
  .container { padding: 0 var(--space-sm); }
  .section { padding: var(--space-xl) 0; }
  .hero { 
    padding-top: 50px;
    padding-bottom: 0;
  }
  /* Add top padding to the hero layout container on mobile so the portrait has breathing room below the nav */
  .hero .container {
    padding-top: 1.5rem;
  }
  .portrait-frame { width: 180px; height: 180px; }
  .btn { width: 100%; justify-content: center; }
  .hero-actions { flex-direction: column; }
  .section-header { flex-direction: column; gap: 0.2rem; }
  .hero-scroll { display: none; }
  .carousel-viewport { max-height: 50vh; }
  .cv-carousel { padding: var(--space-sm); }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal,
  .reveal-hero {
    opacity: 1;
    transform: none;
  }
  .carousel-track { transition: none; }
}
