/* Kun Ryu: personal site, Apple-inspired.
   Font: San Francisco on Apple devices (via the system font), a similar clean font elsewhere. */

:root {
  --text: #1d1d1f;
  --muted: #6e6e73;
  --bg: #fbfbfd;
  --gray: #f5f5f7;
  --line: #d2d2d7;
  --blue: #0071e3;
  --link: #0066cc;
  --white: #f5f5f7;
  --nav-h: 52px;
  --max: 1080px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.47;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.center { text-align: center; }

/* ---------- Navigation ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--nav-h);
  background: rgba(251, 251, 253, 0.8);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}
.nav.scrolled { border-bottom-color: rgba(0, 0, 0, 0.1); }
.nav-in {
  max-width: var(--max); margin: 0 auto; padding: 0 24px; height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { color: var(--text); font-weight: 600; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.nav ul { list-style: none; display: flex; gap: 28px; margin: 0; padding: 0; font-size: 0.8125rem; }
.nav ul a { color: var(--text); opacity: 0.8; }
.nav ul a:hover { opacity: 1; text-decoration: none; }

/* ---------- Buttons and links ---------- */
.pill {
  display: inline-block; background: var(--blue); color: #fff;
  border-radius: 980px; padding: 12px 24px; font-size: 1.0625rem; line-height: 1.2;
  transition: background 0.2s;
}
.pill:hover { background: #0077ed; text-decoration: none; }
.pill.small { padding: 5px 14px; font-size: 0.8125rem; }
.pill.light { background: #fff; color: var(--text); }
.pill.light:hover { background: #e8e8ed; }

.chev { font-size: 1.0625rem; }
.chev::after { content: "\203A"; margin-left: 0.3em; font-size: 1.15em; }
.chev:hover { text-decoration: underline; }

.cta-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px 28px; margin: 32px 0 0; }

/* ---------- Type ---------- */
h1, h2, h3 { margin: 0; font-weight: 700; }
.display {
  font-size: clamp(3.5rem, 12vw, 8rem);
  line-height: 1; letter-spacing: -0.05em;
}
.headline {
  font-size: clamp(2.25rem, 6vw, 4rem);
  line-height: 1.08; letter-spacing: -0.035em;
}
.sub {
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  line-height: 1.25; letter-spacing: -0.015em;
  font-weight: 400; color: var(--muted);
  max-width: 28em; margin: 20px 0 0;
}
.center .sub { margin-left: auto; margin-right: auto; }
.kicker { font-size: 1.1rem; font-weight: 600; margin: 0 0 12px; color: var(--muted); }

/* ---------- Sections ---------- */
section { padding: clamp(72px, 12vw, 140px) 0; }
.gray { background: var(--gray); }
.dark { background: #000; color: var(--white); }
.dark .sub { color: #a1a1a6; }

/* ---------- Hero ---------- */
.hero { padding: calc(var(--nav-h) + clamp(48px, 8vw, 96px)) 0 clamp(56px, 8vw, 96px); }
.hero-grid { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: clamp(40px, 6vw, 80px); align-items: center; }
.hero .display { font-size: clamp(3.25rem, 8vw, 6rem); }
.hero .sub { margin-top: 16px; }
.bio { margin: 24px 0 0; max-width: 36em; color: #424245; font-size: 1.0625rem; line-height: 1.55; }
.bio strong { color: var(--text); font-weight: 600; }
.cta-row.left { justify-content: flex-start; gap: 10px; margin-top: 28px; }
.pill.ghost { background: transparent; color: var(--link); box-shadow: inset 0 0 0 1px var(--line); padding: 11px 20px; font-size: 0.95rem; }
.pill.ghost:hover { background: var(--gray); }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes settle { from { opacity: 0; transform: scale(1.06); } to { opacity: 1; transform: none; } }
.hero .kicker { animation: rise 0.9s var(--ease) both; }
.hero .display { animation: rise 1s var(--ease) 0.08s both; }
.hero .sub { animation: rise 1s var(--ease) 0.18s both; }
.hero .bio { animation: rise 1s var(--ease) 0.28s both; }
.hero .cta-row { animation: rise 1s var(--ease) 0.38s both; }
.portrait-wrap { width: 100%; max-width: 420px; justify-self: end; animation: rise 1.1s var(--ease) 0.2s both; }
.portrait { border-radius: 32px; overflow: hidden; aspect-ratio: 4 / 5; background: var(--gray); }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; animation: settle 1.6s var(--ease) 0.2s both; }

/* ---------- Affiliations ---------- */
.affils { padding: 36px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.aff-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 24px 40px; }
.aff { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.aff img { height: 44px; width: auto; filter: grayscale(1); opacity: 0.75; }
.aff span { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.02em; color: #424245; }
.aff img + span { font-size: 0.75rem; font-weight: 400; color: var(--muted); }

/* ---------- News ---------- */
.news { list-style: none; margin: clamp(32px, 5vw, 56px) 0 0; padding: 0; max-width: 820px; }
.news li { display: grid; grid-template-columns: 110px 1fr; gap: 24px; padding: 18px 0; border-top: 1px solid var(--line); }
.news li:last-child { border-bottom: 1px solid var(--line); }
.news .when { color: var(--muted); font-weight: 600; font-size: 0.95rem; padding-top: 1px; }
.news strong { font-weight: 600; }

/* ---------- Statement (words light up on scroll) ---------- */
.statement { padding-bottom: clamp(48px, 8vw, 90px); }
.scrub {
  font-size: clamp(1.9rem, 5vw, 3.5rem); line-height: 1.15; letter-spacing: -0.03em;
  font-weight: 700; max-width: 18em; margin: 0 auto; color: var(--white);
}
.js .scrub .w { color: rgba(245, 245, 247, 0.25); transition: color 0.35s; }
.js .scrub .w.on { color: var(--white); }

/* ---------- Stats ---------- */
.stats { padding-top: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; text-align: center; }
.stat-num { font-size: clamp(3.5rem, 9vw, 6.5rem); font-weight: 700; letter-spacing: -0.05em; line-height: 1; }
.stat-label { color: #a1a1a6; margin: 14px auto 0; max-width: 16em; font-size: 1.0625rem; }

/* ---------- Research tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: clamp(40px, 6vw, 72px); }
.tile {
  background: var(--gray); border-radius: 28px; padding: clamp(28px, 4vw, 48px);
  display: flex; flex-direction: column; justify-content: flex-start; min-height: 340px;
}
.tile.wide { grid-column: 1 / -1; min-height: 380px; }
.tile.black { background: #000; color: var(--white); }
.tile .tag { font-size: 0.8125rem; font-weight: 600; color: var(--muted); margin: 0 0 10px; }
.tile.black .tag { color: #a1a1a6; }
.tile h3 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 16px; }
.tile p { margin: 0 0 12px; color: #424245; font-size: 1.0625rem; max-width: 34em; }
.tile.black p { color: #d2d2d7; }
.tile.wide p { font-size: 1.15rem; }

/* ---------- Gallery ---------- */
.gallery {
  display: flex; gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0 max(24px, calc((100vw - var(--max)) / 2 + 24px)) 12px;
  margin-top: clamp(40px, 6vw, 72px); scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery figure { margin: 0; flex: 0 0 min(80vw, 480px); scroll-snap-align: center; }
.gallery img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 28px; display: block; background: var(--gray); }

/* ---------- Publications ---------- */
.pubs { max-width: 760px; margin: clamp(40px, 6vw, 72px) auto 0; text-align: left; }
.pub-group + .pub-group { margin-top: 56px; }
.pub-group h3 { font-size: 1.5rem; letter-spacing: -0.02em; margin-bottom: 8px; }
.pub { margin: 0; padding: 20px 0; border-bottom: 1px solid var(--line); }
.pub .title { display: block; font-weight: 600; }
.pub .authors { display: block; color: var(--muted); font-size: 0.95rem; margin-top: 2px; }
.pub .authors strong { color: var(--text); font-weight: 600; }
.pub .venue { display: block; font-size: 0.95rem; margin-top: 2px; }
.pub-note { color: var(--muted); font-size: 0.95rem; margin: 20px 0 0; }

/* ---------- Experience ---------- */
.rows { max-width: 820px; margin: clamp(40px, 6vw, 72px) auto 0; text-align: left; }
.row { display: grid; grid-template-columns: 190px 1fr; gap: 8px 32px; padding: 28px 0; border-top: 1px solid var(--line); }
.row:last-child { border-bottom: 1px solid var(--line); }
.row .when { color: var(--muted); font-size: 0.95rem; padding-top: 3px; }
.row h3 { font-size: 1.35rem; letter-spacing: -0.02em; }
.row .where { color: var(--muted); margin: 2px 0 10px; font-size: 0.98rem; }
.row p { margin: 0 0 8px; }
.row ul { margin: 0; padding-left: 1.1rem; }
.row li { margin-bottom: 6px; }
.subhead { max-width: 820px; margin: 72px auto 0; font-size: 2rem; letter-spacing: -0.03em; text-align: left; }
.subhead + .rows { margin-top: 24px; }

/* ---------- Tech-spec style list ---------- */
.specs { max-width: 820px; margin: clamp(40px, 6vw, 72px) auto 0; text-align: left; }
.spec { display: grid; grid-template-columns: 190px 1fr; gap: 8px 32px; padding: 24px 0; border-top: 1px solid var(--line); }
.spec:last-child { border-bottom: 1px solid var(--line); }
.spec dt { font-weight: 600; }
.spec dd { margin: 0; color: #424245; }

/* ---------- Honors, talks, etc. ---------- */
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 48px; margin-top: clamp(40px, 6vw, 72px); text-align: left; }
.cols h3 { font-size: 1.35rem; letter-spacing: -0.02em; margin-bottom: 14px; }
.cols ul { list-style: none; padding: 0; margin: 0; }
.cols li { margin-bottom: 12px; color: #424245; font-size: 1rem; }

/* ---------- Contact ---------- */
.contact .cta-row { margin-top: 36px; }
.contact .chev { color: #2997ff; }

/* ---------- Footer ---------- */
footer { background: var(--gray); padding: 24px 0 40px; color: var(--muted); font-size: 0.75rem; }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; border-top: 1px solid var(--line); padding-top: 16px; }

/* ---------- Scroll reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(40px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); transition-delay: var(--d, 0s); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- 404 ---------- */
.notfound { padding: calc(var(--nav-h) + 120px) 0 120px; text-align: center; }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .nav ul { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .portrait-wrap { order: -1; justify-self: start; max-width: 300px; }
  .aff-list { justify-content: flex-start; }
  .news li { grid-template-columns: 1fr; gap: 2px; }
  .stat-grid { grid-template-columns: 1fr; gap: 56px; }
  .tiles { grid-template-columns: 1fr; }
  .tile, .tile.wide { min-height: 0; }
  .row, .spec { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; gap: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero .kicker, .hero .display, .hero .sub, .hero .bio, .hero .cta-row, .portrait-wrap, .portrait img { animation: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .js .scrub .w { color: var(--white); transition: none; }
}
