/* Personal academic site: restrained layout, one accent colour, light and dark themes. */

:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --text: #1d2228;
  --muted: #5a6270;
  --accent: #2e4a6b;
  --accent-soft: #e7edf4;
  --rule: #dcd9d1;
  --tbc-bg: #fff1b8;
  --tbc-text: #4a3a00;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15181d;
    --text: #e8e6e1;
    --muted: #a9b0bb;
    --accent: #9ab7d8;
    --accent-soft: #1f2a38;
    --rule: #2c323b;
    --tbc-bg: #4a3d10;
    --tbc-text: #ffe9a3;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15181d;
  --text: #e8e6e1;
  --muted: #a9b0bb;
  --accent: #9ab7d8;
  --accent-soft: #1f2a38;
  --rule: #2c323b;
  --tbc-bg: #4a3d10;
  --tbc-text: #ffe9a3;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

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

/* Layout */

.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

main.wrap {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

@media (min-width: 40rem) {
  main.wrap {
    padding-top: 4.5rem;
  }
}

section {
  margin-block: 3.25rem;
}

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

/* Typography */

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  letter-spacing: -0.01em;
  margin-bottom: 0.4em;
}

h2 {
  font-size: 1.5rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
}

h3 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
}

h4 {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1.5rem;
}

p,
ul,
ol,
dl {
  margin: 0 0 1em;
}

ul,
ol {
  padding-left: 1.2em;
}

li + li {
  margin-top: 0.4em;
}

.lede {
  font-size: 1.2rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.meta {
  color: var(--muted);
  font-size: 0.95rem;
}

strong {
  font-weight: 600;
}

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

a:hover {
  text-decoration-thickness: 2px;
}

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

/* Header and navigation */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 10;
  background: var(--bg);
  color: var(--text);
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
}

.skip-link:focus {
  left: 0.5rem;
}

.site-header {
  border-bottom: 1px solid var(--rule);
  padding-block: 1rem;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.site-name {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

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

nav li + li {
  margin-top: 0;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  padding-block: 0.2rem;
  border-bottom: 1px solid transparent;
}

nav a:hover,
nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Breadcrumb */

.breadcrumb {
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

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

/* Buttons and actions */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  line-height: 1.4;
}

.button:hover {
  background: var(--accent-soft);
}

.button-quiet {
  border-color: var(--rule);
  color: var(--text);
}

/* Project cards */

.card {
  padding-block: 1.25rem;
  border-top: 1px solid var(--rule);
}

.card:last-of-type {
  border-bottom: 1px solid var(--rule);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
}

.card h3 a {
  color: var(--text);
  text-decoration: none;
}

.card h3 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

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

.tag {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

/* Project detail */

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1.25rem;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

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

.facts dd {
  margin: 0;
}

/* Research and publications */

.pubs li {
  margin-bottom: 1rem;
}

.pub-title {
  font-weight: 600;
}

/* About */

.skills dt {
  font-weight: 600;
  margin-top: 0.75rem;
}

.skills dd {
  margin: 0.15rem 0 0;
}

.timeline > li {
  margin-bottom: 1.1rem;
}

.timeline p {
  margin-bottom: 0.25rem;
}

/* Contact */

.contact-list {
  list-style: none;
  padding: 0;
}

.contact-list li {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.5rem;
  padding-block: 0.6rem;
  border-bottom: 1px solid var(--rule);
  margin: 0;
}

.contact-list span:first-child {
  color: var(--muted);
}

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

  .facts {
    grid-template-columns: 1fr;
    gap: 0 0;
  }

  .facts dd {
    margin-bottom: 0.6rem;
  }
}

/* Placeholders: visible markers for content still to be written */

.tbc {
  background: var(--tbc-bg);
  color: var(--tbc-text);
  padding: 0 0.3em;
  border-radius: 3px;
  font-size: 0.95em;
  word-break: break-word;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 1.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

/* Introduction and portrait */

.intro-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem 2.5rem;
}

.intro-text {
  flex: 1 1 26rem;
  min-width: 0;
}

/* On wider screens the portrait sits on the right of the text */
@media (min-width: 40rem) {
  .intro-layout {
    flex-direction: row-reverse;
  }
}

.intro-text h1 {
  margin-top: 0.25rem;
}

.intro-text .lede {
  margin-bottom: 1rem;
}

.portrait {
  flex: 0 0 auto;
  width: 13rem;
  height: 13rem;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  box-shadow: 0 0 0 1px var(--rule);
}

.portrait-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
}

/* Tutoring */

.reference {
  margin: 0 0 1.5rem;
  padding-left: 1.1rem;
  border-left: 2px solid var(--accent);
}

.reference p {
  margin-bottom: 0.4rem;
}

.reference footer {
  color: var(--muted);
  font-size: 0.95rem;
}

.tutor-email {
  font-size: 1.2rem;
  margin-top: 0.5rem;
}

/* Decorative backdrop: blurred time-series traces, fixed behind the page */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--accent);
  opacity: 0.24;
  -webkit-mask: url("backdrop.svg") center / cover no-repeat;
  mask: url("backdrop.svg") center / cover no-repeat;
}

/* Motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
