/* ==========================================================================
   Personal academic site: shared styles
   Sections: tokens, base, layout, header/nav, hero, cards, prose, contact,
   footer, utilities. Add new page-specific styles at the bottom.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-alt: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2027;
  --text-muted: #565e6b;
  --border: #dfe2e7;
  --accent: #a3172a;        /* deep red, a nod to Bristol; change freely */
  --accent-hover: #7f1220;
  --accent-contrast: #ffffff;
  --focus: #1a5fd0;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;

  --measure: 68ch;          /* comfortable reading width */
  --container: 60rem;
  --radius: 10px;
  --space: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --bg-alt: #1b1f26;
    --surface: #1b1f26;
    --text: #e8eaed;
    --text-muted: #a3aab5;
    --border: #2d333d;
    --accent: #ff8a96;
    --accent-hover: #ffb3bb;
    --accent-contrast: #14171c;
    --focus: #7fb0ff;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;  /* keeps anchored sections clear of the sticky header */
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden; /* belt-and-braces: no sideways scroll if anything ever overshoots */
}

h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: 1.2;
  margin: 0 0 0.6em;
  font-weight: 700;
}
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.25em; }

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}
a:hover { color: var(--accent-hover); }

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

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

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 1rem;
  box-sizing: border-box;
}

.section { padding-block: clamp(2.5rem, 7vw, 4.5rem); }
.section--alt { background: var(--bg-alt); }
.section > .container > h2 { margin-bottom: 1.25rem; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 0 0 var(--radius) var(--radius);
}
.skip-link:focus { top: 0; color: var(--accent-contrast); }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.75rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--accent); }

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: block;
  padding: 0.35rem 0;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav-list a:hover { color: var(--text); }
.nav-list a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.nav-toggle {
  display: none;
  padding: 0.4rem 0.8rem;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

/* Only collapse the menu when JS is available to reopen it */
@media (max-width: 40rem) {
  .js .nav-toggle { display: inline-block; }
  .js .site-nav { display: none; width: 100%; padding-bottom: 0.75rem; }
  .js .site-nav.is-open { display: block; }
  .js .nav-list { flex-direction: column; gap: 0; }
  .js .nav-list a { padding: 0.6rem 0; }
}

/* ---------- Hero ---------- */
.hero {
  padding-block: clamp(3rem, 9vw, 6rem);
}

.hero-grid {
  display: grid;
  gap: 2rem;
  align-items: center;
}

@media (min-width: 46rem) {
  .hero-grid { grid-template-columns: 1fr auto; gap: 3.5rem; }
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.lead {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: var(--measure);
}

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

.button {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-contrast);
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }

.button--ghost {
  color: var(--accent);
  background: transparent;
}
.button--ghost:hover { color: var(--accent-contrast); }

/* Portrait: swap the initials for <img class="portrait__img"> when you have a photo */
.portrait {
  display: grid;
  place-items: center;
  width: 11rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 700;
  overflow: hidden;
}
.portrait__img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 45.99rem) {
  .portrait { width: 8rem; font-size: 2.5rem; order: -1; }
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.card {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card h3 { margin-bottom: 0.4em; }
.card p:last-child { margin-bottom: 0; }

/* ---------- Prose (about page, future long-form pages) ---------- */
.page-header {
  padding-block: clamp(2.5rem, 6vw, 4rem) 1rem;
}
.page-header h1 { margin-bottom: 0.3em; }

.prose { max-width: var(--measure); }
.prose h2 { margin-top: 2em; }
.prose h2:first-child { margin-top: 0; }

.two-col {
  display: grid;
  gap: 2.5rem;
}
@media (min-width: 52rem) {
  .two-col { grid-template-columns: minmax(0, 1fr) 17rem; gap: 3.5rem; }
}

/* Figures within prose, e.g. research project write-ups. Always a full-width,
   stacked block, same on mobile and desktop. */
.prose figure { margin: 0 0 1.75rem; }
.prose figure img {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.prose figcaption { margin-top: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }

.facts {
  align-self: start;
  padding: 1.25rem 1.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.97rem;
}
.facts h2 { font-size: 1.1rem; margin-bottom: 0.6em; }
.facts dl { margin: 0; }
.facts dt { font-weight: 600; margin-top: 0.75rem; }
.facts dt:first-child { margin-top: 0; }
.facts dd { margin: 0; color: var(--text-muted); }

/* Simple year/entry list, reusable for education, positions, later CV-style lists */
.timeline { list-style: none; padding: 0; margin: 0 0 1em; }
.timeline li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}
.timeline li:last-child { border-bottom: 1px solid var(--border); }
.timeline .when { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Publications ---------- */
.pub-group-heading {
  margin-top: 2.25em;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.pub-group-heading:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

.pub-list { list-style: none; padding: 0; margin: 0 0 0.5em; }
.pub-list li {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}
.pub-list li:last-child { border-bottom: 1px solid var(--border); }
.pub-list .year {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.pub-list .venue { color: var(--text-muted); font-style: italic; }
.pub-list p { margin: 0; }
.pub-list .pub-links { margin-top: 0.25rem; font-size: 0.92rem; }

@media (max-width: 30rem) {
  .pub-list li { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* Selected-research list on the Research page, linking out to project write-ups */
.research-list { list-style: none; padding: 0; margin: 0 0 1.5em; }
.research-list li {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}
.research-list li:last-child { border-bottom: 1px solid var(--border); }
.research-list h3 { margin: 0 0 0.3em; font-size: 1.05rem; }
.research-list h3 a { text-decoration: none; }
.research-list p { margin: 0; color: var(--text-muted); }

/* Tag chips, e.g. research-area labels */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0 0 1.5em; list-style: none; }
.tag-list li {
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* ---------- Contact ---------- */
.contact-grid {
  display: grid;
  gap: 2rem;
}
@media (min-width: 46rem) {
  .contact-grid { grid-template-columns: 1fr 1fr; gap: 3rem; }
}

.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { padding: 0.5rem 0; }
.contact-list .label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Footer ---------- */
.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--text-muted);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}
.site-footer p { margin: 0; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media print {
  .site-header, .skip-link, .button-row { display: none; }
  body { font-size: 11pt; }
}
