/* ------------------------------------------------------------------
   Base: layout, typography, components. Colours and the layout mode
   are set by a theme file (theme-*.css) through custom properties.
   ------------------------------------------------------------------ */
:root {
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;

  /* palette */
  --olive-900: #26311A;
  --olive-800: #33421F;
  --olive-700: #3F5220;
  --olive-600: #556B2F;
  --olive-500: #6B8038;
  --olive-400: #8A9A5B;
  --olive-300: #B3BE8E;
  --olive-100: #E7EBD9;
  --olive-50:  #F3F5EC;
  --burgundy-900: #3F0F18;
  --burgundy-800: #5C1622;
  --burgundy-700: #7A1F2E;
  --burgundy-600: #8E2A3B;
  --burgundy-400: #B54A5E;
  --burgundy-300: #CF6F81;
  --burgundy-100: #F3E3E6;
  --paper: #FBF9F4;
  --cream: #F4F1E8;
  --ink: #22261C;

  /* semantic defaults (light) */
  --bg: var(--paper);
  --bg-elevated: #FFFFFF;
  --fg: var(--ink);
  --fg-muted: #5F6555;
  --rule: #DDD9CC;
  --accent: var(--olive-600);
  --accent-strong: var(--olive-700);
  --accent-soft: var(--olive-100);
  --accent-2: var(--burgundy-700);
  --accent-2-soft: var(--burgundy-100);
  --link: var(--burgundy-700);
  --link-hover: var(--burgundy-800);
  --heading-font: var(--font-serif);
  --body-font: var(--font-serif);
  --ui-font: var(--font-sans);
  --identity-bg: transparent;
  --identity-fg: var(--fg);
  --identity-muted: var(--fg-muted);
  --nav-bg: transparent;
  --measure: 46rem;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 25, 10, .06), 0 4px 14px rgba(20, 25, 10, .05);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body-font);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration-thickness: .06em; text-underline-offset: .14em; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { font-family: var(--heading-font); line-height: 1.2; margin: 0 0 .5em; font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); }
h2 { font-size: 1.45rem; color: var(--accent-strong); margin-top: 0; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.2em; }
.muted { color: var(--fg-muted); }
.small { font-size: .92rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent-2); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }
.icon { width: 1.05em; height: 1.05em; fill: currentColor; vertical-align: -.18em; flex: none; }
.icon-sm { width: .8em; height: .8em; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- layout skeleton (single column by default) ---------- */
.layout {
  display: grid;
  grid-template-areas: "nav" "identity" "content";
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}
.site-nav  { grid-area: nav; }
.identity  { grid-area: identity; }
.content   { grid-area: content; }

/* ---------- navigation ---------- */
.site-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem;
  font-family: var(--ui-font); font-size: .95rem;
  padding: .85rem 1rem;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--rule);
}
.site-nav .brand { font-family: var(--heading-font); font-weight: 600; font-size: 1.1rem; color: inherit; text-decoration: none; margin-right: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.site-nav a { color: inherit; text-decoration: none; padding: .15rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover, .site-nav a[aria-current="page"] { border-bottom-color: var(--accent-2); }
.nav-tools a { display: inline-flex; align-items: center; gap: .3em; }
.lang-switch { font-weight: 600; }

/* ---------- identity block: hero on the home page, compact elsewhere ---------- */
.identity {
  background: var(--identity-bg); color: var(--identity-fg);
  padding: 2rem 1rem 1rem;
  display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center;
  max-width: var(--measure); margin: 0 auto; width: 100%;
}
.portrait { border-radius: 50%; width: 9.5rem; height: 9.5rem; object-fit: cover; border: 3px solid var(--accent-soft); box-shadow: var(--shadow); }
.portrait-link { display: block; }
.identity .name { font-family: var(--heading-font); font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); font-weight: 600; line-height: 1.15; margin: 0 0 .25rem; }
.identity .name a { color: inherit; text-decoration: none; }
.identity .degrees { font-size: .55em; font-weight: 400; color: var(--identity-muted); }
.identity .tagline { font-family: var(--ui-font); font-size: 1.05rem; color: var(--accent-2); margin: 0 0 .15rem; letter-spacing: .01em; }
.identity .location { font-family: var(--ui-font); color: var(--identity-muted); font-size: .95rem; margin: 0 0 .75rem; }
.identity-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem .5rem; font-family: var(--ui-font); font-size: .9rem; }
.identity-links a { display: inline-flex; align-items: center; gap: .35em; text-decoration: none; color: var(--identity-fg); border: 1px solid var(--rule); border-radius: 999px; padding: .2em .7em .2em .55em; background: var(--bg-elevated); }
.identity-links a:hover { border-color: var(--accent); color: var(--accent-strong); }
body:not(.page-home) .identity { padding: 1.25rem 1rem .5rem; gap: 1rem; }
body:not(.page-home) .portrait { width: 4.25rem; height: 4.25rem; border-width: 2px; }
body:not(.page-home) .identity .name { font-size: 1.35rem; }
body:not(.page-home) .identity .tagline { font-size: .95rem; }
body:not(.page-home) .identity .location,
body:not(.page-home) .identity-links { display: none; }

/* ---------- content ---------- */
.content { width: 100%; }
main { max-width: var(--measure); margin: 0 auto; padding: 1rem 1rem 3rem; }
.section { margin: 2.5rem 0 0; }
.section:first-child { margin-top: 1rem; }
.section > h2 { padding-bottom: .3rem; border-bottom: 2px solid var(--accent); margin-bottom: 1rem; }
.section h3 { color: var(--accent-2); margin-top: 1.5rem; font-family: var(--ui-font); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 1.5rem 2.5rem; }
@media (min-width: 720px) { .two-col { grid-template-columns: 1fr 1fr; } }
.lede { font-size: 1.2rem; line-height: 1.55; }
.page-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin: 1rem 0 .5rem; }
.page-header h1 { margin: 0; }
.page-header p { flex-basis: 100%; margin: 0; }
.toc { display: flex; flex-wrap: wrap; gap: .3rem .5rem; font-family: var(--ui-font); font-size: .88rem; margin: 0 0 .5rem; }
.toc a { text-decoration: none; color: var(--fg-muted); border: 1px solid var(--rule); border-radius: 999px; padding: .1em .7em; }
.toc a:hover { color: var(--accent-strong); border-color: var(--accent); }

.cta-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0 0; }
.btn { display: inline-flex; align-items: center; gap: .4em; font-family: var(--ui-font); font-weight: 600; font-size: .95rem; text-decoration: none; padding: .5em 1em; border-radius: var(--radius); border: 1.5px solid var(--accent); color: var(--accent-strong); background: transparent; }
.btn:hover { background: var(--accent-soft); color: var(--accent-strong); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }

.roles, .interests, .plain, .contact-list { list-style: none; padding: 0; margin: 0; }
.roles li { margin-bottom: .75rem; }
.interests li, .plain li { position: relative; padding-left: 1.1em; margin-bottom: .35rem; }
.interests li::before, .plain li::before { content: ""; position: absolute; left: 0; top: .62em; width: .45em; height: .45em; border-radius: 50%; background: var(--accent-2); }
.contact-list li { margin-bottom: .4rem; display: flex; align-items: center; gap: .5em; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.card { background: var(--bg-elevated); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card h3 { font-family: var(--heading-font); text-transform: none; letter-spacing: 0; font-size: 1.05rem; margin: 0 0 .35rem; color: var(--fg); }
.card p { margin: 0; font-size: .95rem; color: var(--fg-muted); }

/* ---------- entries (publications, talks, positions) ---------- */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 7rem 1fr; gap: .25rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.entry:last-child { border-bottom: 0; }
.entry-when { font-family: var(--ui-font); font-size: .9rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; padding-top: .2em; }
.entry-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.entry-title { font-weight: 600; }
.entry-venue, .entry-note { font-size: .95rem; }
.coauthors { font-size: .92rem; color: var(--fg-muted); }
.doi { font-family: var(--ui-font); font-size: .85rem; word-break: break-all; }
.details { margin: .3rem 0 0; padding-left: 1.1em; font-size: .95rem; }
.details li { margin-bottom: .15rem; }
.timeline .entry { grid-template-columns: 9rem 1fr; }
.timeline .entry.current .entry-when::after { content: "●"; color: var(--accent-2); margin-left: .35em; font-size: .7em; vertical-align: .1em; }
.badge { display: inline-block; font-family: var(--ui-font); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--accent-2); border: 1px solid currentColor; border-radius: 4px; padding: .05em .45em; margin-right: .4em; vertical-align: .15em; }
@media (max-width: 560px) {
  .entry { grid-template-columns: 1fr; gap: .1rem; }
}

/* ---------- latest: posts ---------- */
.latest-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem 2rem; }
@media (min-width: 780px) { .latest-grid { grid-template-columns: 1fr 1fr; } }
.latest-col h3 { margin-top: 0; }
.posts { display: flex; flex-direction: column; gap: .75rem; }
.post { background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); font-size: .95rem; }
.post-title { font-family: var(--heading-font); text-transform: none; letter-spacing: 0; font-size: 1.05rem; margin: 0 0 .3rem; color: var(--fg); }
.post-title a { color: inherit; text-decoration: none; }
.post-title a:hover { color: var(--link); }
.post-text { margin: 0 0 .5rem; white-space: pre-line; }
.post-embed { display: block; text-decoration: none; border: 1px solid var(--rule); border-radius: var(--radius); padding: .5rem .7rem; margin: .25rem 0 .5rem; font-family: var(--ui-font); background: var(--bg); }
.post-embed-title { display: block; font-weight: 600; color: var(--fg); }
.post-embed-host { display: block; font-size: .8rem; color: var(--fg-muted); }
.post-media { margin: 0 0 .4rem; font-family: var(--ui-font); font-size: .85rem; }
.post-meta { font-family: var(--ui-font); font-size: .82rem; color: var(--fg-muted); }
.more { font-family: var(--ui-font); margin: .75rem 0 0; }

/* ---------- skills, languages ---------- */
.skills dt { font-family: var(--ui-font); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); margin: .75rem 0 .3rem; }
.skills dd { margin: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.tag { font-family: var(--ui-font); font-size: .85rem; background: var(--accent-soft); color: var(--accent-strong); border-radius: 4px; padding: .1em .55em; }
.languages { margin: 0; }
.languages div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dotted var(--rule); padding: .3rem 0; }
.languages dt { font-weight: 600; }
.languages dd { margin: 0; color: var(--fg-muted); font-family: var(--ui-font); }

/* ---------- footer ---------- */
.site-footer { max-width: var(--measure); margin: 0 auto; padding: 1.5rem 1rem 2.5rem; border-top: 1px solid var(--rule); font-family: var(--ui-font); font-size: .88rem; color: var(--fg-muted); }
.footer-line { margin: 0 0 .3rem; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding-top: 4rem; }
.notfound h1 { font-size: 5rem; color: var(--accent); margin: 0; }

@media print {
  .site-nav, .cta-row, .toc, .site-footer, .more { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: inherit; }
}

/* ---------- small screens: stack the identity block, keep everything inside the viewport ---------- */
.identity-text { min-width: 0; }
@media (max-width: 600px) {
  .identity { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: .75rem; }
  .identity-links { justify-content: center; }
  body:not(.page-home) .identity { grid-template-columns: auto 1fr; text-align: left; justify-items: start; }
}

/* long tokens (URLs, DOIs, hashtags) must never widen the page */
main, .identity, .site-footer { overflow-wrap: anywhere; }
.post, .card, .entry-body, .post-embed-host { min-width: 0; overflow-wrap: anywhere; }
html { overflow-x: clip; }

/* ---------- projects ---------- */
.link-chips { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .4em; font-family: var(--ui-font); font-size: .88rem; text-decoration: none; color: var(--fg); background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: 999px; padding: .2em .8em .2em .6em; }
.chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.chip-kind { color: var(--fg-muted); font-size: .78em; text-transform: uppercase; letter-spacing: .06em; }
.chip-code { border-color: var(--olive-300); }
.link-chips.small { margin-top: .4rem; }
.link-chips.small .chip { font-size: .8rem; }
.project-meta { margin: 0 0 1rem; font-family: var(--ui-font); font-size: .95rem; display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.project-meta div { display: contents; }
.project-meta dt { color: var(--fg-muted); font-weight: 600; }
.project-meta dd { margin: 0; }
.project .entry-note { color: var(--fg); }
.card-meta { font-family: var(--ui-font); font-size: .85rem; color: var(--fg-muted); margin: -.2rem 0 .4rem; }
.card-links { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-family: var(--ui-font); font-size: .88rem; margin: .5rem 0 0; }
@media (max-width: 560px) { .project-meta { grid-template-columns: 1fr; } .project-meta dt { margin-top: .4rem; } }

/* ---------- prose pages (legal) ---------- */
.prose h2 { font-size: 1.25rem; margin-top: 2rem; }
.prose p { margin-bottom: .8em; }
