/* ============================================================================
   Design tokens

   Light is the default. Dark is opt-in via the toggle only — the OS setting is
   deliberately not followed, so every first visit lands on the light design.

   Palette is white/black dominant: warm paper, near-black ink, and exactly one
   accent used for links and state. Nothing else is coloured.
   ========================================================================== */

:root {
  --color-bg: oklch(99% 0.003 85);        /* warm paper, not clinical #fff */
  --color-surface: oklch(97.2% 0.004 85);
  --color-border: oklch(89% 0.005 85);
  --color-text: oklch(21% 0.012 265);     /* near-black, cool cast */
  --color-muted: oklch(50% 0.014 265);
  --color-accent: oklch(47% 0.17 272);    /* indigo */
  --color-accent-soft: oklch(47% 0.17 272 / 0.09);
  --color-rule: oklch(92.5% 0.005 85);

  /* Serif display against a system sans body — the pairing does the work a
     downloaded webfont would, at zero network cost. */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Charter,
    Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    Helvetica, Arial, sans-serif;

  --text-sm: 0.95rem;
  --text-base: 1.125rem;
  --text-lg: 1.3rem;
  --text-name: clamp(3rem, 2.1rem + 3.8vw, 5rem);

  --space-gutter: clamp(1.25rem, 0.6rem + 2.6vw, 2.5rem);
  --space-section: clamp(2.25rem, 1.6rem + 2.2vw, 3.25rem);
  --measure: 62rem;

  --radius: 10px;
  --duration: 180ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] {
  --color-bg: oklch(17% 0.012 265);
  --color-surface: oklch(21.5% 0.014 265);
  --color-border: oklch(31% 0.016 265);
  --color-text: oklch(94% 0.005 85);
  --color-muted: oklch(70% 0.014 265);
  --color-accent: oklch(79% 0.13 272);
  --color-accent-soft: oklch(79% 0.13 272 / 0.14);
  --color-rule: oklch(27% 0.014 265);
  color-scheme: dark;
}

/* ============================================================================
   Base
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: opacity var(--duration) var(--ease);
}
a:hover { opacity: 0.68; }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 3px;
}

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

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; }

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--space-gutter);
}

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

/* ============================================================================
   Header — deliberately shallow so the fold sits lower
   ========================================================================== */

.site-header {
  border-bottom: 1px solid var(--color-rule);
  background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 3.4rem;
  flex-wrap: wrap;
}

.social { display: flex; align-items: center; gap: 0.85rem; }
.social a { color: var(--color-text); display: inline-flex; }
.social svg { width: 20px; height: 20px; fill: currentColor; display: block; }

.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.85rem, 0.3rem + 1.4vw, 1.6rem);
}
.nav__link { color: var(--color-text); font-size: 1.125rem; }
.nav__link[aria-current="page"] { color: var(--color-accent); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem; height: 2.1rem;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.theme-toggle:hover { background: var(--color-surface); }
.theme-toggle svg { width: 19px; height: 19px; fill: currentColor; }
.theme-toggle__moon { display: none; }
:root[data-theme="dark"] .theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__moon { display: block; }

/* ============================================================================
   Intro — portrait sits on the name row, prose runs full width beneath.
   The earlier two-column version stranded the portrait: top-aligned it floated
   high beside a tall paragraph stack, and once the grid collapsed it landed
   below everything. Anchoring it to the name makes the relationship fixed at
   every width.
   ========================================================================== */

main { padding-block: var(--space-section); }

.intro__head {
  display: flex;
  align-items: center;
  gap: clamp(1.1rem, 0.6rem + 1.8vw, 1.9rem);
  margin-bottom: 1.6rem;
}

.intro__portrait {
  width: clamp(7.5rem, 5rem + 7vw, 11rem);
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--color-border);
}

.intro__name {
  font-size: var(--text-name);
  margin: 0 0 0.08em;
  letter-spacing: -0.02em;
}

.intro__tagline {
  color: var(--color-muted);
  font-size: var(--text-lg);
  margin: 0;
}

.intro__body { max-width: 50rem; }
.intro__body > p { margin: 0 0 1.05rem; }
.intro__body > p:last-child { margin-bottom: 0; }
.intro__body b { font-weight: 620; }
.intro__closer {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--color-text);
  margin-top: 1.4rem !important;
}

/* ============================================================================
   Affiliations — one row, always. Overflow scrolls rather than wrapping into a
   ragged second line.
   ========================================================================== */

/* A grid rather than a nowrap row: at desktop width auto-fit still lays all
   seven out on one line, but on a phone it reflows to three-up instead of
   running off the side of the viewport. */
.affiliations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  justify-items: center;
  gap: 1.75rem 1rem;
  margin: 0;
  padding: 1.5rem 0 0.5rem;
  list-style: none;
}

/* Each mark keeps its natural proportions — a fixed plate made the row read as
   a spreadsheet. What is shared is the invisible band the logo is centred in,
   which is enough to put every label on the same line without boxing anything. */
.affiliation {
  display: grid;
  grid-template-rows: 2.75rem auto;
  justify-items: center;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 7rem;
  color: var(--color-text);
  text-align: center;
}
.affiliation:hover { opacity: 1; }

.affiliation__logo {
  max-height: 2.6rem;
  max-width: 100%;
  width: auto;
  height: auto;
  opacity: 0.9;
  mix-blend-mode: multiply;
  transition: opacity var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.affiliation:hover .affiliation__logo { opacity: 1; transform: translateY(-2px); }

/* Optical sizing: a wordmark set to the same height as a square crest reads far
   heavier, because it carries that height across its whole width. */
.affiliation__logo--wide  { max-height: 1.95rem; }
.affiliation__logo--mid   { max-height: 1.5rem; }
.affiliation__logo--xwide { max-height: 1.3rem; }

/* Dark backgrounds swallow the dark wordmarks. Lifting them with a soft,
   borderless backdrop keeps the row from turning into a set of framed tiles. */
:root[data-theme="dark"] .affiliation__logo {
  mix-blend-mode: normal;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 6px;
  padding: 5px 8px;
}

.affiliation__label {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--color-muted);
}
.affiliation__label b {
  display: block;
  margin-bottom: 0.1rem;
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
}

/* ============================================================================
   Sections
   ========================================================================== */

.section { margin-top: var(--space-section); }

.section__title {
  font-size: 1.8rem;
  margin: 0 0 1.1rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--color-rule);
}

/* Publications ---------------------------------------------------------- */

.pub-list { list-style: none; margin: 0; padding: 0; }

.pub {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  gap: 1.35rem;
  align-items: start;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--color-rule);
}
.pub:last-child { border-bottom: none; }

.pub__thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.pub__title { font-size: 1.25rem; margin: 0 0 0.3rem; line-height: 1.3; }
.pub__authors { color: var(--color-muted); font-size: var(--text-sm); margin: 0 0 0.25rem; }
.pub__authors .me { color: var(--color-text); font-weight: 640; }
.pub__meta { font-size: var(--text-sm); margin: 0; color: var(--color-muted); }
.pub__venue { font-style: italic; }
.pub__links { margin-left: 0.45rem; }

@media (max-width: 40rem) {
  .pub { grid-template-columns: 1fr; gap: 0.85rem; }
  .pub__thumb { max-width: 15rem; }
}

/* Repositories ---------------------------------------------------------- */

.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.repo {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.15rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  transition: border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.repo:hover { border-color: var(--color-accent); transform: translateY(-2px); }

.repo__name { font-family: var(--font-sans); font-size: 1.0625rem; font-weight: 620; margin: 0; }
.repo__owner { color: var(--color-muted); font-weight: 400; }
.repo__desc { margin: 0; font-size: var(--text-sm); color: var(--color-muted); flex: 1; }
.repo__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.repo__lang { display: inline-flex; align-items: center; gap: 0.4rem; }
.repo__dot {
  width: 0.7em; height: 0.7em;
  border-radius: 50%;
  background: var(--color-accent);
  display: inline-block;
}
.repo__badge {
  align-self: flex-start;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

/* ============================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--color-rule);
  margin-top: var(--space-section);
  padding-block: 1.5rem;
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: center;
}

/* ============================================================================
   Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .repo:hover { transform: none; }
}
