/* ------------------------------------------------------------------
   Buddhi Ashan — site stylesheet
   Light-first, warm neutral ground, one teal accent.
   Fonts: Newsreader (headings), IBM Plex Sans (text), IBM Plex Mono (labels)
   ------------------------------------------------------------------ */

:root {
  --bg: #fbf9f4;
  --surface: #ffffff;
  --surface-2: #f4f0e6;
  --text: #1b1a17;
  --text-2: #4b473f;
  --muted: #6b675e;
  --faint: #9a958a;
  --border: #e8e3d6;
  --border-strong: #d6d0c2;
  --bg-glow: radial-gradient(ellipse 70% 40% at 50% -8%, rgba(198, 152, 62, 0.16), rgba(198, 152, 62, 0) 70%);
  --accent: #0f766e;
  --accent-ink: #0b5d57;
  --accent-soft: #e4f2ef;
  --badge-bg: #efeadf;
  --badge-text: #4b473f;
  --warm: #a35a2f;
  --warm-soft: #f4e9e1;
  --grid-line: #c9c4b8;
  --grid-line-2: #9a958a;
  --dropped: #dedad2;
  --ink-fill: #1b1a17;

  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --measure: 1040px;
  --gutter: 20px;
  --radius: 10px;
  --radius-lg: 12px;

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1b1e23;
  --surface-2: #22262c;
  --text: #e8e6e1;
  --text-2: #c9c6bf;
  --muted: #a09d95;
  --faint: #7d7a72;
  --border: #2c3037;
  --border-strong: #3a3f47;
  --accent: #6fd3a3;
  --accent-ink: #93e2bb;
  --accent-soft: #17362a;
  --bg-glow: none;
  --badge-bg: #2a2e35;
  --badge-text: #c9c6bf;
  --warm: #d08a5e;
  --warm-soft: #3a2a20;
  --grid-line: #3a3f47;
  --grid-line-2: #5a606a;
  --dropped: #33383f;
  --ink-fill: #e8e6e1;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1b1e23;
    --surface-2: #22262c;
    --text: #e8e6e1;
    --text-2: #c9c6bf;
    --muted: #a09d95;
    --faint: #7d7a72;
    --border: #2c3037;
    --border-strong: #3a3f47;
    --accent: #6fd3a3;
    --accent-ink: #93e2bb;
    --accent-soft: #17362a;
    --bg-glow: none;
    --badge-bg: #2a2e35;
    --badge-text: #c9c6bf;
    --warm: #d08a5e;
    --warm-soft: #3a2a20;
    --grid-line: #3a3f47;
    --grid-line-2: #5a606a;
    --dropped: #33383f;
    --ink-fill: #e8e6e1;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */

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

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}
h1 { font-size: 40px; }
h2 { font-size: 28px; }
h3 { font-size: 21px; }

p { margin: 0; text-wrap: pretty; text-align: justify; }
figcaption, .service-list li, .course-body li { text-align: justify; }
ul, ol { margin: 0; padding-left: 1.2em; }
img { max-width: 100%; height: auto; display: block; }
em { font-style: italic; }

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted { color: var(--muted); }
.lede { font-size: 17px; color: var(--text-2); max-width: 720px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---------- header / nav ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { color: var(--text); text-decoration: none; }

.nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav a {
  color: var(--muted);
  font-size: 15px;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.nav-divider { width: 1px; height: 18px; background: var(--border); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  html:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

.nav-toggle { display: none; }

/* ---------- page layout ---------- */

main.wrap {
  display: flex;
  flex-direction: column;
  gap: 64px;
  padding-top: 64px;
  padding-bottom: 24px;
}

.page-head { display: flex; flex-direction: column; gap: 14px; }

.section { display: flex; flex-direction: column; gap: 22px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.section-head h2 { font-size: 26px; }
.section-head a { font-size: 14px; white-space: nowrap; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 28px var(--gutter) 40px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

/* ---------- components ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip .mono { font-size: 10px; color: var(--faint); }

.badges { display: flex; flex-wrap: wrap; gap: 8px; }

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--badge-bg);
  color: var(--badge-text);
  white-space: nowrap;
}
.badge-award { background: var(--accent-soft); color: var(--accent-ink); }
.badge-soft { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); }

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
}
.links a, .links summary {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.links a:hover, .links summary:hover { color: var(--accent); text-decoration: none; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13.5px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.fig {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fig img { max-height: 100%; object-fit: contain; background: #ffffff; border-radius: 8px; }
.figure { display: flex; flex-direction: column; gap: 8px; }
.figure figcaption { font-size: 13px; color: var(--faint); }
figure { margin: 0; }

/* ---------- home ---------- */

.hero { display: flex; gap: 48px; align-items: flex-start; }
.hero-photo {
  width: 184px;
  height: 230px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.hero-body { display: flex; flex-direction: column; gap: 18px; flex-grow: 1; min-width: 0; }
.hero h1 { font-size: 44px; line-height: 1.1; }
.hero h1 .surname { font-weight: 400; color: var(--text-2); }
.hero .role { font-size: 17px; color: var(--text-2); }
.hero .pitch { font-size: 19px; line-height: 1.55; max-width: 680px; }

.email-line { font-size: 14.5px; color: var(--text-2); text-align: left; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.email-line .mono { font-size: 11px; }
.sep { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.email-inline { white-space: nowrap; }

.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}
.to-top:hover { color: var(--accent); border-color: var(--accent); }
.to-top svg { width: 20px; height: 20px; }
.to-top[hidden] { display: none; }

.about { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.about p { font-size: 16.5px; color: var(--text-2); }

.background {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 48px;
}
.background h3 { font-size: 18px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.bg-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bg-list li { display: flex; flex-direction: column; gap: 1px; font-size: 14.5px; }
.bg-list .what { color: var(--text); font-weight: 500; }
.bg-list .where { color: var(--muted); }
.bg-list .when { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); letter-spacing: 0.03em; }

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 64px;
  align-items: start;
}

/* ---------- publications ---------- */

.pub-list { display: flex; flex-direction: column; gap: 18px; }

.pub {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
}
.pub-key {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--faint);
  padding-top: 4px;
}
.pub-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pub-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}
.pub-title:hover { color: var(--accent); }
.pub-meta { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.pub-meta strong { color: var(--text); font-weight: 600; }
.pub-meta .pub-venue { color: var(--text-2); font-style: italic; }
.pub .links { align-items: center; gap: 4px 12px; padding-top: 2px; }
.pub .links .badge { font-size: 11px; }

.pub-list.compact .pub { grid-template-columns: minmax(0, 1fr); }
.pub-list.compact .pub-key { display: none; }

.bib { width: auto; }
.bib[open] { width: 100%; }
.bib summary { cursor: pointer; list-style: none; display: inline-block; }
.bib summary::-webkit-details-marker { display: none; }
.bib[open] summary { color: var(--accent); }
.bib-box {
  position: relative;
  margin-top: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.bib-box pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.bib-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

.pub-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.search {
  flex: 1 1 260px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14.5px;
}
.search::placeholder { color: var(--faint); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.pub-empty { color: var(--muted); font-size: 15px; padding: 12px 0; }

.software-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.software {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
}
.software.wide { grid-column: 1 / -1; }
.software-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.software-head a { font-family: var(--font-mono); font-size: 14px; font-weight: 500; }
.software p { font-size: 14px; color: var(--text-2); }

/* ---------- news ---------- */

.news-list { display: flex; flex-direction: column; gap: 14px; }
.news-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}
.news-item .mono { padding-top: 3px; }
.news-item p { font-size: 15px; line-height: 1.5; text-align: left; } /* narrow column: justified one-liners leave wide gaps */

.news-year { display: flex; flex-direction: column; gap: 14px; }
.news-year h2 { font-size: 22px; color: var(--muted); font-weight: 400; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ---------- research ---------- */

.hook {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 30px;
  line-height: 1.25;
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 24px; padding-top: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-family: var(--font-serif); font-size: 22px; line-height: 1.1; white-space: nowrap; }
.stat .l { font-size: 13px; color: var(--muted); }

.research-section { display: flex; flex-direction: column; gap: 24px; }
.research-section > h2 { font-size: 28px; }
.research-text { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.research-text p { font-size: 16px; color: var(--text-2); }

.fig-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.fig-grid .fig { height: 190px; padding: 12px 14px; }
.fig-grid .fig img { max-height: 100%; width: auto; max-width: 100%; }
.fig-grid figcaption { font-size: 12.5px; }

.callout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 32px;
  max-width: 760px;
}
.callout p { font-size: 17px; line-height: 1.55; }

/* ---------- explainer animations ---------- */

.anim {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px;
  scroll-margin-top: 84px;
}
.anim-head { display: flex; flex-direction: column; gap: 2px; }
.anim-head h3 { font-size: 19px; }
.anim-head p { font-size: 13.5px; color: var(--muted); }

.anim-stage {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}
.anim-stage svg { display: block; width: 100%; height: auto; overflow: visible; }

.anim-steps {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.anim-step {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.anim-step:hover { background: var(--surface-2); color: var(--text-2); }
.anim-step .n { font-family: var(--font-mono); font-size: 11px; }

.anim-controls { display: flex; gap: 8px; align-items: center; }

/* two explainer panels side by side: a small canvas beside a tight step list */
.anim-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.anim-grid .anim { gap: 10px; padding: 14px 16px 12px; }
.anim-grid .anim-head { gap: 1px; }
.anim-grid .anim-head h3 { font-size: 16px; }
.anim-grid .anim-head p { font-size: 12.5px; }
.anim-grid .anim-stage { grid-template-columns: 176px minmax(0, 1fr); gap: 14px; align-items: start; }
.anim-grid .anim-stage svg { max-width: 176px; }
.anim-grid .anim-steps { gap: 0; }
.anim-grid .anim-step { font-size: 12.5px; line-height: 1.35; padding: 4px 6px; grid-template-columns: 14px minmax(0, 1fr); gap: 8px; }
.anim-grid .anim-step .n { font-size: 10px; }
.anim-grid .anim-controls .btn { height: 26px; font-size: 12.5px; padding: 0 10px; }
.anim-grid .anim-controls .hint { font-size: 11.5px; }
.anim-controls .hint { font-size: 12.5px; color: var(--faint); margin-left: 4px; }

/* Shared 10 s timeline. Every animated node gets its stage class; the
   --seek variable lets the controls scrub to a point in the timeline. */
.anim { --seek: 0s; --dur: 10s; }
.anim .st1, .anim .st2, .anim .st3, .anim .st4, .anim .st5, .anim .st2dim, .anim .st3only, .anim .st4only,
.anim .bit, .anim .drop, .anim .cp1, .anim .cp2, .anim .cp3, .anim .cp4, .anim .cp5 {
  animation-duration: var(--dur);
  animation-iteration-count: infinite;
  animation-delay: var(--seek);
}
.anim.paused .st1, .anim.paused .st2, .anim.paused .st3, .anim.paused .st4, .anim.paused .st5, .anim.paused .st2dim, .anim.paused .st3only, .anim.paused .st4only,
.anim.paused .bit, .anim.paused .drop,
.anim.paused .cp1, .anim.paused .cp2, .anim.paused .cp3, .anim.paused .cp4, .anim.paused .cp5 {
  animation-play-state: paused;
}
.anim.reset .st1, .anim.reset .st2, .anim.reset .st3, .anim.reset .st4, .anim.reset .st5, .anim.reset .st2dim, .anim.reset .st3only, .anim.reset .st4only,
.anim.reset .bit, .anim.reset .drop,
.anim.reset .cp1, .anim.reset .cp2, .anim.reset .cp3, .anim.reset .cp4, .anim.reset .cp5 {
  animation: none !important;
}

.anim .st1 { animation-name: st1; }
.anim .st2 { animation-name: st2; }
.anim .st3 { animation-name: st3; }
.anim .st4 { animation-name: st4; }
.anim .st5 { animation-name: st5; }
.anim .drop { animation-name: st4; }
.anim .st2dim { animation-name: st2dim; }
.anim .st3only { animation-name: st3only; }
.anim .st4only { animation-name: st4only; }
.anim .bit { animation-name: bit; opacity: 0; }
.anim .b3 { animation-name: bit3; }
.anim .b4 { animation-name: bit4; }
.anim .cp1 { animation-name: cp1; }
.anim .cp2 { animation-name: cp2; }
.anim .cp3 { animation-name: cp3; }
.anim .cp4 { animation-name: cp4; }
.anim .cp5 { animation-name: cp5; }

@keyframes st1 { 0% { opacity: 0; } 6%, 94% { opacity: 1; } 100% { opacity: 0; } }
@keyframes st2 { 0%, 14% { opacity: 0; } 20%, 94% { opacity: 1; } 100% { opacity: 0; } }
@keyframes st3 { 0%, 30% { opacity: 0; } 36%, 94% { opacity: 1; } 100% { opacity: 0; } }
@keyframes st4 { 0%, 48% { opacity: 0; } 56%, 94% { opacity: 1; } 100% { opacity: 0; } }
@keyframes st5 { 0%, 66% { opacity: 0; } 74%, 94% { opacity: 1; } 100% { opacity: 0; } }
@keyframes st2dim { 0%, 14% { opacity: 0; } 20%, 50% { opacity: 1; } 56%, 94% { opacity: 0.3; } 100% { opacity: 0; } }
@keyframes st3only { 0%, 30% { opacity: 0; } 36%, 52% { opacity: 1; } 56%, 100% { opacity: 0; } }
@keyframes st4only { 0%, 50% { opacity: 0; } 56%, 70% { opacity: 1; } 74%, 100% { opacity: 0; } }
@keyframes bit3 { 0%, 34% { opacity: 0; transform: translateY(4px); } 38%, 52% { opacity: 1; transform: translateY(0); } 56%, 100% { opacity: 0; } }
@keyframes bit4 { 0%, 54% { opacity: 0; transform: translateY(4px); } 58%, 70% { opacity: 1; transform: translateY(0); } 74%, 100% { opacity: 0; } }
@keyframes bit { 0%, 66% { opacity: 0; transform: translateY(4px); } 69%, 94% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; } }

@keyframes cp1 { 0%, 14% { color: var(--text); background: var(--surface-2); } 15%, 100% { color: var(--faint); background: transparent; } }
@keyframes cp2 { 0%, 15% { color: var(--faint); background: transparent; } 16%, 30% { color: var(--text); background: var(--surface-2); } 31%, 100% { color: var(--faint); background: transparent; } }
@keyframes cp3 { 0%, 31% { color: var(--faint); background: transparent; } 32%, 48% { color: var(--text); background: var(--surface-2); } 49%, 100% { color: var(--faint); background: transparent; } }
@keyframes cp4 { 0%, 49% { color: var(--faint); background: transparent; } 50%, 66% { color: var(--text); background: var(--surface-2); } 67%, 100% { color: var(--faint); background: transparent; } }
@keyframes cp5 { 0%, 67% { color: var(--faint); background: transparent; } 68%, 94% { color: var(--text); background: var(--surface-2); } 95%, 100% { color: var(--faint); background: transparent; } }

/* SVG paint via theme tokens */
.anim .ink-accent { stroke: var(--accent); }
.anim .fill-accent { fill: var(--accent); }
.anim .fill-accent-soft { fill: var(--accent-soft); }
.anim .ink-warm { stroke: var(--warm); }
.anim .fill-warm-soft { fill: var(--warm-soft); }
.anim .grid-line { stroke: var(--grid-line); }
.anim .grid-line-2 { stroke: var(--grid-line-2); }
.anim .ink { stroke: var(--ink-fill); }
.anim .fill-ink { fill: var(--ink-fill); }
.anim .fill-bg { fill: var(--bg); }
.anim .dropped { stroke: var(--dropped); }
.anim .bit-1 rect { fill: var(--accent); }
.anim .bit-1 text { fill: #ffffff; }
.anim .bit-0 rect { fill: var(--badge-bg); }
.anim .bit-0 text { fill: var(--muted); }
.anim .bit text { font-family: var(--font-mono); font-size: 8.5px; text-anchor: middle; }
.anim .bit-more { fill: var(--faint); font-family: var(--font-mono); font-size: 9px; }

/* ---------- projects ---------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.project {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scroll-margin-top: 84px;
}
.project-media {
  height: 200px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.project-media img { max-height: 100%; object-fit: contain; border-radius: 8px; }
.project-body { display: flex; flex-direction: column; gap: 10px; padding: 20px 22px 22px; }
.project-body h2 { font-size: 22px; line-height: 1.25; }
.project-body p { font-size: 15px; color: var(--text-2); line-height: 1.55; }
.project-body .links { padding-top: 4px; }

.project.wide { grid-column: 1 / -1; flex-direction: row; }
.project.wide .project-media { width: 38%; height: auto; border-bottom: 0; border-right: 1px solid var(--border); flex-shrink: 0; }
.project.wide .project-body { flex-grow: 1; }

/* ---------- teaching ---------- */

.course-list { display: flex; flex-direction: column; gap: 22px; }
.course { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px 24px; }
.course .when { font-family: var(--font-mono); font-size: 12px; color: var(--faint); letter-spacing: 0.03em; padding-top: 5px; }
.course.single { grid-template-columns: minmax(0, 1fr); }
.course-body h3 .term { font-family: var(--font-sans); font-size: 14px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.course-body { display: flex; flex-direction: column; gap: 6px; }
.course-body h3 { font-size: 19px; }
.course-body .where { font-size: 14px; color: var(--muted); }
.course-body ul { font-size: 15px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; padding-left: 1.1em; }
.course-body p { font-size: 15px; color: var(--text-2); }

.service-list { font-size: 15px; color: var(--text-2); display: flex; flex-direction: column; gap: 8px; }
.service-list strong { color: var(--text); font-weight: 500; }
.service-list .when { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); letter-spacing: 0.03em; white-space: nowrap; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .anim-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .anim-grid { grid-template-columns: minmax(0, 1fr); }
  .anim-grid .anim-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .anim-grid .anim-stage svg { max-width: 240px; }
  .anim-grid .anim-steps { width: 100%; }
  .anim-stage svg { max-width: 300px; }
  .anim-steps { width: 100%; }
  .course { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  main.wrap { gap: 48px; padding-top: 40px; }
  h1 { font-size: 32px; }
  .hero { flex-direction: column; gap: 20px; }
  .hero-photo { width: 120px; height: 150px; }
  .hero h1 { font-size: 31px; }
  .hero .pitch { font-size: 17px; }
  .two-col, .background, .fig-grid, .project-grid, .software-grid { grid-template-columns: minmax(0, 1fr); }
  .two-col { gap: 48px; }
  .project.wide { flex-direction: column; }
  .project.wide .project-media { width: 100%; height: 200px; border-right: 0; border-bottom: 1px solid var(--border); }
  .hook { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .anim { padding: 20px 18px; }
  .chip { height: 40px; }
  p, figcaption { hyphens: auto; }

  .nav-toggle { display: inline-flex; }
  .nav ul {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: 64px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px var(--gutter) 12px;
  }
  .nav.open ul { display: flex; }
  .nav ul a { display: block; padding: 12px 4px; border-bottom: 0; font-size: 16px; }
  .nav ul a[aria-current="page"] { color: var(--accent); }
  .nav-divider { display: none; }
}

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

@media print {
  .site-header, .anim-controls, .theme-toggle, .to-top { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
