/* ==========================================================================
   Mahmoud Srewa — personal site
   Tokens first; everything else reads from them so both themes stay in sync.
   ========================================================================== */

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f3f4f1;
  --fg: #171a20;
  --muted: #535a67;
  --faint: #687080;
  --border: #e4e5e0;
  --border-card: #dcddd6;     /* slightly stronger edge for content cards */
  --violet: #5b34a8;          /* "Talk" tag */
  --violet-soft: #f0eafb;
  --accent: #0064a4;          /* UCI blue */
  --accent-hover: #004f82;
  --accent-ink: #ffffff;
  --accent-soft: #e5f0f8;
  --gold: #8a5f00;            /* text-safe gold on light bg (≥4.5:1 on gold-soft) */
  --gold-fill: #ffd200;       /* UCI gold, fills only */
  --gold-soft: #fff6d6;
  --warm: #b84a1f;            /* "aggressive" / lagging group */
  --cool: #1b6e50;            /* "conservative" */
  --paper: #ffffff;           /* figure backdrop: paper figures are drawn on white */
  --shadow: 0 1px 2px rgba(20, 24, 31, .05), 0 8px 24px -12px rgba(20, 24, 31, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1000px;
  --gutter: 24px;
  --nav-h: 58px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1115;
    --surface: #151920;
    --surface-2: #1b2029;
    --fg: #e8eaef;
    --muted: #a7aebb;
    --faint: #7f8794;
    --border: #262c36;
  --border-card: #353d4a;
  --violet: #c4adff;
  --violet-soft: #241c38;
    --accent: #62b3ec;
    --accent-hover: #8cc8f2;
    --accent-ink: #08131d;
    --accent-soft: #10273a;
    --gold: #f3c74f;
    --gold-soft: #2a2312;
    --warm: #f07d4f;
    --cool: #4cc196;
    --paper: #f4f4f1;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1115;
  --surface: #151920;
  --surface-2: #1b2029;
  --fg: #e8eaef;
  --muted: #a7aebb;
  --faint: #7f8794;
  --border: #262c36;
  --border-card: #353d4a;
  --violet: #c4adff;
  --violet-soft: #241c38;
  --accent: #62b3ec;
  --accent-hover: #8cc8f2;
  --accent-ink: #08131d;
  --accent-soft: #10273a;
  --gold: #f3c74f;
  --gold-soft: #2a2312;
  --warm: #f07d4f;
  --cool: #4cc196;
  --paper: #f4f4f1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, video, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
strong { font-weight: 600; }
p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 12px; }

.icon { width: 1.05em; height: 1.05em; flex: none; }
.icon-stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-fill { fill: currentColor; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.topbar.is-scrolled { border-bottom-color: var(--border); }
.topbar .wrap { height: 100%; display: flex; align-items: center; gap: 20px; }
.brand { font: 600 1.06rem/1 var(--serif); color: var(--fg); white-space: nowrap; letter-spacing: -.01em; }
.brand:hover { color: var(--accent); text-decoration: none; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative; padding: 6px 10px; border-radius: 8px;
  color: var(--muted); font-size: .9rem; font-weight: 500; white-space: nowrap;
}
.nav a:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="true"] { color: var(--accent); }
.nav a[aria-current="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.theme-toggle {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--faint); }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

/* ---------- sections ---------- */
main > section { padding: 56px 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head h2 { font: 700 1.6rem/1.2 var(--serif); letter-spacing: -.015em; }
.section-head .aside { color: var(--faint); font-size: .88rem; }
.eyebrow { display: inline-block; font-size: .74rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }

/* ---------- hero ---------- */
.hero { padding-top: 56px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 48px; align-items: start; }
.hero h1 { font: 700 clamp(2.2rem, 5vw, 3rem)/1.08 var(--serif); letter-spacing: -.025em; }
.role { margin: 10px 0 18px; color: var(--muted); font-size: 1.04rem; }
.role a { color: inherit; border-bottom: 1px solid var(--border); }
.role a:hover { color: var(--accent); text-decoration: none; border-color: var(--accent); }

.tagline { font: 500 1.16rem/1.45 var(--sans); margin: 0 0 20px; color: var(--fg); }
.rotator { display: inline-grid; vertical-align: bottom; max-width: 100%; }
.rotator > span { grid-area: 1 / 1; color: var(--accent); font-weight: 600; transition: opacity .45s ease, transform .45s ease; }
.js .rotator > span { opacity: 0; transform: translateY(6px); }
.js .rotator > span.is-active { opacity: 1; transform: none; }
.no-js .rotator > span:not(:first-child) { display: none; }

.bio p { color: var(--muted); max-width: 66ch; }
.bio strong { color: var(--fg); }
.bio a { font-weight: 500; }

.seeking {
  display: flex; gap: 12px; align-items: flex-start; max-width: 66ch; margin: 4px 0 0;
  padding: 12px 16px; border-radius: 12px; font-size: .95rem; color: var(--fg);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.seeking a { font-weight: 600; white-space: nowrap; }
.pulse {
  flex: none; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%;
  background: #22a06b; animation: pulse 2s ease-out 4;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 160, 107, .55); }
  70% { box-shadow: 0 0 0 9px rgba(34, 160, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 160, 107, 0); }
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
  font-size: .9rem; font-weight: 500; line-height: 1.2;
  transition: border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; color: var(--accent); border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }

.highlights { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); color: var(--fg);
  font-size: .82rem; font-weight: 500;
}
.chip:hover { text-decoration: none; color: var(--accent); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.chip.gold .dot { background: var(--gold-fill); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold-fill) 30%, transparent); }
.chip.warm .dot { background: var(--warm); }
.chip.cool .dot { background: var(--cool); }

.portrait { position: relative; width: 220px; aspect-ratio: 1; }
.portrait img, .portrait .initials {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover; box-shadow: var(--shadow);
}
.portrait::before {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--accent), var(--gold-fill), var(--accent));
  opacity: .22; z-index: -1; filter: blur(14px);
}
.initials {
  display: grid; place-items: center;
  background: linear-gradient(135deg, #0a72b8, #08385c);
  color: #fff; font: 600 4.2rem/1 var(--serif); letter-spacing: -.02em;
}
.portrait-caption { margin-top: 14px; text-align: center; color: var(--faint); font-size: .82rem; line-height: 1.45; }

/* ---------- research interests ---------- */
.interests { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.interest {
  display: flex; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.interest:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-2px); box-shadow: var(--shadow); }
.interest .ico {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent);
}
.interest .ico svg { width: 22px; height: 22px; }
.interest h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.interest p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }

/* ---------- featured ---------- */
.featured {
  border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow);
}
.featured-top { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.featured-video { position: relative; background: #000; aspect-ratio: 16 / 9; }
.featured-video video, .featured-strip video { width: 100%; height: 100%; object-fit: cover; }
.featured-body { padding: 24px 26px; display: flex; flex-direction: column; }
.featured-body h3 { font: 700 1.5rem/1.15 var(--serif); letter-spacing: -.015em; margin: 4px 0 4px; }
.featured-body .sub { color: var(--muted); font-size: .92rem; margin-bottom: 14px; }
.featured-body p { color: var(--muted); font-size: .93rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 18px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 10px 9px; }
.stat b { display: block; font: 700 1.2rem/1.1 var(--sans); color: var(--fg); letter-spacing: -.01em; }
.stat span { display: block; font-size: .72rem; color: var(--faint); line-height: 1.3; margin-top: 3px; }
.featured-body .btn-row { margin: auto 0 0; }
.vid-toggle {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(10, 12, 16, .6); color: #fff; opacity: .85; transition: opacity .2s, background .2s;
}
.vid-toggle:hover { opacity: 1; background: rgba(10, 12, 16, .85); }
.vid-toggle svg { width: 14px; height: 14px; }
.vid-toggle .i-play { display: none; }
.vid-toggle.is-paused .i-play { display: block; }
.vid-toggle.is-paused .i-pause { display: none; }
.featured-strip { position: relative; border-top: 1px solid var(--border); background: #000; aspect-ratio: 1600 / 442; }
.strip-caption {
  padding: 12px 22px 14px; font-size: .86rem; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--surface);
}
.strip-caption b { color: var(--fg); }
.tag-aggr, .tag-cons { font-weight: 600; }
.tag-aggr { color: var(--warm); }
.tag-cons { color: var(--cool); }
.speed-note {
  position: absolute; right: 12px; top: 10px; padding: 3px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: .72rem; font-weight: 500; pointer-events: none;
}

/* ---------- news ---------- */
.news-card {
  padding: 18px 22px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-card);
}
.news { list-style: none; border-left: 2px solid var(--border); margin-left: 6px; }
.news li { position: relative; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; padding: 9px 0 9px 22px; }
.news li::before {
  content: ""; position: absolute; left: -7px; top: 17px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--faint);
}
.news li.hl::before { border-color: var(--gold-fill); background: var(--gold-fill); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold-fill) 22%, transparent); }
.news time { color: var(--faint); font-size: .86rem; font-weight: 500; padding-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.news .item { color: var(--fg); font-size: .96rem; }
.news .item a { font-weight: 500; }
.tag {
  display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 6px; vertical-align: 1px;
  font-size: .7rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  background: var(--surface-2); color: var(--muted);
}
.tag.paper { background: var(--accent-soft); color: var(--accent); }
.tag.award { background: var(--gold-soft); color: var(--gold); }
.tag.industry { background: color-mix(in srgb, var(--cool) 14%, transparent); color: var(--cool); }
.tag.preprint { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); }
.tag.talk { background: var(--violet-soft); color: var(--violet); }
.js .news.is-collapsed li.older { display: none; }
.news-more {
  margin: 10px 0 0 30px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px dashed var(--border); background: none; color: var(--muted); font: 500 .86rem var(--sans);
}
.news-more:hover { color: var(--accent); border-color: var(--accent); }
.no-js .news-more { display: none; }

/* ---------- publications ---------- */
.pubs { display: flex; flex-direction: column; gap: 14px; }
.pub {
  display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 26px;
  padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-card);
  transition: border-color .2s, box-shadow .2s;
}
.pub:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border-card)); box-shadow: var(--shadow); }
.pub.is-featured { background: color-mix(in srgb, var(--gold-soft) 55%, transparent); border-color: color-mix(in srgb, var(--gold-fill) 35%, var(--border)); }
.pub-media { position: relative; align-self: start; }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden;
  background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: zoom-in;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; transition: opacity .35s ease, transform .35s ease; }
.thumb:hover img { transform: scale(1.02); }
/* "Tap to enlarge" hint: on hover for mouse users, always visible on touch screens. */
.thumb::after {
  content: ""; position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 26px; height: 26px; border-radius: 7px; pointer-events: none;
  background: rgba(16, 20, 26, .62) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E") center / 13px no-repeat;
  opacity: 0; transition: opacity .2s ease;
}
.thumb:hover::after, .thumb:focus-visible::after { opacity: 1; }
.thumb.is-playing::after { opacity: 0; }
@media (hover: none) { .thumb::after { opacity: .9; } }
.thumb .motion {
  position: absolute; inset: 0; opacity: 0; transition: opacity .35s ease; pointer-events: none;
}
.thumb video.motion { width: 100%; height: 100%; object-fit: cover; background: #000; }
.thumb.is-playing .motion { opacity: 1; }
.thumb.is-playing img { opacity: 0; }
.thumb .lbl {
  position: absolute; right: 8px; padding: 2px 8px; border-radius: 999px;
  color: #fff; font-size: .7rem; font-weight: 600; opacity: 0; transition: opacity .35s ease; pointer-events: none;
}
.thumb .lbl.top { top: 8px; background: #c4511f; }
.thumb .lbl.bottom { top: calc(50% + 8px); background: #23795a; }
.thumb.is-playing .lbl { opacity: 1; }
.motion-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  padding: 3px 11px 3px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: 600 .74rem/1.4 var(--sans); transition: color .15s, border-color .15s;
}
.motion-badge:hover { color: var(--accent); border-color: var(--accent); }
.pub-media.is-on .motion-badge { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.motion-badge svg { width: 9px; height: 9px; }
.motion-badge .when-on { display: none; }
.pub-media.is-on .motion-badge .when-on { display: inline; }
.pub-media.is-on .motion-badge .when-off { display: none; }

.venue {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 6px; margin-bottom: 8px;
  font-size: .74rem; font-weight: 700; letter-spacing: .03em;
  background: var(--surface-2); color: var(--muted);
}
.venue.hl { background: var(--gold-soft); color: var(--gold); }
.venue.blue { background: var(--accent-soft); color: var(--accent); }
.pub h3 { font-size: 1.06rem; font-weight: 600; line-height: 1.38; margin-bottom: 4px; letter-spacing: -.005em; }
.pub h3 a { color: var(--fg); }
.pub h3 a:hover { color: var(--accent); }
.authors { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.authors .me { color: var(--fg); font-weight: 600; }
.blurb { font-size: .93rem; color: var(--muted); margin-bottom: 10px; }
.blurb strong { color: var(--fg); }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.lk {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: 500 .8rem/1.5 var(--sans); cursor: pointer;
}
.lk:hover { text-decoration: none; color: var(--accent); border-color: var(--accent); }
.lk svg { width: 12px; height: 12px; }
.bib { position: relative; margin-top: 10px; }
.bib pre {
  margin: 0; padding: 14px 16px; overflow-x: auto; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font: .76rem/1.55 var(--mono); color: var(--fg); white-space: pre;
}
.bib .copy {
  position: absolute; top: 8px; right: 8px;
  padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: 500 .74rem var(--sans); cursor: pointer;
}
.bib .copy:hover { color: var(--accent); border-color: var(--accent); }

/* APPA mechanism animation (lives inside the APPA thumbnail) */
.appa-demo { background: var(--paper); color: #1b2230; }
.appa-demo text { font-family: var(--sans); fill: #1b2230; }
.appa-demo .muted { fill: #6a7280; }
.appa-demo .track { fill: #e6e8ec; }
.appa-demo .fi-fill { fill: #0064a4; transition: fill .3s; }
.appa-demo.unfair .fi-fill { fill: #d0582a; }
.appa-demo .tau { stroke: #1b2230; stroke-width: 2; }
.appa-demo .bar-a, .appa-demo .w-a { fill: #0064a4; }
.appa-demo .bar-b, .appa-demo .w-b { fill: #d0582a; }
.appa-demo .bar-c, .appa-demo .w-c { fill: #3c8dbc; }
.appa-demo .base { stroke: #c9cdd4; stroke-width: 1.5; }
.appa-demo .status { font-weight: 600; }
.appa-demo.unfair .status { fill: #c4511f; }

/* ---------- experience timeline ---------- */
.timeline { list-style: none; position: relative; margin-left: 6px; border-left: 2px solid var(--border); }
.timeline > li { position: relative; padding: 0 0 26px 26px; }
.timeline > li:last-child { padding-bottom: 4px; }
.timeline > li::before {
  content: ""; position: absolute; left: -8px; top: 6px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
}
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.tl-head h3, .tl-head h4 { margin: 0; font-size: 1.02rem; font-weight: 600; line-height: 1.25; }
.tl-head .org { color: var(--accent); }
.sub-head + .timeline { margin-top: 14px; }
.when { color: var(--faint); font-size: .86rem; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.where { color: var(--faint); font-size: .86rem; margin: 2px 0 8px; display: flex; align-items: center; gap: 10px; }
.where img { width: 34px; height: 34px; border-radius: 8px; background: #fff; padding: 2px; border: 1px solid var(--border); }
.timeline ul { list-style: none; }
.timeline ul li { position: relative; padding-left: 16px; color: var(--muted); font-size: .93rem; margin-bottom: 5px; }
.timeline ul li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.timeline ul li strong { color: var(--fg); }

.sub-head { font: 700 1.2rem/1.2 var(--serif); letter-spacing: -.01em; margin: 34px 0 4px; }

/* ---------- education / teaching / honors ---------- */
.cards-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card h3 { font-size: .98rem; font-weight: 600; margin-bottom: 2px; }
.card .deg { color: var(--accent); font-size: .9rem; font-weight: 500; margin-bottom: 8px; }
.card .meta { color: var(--faint); font-size: .84rem; line-height: 1.5; }
.card .badge { display: inline-block; margin-top: 8px; padding: 2px 8px; border-radius: 6px; background: var(--gold-soft); color: var(--gold); font-size: .74rem; font-weight: 600; }

.plain-list { list-style: none; }
.plain-list > li { padding: 12px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; }
.plain-list > li:last-child { border-bottom: 0; }
.plain-list .what { font-weight: 600; font-size: .97rem; }
.plain-list .what span { color: var(--muted); font-weight: 400; }
.plain-list .desc { grid-column: 1 / -1; color: var(--muted); font-size: .92rem; }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.two-col h3 { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.award-list { list-style: none; }
.award-list li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; font-size: .94rem; }
.award-list li .yr { margin-left: auto; color: var(--faint); font-size: .84rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.award-list li .star { color: var(--gold); flex: none; }
.award-list li.top { font-weight: 600; }

/* ---------- outside the lab ---------- */
.life-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 32px; align-items: stretch; }
.life-lead { color: var(--fg); font-size: 1.02rem; margin-bottom: 16px; }
.facts { list-style: none; display: grid; gap: 10px; }
.facts li {
  display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--muted); font-size: .93rem; line-height: 1.55;
}
.facts li strong { color: var(--fg); }
.facts .emo { flex: none; font-size: 1.25rem; line-height: 1.25; }
.facts li.joke { border-style: dashed; background: var(--surface-2); }
/* Collage stretches to the height of the text column; images are absolutely
   positioned so their intrinsic size never drives the row height. */
.photos {
  display: grid; gap: 10px; min-height: 380px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
.photo { position: relative; display: block; overflow: hidden; border-radius: 12px; box-shadow: var(--shadow); cursor: zoom-in; }
.photo.wide { grid-column: span 2; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.photo.wide img { object-position: 50% 40%; }
/* Caption slides up on hover/focus; always shown on touch screens (no hover). */
.photo .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 12px 10px;
  color: #fff; font-size: .8rem; line-height: 1.35;
  background: linear-gradient(to top, rgba(0, 0, 0, .75), rgba(0, 0, 0, 0));
  opacity: 0; transform: translateY(8px); transition: opacity .3s ease, transform .3s ease; pointer-events: none;
}
.photo .cap b { display: block; font-size: .88rem; font-weight: 600; }
.photo:hover .cap, .photo:focus-visible .cap { opacity: 1; transform: none; }
@media (hover: none) { .photo .cap { opacity: 1; transform: none; } }
.photo:hover img { transform: scale(1.04); }

/* ---------- visitor map ---------- */
.visitors { max-width: 360px; margin: 0 auto; text-align: center; }
.visitors-h { font-size: .74rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.visitors-map {
  min-height: 200px; padding: 10px; overflow: hidden;            /* reserve space so the page doesn't jump */
  background: #fff; border: 1px solid var(--border-card); border-radius: var(--radius);
}
.visitors-map img { margin: 0 auto; }

/* ---------- footer ---------- */
.footer { margin-top: 64px; padding: 26px 0 40px; border-top: 1px solid var(--border); color: var(--faint); font-size: .84rem; }
.footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; }
.footer a { color: var(--muted); }

/* ---------- lightbox ---------- */
.lightbox {
  border: 0; padding: 0; background: transparent; max-width: min(1200px, 94vw); max-height: 92vh; overflow: visible;
}
.lightbox::backdrop { background: rgba(8, 10, 14, .8); backdrop-filter: blur(3px); }
.lightbox img { max-width: 100%; max-height: 84vh; margin: 0 auto; border-radius: 10px; background: #fff; padding: 12px; }
.lightbox p { color: #e8eaef; text-align: center; font-size: .9rem; margin: 10px 0 0; }
.lightbox .close {
  position: absolute; top: -14px; right: -14px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: #fff; color: #111; font-size: 20px; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
}

/* ---------- reveal-on-scroll ---------- */
/* JS marks only below-the-fold elements as pending, so nothing on the first screen fades. */
.reveal { transition: opacity .6s ease, transform .6s ease; }
.reveal.is-pending { opacity: 0; transform: translateY(10px); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .featured-top { grid-template-columns: 1fr; }
  .cards-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --gutter: 16px; }
  .hero { padding-top: 32px; }
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .hero-side { order: -1; display: flex; align-items: center; gap: 16px; }
  /* Phones: put the internship callout and links before the long bio so they're on the first screen. */
  .hero-main { display: flex; flex-direction: column; }
  .hero-main .seeking { order: 1; }
  .hero-main .btn-row { order: 2; margin: 14px 0 20px; }
  .hero-main .bio { order: 3; }
  .hero-main .highlights { order: 4; }
  .portrait { width: 104px; }
  .initials { font-size: 2.2rem; }
  .portrait-caption { margin: 0; text-align: left; }
  .interests, .two-col, .life-grid { grid-template-columns: 1fr; }
  .photos { aspect-ratio: 1; min-height: 0; }
  .pub { grid-template-columns: 1fr; gap: 14px; padding: 14px; }
  .news-card { padding: 14px 14px 12px; }
  .news li { grid-template-columns: 1fr; gap: 0; }
  .brand { display: none; }
  .nav { margin-left: 0; }
  .nav a { padding: 6px 8px; }
  main > section { padding-top: 44px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Touch screens: grow small controls toward a comfortable ~40px tap target. */
@media (pointer: coarse) {
  .nav a { padding: 10px; }
  .lk { padding: 7px 12px; }
  .motion-badge { padding: 7px 13px 7px 11px; }
  .chip { padding: 8px 12px; }
  .news-more { padding: 10px 14px; }
  .bib .copy { padding: 6px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .reveal.is-pending { opacity: 1; transform: none; }
}

@media print {
  .topbar, .theme-toggle, .featured, .motion-badge, .news-more { display: none !important; }
  .js .news.is-collapsed li.older { display: grid; }
  .reveal.is-pending { opacity: 1; transform: none; }
  body { background: #fff; color: #000; }
}
