/* ==========================================================================
   Dr Patrick J. Tait — personal CV site
   Newsreader (headings) + Source Sans 3 (body). One accent colour.
   ========================================================================== */

:root {
  --bg: #faf8f3;
  --surface: #f2eee6;
  --text: #1e1d1a;
  --muted: #5c584f;
  --rule: #ddd6c8;
  --accent: #8a2f2a;
  --accent-soft: #f1e3df;
  --focus: #8a2f2a;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;

  --measure: 40rem;
  --page: 64rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --header-h: 3.5rem;
  color-scheme: light;
}

/* Dark theme: follows the system setting unless the visitor picks a theme with the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161513;
    --surface: #1f1d1a;
    --text: #ebe6dc;
    --muted: #a8a194;
    --rule: #35322c;
    --accent: #9E5949;
    --accent-soft: #2c211e;
    --focus: #9E5949;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161513;
  --surface: #1f1d1a;
  --text: #ebe6dc;
  --muted: #a8a194;
  --rule: #35322c;
  --accent: #9E5949;
  --accent-soft: #2c211e;
  --focus: #9E5949;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: 2px; }

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

.muted { color: var(--muted); }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.9rem;
  background: var(--text);
  color: var(--bg);
  z-index: 100;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--rule); }

.site-header__inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.site-header nav { margin-left: auto; }

.wordmark {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.site-header.is-scrolled .wordmark,
.wordmark:focus-visible { opacity: 1; }

.nav-list {
  display: flex;
  gap: clamp(0.9rem, 2.4vw, 1.75rem);
}
.nav-list a {
  position: relative;
  display: block;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.nav-list a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.nav-list a:hover,
.nav-list a[aria-current="true"] { color: var(--text); }
.nav-list a:hover::after,
.nav-list a[aria-current="true"]::after { transform: scaleX(1); }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-right: -0.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.theme-toggle:hover { color: var(--accent); background: var(--surface); }
.theme-toggle svg { width: 1.125rem; height: 1.125rem; }
.theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (max-width: 40rem) {
  .site-header__inner { gap: 0.75rem; }
  .wordmark { display: none; }
  .site-header nav { flex: 1; min-width: 0; margin-left: 0; }
  /* Links wrap onto a second row rather than scrolling sideways, so all are visible at once */
  .nav-list { flex-wrap: wrap; column-gap: 1.1rem; row-gap: 0; padding: 0.25rem 0; }
  .nav-list a { padding: 0.5rem 0; }
  .theme-toggle { width: 2.75rem; height: 2.75rem; margin-right: -0.75rem; }
}

/* ---------- Layout ---------- */
main {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 3rem;
  padding: clamp(3.5rem, 11vw, 8rem) 0 clamp(3rem, 8vw, 5.5rem);
  border-bottom: 1px solid var(--rule);
}

.eyebrow,
.kicker {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.hero h1 {
  font-size: clamp(2.75rem, 8vw, 5rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 72;
}

.hero__role {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.2rem, 2.6vw, 1.5rem);
  color: var(--muted);
  margin: 0.75rem 0 1.75rem;
}

.hero__summary {
  max-width: 34rem;
  font-size: 1.125rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.portrait {
  margin: 0;
  width: clamp(7.5rem, 18vw, 11rem);
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  outline: 1px solid var(--rule);
  outline-offset: 6px;
}
.portrait__monogram {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  color: var(--accent);
  letter-spacing: 0.05em;
}
.portrait__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 40rem) {
  .hero { grid-template-columns: 1fr; gap: 2rem; }
  .portrait { order: -1; width: 6rem; margin-left: 7px; }
}

/* ---------- Sections ---------- */
.section {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 2rem 3rem;
  padding: clamp(3rem, 7vw, 5rem) 0;
  border-bottom: 1px solid var(--rule);
}
.section:last-of-type { border-bottom: 0; }

.section__title {
  font-size: 0.8125rem;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.45rem;
  position: relative;
}
.section__title::before {
  content: "";
  display: block;
  width: 1.5rem;
  height: 1px;
  background: var(--accent);
  margin-bottom: 0.9rem;
}

.section__body { max-width: var(--measure); }

@media (max-width: 52rem) {
  .section { grid-template-columns: 1fr; gap: 1.5rem; }
}

.prose p { max-width: 38rem; }
.lede {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.4vw, 1.55rem);
  line-height: 1.45;
}

/* ---------- Placeholders ---------- */
.placeholder {
  padding: 0.75rem 1rem;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}
.placeholder strong { color: var(--accent); font-weight: 600; }
.placeholder--inline {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.875rem;
}

/* ---------- Experience timeline ---------- */
.timeline { display: grid; gap: 2.75rem; }

.org {
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
}

.roles {
  position: relative;
  display: grid;
  gap: 1.75rem;
  padding-left: 1.75rem;
}
.roles::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 1px;
  background: var(--rule);
}
.roles:has(> .role:only-child)::before { display: none; }

.role { position: relative; }
.role::before {
  content: "";
  position: absolute;
  left: -1.75rem;
  top: 0.55rem;
  width: 0.5625rem;
  height: 0.5625rem;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--muted);
}
.role--current::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.role__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
}
.role__title {
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}
.role__dates,
.degree__dates {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.role__meta {
  margin: 0.15rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.role__desc {
  margin-top: 0.6rem;
  max-width: 36rem;
}

/* ---------- Education ---------- */
.degrees { display: grid; gap: 1.75rem; }
.degree {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.25rem 1.5rem;
}
.degree__dates { padding-top: 0.3rem; }
.degree__title { font-size: 1.3rem; }
.degree__inst { margin: 0.2rem 0 0; color: var(--muted); }

@media (max-width: 34rem) {
  .degree { grid-template-columns: 1fr; }
  .degree__dates { order: 1; padding-top: 0; }
}

/* ---------- Research ---------- */
.research-card {
  padding: 1.75rem;
  background: var(--surface);
  border-top: 2px solid var(--accent);
}
.research-card .kicker { margin-bottom: 0.75rem; }
.research-card__title {
  font-size: clamp(1.4rem, 2.8vw, 1.75rem);
  margin-bottom: 1rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.tags li {
  font-size: 0.8125rem;
  padding: 0.15rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  background: var(--bg);
}

.subhead {
  font-size: 1.4rem;
  margin: 3rem 0 1.25rem;
}

.pubs { display: grid; gap: 1.5rem; counter-reset: pub; }
.pub { padding-left: 1rem; border-left: 1px solid var(--rule); }
.pub__title { font-family: var(--serif); font-size: 1.15rem; line-height: 1.35; margin-bottom: 0.3rem; }
.pub__title a { color: var(--text); text-decoration-color: var(--rule); }
.pub__title a:hover { color: var(--accent); text-decoration-color: currentColor; }
.pub__authors,
.pub__venue { font-size: 0.9375rem; color: var(--muted); margin: 0; }
.pub__authors b { color: var(--text); font-weight: 600; }

.more-link { margin-top: 1rem; font-size: 0.9375rem; }
.more-link a,
.placeholder a { display: inline-block; padding: 0.35rem 0; }

/* ---------- Skills ---------- */
.core {
  font-family: var(--serif);
  font-size: 1.25rem;
  margin-bottom: 2.25rem;
}
.core__label {
  display: block;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 2rem 2.5rem;
  margin: 0;
}
.skill-group dt {
  font-family: var(--serif);
  font-size: 1.1rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.skill-group dd { margin: 0; }
.skill-group li { font-size: 0.9875rem; padding: 0.15rem 0; }
.inline-list { display: flex; flex-wrap: wrap; gap: 0 0.4rem; }
.inline-list li:not(:last-child)::after { content: " ·"; color: var(--muted); }

/* ---------- Contact ---------- */
.contact__intro { color: var(--muted); }
.contact-links { display: grid; gap: 0.75rem; margin-top: 1.5rem; }
.contact-links a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
  color: var(--text);
  text-decoration: none;
}
.contact-links__label {
  font-family: var(--serif);
  font-size: 1.5rem;
  transition: color 0.2s ease;
}
.contact-links a:hover .contact-links__label { color: var(--accent); }
.contact-links a::after {
  content: "→";
  color: var(--muted);
  transition: transform 0.2s ease, color 0.2s ease;
}
.contact-links a:hover::after { color: var(--accent); transform: translateX(4px); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--page);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 3rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.site-footer p { margin: 0; }
.print-btn {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--rule);
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.print-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   Print — a clean two-page CV
   ========================================================================== */
@media print {
  @page { size: A4; margin: 15mm 16mm; }

  :root,
  :root[data-theme] {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --text: #000;
    --muted: #444;
    --rule: #bbb;
    --accent: #6e1f1b;
    --accent-soft: #fff;
  }

  html { font-size: 9.5pt; }
  body { background: #fff; color: #000; line-height: 1.45; }

  .site-header,
  .skip-link,
  .portrait,
  .print-btn,
  .placeholder,
  .more-link,
  .contact__intro,
  .hero__meta,
  .eyebrow { display: none !important; }

  main, .site-footer { max-width: none; padding: 0; }

  .hero {
    display: block;
    padding: 0 0 4mm;
    border-bottom: 1.5pt solid var(--accent);
  }
  .hero h1 { font-size: 26pt; }
  .hero__role { margin: 1mm 0 2mm; font-size: 12pt; }
  .hero__summary { border-left: 0; padding-left: 0; font-size: 10pt; margin: 0; }

  .section {
    display: block;
    padding: 4mm 0;
    border-bottom: 0.5pt solid var(--rule);
  }
  .section::after { content: ""; display: block; clear: both; }
  .section__title { float: left; width: 30mm; padding-top: 0.5mm; font-size: 8pt; color: var(--accent); }
  .section__body { margin-left: 36mm; }
  .section__title::before { display: none; }
  .section__body { max-width: none; }

  .lede { font-size: 11pt; }

  .timeline { gap: 4mm; }
  .org { font-size: 12.5pt; margin-bottom: 2mm; }
  .roles { gap: 2.5mm; padding-left: 4mm; }
  .roles::before { left: 0.6mm; }
  .role::before { left: -4mm; width: 1.6mm; height: 1.6mm; top: 1.4mm; box-shadow: none; }
  .role__title { font-size: 10pt; }
  .role__desc { margin-top: 1mm; max-width: none; }
  .role, .degree, .skill-group, .research-card { break-inside: avoid; }

  .degrees { gap: 2.5mm; }
  .degree { grid-template-columns: 30mm 1fr; }
  .degree__title { font-size: 11pt; }

  .research-card { padding: 0; border-top: 0; }
  .research-card__title { font-size: 12pt; margin-bottom: 1.5mm; }
  .tags { display: none; }
  .subhead { font-size: 11pt; margin: 3mm 0 1.5mm; }
  /* Hide the publications heading while the list is still a placeholder */
  .subhead:has(+ .pubs > .placeholder:only-child) { display: none; }

  .core { font-size: 10.5pt; margin-bottom: 3mm; }
  .skills { grid-template-columns: repeat(3, 1fr); gap: 3mm 5mm; }
  .skill-group dt { font-size: 10pt; padding-bottom: 1mm; margin-bottom: 1mm; }
  .skill-group li { font-size: 9pt; padding: 0; }

  .contact-links { margin-top: 0; gap: 0; }
  .contact-links a { padding: 1mm 0; border: 0; justify-content: flex-start; }
  .contact-links a::after { display: none; }
  .contact-links__label { font-size: 10pt; min-width: 28mm; }

  .site-footer { border: 0; padding-top: 3mm; font-size: 8pt; }

  a { color: inherit; text-decoration: none; }
  h3, h4 { break-after: avoid; }
}
