/* Anthony A. Fung, PhD: ink and paper */

:root {
  --paper: #F6F2E9;
  --paper-alt: #EFE9DC;
  --ink: #1C1A17;
  --ink-2: #45413A;
  --muted: #6A645A;
  --rule: #DCD4C4;
  --rule-strong: #C9BFAC;
  --seal: #A8322A;
  --seal-dark: #8A2720;

  --orcid: #7FA22B;      /* ORCID green, darkened for contrast on paper */
  --linkedin: #0A66C2;
  --scholar: #3B78E7;

  --font-display: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;

  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  --header-h: 68px;
  --radius: 4px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

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

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

body {
  margin: 0;
  background-color: var(--paper);
  /* Faint paper grain: an inline SVG noise tile */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .27 0 0 0 0 .2 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

img, video, svg { display: block; max-width: 100%; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.15; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; }
em { font-style: italic; }
b { font-weight: 600; }
.nowrap { white-space: nowrap; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color .2s var(--ease), text-decoration-color .2s var(--ease);
}
a:hover { color: var(--seal-dark); text-decoration-color: currentColor; }

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

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

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

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 242, 233, .92);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease);
}
.site-header.is-scrolled { border-bottom-color: var(--rule); }

.header-row {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink);
  text-decoration: none;
  transition: color .2s var(--ease);
}
.brand:hover { color: var(--seal); }

.site-nav ul { list-style: none; display: flex; gap: clamp(16px, 2.4vw, 32px); }
.site-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: .98rem;
  color: var(--ink-2);
  text-decoration: none;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 9px;
  height: 1px;
  background: var(--seal);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.site-nav a:hover, .site-nav a[aria-current="true"] { color: var(--ink); }
.site-nav a:hover::after, .site-nav a[aria-current="true"]::after { transform: scaleX(1); }

.menu-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.menu-toggle-bars, .menu-toggle-bars::before, .menu-toggle-bars::after {
  display: block;
  width: 20px;
  height: 1.5px;
  background: currentColor;
  transition: transform .3s var(--ease), opacity .2s;
}
.menu-toggle-bars { position: relative; }
.menu-toggle-bars::before, .menu-toggle-bars::after { content: ""; position: absolute; left: 0; }
.menu-toggle-bars::before { top: -6px; }
.menu-toggle-bars::after { top: 6px; }
.menu-toggle[aria-expanded="true"] .menu-toggle-bars { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-toggle-bars::before { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle-bars::after { transform: translateY(-6px) rotate(-45deg); }

/* Hero */

.hero {
  min-height: calc(100svh - var(--header-h));
  display: flex;
  align-items: center;
  padding-block: clamp(40px, 7vh, 88px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: clamp(32px, 6vw, 88px);
  align-items: center;
}

/* Logo sits under the Research heading; the lede wraps around it */
.logo-draw { float: left; margin: 4px clamp(18px, 3vw, 32px) 8px -8px; }
.logo-video {
  height: clamp(72px, 10vw, 112px);
  width: auto;
  mix-blend-mode: multiply; /* white video ground drops out on the paper */
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6.2vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.02;
}
.hero h1 em { font-weight: 500; color: var(--ink-2); }

.hero-role {
  margin: 16px 0 0;
  font-size: 1.02rem;
  color: var(--ink-2);
}

.rule {
  display: block;
  width: 44px;
  height: 3px;
  margin: 24px 0;
  background: var(--seal);
  border-radius: 2px;
}

.hero-intro {
  max-width: 34em;
  font-size: clamp(1.06rem, 1.3vw, 1.16rem);
  color: var(--ink-2);
  margin-bottom: 28px;
}

.portrait { margin: 0; }
.portrait img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  outline: 1px solid var(--rule-strong);
  outline-offset: 8px;
  background: #2b2b2b;
}

/* Profile buttons */

.profiles { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; }

.profile {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 16px 0 13px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: .95rem;
  text-decoration: none;
  transition: transform .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease);
}
.profile svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.profile:hover {
  color: var(--ink);
  border-color: var(--ink-2);
  background: rgba(255, 255, 255, .45);
  transform: translateY(-2px);
}
.profile:active { transform: translateY(0); }
.profile.orcid svg { color: var(--orcid); }
.profile.linkedin svg { color: var(--linkedin); }
.profile.scholar svg { color: var(--scholar); }
.profile.x svg { color: var(--ink); }

/* Sections */

.section { padding-block: clamp(72px, 11vw, 128px); border-top: 1px solid var(--rule); }
.section-alt { background: rgba(239, 233, 220, .55); }

.section-head { display: flow-root; max-width: 46em; margin-bottom: clamp(36px, 5vw, 56px); }
.section h2 {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 4.6vw, 3.4rem);
  letter-spacing: -.005em;
  margin-bottom: 18px;
}
.lede { font-size: clamp(1.08rem, 1.4vw, 1.2rem); color: var(--ink-2); margin: 0; }

.kicker {
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--seal);
  margin: 0 0 20px;
}

h4 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Research */

.research-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
/* Raman strip on the left, text on the right */
.research-visual { grid-column: 1; grid-row: 1; }
.research-current { grid-column: 2; grid-row: 1; }

.topic { padding-block: 22px; border-top: 1px solid var(--rule); }
.topic:first-of-type { border-top: 0; padding-top: 0; }
.topic p { margin: 0; color: var(--ink-2); }

.research-visual { position: sticky; top: calc(var(--header-h) + 24px); }
/* The whole strip, top to bottom: height fits the screen, width follows the 394:1080 frame */
.video-frame {
  position: relative;
  height: min(calc(100vh - var(--header-h) - 48px), 860px);
  height: min(calc(100svh - var(--header-h) - 48px), 860px);
  aspect-ratio: 394 / 1080;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.raman-still, .raman-canvas { display: block; width: 100%; height: 100%; }
.raman-canvas { position: absolute; inset: 0; opacity: 0; transition: opacity .3s var(--ease); }
.raman-canvas.is-ready { opacity: 1; }


.future { margin-top: clamp(48px, 6vw, 72px); }

/* Projects: grayscale logos on a slow conveyor */

.projects .section-head { margin-bottom: clamp(28px, 4vw, 44px); }
.conveyor-wrap { position: relative; }
.conveyor {
  --gap: clamp(56px, 8vw, 112px);
  display: flex;
  overflow: hidden;
  padding-block: 12px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
}
.conveyor-track {
  list-style: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--gap);
  padding-right: var(--gap);
  animation: conveyor 48s linear infinite;
}
.conveyor:hover .conveyor-track,
.conveyor:focus-within .conveyor-track,
.conveyor.is-paused .conveyor-track { animation-play-state: paused; }
@keyframes conveyor { to { transform: translateX(-100%); } }

.project {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--ink);
  opacity: .85;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.project:hover, .project:focus-visible { opacity: 1; transform: translateY(-2px); }
.project img { width: auto; height: 44px; filter: grayscale(1); }
.project-ramannoodle img { height: 40px; }
.project-sennet img { height: 40px; }
.project-senweb img { height: 54px; }
.project-vistamap img { height: 52px; }
.senweb-word {
  font-family: "Orbitron", var(--font-body);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: .06em;
  color: #2a2824;
}

.conveyor-toggle {
  display: block;
  margin: 10px 0 0 auto;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .85rem;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}
.conveyor-toggle:hover { color: var(--ink); }
.future-intro { max-width: 44em; color: var(--ink-2); margin-bottom: 32px; }
.future-list {
  list-style: none;
  counter-reset: topic;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 40px);
}
.future-list li { counter-increment: topic; border-top: 1px solid var(--ink); padding-top: 18px; }
.future-list li::before {
  content: counter(topic, decimal-leading-zero);
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--seal);
  margin-bottom: 6px;
}
.future-list p { margin: 0; color: var(--ink-2); font-size: 1rem; }
/* Inside the Research text column the list stacks, next to the pinned Raman frame */
.research-current .future-list { grid-template-columns: 1fr; gap: 28px; }

/* Publications */

.legend { display: inline-block; margin-top: 8px; font-size: .95rem; color: var(--muted); }

.pubs { list-style: none; margin-bottom: clamp(40px, 6vw, 64px); max-width: 52em; }
.pubs li { padding: 18px 0; border-top: 1px solid var(--rule); }
.pubs li:last-child { border-bottom: 1px solid var(--rule); }
.pubs p { margin: 0; }
.pubs .authors { font-size: .95rem; color: var(--ink-2); }
.pubs .authors b { color: var(--ink); }
.pubs .title { font-size: 1.07rem; color: var(--ink); margin: 3px 0; line-height: 1.45; }
.pubs .venue { font-size: .95rem; color: var(--muted); }

.doi {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-top: 4px;
  font-size: .9rem;
  color: var(--seal-dark);
  text-decoration-color: rgba(168, 50, 42, .35);
  overflow-wrap: anywhere;
}
@media (pointer: coarse) { .doi { min-height: 44px; margin-top: 0; } }
.doi::after { content: "↗"; margin-left: 5px; font-size: .85em; transition: transform .2s var(--ease); }
.doi:hover::after { transform: translate(2px, -2px); }

.tag {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: .8rem;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: nowrap;
}
.tag-cf { border-color: rgba(168, 50, 42, .45); color: var(--seal-dark); }

.pubs-more { max-width: 52em; font-size: .98rem; color: var(--ink-2); margin: 0; }

/* Teaching */

.teaching-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
  margin-bottom: clamp(48px, 7vw, 80px);
}

.pull { margin: 0; padding-left: 22px; border-left: 3px solid var(--seal); }
.pull p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  line-height: 1.25;
  margin: 0;
}

.teaching-body > p { color: var(--ink-2); margin-bottom: 32px; }
.plain-list { list-style: none; }
.plain-list li { padding: 12px 0; border-top: 1px solid var(--rule); color: var(--ink-2); }
.plain-list li b { color: var(--ink); font-weight: 600; }

.stats {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.stats li { border-top: 1px solid var(--ink); padding-top: 14px; }
.stat-num { display: block; font-family: var(--font-display); font-size: clamp(2.6rem, 5vw, 3.6rem); line-height: 1; }
.stat-label { display: block; margin-top: 6px; color: var(--ink-2); }
.mentoring-note { max-width: 46em; color: var(--ink-2); margin: 0; }

/* Awards & news */

.news-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(32px, 6vw, 80px); }
.timeline { list-style: none; }
.timeline li {
  display: grid;
  grid-template-columns: 3.4em minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
}
.when { font-family: var(--font-display); font-size: 1.15rem; color: var(--seal); line-height: 1.4; font-variant-numeric: lining-nums tabular-nums; }
.stat-num, .future-list li::before { font-variant-numeric: lining-nums; }

/* Contact */

.contact-inner { max-width: 760px; text-align: center; }
.contact .lede { margin-bottom: 32px; }
.contact-links { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  text-decoration: none;
  font-size: 1.02rem;
  transition: transform .2s var(--ease), background-color .2s var(--ease), color .2s var(--ease);
}
.contact-link svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.contact-link.linkedin svg { color: var(--linkedin); }
.contact-link:hover { background: var(--ink); color: var(--paper); transform: translateY(-2px); }
.contact-link.linkedin:hover svg { color: var(--paper); }
.contact-link:active { transform: translateY(0); }

/* Footer */

.site-footer { border-top: 1px solid var(--rule); padding-block: 28px; font-size: .92rem; color: var(--muted); }
.footer-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-row p { margin: 0; }

/* Entrance: the hero settles in once on load */

.js [data-enter] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.js.is-loaded [data-enter] { opacity: 1; transform: none; }

/* Tablet and phone */

@media (max-width: 900px) {
  .future-list { grid-template-columns: 1fr; }
  .news-grid, .teaching-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --header-h: 60px; }

  /* A backdrop-filter would trap the fixed menu panel inside the header */
  .site-header { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--paper); }
  .menu-toggle { display: inline-flex; }
  .site-nav {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: var(--paper);
    padding: 24px var(--gutter);
    visibility: hidden;
    opacity: 0;
    transition: opacity .25s var(--ease), visibility 0s linear .25s;
  }
  .site-nav.is-open { visibility: visible; opacity: 1; transition: opacity .25s var(--ease); }
  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav li { border-bottom: 1px solid var(--rule); }
  .site-nav a { width: 100%; min-height: 60px; font-family: var(--font-display); font-size: 1.7rem; color: var(--ink); }
  .site-nav a::after { display: none; }
  body.menu-open { overflow: hidden; }

  .hero { min-height: 0; padding-block: 32px 64px; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .portrait { max-width: 320px; width: 78%; }

  .research-grid { grid-template-columns: 1fr; }
  /* Phone: the Raman frame sits between current work and future directions */
  .research-grid { row-gap: 0; }
  .research-current { display: contents; }
  .research-current > .future { order: 2; }
  .research-visual, .research-current { grid-column: auto; grid-row: auto; }
  .research-visual { order: 1; position: static; margin-top: 28px; }
  .video-frame { height: min(80svh, 640px); }

  .project img { height: 36px; }
  .project-ramannoodle img, .project-sennet img { height: 32px; }
  .project-senweb img { height: 44px; }
  .project-vistamap img { height: 42px; }
  .senweb-word { font-size: 1.2rem; }
  .logo-draw { margin-right: 16px; }

  .stats { grid-template-columns: 1fr; gap: 0; }
  .stats li { display: flex; align-items: baseline; gap: 16px; padding-block: 12px; }
  .stat-label { margin-top: 0; }

  .contact-link { width: 100%; justify-content: center; }
}

@media (max-width: 420px) {
  .profiles { display: grid; grid-template-columns: 1fr 1fr; }
  .profile { justify-content: center; padding-inline: 10px; }
}

/* Reduced motion: nothing moves, nothing stays hidden */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .js [data-enter] { opacity: 1; transform: none; }
  .profile:hover, .contact-link:hover, .project:hover { transform: none; }
  .conveyor { -webkit-mask-image: none; mask-image: none; }
  .conveyor-track { flex-wrap: wrap; justify-content: center; flex-shrink: 1; padding-right: 0; row-gap: 24px; animation: none; }
  .conveyor-track[aria-hidden="true"], .conveyor-toggle { display: none; }
}

@media print {
  .site-header, .profiles, .video-frame, .logo-draw, .conveyor-track[aria-hidden="true"], .conveyor-toggle { display: none; }
  .conveyor-track { animation: none; flex-wrap: wrap; }
  .conveyor { -webkit-mask-image: none; mask-image: none; }
  body { background: #fff; }
  .section { padding-block: 24px; }
}
