:root {
  --text: #1b1d21;
  --muted: #5a616d;
  --accent: #1f5f99;
  --rule: #e2e5e9;
  --tag-bg: #eaf1f8;
  --bg: #ffffff;
  --width: 820px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

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

/* Navigation */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--rule);
}
.site-nav .inner {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0.8rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-nav .brand { font-weight: 600; color: var(--text); }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.1rem;
}
.site-nav ul a { color: var(--muted); font-size: 0.95rem; }
.site-nav ul a:hover { color: var(--accent); text-decoration: none; }

/* Layout */
main {
  max-width: var(--width);
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem;
  overflow-x: clip;   /* the sheared gouge layer of the fault effect must not add sideways scroll (clip keeps sticky working) */
}
section { margin-bottom: 3.25rem; }

h1 { font-size: 2.3rem; line-height: 1.2; margin: 0 0 0.3rem; }
h2 {
  font-size: 1.35rem;
  margin: 0 0 1.25rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}
h3 { font-size: 1.05rem; margin: 1.75rem 0 0.6rem; }

/* Intro */
.intro-head {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 2.25rem;
  align-items: start;
}
.intro-head p:last-child { margin-bottom: 0; }
.portrait {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}
.role { margin: 0; color: var(--muted); font-size: 1.1rem; }
.contact { margin: 0.6rem 0 1.75rem; }
.contact-icons {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.contact-icons > a,
.email-btn {
  display: inline-flex;
  color: var(--muted);
  transition: color 0.15s ease;
}
.contact-icons > a:hover,
.email-btn:hover,
.email-btn[aria-expanded="true"] { color: var(--accent); text-decoration: none; }
.contact-icons svg { width: 22px; height: 22px; fill: currentColor; }

.email-btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  border-radius: 3px;
}
.email-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Email popover: expands in flow below the icon row */
.email-popover {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}
.email-popover.open { grid-template-rows: 1fr; }
.email-popover-inner {
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: visibility 0s linear 0.25s;
}
.email-popover.open .email-popover-inner { visibility: visible; transition-delay: 0s; }
.email-bubble {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.75rem 0 0.25rem;
  padding: 0.5rem 0.6rem 0.5rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  font-size: 0.95rem;
  white-space: nowrap;
}
.email-bubble::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 6px;
  width: 10px;
  height: 10px;
  background: var(--bg);
  border-left: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
  transform: rotate(45deg);
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0.2rem 0.65rem 0.2rem 0.55rem;
  border: 0;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.copy-btn:hover { background: #dbe7f3; }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-btn svg { width: 14px; height: 14px; fill: currentColor; }
.copy-btn .icon-check { display: none; }
.copy-btn.copied .icon-copy { display: none; }
.copy-btn.copied .icon-check { display: inline; }

.interests { margin: 0; padding-left: 1.2rem; }
.methods { margin: 0; color: var(--muted); }

/* Research highlights */
.highlight { margin-bottom: 1.9rem; }
.highlight h3 { margin: 0 0 0.35rem; }
.highlight p { margin: 0; }
.highlight .links { margin-top: 0.35rem; font-size: 0.95rem; color: var(--muted); }
.links > span { margin: 0 0.35rem; }
.highlight .figure {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.highlight .figure-narrow { max-width: 480px; }

/* Pinned scroll stages for the research highlight effects (see script.js) */
.stage { margin-bottom: 1.9rem; }
.stage-pin {
  position: sticky;
  top: 4.5rem;
  margin-bottom: 0;
  --shake: 1;
}
.stage-spacer { height: 64em; }         /* 40 lines of scroll drive each effect; all three finish at 85 % */
.stage::after {                          /* then 5 lines of hold: the finished scene rests before it scrolls away */
  content: "";
  display: block;
  height: 8em;
}
/* Phones: plain highlights, no pinning (script.js adds .no-fx when it skips the effects) */
.no-fx .stage-pin { position: static; }
.no-fx .stage-spacer, .no-fx .stage::after { display: none; }

/* Jeju highlight: tall figure beside the text so the pinned block fits the viewport */
.highlight-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.75rem;
  align-items: start;
}
.highlight-side .figure { margin-top: 0.25rem; }

/* Effect 1: fault slip */
.fault { position: relative; }
.fault-content {
  will-change: transform;
  transition: transform 0.12s linear;
}
.fault-layer {
  position: absolute;
  inset: 0;
}
.fault-g {
  z-index: 1;
  pointer-events: none;
  filter: url(#gouge-filter);
}
.fault.ruptured .fault-content,
.fault.ruptured .fault-layer {
  transition: transform 0.32s cubic-bezier(0.25, 1.6, 0.45, 1);
}

/* Ground shaking: a small P-wave wiggle, a larger S-wave burst, then a decaying coda */
.stage-pin.shaking { animation: quake 1.1s linear both; }
@keyframes quake {
  0%   { transform: translate(0, 0); }
  5%   { transform: translate(0, calc(-1.2px * var(--shake))); }
  9%   { transform: translate(0, calc(1.4px * var(--shake))); }
  13%  { transform: translate(0, calc(-1px * var(--shake))); }
  17%  { transform: translate(0, calc(0.8px * var(--shake))); }
  22%  { transform: translate(calc(-9px * var(--shake)), calc(2.5px * var(--shake))); }
  28%  { transform: translate(calc(8.5px * var(--shake)), calc(-2px * var(--shake))); }
  34%  { transform: translate(calc(-6.5px * var(--shake)), calc(1.5px * var(--shake))); }
  40%  { transform: translate(calc(5px * var(--shake)), calc(-1px * var(--shake))); }
  47%  { transform: translate(calc(-3.5px * var(--shake)), 0); }
  55%  { transform: translate(calc(2.5px * var(--shake)), 0); }
  64%  { transform: translate(calc(-1.6px * var(--shake)), 0); }
  74%  { transform: translate(calc(1px * var(--shake)), 0); }
  86%  { transform: translate(calc(-0.5px * var(--shake)), 0); }
  100% { transform: translate(0, 0); }
}

/* Effect 2: cascading rupture. Each letter (.c) carries a ghost copy (.sw > .s) rendered
   through the ink-smear filter. A rupture front flashes the ghost to full strength and lets
   it settle at half strength (.sw). Healing then fades each ghost (.s) on a fixed clock:
   --hdelay (per letter) and --hdur are set in script.js. */
.rupture { position: relative; }
.rupture .w { display: inline-block; white-space: nowrap; }
.rupture .c { position: relative; display: inline-block; }
.rupture .c > .sw {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.rupture .c > .sw > .s {
  display: block;
  white-space: pre;
  opacity: 0.5;                          /* smear strength: keeps the smeared text readable */
  filter: url(#smear-glyph);
  transition: opacity 0.35s ease;        /* scrolling back: the smear returns quickly */
}
.rupture.healing .c > .sw > .s {
  opacity: 0;
  transition: opacity var(--hdur, 1s) ease-in-out var(--hdelay, 0s);
}
.rupture.instant .c > .sw > .s { transition: none; }   /* page opened past the rupture */
.rupture .c.nuc > .sw { animation: smear-flicker 0.6s ease-in-out both; }
.rupture .c.hit > .sw { animation: smear-pulse var(--sdur, 1.1s) cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.rupture .c.hit.still > .sw { animation-duration: 0s; }
@keyframes smear-pulse {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0.5; }
}
@keyframes smear-flicker {
  0%   { opacity: 0; }
  40%  { opacity: 0.7; }
  100% { opacity: 0; }
}

/* Effect 3: passing seismic waves */
.wave .w { display: inline-block; white-space: nowrap; }
.wave .c { display: inline-block; }
.wave .w.p-hit { animation: p-kick 0.5s ease-out both; }
.wave .c.s-hit { animation: s-kick var(--dur, 2s) linear both; }
@keyframes p-kick {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(var(--px, 3px)); }
  50%  { transform: translateX(calc(var(--px, 3px) * -0.45)); }
  80%  { transform: translateX(calc(var(--px, 3px) * 0.15)); }
  100% { transform: translateX(0); }
}
@keyframes s-kick {
  0%   { transform: translate(0, 0) rotate(0deg); animation-timing-function: ease-out; }
  5%   { transform: translate(var(--kx, 0px), var(--ky, 8px)) rotate(var(--kr, 0deg)); animation-timing-function: ease-in-out; }
  22%  { transform: translate(calc(var(--kx, 0px) * -0.62), calc(var(--ky, 8px) * -0.62)) rotate(calc(var(--kr, 0deg) * -0.6)); animation-timing-function: ease-in-out; }
  40%  { transform: translate(calc(var(--kx, 0px) * 0.38), calc(var(--ky, 8px) * 0.38)) rotate(calc(var(--kr, 0deg) * 0.35)); animation-timing-function: ease-in-out; }
  58%  { transform: translate(calc(var(--kx, 0px) * -0.22), calc(var(--ky, 8px) * -0.22)) rotate(calc(var(--kr, 0deg) * -0.2)); animation-timing-function: ease-in-out; }
  76%  { transform: translate(calc(var(--kx, 0px) * 0.12), calc(var(--ky, 8px) * 0.12)) rotate(calc(var(--kr, 0deg) * 0.1)); animation-timing-function: ease-in-out; }
  90%  { transform: translate(calc(var(--kx, 0px) * -0.05), calc(var(--ky, 8px) * -0.05)) rotate(0deg); animation-timing-function: ease-in-out; }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* Visually hidden but available to assistive technology */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .stage-pin.shaking { animation: none; }
  .fault-content, .fault-layer,
  .fault.ruptured .fault-content, .fault.ruptured .fault-layer { transition: none; }
  .rupture .c.nuc > .sw { animation: none; }
  .rupture .c.hit > .sw { animation-duration: 0s; }
  .rupture .c > .sw > .s, .rupture.healing .c > .sw > .s { transition: none; }
  .wave .w.p-hit, .wave .c.s-hit { animation: none; }
}

/* Media coverage */
.media-intro { margin: 0 0 1rem; color: var(--muted); }
.media { list-style: none; margin: 0; padding: 0; }
.media li { margin-bottom: 0.85rem; }
.media-meta { display: block; color: var(--muted); font-size: 0.9rem; }

/* Publications and talks */
.items { margin: 0; padding-left: 1.8rem; }
.items li { margin-bottom: 1.1rem; padding-left: 0.2rem; }
.items li::marker { color: var(--muted); }
.item-title { margin: 0; font-weight: 600; }
.item-meta { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.95rem; }
.item-meta a { overflow-wrap: anywhere; }
.me { color: var(--text); }

.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: 0.12em;
}

/* Experience and education */
.entry { margin-bottom: 1.2rem; }
.entry-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1rem;
}
.entry-title { font-weight: 600; }
.entry-date { color: var(--muted); white-space: nowrap; }
.entry-org { color: var(--muted); }
.entry ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }

/* Experience groups: academic positions vs. field deployments */
.group + .group {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--rule);
}
.group-title {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.deployments .entry { margin-bottom: 0.7rem; }
.deployments .entry-title { font-weight: 500; }

/* Awards */
.awards { list-style: none; margin: 0; padding: 0; }
.awards li { margin-bottom: 0.6rem; color: var(--muted); }
.award-name { color: var(--text); font-weight: 600; }
a.award-name { color: var(--accent); }
.award-year { white-space: nowrap; margin-left: 0.25rem; }
.award-year::before { content: "· "; }

/* Footer */
footer {
  max-width: var(--width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}
footer p { margin: 0; }

/* Small screens */
@media (max-width: 680px) {
  body { font-size: 16px; }
  main { padding: 2rem 1rem 1.5rem; }
  .site-nav .inner { padding: 0.7rem 1rem; }
  .site-nav .brand { display: none; }
  .site-nav ul { gap: 0.9rem; overflow-x: auto; white-space: nowrap; }
  h1 { font-size: 1.9rem; }
  .items { padding-left: 1.5rem; }
  .intro-head { grid-template-columns: 1fr; gap: 1.25rem; }
  .portrait { order: -1; width: 150px; }
  .highlight-side { grid-template-columns: 1fr; gap: 0; }
  .stage-pin { position: static; }                         /* same as .no-fx, from the first paint */
  .stage-spacer, .stage::after { display: none; }
  .highlight-side .figure { margin-top: 0.9rem; max-width: 260px; }
}

/* Mid widths: the nav has too many links to keep the name beside it */
@media (max-width: 900px) {
  .site-nav .brand { display: none; }
}
