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

:root {
  --bg: #FAFAF8;
  --text: #1a1a1a;
  --text-secondary: #86868b;
  --accent: #1d3557;
  --accent-hover: #0d1b2a;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.03), 0 8px 24px rgba(0,0,0,0.06), 0 24px 48px rgba(0,0,0,0.06);
  --shadow-lg: 0 2px 4px rgba(0,0,0,0.02), 0 12px 28px rgba(0,0,0,0.06), 0 40px 80px rgba(0,0,0,0.08);
  --font-display: 'Cormorant Garamond', 'Garamond', 'Georgia', serif;
  --font-body: 'Source Serif 4', 'Georgia', serif;
  --font-ui: 'Inter', -apple-system, 'Helvetica Neue', sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

::selection {
  background: rgba(29, 53, 87, 0.12);
}

html {
  -webkit-text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.82;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'liga' 1, 'kern' 1;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

body.nav-open {
  overflow: hidden;
}


/* ---- Grain Texture ---- */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.02;
  mix-blend-mode: multiply;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}


/* ---- Font Loading ---- */

html.fonts-loading .appear,
html.fonts-loading .appear-hero {
  animation: none !important;
  opacity: 0;
}

html.fonts-loading .site-name {
  opacity: 0;
}


/* ---- Skip Link ---- */

.skip-link {
  position: absolute;
  top: -3rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  padding: 0.5rem 1.25rem;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  border-radius: 0 0 6px 6px;
  transition: top 0.25s var(--ease);
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
  outline: none;
  background-image: none;
}


/* ---- Links ---- */

a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.5s var(--ease), color 0.3s ease;
}

a:hover {
  color: var(--accent-hover);
  background-image: linear-gradient(var(--accent-hover), var(--accent-hover));
  background-size: 100% 1.5px;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}


/* ---- Navigation ---- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 248, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: 66rem;
  margin: 0 auto;
  padding: 1.6rem 3rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.site-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
  background: none;
  transition: opacity 0.3s ease;
}

.site-name:hover {
  opacity: 0.5;
  background: none;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 3rem;
}

.nav-links a {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: none;
  position: relative;
  transition: color 0.3s ease;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text);
  transition: width 0.5s var(--ease);
}

.nav-links a:hover {
  color: var(--text);
  background: none;
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-links a.active {
  color: var(--text);
  background: none;
}

.nav-links a.active::after {
  width: 100%;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 110;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 1.5px;
  background: var(--text);
  transition: transform 0.4s var(--ease), opacity 0.3s ease;
  transform-origin: center;
}

.nav-toggle.open span:nth-child(1) {
  transform: rotate(45deg) translate(4.5px, 4.5px);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: rotate(-45deg) translate(4.5px, -4.5px);
}


/* ---- Appear (above-fold, CSS animation) ---- */

.appear {
  animation: fadeUp 0.9s var(--ease) backwards;
}

.appear-d1 { animation-delay: 0.12s; }
.appear-d2 { animation-delay: 0.24s; }
.appear-d3 { animation-delay: 0.36s; }
.appear-d4 { animation-delay: 0.48s; }

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ---- Reveal (below-fold, intersection observer) ---- */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}

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

.reveal-d1 { transition-delay: 0.12s; }
.reveal-d2 { transition-delay: 0.24s; }


/* ---- Page Transitions ---- */

.transition-in .appear,
.transition-in .appear-hero {
  animation: none !important;
  opacity: 1 !important;
}


/* ---- Page Exit Transition ---- */

body.is-leaving main,
body.is-leaving .site-footer {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.28s var(--ease-smooth), transform 0.28s var(--ease-smooth);
}


/* ---- Home Page ---- */

.page-home {
  padding: 8rem 3rem 0;
  position: relative;
}

.page-home::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(29, 53, 87, 0.04), transparent 60%);
  pointer-events: none;
  z-index: -1;
}

.hero {
  text-align: center;
  max-width: 50rem;
  margin: 0 auto;
}

.hero-photo {
  margin: 0 auto 3.5rem;
  max-width: 380px;
  will-change: transform;
}

.appear-hero {
  animation: fadeUpScale 1.1s var(--ease) backwards;
}

@keyframes fadeUpScale {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.93);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.headshot {
  width: 100%;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
}

.hero-name {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 300;
  letter-spacing: 0.07em;
  color: var(--text);
  margin-bottom: 1rem;
}

.hero-title {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1.7;
}

.hero-rule {
  width: 52px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--text), transparent);
  opacity: 0.2;
  border: none;
  margin: 3.5rem auto 4rem;
}

.bio {
  max-width: 35rem;
  margin: 0 auto;
  padding-bottom: 12rem;
}

.bio p {
  margin-bottom: 1.75rem;
  text-align: left;
}

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


/* ---- Inner Pages ---- */

.page-content {
  max-width: 37rem;
  margin: 0 auto;
  padding: 6rem 3rem 10rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--text);
}

.page-rule {
  width: 52px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--text), transparent);
  opacity: 0.2;
  border: none;
  margin: 2rem 0 3.5rem;
}

.page-content p {
  margin-bottom: 1.75rem;
}

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


/* ---- Research Page ---- */

.books-image {
  width: calc(100% + 6rem);
  margin-left: -3rem;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  margin-top: 2.5rem;
  margin-bottom: 3.5rem;
}


/* ---- CV Page ---- */

.page-cv {
  max-width: 40rem;
  margin: 0 auto;
  padding: 6rem 3rem 10rem;
}

.cv-header {
  text-align: center;
  margin-bottom: 4rem;
}

.cv-header .page-title {
  margin-bottom: 0.25rem;
}

.cv-header .page-rule {
  margin: 1.75rem auto 2.5rem;
}

.cv-download-link {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.cv-download-link svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  transition: transform 0.4s var(--ease);
}

.cv-download-link:hover svg {
  transform: translateY(3px);
}

.cv-rendered {
  text-align: left;
}

.cv-section {
  margin-bottom: 2.75rem;
}

.cv-section:last-child {
  margin-bottom: 0;
}

.cv-heading {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
}

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

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

.cv-entry-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.cv-entry-title {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}

.cv-entry-year {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.cv-entry-sub {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--text-secondary);
  margin-top: 0.125rem;
  line-height: 1.5;
}

.cv-entry-detail {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
  line-height: 1.5;
}


/* ---- Footer ---- */

.site-footer {
  background: #141414;
  padding: 5rem 3rem;
  text-align: center;
}

.footer-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 0.875rem;
}

.footer-detail {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.06em;
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.footer-email a {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.04em;
  background: none;
  transition: color 0.3s ease;
}

.footer-email a:hover {
  color: rgba(255, 255, 255, 0.85);
  background: none;
}


/* ---- Responsive: Tablet ---- */

@media (max-width: 768px) {
  body::before {
    display: none;
  }

  .site-header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }

  .nav {
    padding: 1.25rem 2rem;
    align-items: center;
  }

  .site-name {
    font-size: 1.15rem;
    letter-spacing: 0.12em;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: fixed;
    inset: 0;
    z-index: 105;
    background: var(--bg);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.45s var(--ease-smooth), visibility 0.45s var(--ease-smooth);
  }

  .nav-links.open {
    opacity: 1;
    visibility: visible;
  }

  .nav-links a {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.06em;
    text-transform: none;
    color: var(--text);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s var(--ease), transform 0.5s var(--ease), color 0.3s ease;
  }

  .nav-links.open a {
    opacity: 1;
    transform: translateY(0);
  }

  .nav-links li:nth-child(1) a { transition-delay: 0.06s; }
  .nav-links li:nth-child(2) a { transition-delay: 0.12s; }
  .nav-links li:nth-child(3) a { transition-delay: 0.18s; }

  .nav-links a::after {
    display: none;
  }

  .nav-links a.active {
    opacity: 0.4;
  }

  .nav-links.open a.active {
    opacity: 0.4;
  }

  .page-home {
    padding: 4.5rem 2rem 0;
  }

  .hero-photo {
    max-width: 260px;
  }

  .hero-name {
    font-size: 2.5rem;
  }

  .hero-title {
    font-size: 0.75rem;
  }

  .hero-rule {
    margin: 2.75rem auto 3rem;
  }

  .bio {
    padding-bottom: 6rem;
  }

  .page-content {
    padding: 4rem 2rem 6rem;
  }

  .page-cv {
    padding: 4rem 2rem 6rem;
  }

  .page-title {
    font-size: 2.5rem;
  }

  .books-image {
    width: calc(100% + 2rem);
    margin-left: -1rem;
  }

  .cv-entry-row {
    flex-direction: column;
    gap: 0;
  }

  .cv-entry-year {
    order: -1;
    margin-bottom: 0.125rem;
  }

  .site-footer {
    padding: 3.5rem 2rem;
  }

  body {
    font-size: 1.0625rem;
  }
}


/* ---- Responsive: Phone ---- */

@media (max-width: 480px) {
  .nav {
    padding: 1rem 1.5rem;
  }

  .site-name {
    font-size: 1rem;
    letter-spacing: 0.1em;
  }

  .page-home {
    padding: 3.5rem 1.5rem 0;
  }

  .hero-photo {
    max-width: 220px;
    margin-bottom: 2.25rem;
  }

  .hero-name {
    font-size: 2rem;
    letter-spacing: 0.05em;
  }

  .hero-title {
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
  }

  .hero-rule {
    width: 40px;
    margin: 2.25rem auto 2.5rem;
  }

  .bio {
    padding-bottom: 4.5rem;
  }

  .page-content {
    padding: 3rem 1.5rem 5rem;
  }

  .page-cv {
    padding: 3rem 1.5rem 5rem;
  }

  .page-title {
    font-size: 2rem;
  }

  .page-rule {
    width: 40px;
    margin: 1.5rem 0 2.5rem;
  }

  .books-image {
    width: calc(100% + 1.5rem);
    margin-left: -0.75rem;
    border-radius: 4px;
  }

  .site-footer {
    padding: 3rem 1.5rem;
  }

  body {
    font-size: 1rem;
    line-height: 1.78;
  }
}


/* ---- Reduced Motion ---- */

@media (prefers-reduced-motion: reduce) {
  .appear,
  .appear-hero {
    animation: none !important;
    opacity: 1 !important;
  }

  .reveal {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  body.is-leaving main,
  body.is-leaving .site-footer {
    transition: none !important;
  }

  a,
  .nav-links a,
  .nav-links a::after,
  .site-name,
  .nav-toggle span,
  .cv-download-link svg {
    transition: none !important;
  }

  html.fonts-loading .appear,
  html.fonts-loading .appear-hero,
  html.fonts-loading .site-name {
    opacity: 1 !important;
  }
}


/* ---- Print ---- */

@media print {
  body::before,
  .site-header,
  .site-footer,
  .nav-toggle,
  .hero-rule,
  .page-rule,
  .skip-link {
    display: none !important;
  }

  body {
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }

  .page-home,
  .page-content,
  .page-cv {
    padding: 0;
    max-width: none;
    min-height: auto;
  }

  .appear,
  .appear-hero,
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  a {
    color: #000;
    background: none;
    text-decoration: underline;
  }

  .headshot {
    max-width: 180px;
    box-shadow: none;
  }

  .books-image {
    width: 100%;
    margin-left: 0;
    box-shadow: none;
  }
}
