/* =========================================================
   Personal academic site: one stylesheet for every page.
   Change colours in :root, fonts in --serif / --sans.
   ========================================================= */

/* ---------- Fonts (self-hosted: no requests to Google) ---------- */
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 300; font-display: swap;
  src: url("../fonts/spectral-latin-300-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 300; font-display: swap;
  src: url("../fonts/spectral-latin-ext-300-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/spectral-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/spectral-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/spectral-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/spectral-latin-ext-400-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/spectral-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/spectral-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/instrument-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/instrument-sans-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/instrument-sans-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/instrument-sans-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

/* ---------- Design tokens ---------- */
/* Dark is the default. Light applies when the visitor picks it
   (the button sets data-theme="light" on <html>). */
:root {
  --paper: #0E1426;          /* page background */
  --paper-alt: #131A30;      /* alternate section background */
  --ink: #E4E8F1;            /* main text */
  --muted: #9AA3B8;          /* secondary text */
  --rule: #273049;           /* thin lines */
  --accent: #7CC6CD;         /* links: an [O III]-teal */
  --accent-strong: #AEE0E4;
  --plate: #FFFFFF;          /* background behind figures */
  --night: #0B1124;          /* header fallback colour (header is dark in both modes) */
  --on-night: #EEF1F7;
  --on-night-muted: rgba(238, 241, 247, 0.78);

  --serif: "Spectral", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  --measure: 38rem;          /* comfortable line length for body text */
  --wide: 72rem;             /* page width */
  --gutter: clamp(1.25rem, 5vw, 3rem);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --paper: #F6F7F9;
  --paper-alt: #ECEFF4;
  --ink: #17203A;
  --muted: #566079;
  --rule: #D9DEE7;
  --accent: #1C6B73;
  --accent-strong: #11494F;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
p { margin: 0 0 1.1em; }
h1, h2, h3 { font-weight: 400; line-height: 1.2; margin: 0; text-wrap: balance; }
h2 { font-size: 2rem; letter-spacing: -0.005em; margin-bottom: 1rem; }
a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-strong); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--paper); color: var(--ink);
  font-family: var(--sans); padding: 0.5rem 0.9rem; border-radius: 4px;
}
.skip-link:focus { top: 1rem; }

.container { max-width: var(--wide); margin: 0 auto; }
.section { padding: clamp(3rem, 7vw, 5.5rem) var(--gutter); }
.section--alt { background: var(--paper-alt); }
.prose { max-width: var(--measure); }

/* ---------- Hero (the night-sky header) ---------- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: min(86vh, 860px);
  padding: 0 var(--gutter) 3.75rem;
  color: var(--on-night);
  background-color: var(--night);
  background-image:
    linear-gradient(180deg, rgba(8, 12, 28, 0.55) 0%, rgba(8, 12, 28, 0) 22%,
                    rgba(8, 12, 28, 0) 48%, rgba(8, 12, 28, 0.78) 100%),
    url("../../images/hero.jpg");
  background-size: cover;
  background-position: center;
}
.hero--page { min-height: 0; padding-bottom: 3rem; }
.hero ::selection { background: var(--on-night); color: var(--night); }
.hero :focus-visible { outline-color: var(--on-night); }

.hero__text { width: 100%; max-width: var(--wide); margin: auto auto 0; padding-top: 5rem; }
.hero--page .hero__text { padding-top: 3.5rem; }
.hero__name {
  font-weight: 300;
  font-size: clamp(3rem, 1.4rem + 6.5vw, 6.75rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem -0.04em;    /* optical alignment of the first letter */
}
.hero--page .hero__name { font-size: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem); margin-bottom: 0; }
.hero__role {
  font-family: var(--sans);
  font-size: clamp(1rem, 0.92rem + 0.4vw, 1.25rem);
  line-height: 1.5;
  color: var(--on-night-muted);
  margin: 0;
}
.hero__credit {
  position: absolute; right: var(--gutter); bottom: 0.9rem;
  max-width: 44ch; margin: 0; text-align: right;
  font-family: var(--sans); font-size: 0.75rem; line-height: 1.4;
  color: rgba(238, 241, 247, 0.55);
}
.hero__credit a { color: inherit; }

/* ---------- Navigation ---------- */
.site-nav {
  display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 1.5rem;
  width: 100%; max-width: var(--wide); margin: 0 auto; padding: 1.25rem 0;
  font-family: var(--sans); font-size: 0.95rem;
}
.site-nav__name { color: inherit; text-decoration: none; font-weight: 500; }
.site-nav__name:hover { color: inherit; }
.site-nav__links {
  display: flex; align-items: center; gap: 1.75rem;
  list-style: none; margin: 0 0 0 auto; padding: 0;
}
.site-nav__links a {
  color: var(--on-night-muted);
  text-decoration: none;
  padding: 0.3rem 0;
  border-bottom: 1px solid transparent;
}
.site-nav__links a:hover,
.site-nav__links a[aria-current="page"] { color: var(--on-night); border-bottom-color: currentColor; }
.site-nav__toggle {
  display: none;
  margin-left: auto;
  font: 500 0.95rem/1 var(--sans);
  color: var(--on-night);
  background: transparent;
  border: 1px solid rgba(238, 241, 247, 0.45);
  border-radius: 4px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
}

/* Light/dark button: shown only when JavaScript runs, since it needs it */
.site-nav__theme { display: none; }
.js .site-nav__theme { display: block; }
.theme-toggle {
  display: inline-flex; align-items: center;
  font: 500 0.9rem/1 var(--sans);
  color: var(--on-night);
  background: rgba(238, 241, 247, 0.08);
  border: 1px solid rgba(238, 241, 247, 0.5);
  border-radius: 999px;
  padding: 0.5rem;
  cursor: pointer;
}
.theme-toggle:hover { background: rgba(238, 241, 247, 0.18); border-color: var(--on-night); }
.theme-toggle__light, .theme-toggle__dark { display: inline-flex; align-items: center; gap: 0.45rem; }
.theme-toggle svg { width: 1rem; height: 1rem; flex: none; }
.theme-toggle__dark { display: none; }
:root[data-theme="light"] .theme-toggle__light { display: none; }
:root[data-theme="light"] .theme-toggle__dark { display: inline-flex; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

@media (max-width: 46rem) {
  .js .site-nav__toggle { display: block; }
  .js .site-nav__links {
    display: none;
    flex-basis: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    margin: 0; padding: 0.4rem 1rem;
    background: rgba(8, 12, 28, 0.9);
    border: 1px solid rgba(238, 241, 247, 0.15);
    border-radius: 6px;
  }
  .js .site-nav.is-open .site-nav__links { display: flex; }
  .js .site-nav__links a { display: block; padding: 0.75rem 0; border-bottom: 0; }
  .js .site-nav__links li + li { border-top: 1px solid rgba(238, 241, 247, 0.12); }
  .js .site-nav__links .site-nav__theme { padding: 0.75rem 0; }
  .js .site-nav__links a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }
  /* No-JS fallback: links simply wrap under the name */
  .site-nav__links { flex-wrap: wrap; gap: 0.5rem 1.25rem; }
  .hero__credit { left: var(--gutter); text-align: left; }
}

/* ---------- Home: about ---------- */
.about {
  display: grid;
  grid-template-columns: 13.75rem minmax(0, var(--measure));
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
.about__portrait {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 50%;
  margin-top: 0.4rem;
}
@media (max-width: 46rem) {
  .about { grid-template-columns: 1fr; }
  .about__portrait { width: 10rem; }
}

/* Profile links (used on home and in the footer) */
.links {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  list-style: none; margin: 1.75rem 0 0; padding: 0;
  font-family: var(--sans); font-size: 0.95rem;
}

/* Lines a section up with the text column of the about block */
@media (min-width: 46.01rem) {
  .offset { display: grid; grid-template-columns: 13.75rem minmax(0, 1fr); column-gap: clamp(2rem, 5vw, 4.5rem); }
  .offset > * { grid-column: 2; }
}

/* ---------- Home: news ---------- */
.news { list-style: none; margin: 0; padding: 0; max-width: 48rem; }
.news li {
  display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0.25rem 1.5rem;
  padding: 1rem 0; border-top: 1px solid var(--rule);
}
.news li:last-child { border-bottom: 1px solid var(--rule); }
.news time {
  font-family: var(--sans); font-size: 0.9rem; color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums; padding-top: 0.2rem;
}
.news p { margin: 0; }
@media (max-width: 36rem) { .news li { grid-template-columns: 1fr; } }

/* ---------- Research: project blocks ---------- */
.projects { counter-reset: fig; }
.intro { max-width: var(--measure); margin-bottom: clamp(1rem, 3vw, 2rem); }

.project {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  grid-template-areas: "head head" "figure body";
  gap: 1.5rem clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  padding: clamp(2.5rem, 6vw, 4.5rem) 0;
  border-top: 1px solid var(--rule);
}
.project:nth-of-type(even) {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  grid-template-areas: "head head" "body figure";
}
.project__head { grid-area: head; max-width: 48rem; }
.project__head h2 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem); margin-bottom: 0.5rem; }
.project__meta {
  font-family: var(--sans); font-size: 0.9rem; color: var(--muted); margin: 0;
  font-variant-numeric: lining-nums;
}
.project__body { grid-area: body; max-width: var(--measure); }
.project__body p:last-child { margin-bottom: 0; }
.project .figure { grid-area: figure; }

@media (max-width: 52rem) {
  .project, .project:nth-of-type(even) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "figure" "body";
  }
}

/* Figures with journal-style numbered captions */
.figure { margin: 0; counter-increment: fig; }
.figure__plate {
  display: block;
  background: var(--plate);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.75rem;
}
.figure__plate:hover { border-color: var(--muted); }
.figure figcaption {
  margin-top: 0.8rem; max-width: 62ch;
  font-family: var(--sans); font-size: 0.875rem; line-height: 1.55; color: var(--muted);
  font-variant-numeric: lining-nums;
}
.figure figcaption::before { content: "Figure " counter(fig) ". "; font-weight: 500; color: var(--ink); }

/* ---------- Publications ---------- */
.pub-year {
  font-size: 1.6rem; font-variant-numeric: lining-nums;
  margin: 2.75rem 0 0.25rem; padding-top: 0.5rem;
}
.pub-year:first-of-type { margin-top: 0.5rem; }
.pubs { list-style: none; margin: 0; padding: 0; max-width: 48rem; }
.pub { padding: 1.1rem 0; border-top: 1px solid var(--rule); }
.pub__title { margin: 0 0 0.3rem; line-height: 1.4; }
.pub__authors, .pub__venue {
  margin: 0; font-family: var(--sans); font-size: 0.9rem; line-height: 1.5; color: var(--muted);
  font-variant-numeric: lining-nums;
}
.pub__authors strong { color: var(--ink); font-weight: 500; }
.pub__venue cite { font-style: italic; }
.pub__venue a { margin-left: 0.9rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem var(--gutter) 2.5rem;
  font-family: var(--sans); font-size: 0.9rem; color: var(--muted);
}
.site-footer .container {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 1rem 2rem;
}
.site-footer p { margin: 0; }
.site-footer .links { margin: 0; font-size: 0.9rem; }

@media print {
  .hero { min-height: 0; color: #000; background: none; }
  .site-nav, .hero__credit, .skip-link { display: none; }
}
