/* ============ Design tokens ============ */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --text: #1a1d21;
  --text-soft: #565c66;
  --border: #e6e8eb;
  --accent: #1b3a6b;        /* restrained deep blue */
  --accent-soft: #eaf0f8;
  --radius: 12px;
  --maxw: 1040px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ============ Navigation ============ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.nav__brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.nav__brand:hover { text-decoration: none; color: var(--accent); }

.nav__menu {
  list-style: none; display: flex; align-items: center; gap: 28px; margin: 0; padding: 0;
}
.nav__menu a { color: var(--text-soft); font-weight: 500; font-size: 0.96rem; }
.nav__menu a:hover { color: var(--accent); text-decoration: none; }
.nav__cv {
  border: 1px solid var(--accent); color: var(--accent) !important;
  padding: 6px 14px; border-radius: 999px;
}
.nav__cv:hover { background: var(--accent); color: #fff !important; }

.nav__toggle {
  display: none; flex-direction: column; gap: 5px; background: none;
  border: 0; cursor: pointer; padding: 8px;
}
.nav__toggle span { width: 24px; height: 2px; background: var(--text); transition: 0.25s; }

/* ============ Hero ============ */
.hero {
  display: grid; grid-template-columns: 220px 1fr; gap: 48px;
  align-items: center; padding: 72px 24px 56px;
}
.hero__photo-wrap {
  position: relative;
  width: 220px; height: 220px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.hero__photo {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* Maple leaves falling onto the portfolio photo */
.maple-leaves {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.maple-leaf {
  position: absolute;
  top: -28px;
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.92;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18));
  animation-name: maple-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform;
}
.maple-leaf--1 { left: 8%;  animation-duration: 6.5s; animation-delay: 0s;    font-size: 1.05rem; }
.maple-leaf--2 { left: 28%; animation-duration: 7.8s; animation-delay: -1.8s; font-size: 1.3rem; }
.maple-leaf--3 { left: 48%; animation-duration: 5.9s; animation-delay: -3.2s; font-size: 0.95rem; }
.maple-leaf--4 { left: 62%; animation-duration: 8.2s; animation-delay: -0.7s; font-size: 1.2rem; }
.maple-leaf--5 { left: 78%; animation-duration: 6.9s; animation-delay: -4.1s; font-size: 1.1rem; }
.maple-leaf--6 { left: 18%; animation-duration: 7.4s; animation-delay: -5.5s; font-size: 0.9rem; }

@keyframes maple-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  8% { opacity: 0.95; }
  25% {
    transform: translate3d(10px, 60px, 0) rotate(55deg);
  }
  50% {
    transform: translate3d(-12px, 120px, 0) rotate(140deg);
  }
  75% {
    transform: translate3d(8px, 180px, 0) rotate(230deg);
  }
  92% { opacity: 0.9; }
  100% {
    transform: translate3d(-6px, 240px, 0) rotate(320deg);
    opacity: 0;
  }
}
.hero__name { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.02em; }
.hero__role { font-size: 1.2rem; font-weight: 600; margin-top: 6px; color: var(--text); }
.hero__affiliation { color: var(--text-soft); margin: 4px 0 0; }
.hero__statement { margin: 18px 0 0; max-width: 60ch; color: #2c3138; }
.hero__links {
  list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; padding: 0;
}
.hero__links a {
  display: inline-block; padding: 7px 16px; border: 1px solid var(--border);
  border-radius: 999px; font-weight: 500; font-size: 0.92rem; color: var(--text);
  background: var(--bg-soft); transition: 0.2s;
}
.hero__links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ============ Sections ============ */
.section { padding: 44px 24px; border-top: 1px solid var(--border); }
.section__title {
  font-size: 1.5rem; font-weight: 700; margin-bottom: 24px; letter-spacing: -0.01em;
}
.section__note { color: var(--text-soft); font-size: 0.9rem; margin-top: 18px; }
.section__note code { background: var(--bg-soft); padding: 1px 6px; border-radius: 5px; }

/* ============ Research interests / service tags ============ */
.service__intro { margin: 0 0 16px; color: #2c3138; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; }
.tags li {
  background: var(--accent-soft); color: var(--accent); font-weight: 500;
  padding: 7px 15px; border-radius: 999px; font-size: 0.92rem;
}

/* ============ Project cards ============ */
.project {
  display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: center;
  padding: 22px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px; background: var(--bg); transition: 0.2s;
}
.project:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.07); transform: translateY(-2px); }
.project__media {
  display: block; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); background: #fff;
}
.project__media img {
  width: 100%; height: auto; display: block; object-fit: contain; transition: transform 0.3s;
}
.project__media:hover img { transform: scale(1.02); }
.project__title { font-size: 1.18rem; font-weight: 600; }
.project__desc { margin: 8px 0 0; color: #2c3138; }
.project__venue { margin: 12px 0 0; color: var(--text-soft); font-size: 0.92rem; font-weight: 500; }
.project__links { margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.project__links a {
  font-weight: 600; font-size: 0.9rem; padding: 5px 14px;
  border: 1px solid var(--accent); border-radius: 8px;
}
.project__links a:hover { background: var(--accent); color: #fff; text-decoration: none; }

.badge {
  display: inline-block; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; padding: 2px 9px; border-radius: 999px; margin-left: 6px;
  background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--border);
  vertical-align: middle;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ============ Publications ============ */
.me { font-weight: 700; color: var(--text); }
.pub-group {
  font-size: 1.05rem; font-weight: 700; color: var(--accent);
  margin: 26px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--accent-soft);
}
.pub-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.pub { padding-left: 16px; border-left: 2px solid var(--border); }
.pub__title { font-weight: 600; margin: 0; }
.pub__authors { margin: 3px 0 0; color: #2c3138; font-size: 0.95rem; }
.pub__venue { margin: 3px 0 0; color: var(--text-soft); font-size: 0.9rem; font-style: italic; }
.pub__links { margin: 6px 0 0; display: flex; gap: 12px; }
.pub__links a { font-size: 0.88rem; font-weight: 600; }

/* ============ News ============ */
.news {
  list-style: none; margin: 0; padding: 0 14px 0 0; display: grid; gap: 12px;
  max-height: 200px; overflow-y: auto;
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* WebKit/Chromium scrollbar */
.news::-webkit-scrollbar { width: 8px; }
.news::-webkit-scrollbar-track { background: transparent; }
.news::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 999px;
}
.news::-webkit-scrollbar-thumb:hover { background: #c8ccd2; }
.news li { display: grid; grid-template-columns: 84px 1fr; gap: 16px; align-items: baseline; }
.news__date { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.news__text { color: #2c3138; }

/* ============ Footer ============ */
.footer { border-top: 1px solid var(--border); background: var(--bg-soft); margin-top: 20px; }
.footer__inner { padding: 28px 24px; text-align: center; }
.footer__links { margin: 0; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.footer__copy { margin: 10px 0 0; color: var(--text-soft); font-size: 0.88rem; }

/* Visitors module */
.visitors__total {
  margin: 0 0 18px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}
.visitors__total #visit-count { color: var(--accent); }
.visitors__regions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.visitors__regions li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  font-size: 0.92rem;
  color: #2c3138;
}
.visitors__regions .flag { font-size: 1.15rem; line-height: 1; }
.visitors__regions .count {
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.visitors__you {
  margin: 16px 0 0;
  font-size: 0.88rem;
  color: var(--text-soft);
}

/* ============ Responsive ============ */
@media (max-width: 860px) {
  .nav__toggle { display: flex; }
  .nav__menu {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: #fff; border-bottom: 1px solid var(--border);
    max-height: 0; overflow: hidden; transition: max-height 0.3s ease;
  }
  .nav__menu.is-open { max-height: 340px; }
  .nav__menu li { width: 100%; }
  .nav__menu a { display: block; padding: 14px 24px; width: 100%; }
  .nav__cv { border: 0; border-radius: 0; }
  .nav__cv:hover { background: var(--accent-soft); color: var(--accent) !important; }

  .hero {
    grid-template-columns: 1fr; text-align: center; gap: 24px; padding-top: 48px;
  }
  .hero__photo-wrap { width: 160px; height: 160px; margin: 0 auto; }
  .hero__statement { margin-left: auto; margin-right: auto; }
  .hero__links { justify-content: center; }

  .project { grid-template-columns: 1fr; gap: 18px; }

  .news li { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 420px) {
  body { font-size: 16px; }
  .hero__name { font-size: 2.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
  .maple-leaves { display: none; }
}

/* ============ Running dog (decorative) ============ */
.dog-track {
  position: relative;
  height: 56px;
  overflow: hidden;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}
/* a subtle ground line the dog runs along */
.dog-track::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  border-bottom: 2px dashed var(--border);
}
.dog-runner {
  position: absolute;
  bottom: 8px;
  left: 0;
  will-change: transform;
  animation: dog-across 30s linear infinite;
}
.dog {
  display: inline-block;
  font-size: 2rem;
  line-height: 1;
  /* dog emoji faces left by default; flip so it faces its direction of travel */
  transform: scaleX(-1);
  animation: dog-bob 0.32s ease-in-out infinite alternate;
}
@keyframes dog-across {
  from { transform: translateX(-72px); }
  to   { transform: translateX(calc(100vw + 72px)); }
}
@keyframes dog-bob {
  from { transform: scaleX(-1) translateY(0); }
  to   { transform: scaleX(-1) translateY(-7px); }
}
@media (prefers-reduced-motion: reduce) {
  .dog-runner { animation: none; left: 24px; }
  .dog { animation: none; }
}
