/* ==========================================================================
   Mehrshad Alipoor - site styles
   Minimal, warm-paper palette; serif headings, sans body; light + dark.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f2ed;
  --ink: #16181d;
  --muted: #4f5561;
  --subtle: #676d79;
  --line: #e5e1d8;
  --line-strong: #d3cec2;

  --accent: #155e75;
  --accent-ink: #0e4a5c;
  --accent-soft: #e5f0f2;

  /* Story chapters */
  --c-engineering: #b45309;
  --c-building: #6d28d9;
  --c-clinical-ai: #0f766e;

  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 8px 24px rgba(22, 24, 29, 0.06);
  --max: 1080px;
  --measure: 66ch;
  --nav-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #161920;
    --surface-2: #1c2028;
    --ink: #eceef1;
    --muted: #b0b6c1;
    --subtle: #959cab;
    --line: #272b34;
    --line-strong: #353a45;

    --accent: #67c6d8;
    --accent-ink: #8fd7e4;
    --accent-soft: #15303a;

    --c-engineering: #f59e0b;
    --c-building: #a78bfa;
    --c-clinical-ai: #2dd4bf;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.1rem, 4.6vw, 3.4rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 2.8vw, 2.1rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  transition: color 0.2s, text-decoration-color 0.2s;
}
a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }

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

::selection { background: var(--accent-soft); color: var(--ink); }

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.section { padding: 88px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-tight { padding: 56px 0; }

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: var(--measure);
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
}
.section-head h2 { margin: 0; }
.section-head p { margin: 8px 0 0; color: var(--muted); max-width: var(--measure); }

.arrow-link {
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.arrow-link::after {
  content: " \2192";
  display: inline-block;
  transition: transform 0.25s var(--ease);
}
.arrow-link:hover::after { transform: translateX(3px); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn svg { width: 16px; height: 16px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-row.spaced { margin-top: 24px; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}
.site-header.scrolled { border-bottom-color: var(--line); }

.nav {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  display: block;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a[aria-current="page"]::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-links .nav-cv {
  margin-left: 8px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
.nav-links .nav-cv:hover { border-color: var(--ink); background: transparent; }

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  margin: 5px auto;
  background: currentColor;
  transition: transform 0.3s var(--ease), opacity 0.2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ── Hero (home) ────────────────────────────────────────────────────────── */
.hero { padding: 72px 0 56px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 64px;
  align-items: center;
}

.hero h1 { margin-bottom: 20px; max-width: 16ch; }
.hero .lead { margin-bottom: 28px; }
.hero .btn-row { margin-bottom: 28px; }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 0.9rem;
  color: var(--subtle);
}
.hero-meta span { display: inline-flex; align-items: flex-start; gap: 8px; }
.dot-live {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 0.45em;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.portrait {
  position: relative;
  margin: 0;
  justify-self: end;
  width: min(100%, 360px);
}
.portrait img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 30%;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.portrait::before {
  content: "";
  position: absolute;
  inset: 18px -18px -18px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  z-index: -1;
}
.portrait figcaption {
  position: absolute;
  left: -20px;
  bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.35;
}
.portrait figcaption strong { display: block; font-size: 0.9rem; }

/* ── News ───────────────────────────────────────────────────────────────── */
.news { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.news li {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.news time {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s var(--ease);
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card > p:last-child { margin-bottom: 0; }

.feature {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 40px;
  padding: 36px;
}
.feature h3 { font-size: 1.5rem; margin-top: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  align-self: start;
}
.stats.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); padding: 18px 20px; }
.stat-value {
  display: block;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 0.85rem; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tag {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
}
.badge-quiet { color: var(--muted); background: var(--surface-2); }

/* ── Project grid & list ────────────────────────────────────────────────── */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.project-card { display: flex; flex-direction: column; gap: 14px; }
.project-card h3 { margin: 0; }
.project-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.project-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--subtle);
}
.project-links { display: flex; gap: 16px; margin-top: auto; padding-top: 6px; font-size: 0.92rem; }

.project-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.project-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.project-row h3 { font-size: 1.08rem; margin: 0 0 4px; }
.project-row p { margin: 0 0 10px; color: var(--muted); font-size: 0.95rem; }
.project-row .year { color: var(--subtle); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header { padding: 72px 0 40px; }
.page-header h1 { max-width: 20ch; }
.page-header .lead { margin: 0; }

/* ── Story timeline (about) ─────────────────────────────────────────────── */
.chapters {
  position: sticky;
  top: var(--nav-h);
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.chapters-inner {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 14px;
}
.chapter-tab {
  display: block;
  text-decoration: none;
  color: var(--subtle);
  font-size: 0.85rem;
  line-height: 1.3;
}
.chapter-tab strong { display: block; color: var(--muted); font-weight: 600; transition: color 0.3s; }
.chapter-bar {
  display: block;
  height: 3px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.chapter-bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--chapter-color);
  transition: transform 0.15s linear;
}
.chapter-tab.active strong { color: var(--ink); }
.chapter-tab[data-chapter="engineering"] { --chapter-color: var(--c-engineering); }
.chapter-tab[data-chapter="building"] { --chapter-color: var(--c-building); }
.chapter-tab[data-chapter="clinical-ai"] { --chapter-color: var(--c-clinical-ai); }

.story {
  position: relative;
  padding: 72px 0 40px;
}

.story-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--line);
  border-radius: 2px;
}
.story-progress {
  position: absolute;
  inset: 0 0 auto 0;
  height: 0;
  border-radius: 2px;
  background: linear-gradient(
    to bottom,
    var(--c-engineering) 0%,
    var(--c-building) 45%,
    var(--c-clinical-ai) 75%
  );
  background-size: 100% var(--story-h, 2000px);
}
.story-head {
  position: absolute;
  left: 50%;
  top: 0;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent),
              0 0 24px 4px color-mix(in srgb, var(--accent) 45%, transparent);
  opacity: 0;
  transition: opacity 0.3s, background 0.4s;
  pointer-events: none;
}

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

.milestone {
  --chapter-color: var(--accent);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
  align-items: center;
  margin-bottom: 28px;
}
.milestone[data-chapter="engineering"] { --chapter-color: var(--c-engineering); }
.milestone[data-chapter="building"] { --chapter-color: var(--c-building); }
.milestone[data-chapter="clinical-ai"] { --chapter-color: var(--c-clinical-ai); }

.milestone-node {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--line-strong);
  transition: border-color 0.4s, background 0.4s, transform 0.5s var(--ease), box-shadow 0.5s;
  z-index: 1;
}
.milestone.lit .milestone-node {
  border-color: var(--chapter-color);
  background: var(--chapter-color);
  transform: scale(1.15);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--chapter-color) 15%, transparent);
}

.milestone-year {
  grid-row: 1;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--chapter-color);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  font-variant-numeric: tabular-nums;
}

.milestone-card {
  grid-row: 1;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  opacity: 0;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease), box-shadow 0.3s, border-color 0.3s;
}
.milestone-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--chapter-color);
  opacity: 0.85;
}
.milestone-card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.milestone-card h3 { margin-bottom: 4px; font-size: 1.15rem; }
.milestone-place { font-size: 0.85rem; color: var(--chapter-color); font-weight: 500; margin-bottom: 10px; }
.milestone-card p:last-child { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* Alternate sides on wide screens */
.milestone:nth-child(odd) .milestone-card { grid-column: 1; transform: translateX(-28px); }
.milestone:nth-child(odd) .milestone-year { grid-column: 3; justify-self: start; }
.milestone:nth-child(even) .milestone-card { grid-column: 3; transform: translateX(28px); }
.milestone:nth-child(even) .milestone-year { grid-column: 1; justify-self: end; }

.milestone.in .milestone-card { opacity: 1; transform: none; }
.milestone.in .milestone-year { opacity: 1; transform: none; }

.milestone.future .milestone-node { border-style: dashed; background: var(--bg); }
.milestone.future .milestone-card { border-style: dashed; background: transparent; }

/* No-JS and reduced motion: everything visible, no movement */
.no-js .milestone-card,
.no-js .milestone-year { opacity: 1; transform: none; }

.strengths .card h3 { font-size: 1.1rem; }
.strengths .card p { margin: 0; color: var(--muted); }

/* ── Research ───────────────────────────────────────────────────────────── */
.prose { max-width: var(--measure); }
.prose p { color: var(--muted); }
.prose p strong { color: var(--ink); }

.flow {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 36px 0;
  counter-reset: flow;
}
.flow-step {
  position: relative;
  padding: 18px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-right: 22px;
  border-radius: 12px;
}
.flow-step:last-child { margin-right: 0; }
.flow-step:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -17px;
  top: 50%;
  width: 12px;
  height: 12px;
  border-top: 2px solid var(--line-strong);
  border-right: 2px solid var(--line-strong);
  transform: translateY(-50%) rotate(45deg);
}
.flow-step .step-n {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.flow-step strong { display: block; font-size: 0.98rem; margin-bottom: 4px; }
.flow-step span:last-child { font-size: 0.85rem; color: var(--muted); line-height: 1.45; display: block; }
.flow-step.judge { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

.tiers { margin-top: 8px; }
.tier h3 { font-size: 1.1rem; margin-bottom: 14px; }
.metric-list { list-style: none; margin: 0; padding: 0; }
.metric-list li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.93rem; color: var(--muted); }
.metric-list li strong { display: block; color: var(--ink); font-weight: 600; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.results-table th,
.results-table td { text-align: left; padding: 12px 0; border-bottom: 1px solid var(--line); }
.results-table th { font-size: 0.8rem; font-weight: 600; color: var(--subtle); text-transform: uppercase; letter-spacing: 0.06em; }
.results-table td:last-child,
.results-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.findings { margin: 0; padding-left: 1.2em; }
.findings li { margin-bottom: 12px; color: var(--muted); }
.findings li::marker { color: var(--accent); font-weight: 600; }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  font-size: 0.92rem;
  color: var(--muted);
  margin: 20px 0 0;
}

/* Publications */
.pubs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.pub {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.pub .year { color: var(--subtle); font-variant-numeric: tabular-nums; padding-top: 2px; }
.pub h3 { font-family: var(--font-sans); font-size: 1.02rem; font-weight: 600; line-height: 1.45; margin: 0 0 6px; }
.pub .authors { font-size: 0.9rem; color: var(--muted); margin: 0 0 6px; }
.pub .authors strong { color: var(--ink); }
.pub .venue { font-size: 0.9rem; font-style: italic; color: var(--muted); margin: 0 0 10px; }
.pub-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: 0.9rem; }

/* ── CV page ────────────────────────────────────────────────────────────── */
.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;
}

/* Each block sets --c to its chapter colour */
.ch-engineering { --c: var(--c-engineering); }
.ch-building { --c: var(--c-building); }
.ch-clinical-ai { --c: var(--c-clinical-ai); }

.ico { width: 16px; height: 16px; flex: none; }

.cv-stats { margin-bottom: 8px; }
.cv-section { padding: 56px 0; border-top: 1px solid var(--line); }
.cv-stats + .cv-section { border-top: 0; }
.cv-section > h2 { margin-bottom: 28px; }

/* Career timeline chart */
.career { margin: 0; }
.career-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.career-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }

.career-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.career-chart {
  position: relative;
  min-width: 720px;
  margin: 0 24px 0 20px;
  padding: 44px 0 20px;
}
.career-axis {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.career-axis .tick {
  position: absolute;
  top: 14px;
  bottom: 0;
  border-left: 1px dashed var(--line);
  padding-left: 6px;
  font-size: 0.75rem;
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
}
.career-rows { position: relative; list-style: none; margin: 0; padding: 0; }
.career-row { position: relative; height: 40px; }
.career-row + .career-row { margin-top: 6px; }

.bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--l);
  width: var(--w);
  min-width: 6px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
  border-left: 4px solid var(--c);
  transform-origin: left center;
}
.flip .bar { border-left: 0; border-right: 4px solid var(--c); transform-origin: right center; }
.bar-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--ink);
}
.bar-label .ico { color: var(--c); }
.bar-label span { color: var(--muted); }
/* Label inside the bar, or beside it (after early bars, before late ones) */
.lbl-inside .bar-label { left: calc(var(--l) + 14px); }
.lbl-inside.flip .bar-label { left: auto; right: calc(100% - var(--l) - var(--w) + 14px); }
.lbl-after .bar-label { left: calc(var(--l) + var(--w) + 10px); }
.lbl-before .bar-label { right: calc(100% - var(--l) + 10px); }

.career-row.papers { height: 28px; margin-top: 12px; }
.paper-dot {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  border: 2px solid var(--surface);
}
.career-now {
  position: absolute;
  top: 34px;
  bottom: 8px;
  border-left: 2px solid var(--accent);
}
.career-now span {
  position: absolute;
  top: -22px;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--surface);
  padding: 0 4px;
}

/* Grow the bars in when the chart scrolls into view */
.js .career.reveal .bar { transform: scaleX(0); transition: transform 0.9s var(--ease); }
.js .career.reveal.visible .bar { transform: none; }
.js .career.reveal .career-row:nth-child(2) .bar { transition-delay: 0.08s; }
.js .career.reveal .career-row:nth-child(3) .bar { transition-delay: 0.16s; }
.js .career.reveal .career-row:nth-child(4) .bar { transition-delay: 0.24s; }
.js .career.reveal .career-row:nth-child(5) .bar { transition-delay: 0.32s; }
.js .career.reveal .career-row:nth-child(6) .bar { transition-delay: 0.4s; }
.js .career.reveal .career-row:nth-child(7) .bar { transition-delay: 0.48s; }

/* Experience cards */
.xp { display: flex; flex-direction: column; gap: 18px; border-top: 3px solid var(--c); }
.xp-head { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; align-items: start; }
.monogram {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
  color: var(--c);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
}
.xp h3 { font-size: 1.1rem; margin: 0; }
.xp-where { margin: 2px 0 0; font-weight: 500; font-size: 0.92rem; }
.xp-when { margin: 0; font-size: 0.85rem; color: var(--subtle); }
.impact {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.impact li {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.impact strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--c);
  font-variant-numeric: tabular-nums;
}
.impact span { font-size: 0.8rem; color: var(--muted); line-height: 1.3; display: block; }
.more { margin-top: auto; font-size: 0.9rem; color: var(--muted); }
.more summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--accent);
  width: fit-content;
}
.more ul { margin: 10px 0 0; padding-left: 1.1em; }
.more li { margin-bottom: 6px; }

/* Education cards */
.edu { display: flex; flex-direction: column; gap: 4px; }
.edu-degree {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--c);
  margin-bottom: 10px;
}
.edu h3 { font-size: 1.02rem; font-family: var(--font-sans); margin: 0; }
.edu-where { margin: 0; color: var(--muted); font-size: 0.92rem; }
.edu-when { margin: 0 0 8px; color: var(--subtle); font-size: 0.85rem; }
.edu .arrow-link { margin-top: auto; padding-top: 8px; }
.meter { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.meter-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.meter-label { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Publications */
.cv-pubs { list-style: none; margin: 0 0 16px; padding: 0; }
.cv-pubs li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.cv-pubs li:first-child { padding-top: 0; }
.cv-pub-year {
  align-self: start;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 0;
}
.cv-pubs h3 { font-family: var(--font-sans); font-size: 1rem; line-height: 1.45; margin: 0 0 4px; }
.cv-pubs h3 a { color: var(--ink); }
.cv-pubs p { margin: 0; font-size: 0.88rem; color: var(--muted); }
.cv-pubs .badge { margin-left: 6px; vertical-align: 1px; font-size: 0.68rem; }

/* Skills */
.skill-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 32px; }
.skill-group h3 { font-family: var(--font-sans); font-size: 0.95rem; margin: 0 0 10px; }
.skill-group .tag { font-size: 0.82rem; padding: 4px 11px; }
.langs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.langs li { display: grid; grid-template-columns: 72px auto minmax(0, 1fr); align-items: center; gap: 10px; font-size: 0.92rem; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dots i.on { background: var(--accent); }

/* ── Contact ────────────────────────────────────────────────────────────── */
.contact-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); max-width: 760px; }
.contact-list a {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 20px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.2s, padding 0.3s var(--ease);
}
.contact-list a:hover { background: var(--surface); padding-left: 14px; padding-right: 14px; }
.contact-list .label { font-size: 0.85rem; color: var(--subtle); font-weight: 500; }
.contact-list .value { font-weight: 500; overflow-wrap: anywhere; }
.contact-list .go { color: var(--accent); transition: transform 0.3s var(--ease); }
.contact-list a:hover .go { transform: translateX(4px); }

/* ── CTA band ───────────────────────────────────────────────────────────── */
.cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  padding: 40px;
  border-radius: 20px;
  background: var(--ink);
  color: var(--bg);
}
.cta h2 { margin: 0 0 6px; color: var(--bg); }
.cta p { margin: 0; color: color-mix(in srgb, var(--bg) 75%, transparent); }
.cta .btn-primary { background: var(--bg); color: var(--ink); }
.cta .btn-primary:hover { background: var(--accent-soft); color: var(--ink); }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 0 40px;
  font-size: 0.9rem;
  color: var(--subtle);
}
.footer-inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--ink); }

/* ── Reveal on scroll ───────────────────────────────────────────────────── */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.js .reveal.visible { opacity: 1; transform: none; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .portrait { justify-self: start; width: min(100%, 300px); order: -1; }
  .feature { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .flow-step { margin-right: 0; }
  .flow-step:not(:last-child)::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -17px;
    transform: translateX(-50%) rotate(135deg);
  }
  .skill-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Timeline: single column, spine on the left */
  .story-spine, .story-head { left: 15px; }
  .milestone { grid-template-columns: 32px minmax(0, 1fr); align-items: start; margin-bottom: 20px; }
  .milestone-node { grid-column: 1; grid-row: 1 / span 2; justify-self: center; margin-top: 8px; }
  .milestone:nth-child(n) .milestone-year {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    font-size: 1.6rem;
    margin: 0 0 8px;
  }
  .milestone:nth-child(n) .milestone-card { grid-column: 2; grid-row: 2; transform: translateY(18px); }
  .milestone.in .milestone-card { transform: none; }
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px 16px 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px; border-radius: var(--radius-sm); }
  .nav-links a[aria-current="page"]::after { display: none; }
  .nav-links a[aria-current="page"] { background: var(--surface-2); }
  .nav-links .nav-cv { margin: 6px 0 0; text-align: center; }

  .section { padding: 64px 0; }
  .hero { padding: 40px 0 32px; }
  .page-header { padding: 48px 0 24px; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .stats.stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature { padding: 24px; }
  .news li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .project-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .pub { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .contact-list a { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .contact-list .label { grid-column: 1; }
  .contact-list .value { grid-column: 1; }
  .contact-list .go { grid-column: 2; grid-row: 1 / span 2; }
  .cta { padding: 28px; }
  .cv-section { padding: 44px 0; }
  .career-scroll { overflow: visible; }
  .career-chart { min-width: 0; margin: 0 14px; padding-top: 40px; }
  .career-axis .tick:nth-child(even) { color: transparent; }
  .career-row { height: auto; padding-bottom: 16px; }
  .career-row + .career-row { margin-top: 12px; }
  .bar { top: auto; height: 10px; border-radius: 4px; border-width: 3px; }
  .career-row .bar-label {
    position: relative;
    inset: auto;
    transform: none;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 6px;
    white-space: normal;
    font-size: 0.82rem;
    line-height: 1.35;
    margin-bottom: 6px;
  }
  .career-row.papers { padding-bottom: 0; }
  .skill-groups { grid-template-columns: minmax(0, 1fr); }
  .langs li { grid-template-columns: 72px auto; }
  .langs li .small { grid-column: 1 / -1; margin-top: -6px; }
  .chapters-inner { padding-top: 10px; padding-bottom: 12px; gap: 10px; }
  .chapter-tab { font-size: 0.75rem; }
  .chapter-years { display: none; }
  .portrait { width: 104px; }
  .portrait img { aspect-ratio: 1; border-radius: 50%; }
  .portrait::before,
  .portrait figcaption { display: none; }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .btn-row .btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal,
  .js .career.reveal .bar,
  .milestone-card,
  .milestone-year { opacity: 1 !important; transform: none !important; }
}
