@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Inter:wght@400;500;700&display=swap');

:root {
  --bg: #faf9f7;
  --text: #1c1c1a;
  --text-secondary: #6a6a65;
  --accent: #2a5c45;
  --accent-light: #e8f0ec;
  --border: #e4e3de;
  --max-width: 660px;
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'EB Garamond', Georgia, serif;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Navigation ─────────────────────────────────────────── */

nav {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-name {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

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

.nav-links a {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
  letter-spacing: 0.01em;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

/* ── Layout ─────────────────────────────────────────────── */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4.5rem 2rem 7rem;
}

.home-main {
  max-width: 100%;
  margin: 0;
  padding: 2.5rem 4rem 7rem;
}

/* ── Typography ─────────────────────────────────────────── */

h1 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 2.2rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

h2 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
  margin-top: 3rem;
}

h2:first-child {
  margin-top: 0;
}

h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  margin-top: 2rem;
}

h3:first-child {
  margin-top: 0;
}

p {
  margin-bottom: 1.4rem;
  color: var(--text);
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Home page ──────────────────────────────────────────── */

.intro-header {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.intro-header .subtitle {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  margin-bottom: 0;
}

.intro-body p {
  font-size: 1.05rem;
}

.intro-links {
  margin-top: 2.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.intro-links a {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}

.intro-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ── Home intro layout ──────────────────────────────────────── */

.intro-layout {
  display: grid;
  grid-template-columns: minmax(300px, 520px) 1fr;
  gap: 4rem;
  align-items: start;
}

.intro-text {
  min-width: 0;
}

.intro-image-col {
  width: 440px;
  justify-self: end;
}

.intro-figure {
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.75rem;
  background: #fff;
  text-align: center;
}

.intro-figure img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 0.5rem;
}

.intro-figure figcaption {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: normal;
  line-height: 1.6;
  text-align: center;
}

.intro-image-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
  font-style: italic;
  margin-bottom: 0;
}

@media (max-width: 700px) {
  .intro-layout {
    flex-direction: column-reverse;
    gap: 2rem;
  }

  .intro-image-col {
    flex: none;
    width: 100%;
  }

  .intro-figure {
    max-width: 340px;
  }
}

/* ── Writing index ──────────────────────────────────────── */

.writing-list {
  list-style: none;
}

.writing-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.writing-item:first-child {
  border-top: 1px solid var(--border);
}

.writing-item a {
  color: var(--text);
  text-decoration: none;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1.25rem;
  align-items: center;
}

.writing-item a:hover .writing-title {
  color: var(--accent);
}

.writing-thumb {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: block;
}

.writing-title {
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.3;
  transition: color 0.15s;
  margin-bottom: 0.3rem;
}

.writing-meta {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.writing-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  margin-bottom: 0;
  line-height: 1.5;
}

/* ── Essay / document pages ─────────────────────────────── */

.doc-header {
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.doc-header h1 {
  margin-bottom: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
}

.doc-subtitle {
  display: block;
  font-size: 1.3rem;
  font-weight: 400;
  font-style: italic;
  margin-top: 0.4rem;
  color: var(--text-secondary);
}

.doc-meta {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.doc-body {
  font-size: 1.1rem;
  line-height: 1.8;
}

.doc-body p {
  margin-bottom: 1.5rem;
}

.doc-body .drop-cap::first-letter {
  font-size: 3rem;
  font-weight: 500;
  float: left;
  line-height: 0.82;
  margin-right: 0.08em;
  margin-top: 0.08em;
  color: var(--accent);
}

/* ── Dissertation figures ──────────────────────────────── */

.dissertation-figure {
  margin: 2.5rem 0;
}

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

.dissertation-figure figcaption {
  margin-top: 0.6rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.doc-body h2 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
  margin-top: 3rem;
  margin-bottom: 1rem;
}

.doc-body h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 500;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.doc-body blockquote {
  border-left: 2px solid var(--border);
  margin: 2rem 0;
  padding: 0 0 0 1.5rem;
  color: var(--text-secondary);
  font-style: italic;
}

.doc-body ul,
.doc-body ol {
  margin: 0 0 1.5rem 1.5rem;
}

.doc-body li {
  margin-bottom: 0.4rem;
}

.back-link {
  display: inline-block;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 3rem;
  letter-spacing: 0.01em;
}

.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ── About / Skills page ────────────────────────────────── */

.about-section {
  margin-bottom: 3.5rem;
}

.skills-group {
  margin-bottom: 2.5rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.tag {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ── Footer ─────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ── Sidebar TOC ─────────────────────────────────────────── */

.page-with-sidebar {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4.5rem 2rem 7rem;
}

.toc-sidebar {
  display: none;
}

@media (min-width: 1120px) {
  .page-with-sidebar {
    padding: 4.5rem 2rem 7rem;
  }

  .toc-sidebar {
    display: block;
    position: absolute;
    left: -260px;
    top: 4.5rem;
    width: 220px;
    height: calc(100% - 9rem);
  }

  .toc-sidebar-inner {
    position: sticky;
    top: 3rem;
  }

  .toc-sidebar-inner h2 {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    margin-bottom: 0.85rem;
    margin-top: 0;
  }

  .toc-sidebar nav ol {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .toc-sidebar nav ol ol {
    margin-left: 0.85rem;
    margin-top: 0.1rem;
  }

  .toc-sidebar nav li {
    margin-bottom: 0;
  }

  .toc-sidebar nav > ol {
    counter-reset: toc-main;
  }

  .toc-sidebar nav > ol > li {
    counter-increment: toc-main;
  }

  .toc-sidebar nav > ol > li > ol {
    counter-reset: toc-sub;
  }

  .toc-sidebar nav > ol > li > ol > li {
    counter-increment: toc-sub;
  }

  .toc-sidebar nav a {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 0.2rem 0;
    line-height: 1.45;
    border-left: 2px solid transparent;
    padding-left: 0.6rem;
    transition: color 0.15s, border-color 0.15s;
  }

  .toc-sidebar nav ol ol a {
    font-size: 0.8rem;
  }

  .toc-sidebar nav > ol > li > a::before {
    content: counter(toc-main, decimal) ". ";
  }

  .toc-sidebar nav > ol > li > ol > li > a::before {
    content: counter(toc-main, decimal) "." counter(toc-sub, decimal) " ";
  }

  .toc-sidebar nav a:hover {
    color: var(--text);
  }

  .toc-sidebar nav a.active {
    color: var(--accent);
    border-left-color: var(--accent);
  }
}

/* ── Document front matter ──────────────────────────────── */

.doc-front {
  margin-bottom: 3.5rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  line-height: 1.8;
}

.dedication {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.doc-statement {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-top: 1.5rem;
}

.dedication p {
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.figures-list {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.figures-list ol {
  margin: 0.75rem 0 0 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.figures-list li {
  margin-bottom: 0.35rem;
}

.doc-toc ol {
  margin: 0.75rem 0 0 1.5rem;
}

.doc-toc li {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.doc-toc a {
  color: var(--text-secondary);
  text-decoration: none;
}

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

.doc-toc ol ol {
  margin-top: 0.2rem;
  margin-left: 1.2rem;
}

/* ── Document body extras ───────────────────────────────── */

.doc-body h4 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1rem;
  font-weight: 400;
  font-style: italic;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.doc-body figure,
.doc-front figure {
  margin: 2rem auto;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.85rem 1rem;
  background: #fff;
  max-width: 600px;
  text-align: center;
}

.doc-body figure img,
.doc-front figure img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 0.75rem;
}

.doc-body figcaption,
.doc-front figcaption {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
}

.fig-placeholder {
  height: 160px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  border-radius: 2px;
  letter-spacing: 0.04em;
}

.field-note {
  border-left: 2px solid var(--border);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 1.5rem 0;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 600px) {
  nav {
    padding: 1rem 1.25rem;
  }

  main {
    padding: 2.5rem 1.25rem 5rem;
  }

  h1 {
    font-size: 1.75rem;
  }
}

/* ── Figure pairs (side-by-side) ───────────────────────── */

.figure-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2.5rem 0 0.5rem;
}

.figure-pair .dissertation-figure {
  margin: 0;
}

.figure-caption {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 2.5rem;
}

@media (max-width: 600px) {
  .figure-pair {
    grid-template-columns: 1fr;
  }
}

/* ── Doc note / divider ─────────────────────────────────── */

/* ── Footnotes ──────────────────────────────────────────── */

.fn-ref {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.7rem;
  color: var(--accent);
  text-decoration: none;
  vertical-align: super;
  line-height: 0;
  margin-left: 0.1em;
}

.fn-ref:hover {
  text-decoration: underline;
}

.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.footnotes ol {
  padding-left: 1.25rem;
  margin-top: 0.75rem;
}

.footnotes li {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.fn-back {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 0.25em;
  text-decoration: none;
}

.fn-back:hover {
  color: var(--accent);
  text-decoration: none;
}

.doc-disclaimer {
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  margin-bottom: 3rem !important;
}

.doc-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3.5rem 0 2rem;
}

.doc-note {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
}
