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

:root {
  --text:   #1a1a1a;
  --muted:  #606060;
  --accent: #1d4ed8;
  --border: #e2e2e2;
  --bg:     #fff;
  --max-w:  680px;
  --pad:    clamp(1rem, 5vw, 2rem);
}

html { scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: clamp(14px, 1.8vw, 16px);
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
}

/* ── Header ───────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 1.75rem var(--pad);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

h1 {
  font-size: 1.4rem;
  font-weight: normal;
}

.role {
  font-style: italic;
  color: var(--muted);
  font-size: 0.9em;
  margin-top: 0.15rem;
}

.affiliation {
  color: var(--muted);
  font-size: 0.85em;
}

nav {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

nav a {
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

nav a:hover { color: var(--text); }

/* ── Main ─────────────────────────────────────── */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad) 3rem;
}

section {
  padding: 2.25rem 0;
  border-bottom: 1px solid var(--border);
}

section:last-child { border-bottom: none; }

h2 {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #aaa;
  margin-bottom: 1rem;
}

section p {
  margin-bottom: 0.65rem;
}

section p:last-child { margin-bottom: 0; }

section ul {
  padding-left: 1.2em;
  margin-top: 0.5rem;
}

section li { margin-bottom: 0.4rem; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: #bbb;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

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

/* ── Social icons ─────────────────────────────── */
.social-icons {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.social-icons a {
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.social-icons a:hover { color: var(--text); }

.social-icons svg {
  width: 16px;
  height: 16px;
}

/* ── Profile photo ────────────────────────────── */
.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.profile-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  filter: grayscale(10%);
}

/* ── Publications ─────────────────────────────── */
.pub-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pub-list li { font-size: 0.92em; }

.pub-title { font-style: italic; }
.pub-venue { color: var(--muted); }

.pub-list a {
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  margin-left: 0.25rem;
  color: var(--muted);
}

/* ── NCA email widget ─────────────────────────── */
.widget-wrap {
  display: flex;
  justify-content: center;
  margin-top: 1.5em;
}

:root {
  --canvas-w: 400px;
  --canvas-h: 150px;
  --crop-left: 10px;
  --crop-top: 10px;
  --crop-width: 380px;
  --crop-height: 130px;
  --erase-radius: 8px;
}

.email-widget {
  position: relative;
  width: var(--crop-width);
  height: var(--crop-height);
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  touch-action: none;
}
.email-widget.is-active { cursor: none; }
.email-widget.is-active .ctrl-btn,
.email-widget.is-active .info-popup a,
.email-widget.is-active .letter-cell { cursor: pointer; }
.email-widget.is-active .info-popup { cursor: default; }

.canvas-wrap { position: absolute; inset: 0; overflow: hidden; }
canvas#ca-canvas {
  position: absolute;
  width: var(--canvas-w);
  height: var(--canvas-h);
  left: calc(-1 * var(--crop-left));
  top: calc(-1 * var(--crop-top));
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  touch-action: none;
}

.reveal-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity 250ms ease;
  z-index: 5;
  pointer-events: none;
}
.reveal-overlay span {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #4a4a4a;
  padding: 5px 13px;
  border: 1px solid #d8dbe6;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  font-family: system-ui, sans-serif;
}
.email-widget.is-active .reveal-overlay { opacity: 0; }

.controls {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 20;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.email-widget.is-active .controls,
.email-widget:hover .controls { opacity: 1; pointer-events: auto; }

.ctrl-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #888;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.ctrl-btn:hover { background: #555; }
.ctrl-btn svg { width: 13px; height: 13px; fill: #fff; }

.info-popup {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 24px);
  max-width: 300px;
  background: #fff;
  border: 1px solid #e5e7ef;
  border-radius: 8px;
  padding: 10px 14px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  z-index: 30;
  font-size: 12px;
  line-height: 1.45;
  color: #2a2a2a;
  display: none;
  font-family: system-ui, sans-serif;
}
.info-popup.open { display: block; }
.info-popup .info-close {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px;
  border: none; background: transparent;
  color: #888; font-size: 16px; line-height: 1;
  padding: 0; cursor: pointer; border-radius: 4px;
  display: grid; place-items: center;
}
.info-popup .info-close:hover { color: #222; background: #f1f3f8; }
.info-popup ul { margin: 0; padding-left: 16px; }
.info-popup li { margin: 2px 0; }
.info-popup .info-footer { margin: 8px 0 0; color: #555; }
.info-popup a { color: inherit; }

.letter-picker {
  position: absolute;
  z-index: 40;
  background: rgba(255,255,255,0.97);
  border: 1px solid #e5e7ef;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  padding: 4px;
  display: none;
  grid-template-columns: repeat(6, 22px);
  gap: 3px;
}
.letter-picker.open { display: grid; }
.letter-cell {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  cursor: pointer; border-radius: 4px;
  color: #fff; border: 1px solid transparent;
}
.letter-cell:hover { border-color: #888; }

.cursor-dot {
  position: absolute;
  left: 0; top: 0;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(40,40,40,0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  z-index: 15;
  transition: width 110ms ease, height 110ms ease, background-color 110ms ease, opacity 80ms ease;
}
.email-widget.is-active .cursor-dot.is-visible { opacity: 1; }
.email-widget.is-active.is-erasing .cursor-dot {
  width: calc(var(--erase-radius) * 2);
  height: calc(var(--erase-radius) * 2);
  background: rgba(255,224,110,0.65);
  border: 1px solid rgba(184,142,0,0.30);
}

/* ── Footer ───────────────────────────────────── */
footer {
  text-align: center;
  padding: 1rem var(--pad);
  font-size: 0.78rem;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  border-top: 1px solid var(--border);
}

/* ── Mobile ───────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  nav { gap: 1rem; }
  .profile-photo { width: 72px; height: 72px; }
}
